From d201fe3579697dc862852176ddab44773b2d3217 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Thu, 9 Dec 2004 17:44:17 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'bran'. Sprout from master 2004-12-09 17:44:15 UTC Jean Michel-Lemieux 'Bug 75735 Changes to working set names not reflected in synchronize dropdown' Delete: bundles/org.eclipse.compare/.classpath bundles/org.eclipse.compare/.cvsignore bundles/org.eclipse.compare/.project bundles/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.compare/about.html bundles/org.eclipse.compare/build.properties bundles/org.eclipse.compare/buildnotes_compare.html bundles/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java bundles/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java bundles/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java bundles/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextMergeViewerCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java bundles/org.eclipse.compare/compare/org/eclipse/compare/package.html bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html bundles/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/next_nav.gif bundles/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif bundles/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif bundles/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif bundles/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif bundles/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif bundles/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif bundles/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif bundles/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif bundles/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif bundles/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif bundles/org.eclipse.compare/icons/full/elcl16/next_nav.gif bundles/org.eclipse.compare/icons/full/elcl16/prev_nav.gif bundles/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif bundles/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif bundles/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif bundles/org.eclipse.compare/icons/full/etool16/conflict_edit.gif bundles/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif bundles/org.eclipse.compare/icons/full/eview16/compare_view.gif bundles/org.eclipse.compare/icons/full/obj16/day_obj.gif bundles/org.eclipse.compare/icons/full/obj16/resource_obj.gif bundles/org.eclipse.compare/icons/full/ovr16/add_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/chg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/del_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/error_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/indel_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif bundles/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif bundles/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif bundles/org.eclipse.compare/old_buildnotes_compare_3_0.html bundles/org.eclipse.compare/plugin.properties bundles/org.eclipse.compare/plugin.xml bundles/org.eclipse.compare/plugins/org.eclipse.compare/.classpath bundles/org.eclipse.compare/plugins/org.eclipse.compare/.cvsignore bundles/org.eclipse.compare/plugins/org.eclipse.compare/.project bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.compare/plugins/org.eclipse.compare/about.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/build.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextMergeViewerCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Attic/LineReader.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/package.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/next_nav.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/next_nav.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/prev_nav.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/conflict_edit.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/eview16/compare_view.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/day_obj.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/resource_obj.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/add_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/chg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/del_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/error_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/indel_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif bundles/org.eclipse.compare/plugins/org.eclipse.compare/old_buildnotes_compare_3_0.html bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd bundles/org.eclipse.compare/plugins/org.eclipse.compare/scripts/exportplugin.xml bundles/org.eclipse.compare/schema/contentMergeViewers.exsd bundles/org.eclipse.compare/schema/contentViewers.exsd bundles/org.eclipse.compare/schema/streamMergers.exsd bundles/org.eclipse.compare/schema/structureCreators.exsd bundles/org.eclipse.compare/schema/structureMergeViewers.exsd bundles/org.eclipse.compare/scripts/exportplugin.xml bundles/org.eclipse.team.core/.classpath bundles/org.eclipse.team.core/.cvsignore bundles/org.eclipse.team.core/.options bundles/org.eclipse.team.core/.project bundles/org.eclipse.team.core/about.html bundles/org.eclipse.team.core/build.properties bundles/org.eclipse.team.core/buildnotes_team.html bundles/org.eclipse.team.core/plugin.properties bundles/org.eclipse.team.core/plugin.xml bundles/org.eclipse.team.core/schema/defaultFileModificationValidator.exsd bundles/org.eclipse.team.core/schema/fileTypes.exsd bundles/org.eclipse.team.core/schema/ignore.exsd bundles/org.eclipse.team.core/schema/projectSets.exsd bundles/org.eclipse.team.core/schema/repository.exsd bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileTypeInfo.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/IIgnoreInfo.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/IProjectSetSerializer.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/ITeamStatus.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetSerializationContext.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamStatus.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/package.html bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ActiveChangeSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSetCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/CheckedInChangeSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/IChangeSetChangeListener.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeListener.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/package.html bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/FastSyncInfoFilter.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeListener.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoTreeChangeEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoFilter.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/package.html bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/package.html bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Assert.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultMoveDeleteHook.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultProjectSetCapability.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/IJobListener.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/MoveDeleteManager.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/NullSubProgressMonitor.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PessimisticResourceRuleFactory.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Sorter.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StringMatcher.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamHookDispatcher.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/simpleAccess/SimpleAccessOperations.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/CRLFtoLFInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutInputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ContentComparator.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncByteConverter.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoStatistics.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoWorkingSetFilter.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetChangedEvent.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java bundles/org.eclipse.team.cvs.core/.classpath bundles/org.eclipse.team.cvs.core/.cvsignore bundles/org.eclipse.team.cvs.core/.options bundles/org.eclipse.team.cvs.core/.project bundles/org.eclipse.team.cvs.core/about.html bundles/org.eclipse.team.cvs.core/asl-v20.txt bundles/org.eclipse.team.cvs.core/build.properties bundles/org.eclipse.team.cvs.core/buildnotes_cvs.html bundles/org.eclipse.team.cvs.core/doc/hglegal.htm bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html bundles/org.eclipse.team.cvs.core/plugin.properties bundles/org.eclipse.team.cvs.core/plugin.xml bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateWithOverwrite.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/CompareDiffListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java bundles/org.eclipse.team.cvs.ssh/.classpath bundles/org.eclipse.team.cvs.ssh/.cvsignore bundles/org.eclipse.team.cvs.ssh/.options bundles/org.eclipse.team.cvs.ssh/.project bundles/org.eclipse.team.cvs.ssh/about.html bundles/org.eclipse.team.cvs.ssh/build.properties bundles/org.eclipse.team.cvs.ssh/plugin.properties bundles/org.eclipse.team.cvs.ssh/plugin.xml bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Blowfish.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Cipher.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Client.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ClientPacket.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/KnownHosts.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Misc.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Packet.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Policy.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHMethod.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHPlugin.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHServerConnection.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ServerPacket.java bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/messages.properties bundles/org.eclipse.team.cvs.ssh2/.classpath bundles/org.eclipse.team.cvs.ssh2/.cvsignore bundles/org.eclipse.team.cvs.ssh2/.project bundles/org.eclipse.team.cvs.ssh2/about.html bundles/org.eclipse.team.cvs.ssh2/build.properties bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar bundles/org.eclipse.team.cvs.ssh2/plugin.properties bundles/org.eclipse.team.cvs.ssh2/plugin.xml bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties bundles/org.eclipse.team.cvs.ui/.classpath bundles/org.eclipse.team.cvs.ui/.cvsignore bundles/org.eclipse.team.cvs.ui/.options bundles/org.eclipse.team.cvs.ui/.project bundles/org.eclipse.team.cvs.ui/about.html bundles/org.eclipse.team.cvs.ui/build.properties bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/clear_co.gif bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/collapseall.gif bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/filter_history.gif bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/newstream_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/refresh.gif bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/synced.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/annotate.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/checkout.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/cvs_synch.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/history.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/ignorefiles.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newconnect_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newlocation_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/share_prj_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/clear_co.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/collapseall.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/filter_history.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/newstream_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/refresh.gif bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/synced.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/annotate.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/checkout.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/cvs_synch.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/history.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newconnect_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newlocation_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/etool16/share_prj_wiz.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/annotate_view.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/compare_view.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/console_view.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/cvs_persp.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/history_view.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/rep_editors_view.gif bundles/org.eclipse.team.cvs.ui/icons/full/eview16/repo_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph1.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph2.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph3.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph4.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph5.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph6.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph7.gif bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph8.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/branches_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/changelog_obj.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/date.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/dates.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/module_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/prjversions_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/repository_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/tag.gif bundles/org.eclipse.team.cvs.ui/icons/full/obj16/versions_rep.gif bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/confauto_ov.gif bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/edited_ov.gif bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/merged_ov.gif bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/no_remotedir_ov.gif bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/question_ov.gif bundles/org.eclipse.team.cvs.ui/icons/full/wizban/createpatch_wizban.gif bundles/org.eclipse.team.cvs.ui/icons/full/wizban/keywordsub_wizban.gif bundles/org.eclipse.team.cvs.ui/icons/full/wizban/mergestream_wizban.gif bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newconnect_wizban.gif bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newlocation_wizban.gif bundles/org.eclipse.team.cvs.ui/plugin.properties bundles/org.eclipse.team.cvs.ui/plugin.xml bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableHierarchicalResourceList.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableResourceList.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFieldEditorPreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryDropAdapter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/OverlayIconCache.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationEditorInput.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationStorage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResizableWizardDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/SimpleContentProvider.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagetLocationSelectionDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TextViewerAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/VersionCollator.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/XMLWriter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutWizardAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/NewRepositoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowCVSPerspectiveAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UneditAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsoleFactory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleDocument.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleRemoveAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/AllRootsElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFolderPropertySource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryLocationPropertySource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryRootElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSResourceElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/GroupedByVersionCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/ModulesCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteResourceElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteVersionModule.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RepositoryLocationSchedulingRule.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/TagCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepoViewAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CopyRepositoryNameAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewCVSRepositoryAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewDateTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSActionDelegateWrapper.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndCommitAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateSubscriberOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SyncInfoSetDetailsDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/UpdateDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ToolTipMessageDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFileElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFolderElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ICVSWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardDirtyFilesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSharedFilesPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSummaryPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java examples/org.eclipse.compare.examples.xml/.classpath examples/org.eclipse.compare.examples.xml/.cvsignore examples/org.eclipse.compare.examples.xml/.project examples/org.eclipse.compare.examples.xml/.settings/org.eclipse.jdt.core.prefs examples/org.eclipse.compare.examples.xml/IdMaps/ant_test.xml examples/org.eclipse.compare.examples.xml/IdMaps/idmap.dtd examples/org.eclipse.compare.examples.xml/about.html examples/org.eclipse.compare.examples.xml/build.properties examples/org.eclipse.compare.examples.xml/doc-html/CreateNewIDMapButton.gif examples/org.eclipse.compare.examples.xml/doc-html/EditCopy.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMapContextMenu.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_GeneralMatching.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_MyPlugin.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewIDMapScheme.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_ContextMenu.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_PreferencePage.gif examples/org.eclipse.compare.examples.xml/doc-html/IDMap_SelectMyPlugin.gif examples/org.eclipse.compare.examples.xml/doc-html/Ordered_MyANT.gif examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewIDMapScheme.gif examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_ContextMenu.gif examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_PreferencePage.gif examples/org.eclipse.compare.examples.xml/doc-html/Ordered_UnorderedScheme.gif examples/org.eclipse.compare.examples.xml/doc-html/PreferencePage.gif examples/org.eclipse.compare.examples.xml/doc-html/addidmap.gif examples/org.eclipse.compare.examples.xml/doc-html/hglegal.htm examples/org.eclipse.compare.examples.xml/doc-html/idMapping.html examples/org.eclipse.compare.examples.xml/doc-html/ngibmcpy.gif examples/org.eclipse.compare.examples.xml/doc-html/smartmode_co.gif examples/org.eclipse.compare.examples.xml/doc-html/tutorial_and_examples.html examples/org.eclipse.compare.examples.xml/doc-html/ui_xmlcompare_ex.html examples/org.eclipse.compare.examples.xml/icons/full/obj16/addidmap.gif examples/org.eclipse.compare.examples.xml/icons/full/obj16/attribute_obj.gif examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_obj.gif examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_ordered_obj.gif examples/org.eclipse.compare.examples.xml/icons/full/obj16/smartmode_co.gif examples/org.eclipse.compare.examples.xml/icons/full/obj16/text_obj.gif examples/org.eclipse.compare.examples.xml/plugin.properties examples/org.eclipse.compare.examples.xml/plugin.xml examples/org.eclipse.compare.examples.xml/schema/idMapping.exsd examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AttributesImpl.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/CreateNewIdMapAction.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/IdMap.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SWTUtil.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewerCreator.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusDialog.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusInfo.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/xmlcompare.properties examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/AllXMLCompareTests.java examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/TestXMLStructureCreator.java examples/org.eclipse.compare.examples/.classpath examples/org.eclipse.compare.examples/.cvsignore examples/org.eclipse.compare.examples/.project examples/org.eclipse.compare.examples/.settings/org.eclipse.jdt.core.prefs examples/org.eclipse.compare.examples/about.html examples/org.eclipse.compare.examples/build.properties examples/org.eclipse.compare.examples/doc-html/hglegal.htm examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html examples/org.eclipse.compare.examples/plugin.properties examples/org.eclipse.compare.examples/plugin.xml examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java examples/org.eclipse.team.examples.filesystem/.classpath examples/org.eclipse.team.examples.filesystem/.cvsignore examples/org.eclipse.team.examples.filesystem/.project examples/org.eclipse.team.examples.filesystem/about.html examples/org.eclipse.team.examples.filesystem/build.properties examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html examples/org.eclipse.team.examples.filesystem/doc-html/team_localhistory_ex.html examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif examples/org.eclipse.team.examples.filesystem/icons/full/wizards/synced.gif examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif examples/org.eclipse.team.examples.filesystem/plugin.properties examples/org.eclipse.team.examples.filesystem/plugin.xml examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSyncInfo.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeOperation.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeOperation.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeOperation.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeWizard.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySynchronizeWizard.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariant.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariantComparator.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IPessimisticFilesystemConstants.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IResourceStateListener.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/BlankPage.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckInAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckOutAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/ConfigurationWizard.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticPreferencesPage.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/UncheckOutAction.java tests/org.eclipse.compare.tests/.classpath tests/org.eclipse.compare.tests/.cvsignore tests/org.eclipse.compare.tests/.project tests/org.eclipse.compare.tests/.settings/org.eclipse.jdt.core.prefs tests/org.eclipse.compare.tests/about.html tests/org.eclipse.compare.tests/build.properties tests/org.eclipse.compare.tests/plugin.properties tests/org.eclipse.compare.tests/plugin.xml tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareTestPlugin.java tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StreamMergerTest.java tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UITest.java tests/org.eclipse.compare.tests/test.xml tests/org.eclipse.team.tests.core/.classpath tests/org.eclipse.team.tests.core/.cvsignore tests/org.eclipse.team.tests.core/.project tests/org.eclipse.team.tests.core/about.html tests/org.eclipse.team.tests.core/build-tests.xml tests/org.eclipse.team.tests.core/build.properties tests/org.eclipse.team.tests.core/plugin.xml tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderBic.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderNaish.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTypeBic.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderWithLinking.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/StreamTests.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java tests/org.eclipse.team.tests.core/test.xml tests/org.eclipse.team.tests.cvs.core/.classpath tests/org.eclipse.team.tests.cvs.core/.cvsignore tests/org.eclipse.team.tests.cvs.core/.project tests/org.eclipse.team.tests.cvs.core/.settings/org.eclipse.jdt.core.prefs tests/org.eclipse.team.tests.cvs.core/about.html tests/org.eclipse.team.tests.cvs.core/benchmark/cvsui_benchmark.bat tests/org.eclipse.team.tests.cvs.core/benchmark/readme.txt tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_02_26.integration.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_03_19.integration.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_04_24.milestone5.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_04_25.integration.commandline.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_07_10.release2_0.commandline.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.0/2002_07_11.release2_0.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.1/I20021127.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.1/I20030129.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/team2.1/RC1.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/teamui_benchmark.bat tests/org.eclipse.team.tests.cvs.core/benchmark/vcm1.0/2002_02_26.integration.all.xml tests/org.eclipse.team.tests.cvs.core/benchmark/vcmui_benchmark.bat tests/org.eclipse.team.tests.cvs.core/book.css tests/org.eclipse.team.tests.cvs.core/build-tests.xml tests/org.eclipse.team.tests.cvs.core/build.properties tests/org.eclipse.team.tests.cvs.core/html/00000.html tests/org.eclipse.team.tests.cvs.core/html/00001.html tests/org.eclipse.team.tests.cvs.core/html/00002.html tests/org.eclipse.team.tests.cvs.core/html/00003.html tests/org.eclipse.team.tests.cvs.core/html/00004.html tests/org.eclipse.team.tests.cvs.core/html/00005.html tests/org.eclipse.team.tests.cvs.core/html/00006.html tests/org.eclipse.team.tests.cvs.core/html/00007.html tests/org.eclipse.team.tests.cvs.core/html/00008.html tests/org.eclipse.team.tests.cvs.core/html/00009.html tests/org.eclipse.team.tests.cvs.core/html/00010.html tests/org.eclipse.team.tests.cvs.core/html/00011.html tests/org.eclipse.team.tests.cvs.core/html/00012.html tests/org.eclipse.team.tests.cvs.core/html/00013.html tests/org.eclipse.team.tests.cvs.core/html/00014.html tests/org.eclipse.team.tests.cvs.core/html/00015.html tests/org.eclipse.team.tests.cvs.core/html/00016.html tests/org.eclipse.team.tests.cvs.core/html/00017.html tests/org.eclipse.team.tests.cvs.core/html/00018.html tests/org.eclipse.team.tests.cvs.core/html/00019.html tests/org.eclipse.team.tests.cvs.core/html/00020.html tests/org.eclipse.team.tests.cvs.core/html/00021.html tests/org.eclipse.team.tests.cvs.core/html/00022.html tests/org.eclipse.team.tests.cvs.core/html/00023.html tests/org.eclipse.team.tests.cvs.core/html/00024.html tests/org.eclipse.team.tests.cvs.core/html/00025.html tests/org.eclipse.team.tests.cvs.core/html/00026.html tests/org.eclipse.team.tests.cvs.core/html/00027.html tests/org.eclipse.team.tests.cvs.core/html/00028.html tests/org.eclipse.team.tests.cvs.core/html/00028a.html tests/org.eclipse.team.tests.cvs.core/html/00029.html tests/org.eclipse.team.tests.cvs.core/html/00029a.html tests/org.eclipse.team.tests.cvs.core/html/00030.html tests/org.eclipse.team.tests.cvs.core/html/00030a.html tests/org.eclipse.team.tests.cvs.core/html/00031.html tests/org.eclipse.team.tests.cvs.core/html/00032.html tests/org.eclipse.team.tests.cvs.core/html/00033.html tests/org.eclipse.team.tests.cvs.core/html/00034.html tests/org.eclipse.team.tests.cvs.core/html/00035.html tests/org.eclipse.team.tests.cvs.core/html/00036.html tests/org.eclipse.team.tests.cvs.core/html/00037.html tests/org.eclipse.team.tests.cvs.core/html/00038.html tests/org.eclipse.team.tests.cvs.core/html/00039.html tests/org.eclipse.team.tests.cvs.core/html/00040.html tests/org.eclipse.team.tests.cvs.core/html/00041.html tests/org.eclipse.team.tests.cvs.core/html/00042.html tests/org.eclipse.team.tests.cvs.core/html/00043.html tests/org.eclipse.team.tests.cvs.core/html/00044.html tests/org.eclipse.team.tests.cvs.core/html/00045.html tests/org.eclipse.team.tests.cvs.core/html/00046.html tests/org.eclipse.team.tests.cvs.core/html/00047.html tests/org.eclipse.team.tests.cvs.core/html/00048.html tests/org.eclipse.team.tests.cvs.core/html/00049.html tests/org.eclipse.team.tests.cvs.core/html/00050.html tests/org.eclipse.team.tests.cvs.core/html/auth_problems00001.html tests/org.eclipse.team.tests.cvs.core/html/checkoutwizard00001.html tests/org.eclipse.team.tests.cvs.core/html/commands00001.html tests/org.eclipse.team.tests.cvs.core/html/commit_sets00001.html tests/org.eclipse.team.tests.cvs.core/html/commit_stes00001.html tests/org.eclipse.team.tests.cvs.core/html/connections00001.html tests/org.eclipse.team.tests.cvs.core/html/datetags_repoview00001.html tests/org.eclipse.team.tests.cvs.core/html/encoding00001.html tests/org.eclipse.team.tests.cvs.core/html/ext_connection_method00001.html tests/org.eclipse.team.tests.cvs.core/html/failures00001.html tests/org.eclipse.team.tests.cvs.core/html/latest_revision_commit_set00001.html tests/org.eclipse.team.tests.cvs.core/html/misc00001.html tests/org.eclipse.team.tests.cvs.core/html/passwords00001.html tests/org.eclipse.team.tests.cvs.core/html/perf00001.html tests/org.eclipse.team.tests.cvs.core/html/perf00002.html tests/org.eclipse.team.tests.cvs.core/html/perf00003.html tests/org.eclipse.team.tests.cvs.core/html/perf00004.html tests/org.eclipse.team.tests.cvs.core/html/perf00005.html tests/org.eclipse.team.tests.cvs.core/html/perf00006.html tests/org.eclipse.team.tests.cvs.core/html/perf00007.html tests/org.eclipse.team.tests.cvs.core/html/project_sets00001.html tests/org.eclipse.team.tests.cvs.core/html/quickdiff00001.html tests/org.eclipse.team.tests.cvs.core/html/repoview_basics00001.html tests/org.eclipse.team.tests.cvs.core/html/sharingbasics00001.html tests/org.eclipse.team.tests.cvs.core/html/sync00001.html tests/org.eclipse.team.tests.cvs.core/html/teamupdate00001.html tests/org.eclipse.team.tests.cvs.core/html/update00001.html tests/org.eclipse.team.tests.cvs.core/html/update_command00001.html tests/org.eclipse.team.tests.cvs.core/html/validate_edit00001.html tests/org.eclipse.team.tests.cvs.core/html/validate_edit_editing_files00001.html tests/org.eclipse.team.tests.cvs.core/html/validate_edit_refactoring00001.html tests/org.eclipse.team.tests.cvs.core/html/watch_edit00001.html tests/org.eclipse.team.tests.cvs.core/html/watch_edit_basic00001.html tests/org.eclipse.team.tests.cvs.core/html/watch_edit_editorsview00001.html tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS Core Tests.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests (Linux).launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/CVS UI Tests.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Performance - SyncTests.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/Test using Ant application.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/benchmark/Benchmark Test.launch tests/org.eclipse.team.tests.cvs.core/launchConfigurations/benchmark/PrintDiffMain.launch tests/org.eclipse.team.tests.cvs.core/plugin.xml tests/org.eclipse.team.tests.cvs.core/readme.html tests/org.eclipse.team.tests.cvs.core/repository.properties tests/org.eclipse.team.tests.cvs.core/resources/BenchmarkTest/benchmarkBig.zip tests/org.eclipse.team.tests.cvs.core/resources/BenchmarkTest/benchmarkSmall.zip tests/org.eclipse.team.tests.cvs.core/resources/BenchmarkTest/benchmarkTiny.zip tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/CVSROOT/modules tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/common/docs/readme.html tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/common/macros/macro1 tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project1/f1/file-in-p1.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project2/file-p2.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project3/src/file.c tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project3/src/file.h tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project3/sub/file-sub.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project7/common/common.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project7/linux/linux.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project7/pc/pc.txt tests/org.eclipse.team.tests.cvs.core/resources/CommandTest/project8/file-p8.txt tests/org.eclipse.team.tests.cvs.core/self-host.xml tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestLogListener.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSUITestSetup.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/ICVSClient.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/BatchedTestSetup.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseFolderTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncBytesTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ConcurrencyTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/IsModifiedTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/LinkResourcesTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/WatchEditTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/AllTestsTeamSubscriber.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncSetTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestCommitOperation.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestMergeUpdateOperation.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestOverrideAndUpdateOperation.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSOperationTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CheckoutOperationTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CommitSetTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CompareOperationTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MenuEnablementTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MiscOperationsTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTestSetup.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SequenceGenerator.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/ShareAndCheckoutTest.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SyncTests.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/Util.java tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/WorkflowTests.java tests/org.eclipse.team.tests.cvs.core/test.xml tests/org.eclipse.team.tests.cvs.core/toc.html tests/org.eclipse.team.tests.cvs.core/toc.xml--- bundles/org.eclipse.compare/.classpath | 7 - bundles/org.eclipse.compare/.cvsignore | 1 - bundles/org.eclipse.compare/.project | 37 - .../.settings/org.eclipse.jdt.core.prefs | 70 - bundles/org.eclipse.compare/about.html | 30 - bundles/org.eclipse.compare/build.properties | 18 - .../org.eclipse.compare/buildnotes_compare.html | 87 - .../org/eclipse/compare/BufferedContent.java | 130 - .../org/eclipse/compare/CompareConfiguration.java | 450 -- .../org/eclipse/compare/CompareEditorInput.java | 815 ---- .../compare/org/eclipse/compare/CompareUI.java | 323 -- .../org/eclipse/compare/CompareViewerPane.java | 151 - .../compare/CompareViewerSwitchingPane.java | 369 -- .../eclipse/compare/EditionSelectionDialog.java | 1128 ----- .../compare/org/eclipse/compare/HistoryItem.java | 109 - .../org/eclipse/compare/ICompareNavigator.java | 34 - .../eclipse/compare/IContentChangeListener.java | 30 - .../eclipse/compare/IContentChangeNotifier.java | 39 - .../org/eclipse/compare/IEditableContent.java | 70 - .../compare/IEncodedStreamContentAccessor.java | 39 - .../org/eclipse/compare/IModificationDate.java | 31 - .../eclipse/compare/IPropertyChangeNotifier.java | 41 - .../eclipse/compare/IStreamContentAccessor.java | 36 - .../compare/org/eclipse/compare/IStreamMerger.java | 69 - .../compare/org/eclipse/compare/ITypedElement.java | 68 - .../org/eclipse/compare/IViewerCreator.java | 34 - .../org/eclipse/compare/NavigationAction.java | 94 - .../compare/org/eclipse/compare/ResourceNode.java | 215 - .../compare/org/eclipse/compare/Splitter.java | 129 - .../eclipse/compare/ZipFileStructureCreator.java | 322 -- .../contentmergeviewer/ContentMergeViewer.java | 1043 ----- .../compare/contentmergeviewer/IDocumentRange.java | 54 - .../IMergeViewerContentProvider.java | 155 - .../contentmergeviewer/ITokenComparator.java | 57 - .../contentmergeviewer/TextMergeViewer.java | 4303 -------------------- .../TextMergeViewerResources.properties | 98 - .../compare/contentmergeviewer/package.html | 45 - .../eclipse/compare/internal/AbstractViewer.java | 38 - .../compare/internal/AddFromHistoryAction.java | 139 - .../internal/AddFromHistoryAction.properties | 45 - .../compare/internal/AddFromHistoryDialog.java | 475 --- .../compare/internal/BaseCompareAction.java | 43 - .../compare/internal/BinaryCompareViewer.java | 117 - .../internal/BinaryCompareViewerCreator.java | 29 - .../BinaryCompareViewerResources.properties | 22 - .../eclipse/compare/internal/BufferedCanvas.java | 98 - .../compare/internal/BufferedResourceNode.java | 128 - .../compare/internal/ChangePropertyAction.java | 53 - .../eclipse/compare/internal/CompareAction.java | 59 - .../eclipse/compare/internal/CompareDialog.java | 124 - .../eclipse/compare/internal/CompareEditor.java | 260 -- .../compare/internal/CompareEditorContributor.java | 106 - .../eclipse/compare/internal/CompareFilter.java | 397 -- .../eclipse/compare/internal/CompareMessages.java | 33 - .../compare/internal/CompareMessages.properties | 58 - .../eclipse/compare/internal/CompareNavigator.java | 158 - .../compare/internal/CompareOutlinePage.java | 106 - .../compare/internal/ComparePreferencePage.java | 389 -- .../eclipse/compare/internal/CompareUIPlugin.java | 1155 ------ .../compare/internal/CompareWithEditionAction.java | 20 - .../internal/CompareWithEditionAction.properties | 38 - .../org/eclipse/compare/internal/DiffImage.java | 78 - .../compare/internal/DocLineComparator.java | 202 - .../eclipse/compare/internal/DocumentManager.java | 65 - .../eclipse/compare/internal/EditionAction.java | 237 -- .../eclipse/compare/internal/ExceptionHandler.java | 133 - .../compare/internal/ICompareContextIds.java | 53 - .../org/eclipse/compare/internal/INavigatable.java | 21 - .../org/eclipse/compare/internal/IOpenable.java | 24 - .../compare/internal/IResourceProvider.java | 23 - .../org/eclipse/compare/internal/ISavable.java | 19 - .../compare/internal/IViewerDescriptor.java | 41 - .../compare/internal/IgnoreWhiteSpaceAction.java | 26 - .../org/eclipse/compare/internal/ImageCanvas.java | 139 - .../eclipse/compare/internal/ImageMergeViewer.java | 145 - .../compare/internal/ImageMergeViewerCreator.java | 30 - .../internal/ImageMergeViewerResources.properties | 32 - .../compare/internal/ListContentProvider.java | 49 - .../org/eclipse/compare/internal/ListDialog.java | 90 - .../compare/internal/MergeSourceViewer.java | 410 -- .../compare/internal/MergeViewerAction.java | 44 - .../internal/MergeViewerContentProvider.java | 199 - .../org/eclipse/compare/internal/NullViewer.java | 35 - .../compare/internal/OverlayPreferenceStore.java | 452 -- .../compare/internal/ReplaceWithEditionAction.java | 20 - .../internal/ReplaceWithEditionAction.properties | 40 - .../internal/ReplaceWithPreviousEditionAction.java | 21 - .../eclipse/compare/internal/ResizableDialog.java | 163 - .../compare/internal/ResourceCompareInput.java | 423 -- .../compare/internal/ShowPseudoConflicts.java | 26 - .../eclipse/compare/internal/SimpleTextViewer.java | 65 - .../compare/internal/StreamMergerDescriptor.java | 47 - .../internal/StructureCreatorDescriptor.java | 57 - .../eclipse/compare/internal/TabFolderLayout.java | 53 - .../compare/internal/TextMergeViewerCreator.java | 31 - .../compare/internal/TextViewerCreator.java | 32 - .../eclipse/compare/internal/TokenComparator.java | 175 - .../org/eclipse/compare/internal/Utilities.java | 592 --- .../eclipse/compare/internal/ViewerDescriptor.java | 65 - .../compare/internal/ViewerSwitchingCancelled.java | 19 - .../compare/internal/merge/LineComparator.java | 69 - .../compare/internal/merge/MergeMessages.java | 33 - .../internal/merge/MergeMessages.properties | 15 - .../compare/internal/merge/TextStreamMerger.java | 97 - .../internal/patch/CompareWithPatchAction.java | 154 - .../org/eclipse/compare/internal/patch/Diff.java | 102 - .../org/eclipse/compare/internal/patch/Hunk.java | 132 - .../compare/internal/patch/InputPatchPage.java | 532 --- .../eclipse/compare/internal/patch/LineReader.java | 134 - .../compare/internal/patch/PatchErrorDialog.java | 19 - .../compare/internal/patch/PatchMessages.java | 33 - .../internal/patch/PatchMessages.properties | 91 - .../compare/internal/patch/PatchWizard.java | 135 - .../eclipse/compare/internal/patch/Patcher.java | 1081 ----- .../compare/internal/patch/PreviewPatchPage.java | 740 ---- .../compare/org/eclipse/compare/package.html | 113 - .../rangedifferencer/DifferencesIterator.java | 77 - .../compare/rangedifferencer/IRangeComparator.java | 60 - .../rangedifferencer/LinkedRangeDifference.java | 57 - .../compare/rangedifferencer/RangeDifference.java | 208 - .../compare/rangedifferencer/RangeDifferencer.java | 536 --- .../eclipse/compare/rangedifferencer/package.html | 44 - .../structuremergeviewer/DiffContainer.java | 107 - .../compare/structuremergeviewer/DiffElement.java | 93 - .../compare/structuremergeviewer/DiffNode.java | 365 -- .../structuremergeviewer/DiffTreeViewer.java | 727 ---- .../DiffTreeViewerResources.properties | 53 - .../compare/structuremergeviewer/Differencer.java | 529 --- .../structuremergeviewer/DocumentRangeNode.java | 358 -- .../structuremergeviewer/ICompareInput.java | 142 - .../ICompareInputChangeListener.java | 38 - .../structuremergeviewer/IDiffContainer.java | 62 - .../compare/structuremergeviewer/IDiffElement.java | 61 - .../structuremergeviewer/IStructureComparator.java | 45 - .../structuremergeviewer/IStructureCreator.java | 110 - .../structuremergeviewer/StructureDiffViewer.java | 375 -- .../compare/structuremergeviewer/package.html | 79 - .../icons/full/dlcl16/ancestorpane_co.gif | Bin 348 -> 0 bytes .../icons/full/dlcl16/copy_l_co.gif | Bin 361 -> 0 bytes .../icons/full/dlcl16/copy_r_co.gif | Bin 373 -> 0 bytes .../icons/full/dlcl16/copycont_l_co.gif | Bin 351 -> 0 bytes .../icons/full/dlcl16/copycont_r_co.gif | Bin 354 -> 0 bytes .../icons/full/dlcl16/next_nav.gif | Bin 152 -> 0 bytes .../icons/full/dlcl16/prev_nav.gif | Bin 152 -> 0 bytes .../icons/full/dlcl16/smartmode_co.gif | Bin 330 -> 0 bytes .../icons/full/dlcl16/syncpane_co.gif | Bin 235 -> 0 bytes .../icons/full/dlcl16/twowaycompare_co.gif | Bin 225 -> 0 bytes .../icons/full/dtool16/conflict_edit.gif | Bin 142 -> 0 bytes .../icons/full/dtool16/ignorews_edit.gif | Bin 247 -> 0 bytes .../icons/full/elcl16/ancestorpane_co.gif | Bin 623 -> 0 bytes .../icons/full/elcl16/copy_l_co.gif | Bin 607 -> 0 bytes .../icons/full/elcl16/copy_r_co.gif | Bin 625 -> 0 bytes .../icons/full/elcl16/copycont_l_co.gif | Bin 582 -> 0 bytes .../icons/full/elcl16/copycont_r_co.gif | Bin 578 -> 0 bytes .../icons/full/elcl16/next_nav.gif | Bin 332 -> 0 bytes .../icons/full/elcl16/prev_nav.gif | Bin 322 -> 0 bytes .../icons/full/elcl16/smartmode_co.gif | Bin 553 -> 0 bytes .../icons/full/elcl16/syncpane_co.gif | Bin 604 -> 0 bytes .../icons/full/elcl16/twowaycompare_co.gif | Bin 376 -> 0 bytes .../icons/full/etool16/conflict_edit.gif | Bin 204 -> 0 bytes .../icons/full/etool16/ignorews_edit.gif | Bin 619 -> 0 bytes .../icons/full/eview16/compare_view.gif | Bin 224 -> 0 bytes .../icons/full/obj16/day_obj.gif | Bin 594 -> 0 bytes .../icons/full/obj16/resource_obj.gif | Bin 535 -> 0 bytes .../icons/full/ovr16/add_ov.gif | Bin 186 -> 0 bytes .../icons/full/ovr16/chg_ov.gif | Bin 187 -> 0 bytes .../icons/full/ovr16/confadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/confchg_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/confdel_ov.gif | Bin 192 -> 0 bytes .../icons/full/ovr16/del_ov.gif | Bin 184 -> 0 bytes .../icons/full/ovr16/error_ov.gif | Bin 179 -> 0 bytes .../icons/full/ovr16/inadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/inchg_ov.gif | Bin 191 -> 0 bytes .../icons/full/ovr16/indel_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/outadd_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/outchg_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/outdel_ov.gif | Bin 188 -> 0 bytes .../icons/full/ovr16/r_inadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/r_inchg_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_indel_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_outadd_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_outchg_ov.gif | Bin 196 -> 0 bytes .../icons/full/ovr16/r_outdel_ov.gif | Bin 188 -> 0 bytes .../icons/full/wizban/applypatch_wizban.gif | Bin 3398 -> 0 bytes .../old_buildnotes_compare_3_0.html | 1557 ------- bundles/org.eclipse.compare/plugin.properties | 216 - bundles/org.eclipse.compare/plugin.xml | 368 -- .../plugins/org.eclipse.compare/.classpath | 7 - .../plugins/org.eclipse.compare/.cvsignore | 1 - .../plugins/org.eclipse.compare/.project | 37 - .../.settings/org.eclipse.jdt.core.prefs | 70 - .../plugins/org.eclipse.compare/about.html | 30 - .../plugins/org.eclipse.compare/build.properties | 18 - .../org.eclipse.compare/buildnotes_compare.html | 87 - .../org/eclipse/compare/BufferedContent.java | 130 - .../org/eclipse/compare/CompareConfiguration.java | 450 -- .../org/eclipse/compare/CompareEditorInput.java | 815 ---- .../compare/org/eclipse/compare/CompareUI.java | 323 -- .../org/eclipse/compare/CompareViewerPane.java | 151 - .../compare/CompareViewerSwitchingPane.java | 369 -- .../eclipse/compare/EditionSelectionDialog.java | 1128 ----- .../compare/org/eclipse/compare/HistoryItem.java | 109 - .../org/eclipse/compare/ICompareNavigator.java | 34 - .../eclipse/compare/IContentChangeListener.java | 30 - .../eclipse/compare/IContentChangeNotifier.java | 39 - .../org/eclipse/compare/IEditableContent.java | 70 - .../compare/IEncodedStreamContentAccessor.java | 39 - .../org/eclipse/compare/IModificationDate.java | 31 - .../eclipse/compare/IPropertyChangeNotifier.java | 41 - .../eclipse/compare/IStreamContentAccessor.java | 36 - .../compare/org/eclipse/compare/IStreamMerger.java | 69 - .../compare/org/eclipse/compare/ITypedElement.java | 68 - .../org/eclipse/compare/IViewerCreator.java | 34 - .../org/eclipse/compare/NavigationAction.java | 94 - .../compare/org/eclipse/compare/ResourceNode.java | 215 - .../compare/org/eclipse/compare/Splitter.java | 129 - .../eclipse/compare/ZipFileStructureCreator.java | 322 -- .../contentmergeviewer/ContentMergeViewer.java | 1043 ----- .../compare/contentmergeviewer/IDocumentRange.java | 54 - .../IMergeViewerContentProvider.java | 155 - .../contentmergeviewer/ITokenComparator.java | 57 - .../contentmergeviewer/TextMergeViewer.java | 4303 -------------------- .../TextMergeViewerResources.properties | 98 - .../compare/contentmergeviewer/package.html | 45 - .../eclipse/compare/internal/AbstractViewer.java | 38 - .../compare/internal/AddFromHistoryAction.java | 139 - .../internal/AddFromHistoryAction.properties | 45 - .../compare/internal/AddFromHistoryDialog.java | 475 --- .../compare/internal/BaseCompareAction.java | 43 - .../compare/internal/BinaryCompareViewer.java | 117 - .../internal/BinaryCompareViewerCreator.java | 29 - .../BinaryCompareViewerResources.properties | 22 - .../eclipse/compare/internal/BufferedCanvas.java | 98 - .../compare/internal/BufferedResourceNode.java | 128 - .../compare/internal/ChangePropertyAction.java | 53 - .../eclipse/compare/internal/CompareAction.java | 59 - .../eclipse/compare/internal/CompareDialog.java | 124 - .../eclipse/compare/internal/CompareEditor.java | 260 -- .../compare/internal/CompareEditorContributor.java | 106 - .../eclipse/compare/internal/CompareFilter.java | 397 -- .../eclipse/compare/internal/CompareMessages.java | 33 - .../compare/internal/CompareMessages.properties | 58 - .../eclipse/compare/internal/CompareNavigator.java | 158 - .../compare/internal/CompareOutlinePage.java | 106 - .../compare/internal/ComparePreferencePage.java | 389 -- .../eclipse/compare/internal/CompareUIPlugin.java | 1155 ------ .../compare/internal/CompareWithEditionAction.java | 20 - .../internal/CompareWithEditionAction.properties | 38 - .../org/eclipse/compare/internal/DiffImage.java | 78 - .../compare/internal/DocLineComparator.java | 202 - .../eclipse/compare/internal/DocumentManager.java | 65 - .../eclipse/compare/internal/EditionAction.java | 237 -- .../eclipse/compare/internal/ExceptionHandler.java | 133 - .../compare/internal/ICompareContextIds.java | 53 - .../org/eclipse/compare/internal/INavigatable.java | 21 - .../org/eclipse/compare/internal/IOpenable.java | 24 - .../compare/internal/IResourceProvider.java | 23 - .../org/eclipse/compare/internal/ISavable.java | 19 - .../compare/internal/IViewerDescriptor.java | 41 - .../compare/internal/IgnoreWhiteSpaceAction.java | 26 - .../org/eclipse/compare/internal/ImageCanvas.java | 139 - .../eclipse/compare/internal/ImageMergeViewer.java | 145 - .../compare/internal/ImageMergeViewerCreator.java | 30 - .../internal/ImageMergeViewerResources.properties | 32 - .../compare/internal/ListContentProvider.java | 49 - .../org/eclipse/compare/internal/ListDialog.java | 90 - .../compare/internal/MergeSourceViewer.java | 410 -- .../compare/internal/MergeViewerAction.java | 44 - .../internal/MergeViewerContentProvider.java | 199 - .../org/eclipse/compare/internal/NullViewer.java | 35 - .../compare/internal/OverlayPreferenceStore.java | 452 -- .../compare/internal/ReplaceWithEditionAction.java | 20 - .../internal/ReplaceWithEditionAction.properties | 40 - .../internal/ReplaceWithPreviousEditionAction.java | 21 - .../eclipse/compare/internal/ResizableDialog.java | 163 - .../compare/internal/ResourceCompareInput.java | 423 -- .../compare/internal/ShowPseudoConflicts.java | 26 - .../eclipse/compare/internal/SimpleTextViewer.java | 65 - .../compare/internal/StreamMergerDescriptor.java | 47 - .../internal/StructureCreatorDescriptor.java | 57 - .../eclipse/compare/internal/TabFolderLayout.java | 53 - .../compare/internal/TextMergeViewerCreator.java | 31 - .../compare/internal/TextViewerCreator.java | 32 - .../eclipse/compare/internal/TokenComparator.java | 175 - .../org/eclipse/compare/internal/Utilities.java | 592 --- .../eclipse/compare/internal/ViewerDescriptor.java | 65 - .../compare/internal/ViewerSwitchingCancelled.java | 19 - .../compare/internal/merge/LineComparator.java | 69 - .../compare/internal/merge/MergeMessages.java | 33 - .../internal/merge/MergeMessages.properties | 15 - .../compare/internal/merge/TextStreamMerger.java | 97 - .../compare/internal/patch/Attic/LineReader.java | 134 - .../internal/patch/CompareWithPatchAction.java | 154 - .../org/eclipse/compare/internal/patch/Diff.java | 102 - .../org/eclipse/compare/internal/patch/Hunk.java | 132 - .../compare/internal/patch/InputPatchPage.java | 532 --- .../eclipse/compare/internal/patch/LineReader.java | 134 - .../compare/internal/patch/PatchErrorDialog.java | 19 - .../compare/internal/patch/PatchMessages.java | 33 - .../internal/patch/PatchMessages.properties | 91 - .../compare/internal/patch/PatchWizard.java | 135 - .../eclipse/compare/internal/patch/Patcher.java | 1081 ----- .../compare/internal/patch/PreviewPatchPage.java | 740 ---- .../compare/org/eclipse/compare/package.html | 113 - .../rangedifferencer/DifferencesIterator.java | 77 - .../compare/rangedifferencer/IRangeComparator.java | 60 - .../rangedifferencer/LinkedRangeDifference.java | 57 - .../compare/rangedifferencer/RangeDifference.java | 208 - .../compare/rangedifferencer/RangeDifferencer.java | 536 --- .../eclipse/compare/rangedifferencer/package.html | 44 - .../structuremergeviewer/DiffContainer.java | 107 - .../compare/structuremergeviewer/DiffElement.java | 93 - .../compare/structuremergeviewer/DiffNode.java | 365 -- .../structuremergeviewer/DiffTreeViewer.java | 727 ---- .../DiffTreeViewerResources.properties | 53 - .../compare/structuremergeviewer/Differencer.java | 529 --- .../structuremergeviewer/DocumentRangeNode.java | 358 -- .../structuremergeviewer/ICompareInput.java | 142 - .../ICompareInputChangeListener.java | 38 - .../structuremergeviewer/IDiffContainer.java | 62 - .../compare/structuremergeviewer/IDiffElement.java | 61 - .../structuremergeviewer/IStructureComparator.java | 45 - .../structuremergeviewer/IStructureCreator.java | 110 - .../structuremergeviewer/StructureDiffViewer.java | 375 -- .../compare/structuremergeviewer/package.html | 79 - .../icons/full/dlcl16/ancestorpane_co.gif | Bin 348 -> 0 bytes .../icons/full/dlcl16/copy_l_co.gif | Bin 361 -> 0 bytes .../icons/full/dlcl16/copy_r_co.gif | Bin 373 -> 0 bytes .../icons/full/dlcl16/copycont_l_co.gif | Bin 351 -> 0 bytes .../icons/full/dlcl16/copycont_r_co.gif | Bin 354 -> 0 bytes .../icons/full/dlcl16/next_nav.gif | Bin 152 -> 0 bytes .../icons/full/dlcl16/prev_nav.gif | Bin 152 -> 0 bytes .../icons/full/dlcl16/smartmode_co.gif | Bin 330 -> 0 bytes .../icons/full/dlcl16/syncpane_co.gif | Bin 235 -> 0 bytes .../icons/full/dlcl16/twowaycompare_co.gif | Bin 225 -> 0 bytes .../icons/full/dtool16/conflict_edit.gif | Bin 142 -> 0 bytes .../icons/full/dtool16/ignorews_edit.gif | Bin 247 -> 0 bytes .../icons/full/elcl16/ancestorpane_co.gif | Bin 623 -> 0 bytes .../icons/full/elcl16/copy_l_co.gif | Bin 607 -> 0 bytes .../icons/full/elcl16/copy_r_co.gif | Bin 625 -> 0 bytes .../icons/full/elcl16/copycont_l_co.gif | Bin 582 -> 0 bytes .../icons/full/elcl16/copycont_r_co.gif | Bin 578 -> 0 bytes .../icons/full/elcl16/next_nav.gif | Bin 332 -> 0 bytes .../icons/full/elcl16/prev_nav.gif | Bin 322 -> 0 bytes .../icons/full/elcl16/smartmode_co.gif | Bin 553 -> 0 bytes .../icons/full/elcl16/syncpane_co.gif | Bin 604 -> 0 bytes .../icons/full/elcl16/twowaycompare_co.gif | Bin 376 -> 0 bytes .../icons/full/etool16/conflict_edit.gif | Bin 204 -> 0 bytes .../icons/full/etool16/ignorews_edit.gif | Bin 619 -> 0 bytes .../icons/full/eview16/compare_view.gif | Bin 224 -> 0 bytes .../icons/full/obj16/day_obj.gif | Bin 594 -> 0 bytes .../icons/full/obj16/resource_obj.gif | Bin 535 -> 0 bytes .../icons/full/ovr16/add_ov.gif | Bin 186 -> 0 bytes .../icons/full/ovr16/chg_ov.gif | Bin 187 -> 0 bytes .../icons/full/ovr16/confadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/confchg_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/confdel_ov.gif | Bin 192 -> 0 bytes .../icons/full/ovr16/del_ov.gif | Bin 184 -> 0 bytes .../icons/full/ovr16/error_ov.gif | Bin 179 -> 0 bytes .../icons/full/ovr16/inadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/inchg_ov.gif | Bin 191 -> 0 bytes .../icons/full/ovr16/indel_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/outadd_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/outchg_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/outdel_ov.gif | Bin 188 -> 0 bytes .../icons/full/ovr16/r_inadd_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/r_inchg_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_indel_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_outadd_ov.gif | Bin 190 -> 0 bytes .../icons/full/ovr16/r_outchg_ov.gif | Bin 196 -> 0 bytes .../icons/full/ovr16/r_outdel_ov.gif | Bin 188 -> 0 bytes .../icons/full/wizban/applypatch_wizban.gif | Bin 3398 -> 0 bytes .../old_buildnotes_compare_3_0.html | 1557 ------- .../plugins/org.eclipse.compare/plugin.properties | 216 - .../plugins/org.eclipse.compare/plugin.xml | 368 -- .../schema/contentMergeViewers.exsd | 149 - .../org.eclipse.compare/schema/contentViewers.exsd | 148 - .../org.eclipse.compare/schema/streamMergers.exsd | 154 - .../schema/structureCreators.exsd | 147 - .../schema/structureMergeViewers.exsd | 150 - .../org.eclipse.compare/scripts/exportplugin.xml | 30 - .../schema/contentMergeViewers.exsd | 149 - .../org.eclipse.compare/schema/contentViewers.exsd | 148 - .../org.eclipse.compare/schema/streamMergers.exsd | 154 - .../schema/structureCreators.exsd | 147 - .../schema/structureMergeViewers.exsd | 150 - .../org.eclipse.compare/scripts/exportplugin.xml | 30 - bundles/org.eclipse.team.core/.classpath | 7 - bundles/org.eclipse.team.core/.cvsignore | 1 - bundles/org.eclipse.team.core/.options | 10 - bundles/org.eclipse.team.core/.project | 30 - bundles/org.eclipse.team.core/about.html | 30 - bundles/org.eclipse.team.core/build.properties | 14 - bundles/org.eclipse.team.core/buildnotes_team.html | 547 --- bundles/org.eclipse.team.core/plugin.properties | 17 - bundles/org.eclipse.team.core/plugin.xml | 165 - .../schema/defaultFileModificationValidator.exsd | 96 - .../org.eclipse.team.core/schema/fileTypes.exsd | 112 - bundles/org.eclipse.team.core/schema/ignore.exsd | 110 - .../org.eclipse.team.core/schema/projectSets.exsd | 119 - .../org.eclipse.team.core/schema/repository.exsd | 134 - .../team/core/DefaultRepositoryProviderType.java | 18 - .../src/org/eclipse/team/core/IFileTypeInfo.java | 39 - .../src/org/eclipse/team/core/IIgnoreInfo.java | 40 - .../eclipse/team/core/IProjectSetSerializer.java | 69 - .../src/org/eclipse/team/core/ITeamStatus.java | 48 - .../eclipse/team/core/ProjectSetCapability.java | 268 -- .../team/core/ProjectSetSerializationContext.java | 82 - .../org/eclipse/team/core/RepositoryProvider.java | 666 --- .../eclipse/team/core/RepositoryProviderType.java | 174 - .../src/org/eclipse/team/core/Team.java | 601 --- .../src/org/eclipse/team/core/TeamException.java | 128 - .../src/org/eclipse/team/core/TeamStatus.java | 55 - .../src/org/eclipse/team/core/package.html | 20 - .../team/core/subscribers/ActiveChangeSet.java | 213 - .../eclipse/team/core/subscribers/ChangeSet.java | 183 - .../team/core/subscribers/ChangeSetCollector.java | 210 - .../team/core/subscribers/CheckedInChangeSet.java | 32 - .../core/subscribers/IChangeSetChangeListener.java | 58 - .../core/subscribers/ISubscriberChangeEvent.java | 75 - .../subscribers/ISubscriberChangeListener.java | 36 - .../eclipse/team/core/subscribers/Subscriber.java | 334 -- .../core/subscribers/SubscriberChangeEvent.java | 77 - .../subscribers/SubscriberChangeSetCollector.java | 566 --- .../org/eclipse/team/core/subscribers/package.html | 50 - .../team/core/synchronize/FastSyncInfoFilter.java | 225 - .../core/synchronize/ISyncInfoSetChangeEvent.java | 68 - .../synchronize/ISyncInfoSetChangeListener.java | 77 - .../core/synchronize/ISyncInfoTreeChangeEvent.java | 53 - .../eclipse/team/core/synchronize/SyncInfo.java | 474 --- .../team/core/synchronize/SyncInfoFilter.java | 94 - .../eclipse/team/core/synchronize/SyncInfoSet.java | 650 --- .../team/core/synchronize/SyncInfoTree.java | 353 -- .../org/eclipse/team/core/synchronize/package.html | 61 - .../core/variants/AbstractResourceVariantTree.java | 272 -- .../team/core/variants/CachedResourceVariant.java | 282 -- .../team/core/variants/IResourceVariant.java | 84 - .../core/variants/IResourceVariantComparator.java | 61 - .../team/core/variants/IResourceVariantTree.java | 88 - .../core/variants/ISynchronizerChangeListener.java | 30 - .../PersistantResourceVariantByteStore.java | 179 - .../core/variants/ResourceVariantByteStore.java | 135 - .../team/core/variants/ResourceVariantTree.java | 117 - .../variants/ResourceVariantTreeSubscriber.java | 185 - .../variants/SessionResourceVariantByteStore.java | 145 - .../team/core/variants/ThreeWayRemoteTree.java | 117 - .../core/variants/ThreeWayResourceComparator.java | 93 - .../team/core/variants/ThreeWaySubscriber.java | 174 - .../team/core/variants/ThreeWaySynchronizer.java | 519 --- .../org/eclipse/team/core/variants/package.html | 80 - .../src/org/eclipse/team/internal/core/Assert.java | 108 - .../team/internal/core/BackgroundEventHandler.java | 429 -- .../core/DefaultFileModificationValidator.java | 114 - .../team/internal/core/DefaultMoveDeleteHook.java | 101 - .../internal/core/DefaultProjectSetCapability.java | 26 - .../team/internal/core/ExceptionCollector.java | 157 - .../core/FileModificationValidatorManager.java | 109 - .../eclipse/team/internal/core/IJobListener.java | 26 - .../internal/core/InfiniteSubProgressMonitor.java | 91 - .../team/internal/core/MoveDeleteManager.java | 116 - .../team/internal/core/NullSubProgressMonitor.java | 65 - .../core/PessimisticResourceRuleFactory.java | 68 - .../src/org/eclipse/team/internal/core/Policy.java | 117 - .../team/internal/core/ResourceVariantCache.java | 247 -- .../internal/core/ResourceVariantCacheEntry.java | 216 - .../src/org/eclipse/team/internal/core/Sorter.java | 67 - .../eclipse/team/internal/core/StringMatcher.java | 398 -- .../team/internal/core/TeamHookDispatcher.java | 89 - .../org/eclipse/team/internal/core/TeamPlugin.java | 161 - .../eclipse/team/internal/core/messages.properties | 126 - .../core/simpleAccess/SimpleAccessOperations.java | 267 -- .../internal/core/streams/CRLFtoLFInputStream.java | 155 - .../internal/core/streams/LFtoCRLFInputStream.java | 146 - .../internal/core/streams/PollingInputStream.java | 189 - .../internal/core/streams/PollingOutputStream.java | 189 - .../core/streams/ProgressMonitorInputStream.java | 139 - .../core/streams/SizeConstrainedInputStream.java | 138 - .../internal/core/streams/TimeoutInputStream.java | 325 -- .../internal/core/streams/TimeoutOutputStream.java | 289 -- .../internal/core/subscribers/BatchingLock.java | 339 -- .../core/subscribers/ContentComparator.java | 142 - .../DescendantResourceVariantByteStore.java | 183 - .../core/subscribers/SubscriberEventHandler.java | 490 --- .../subscribers/SubscriberResourceCollector.java | 244 -- .../subscribers/SubscriberSyncInfoCollector.java | 215 - .../core/subscribers/SubscriberSyncInfoSet.java | 89 - .../core/subscribers/SyncByteConverter.java | 152 - .../core/subscribers/SyncInfoStatistics.java | 107 - .../core/subscribers/SyncInfoTreeChangeEvent.java | 95 - .../core/subscribers/SyncInfoWorkingSetFilter.java | 110 - .../core/subscribers/SyncSetChangedEvent.java | 108 - .../internal/core/subscribers/SyncSetInput.java | 93 - .../subscribers/SyncSetInputFromSubscriber.java | 57 - .../core/subscribers/SyncSetInputFromSyncSet.java | 120 - .../core/subscribers/ThreeWayBaseTree.java | 113 - .../WorkingSetFilteredSyncInfoCollector.java | 195 - .../core/subscribers/WorkingSetSyncSetInput.java | 36 - bundles/org.eclipse.team.cvs.core/.classpath | 7 - bundles/org.eclipse.team.cvs.core/.cvsignore | 1 - bundles/org.eclipse.team.cvs.core/.options | 18 - bundles/org.eclipse.team.cvs.core/.project | 32 - bundles/org.eclipse.team.cvs.core/about.html | 45 - bundles/org.eclipse.team.cvs.core/asl-v20.txt | 202 - bundles/org.eclipse.team.cvs.core/build.properties | 14 - .../org.eclipse.team.cvs.core/buildnotes_cvs.html | 751 ---- bundles/org.eclipse.team.cvs.core/doc/hglegal.htm | 14 - bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif | Bin 1045 -> 0 bytes .../doc/org_eclipse_team_cvs_core.html | 15 - .../org.eclipse.team.cvs.core/plugin.properties | 13 - bundles/org.eclipse.team.cvs.core/plugin.xml | 197 - .../schema/authenticator.exsd | 97 - .../schema/connectionmethods.exsd | 146 - .../schema/filemodificationvalidator.exsd | 97 - .../team/internal/ccvs/core/CVSAnnotateBlock.java | 131 - .../internal/ccvs/core/CVSCompareSubscriber.java | 277 -- .../core/CVSCoreFileModificationValidator.java | 177 - .../team/internal/ccvs/core/CVSException.java | 102 - .../internal/ccvs/core/CVSMergeSubscriber.java | 351 -- .../team/internal/ccvs/core/CVSMergeSyncInfo.java | 62 - .../ccvs/core/CVSProjectSetCapability.java | 519 --- .../team/internal/ccvs/core/CVSProviderPlugin.java | 620 --- .../core/CVSRevisionNumberCompareCriteria.java | 104 - .../eclipse/team/internal/ccvs/core/CVSStatus.java | 71 - .../team/internal/ccvs/core/CVSSyncInfo.java | 371 -- .../internal/ccvs/core/CVSSyncTreeSubscriber.java | 146 - .../eclipse/team/internal/ccvs/core/CVSTag.java | 131 - .../team/internal/ccvs/core/CVSTeamProvider.java | 1013 ----- .../internal/ccvs/core/CVSTeamProviderType.java | 37 - .../internal/ccvs/core/CVSWorkspaceSubscriber.java | 282 -- .../eclipse/team/internal/ccvs/core/DateUtil.java | 92 - .../team/internal/ccvs/core/EditorsInfo.java | 95 - .../ccvs/core/ICVSDecoratorEnablementListener.java | 30 - .../eclipse/team/internal/ccvs/core/ICVSFile.java | 198 - .../ccvs/core/ICVSFileModificationValidator.java | 30 - .../team/internal/ccvs/core/ICVSFolder.java | 181 - .../team/internal/ccvs/core/ICVSListener.java | 19 - .../team/internal/ccvs/core/ICVSRemoteFile.java | 58 - .../team/internal/ccvs/core/ICVSRemoteFolder.java | 57 - .../internal/ccvs/core/ICVSRemoteResource.java | 88 - .../internal/ccvs/core/ICVSRepositoryLocation.java | 157 - .../team/internal/ccvs/core/ICVSResource.java | 173 - .../internal/ccvs/core/ICVSResourceVisitor.java | 23 - .../team/internal/ccvs/core/ICVSRunnable.java | 42 - .../team/internal/ccvs/core/ICVSStorage.java | 57 - .../team/internal/ccvs/core/IConnectionMethod.java | 51 - .../eclipse/team/internal/ccvs/core/ILogEntry.java | 66 - .../ccvs/core/IResourceStateChangeListener.java | 97 - .../team/internal/ccvs/core/IServerConnection.java | 48 - .../internal/ccvs/core/IUserAuthenticator.java | 126 - .../eclipse/team/internal/ccvs/core/IUserInfo.java | 40 - .../eclipse/team/internal/ccvs/core/Policy.java | 154 - .../ccvs/core/client/AbstractMessageCommand.java | 36 - .../ccvs/core/client/AbstractStructureVisitor.java | 292 -- .../team/internal/ccvs/core/client/Add.java | 100 - .../ccvs/core/client/AddStructureVisitor.java | 64 - .../team/internal/ccvs/core/client/Admin.java | 22 - .../team/internal/ccvs/core/client/Annotate.java | 32 - .../ccvs/core/client/ByteCountOutputStream.java | 25 - .../ccvs/core/client/CRLFDetectInputStream.java | 98 - .../ccvs/core/client/CheckedInHandler.java | 54 - .../team/internal/ccvs/core/client/Checkout.java | 188 - .../ccvs/core/client/CheckoutWithOverwrite.java | 64 - .../team/internal/ccvs/core/client/Command.java | 764 ---- .../ccvs/core/client/CommandOutputListener.java | 71 - .../team/internal/ccvs/core/client/Commit.java | 124 - .../ccvs/core/client/ConsoleListeners.java | 131 - .../internal/ccvs/core/client/CopyHandler.java | 61 - .../team/internal/ccvs/core/client/Diff.java | 64 - .../ccvs/core/client/DiffStructureVisitor.java | 53 - .../team/internal/ccvs/core/client/Editors.java | 36 - .../internal/ccvs/core/client/ExpandModules.java | 31 - .../ccvs/core/client/FileStructureVisitor.java | 118 - .../team/internal/ccvs/core/client/Import.java | 69 - .../ccvs/core/client/ImportStructureVisitor.java | 132 - .../team/internal/ccvs/core/client/Log.java | 42 - .../team/internal/ccvs/core/client/MTHandler.java | 105 - .../internal/ccvs/core/client/ModTimeHandler.java | 49 - .../ccvs/core/client/ModifiedFileSender.java | 53 - .../ccvs/core/client/ModuleExpansionHandler.java | 35 - .../internal/ccvs/core/client/NOOPCommand.java | 59 - .../internal/ccvs/core/client/NOOPVisitor.java | 43 - .../internal/ccvs/core/client/NewEntryHandler.java | 53 - .../internal/ccvs/core/client/NotifiedHandler.java | 55 - .../ccvs/core/client/PruneFolderVisitor.java | 106 - .../team/internal/ccvs/core/client/RDiff.java | 46 - .../team/internal/ccvs/core/client/RLog.java | 96 - .../team/internal/ccvs/core/client/RTag.java | 110 - .../internal/ccvs/core/client/RemoteCommand.java | 73 - .../team/internal/ccvs/core/client/Remove.java | 36 - .../ccvs/core/client/RemoveEntryHandler.java | 61 - .../internal/ccvs/core/client/RemovedHandler.java | 81 - .../team/internal/ccvs/core/client/Request.java | 239 -- .../internal/ccvs/core/client/ResponseHandler.java | 157 - .../team/internal/ccvs/core/client/Session.java | 1011 ----- .../internal/ccvs/core/client/StaticHandler.java | 76 - .../team/internal/ccvs/core/client/Status.java | 21 - .../internal/ccvs/core/client/StickyHandler.java | 83 - .../team/internal/ccvs/core/client/SyncUpdate.java | 50 - .../team/internal/ccvs/core/client/Tag.java | 107 - .../internal/ccvs/core/client/TagFileSender.java | 50 - .../internal/ccvs/core/client/TemplateHandler.java | 108 - .../team/internal/ccvs/core/client/Update.java | 213 - .../ccvs/core/client/UpdateMergableOnly.java | 161 - .../ccvs/core/client/UpdateWithOverwrite.java | 64 - .../internal/ccvs/core/client/UpdatedHandler.java | 149 - .../internal/ccvs/core/client/ValidRequests.java | 28 - .../ccvs/core/client/ValidRequestsHandler.java | 43 - .../team/internal/ccvs/core/client/Version.java | 98 - .../core/client/listeners/AdminKSubstListener.java | 125 - .../core/client/listeners/AnnotateListener.java | 121 - .../core/client/listeners/CompareDiffListener.java | 115 - .../ccvs/core/client/listeners/DiffListener.java | 56 - .../core/client/listeners/EditorsListener.java | 103 - .../client/listeners/ICommandOutputListener.java | 72 - .../core/client/listeners/IConsoleListener.java | 47 - .../core/client/listeners/ILogEntryListener.java | 26 - .../core/client/listeners/IMessagePatterns.java | 38 - .../core/client/listeners/IStatusListener.java | 27 - .../client/listeners/IUpdateMessageListener.java | 51 - .../ccvs/core/client/listeners/LogEntry.java | 99 - .../ccvs/core/client/listeners/LogListener.java | 226 - .../listeners/ModuleDefinitionsListener.java | 71 - .../core/client/listeners/ModuleExpansion.java | 126 - .../client/listeners/RDiffSummaryListener.java | 144 - .../client/listeners/ServerMessageLineMatcher.java | 99 - .../ccvs/core/client/listeners/StatusListener.java | 77 - .../ccvs/core/client/listeners/TagListener.java | 64 - .../ccvs/core/client/listeners/UpdateListener.java | 293 -- .../connection/CVSAuthenticationException.java | 53 - .../core/connection/CVSCommunicationException.java | 79 - .../core/connection/CVSRepositoryLocation.java | 1235 ------ .../ccvs/core/connection/CVSServerException.java | 79 - .../internal/ccvs/core/connection/Connection.java | 229 -- .../ccvs/core/connection/ExtConnection.java | 133 - .../ccvs/core/connection/ExtConnectionMethod.java | 33 - .../ccvs/core/connection/PServerConnection.java | 257 -- .../core/connection/PServerConnectionMethod.java | 35 - .../internal/ccvs/core/connection/UserInfo.java | 64 - .../team/internal/ccvs/core/messages.properties | 351 -- .../ccvs/core/resources/CVSEntryLineTag.java | 129 - .../ccvs/core/resources/CVSWorkspaceRoot.java | 329 -- .../internal/ccvs/core/resources/EclipseFile.java | 613 --- .../ccvs/core/resources/EclipseFolder.java | 380 -- .../ccvs/core/resources/EclipseResource.java | 281 -- .../ccvs/core/resources/EclipseSynchronizer.java | 1888 --------- .../core/resources/FileContentCachingService.java | 137 - .../core/resources/FileModificationManager.java | 209 - .../internal/ccvs/core/resources/RemoteFile.java | 657 --- .../internal/ccvs/core/resources/RemoteFolder.java | 615 --- .../core/resources/RemoteFolderMemberFetcher.java | 314 -- .../ccvs/core/resources/RemoteFolderSandbox.java | 101 - .../ccvs/core/resources/RemoteFolderTree.java | 65 - .../core/resources/RemoteFolderTreeBuilder.java | 813 ---- .../internal/ccvs/core/resources/RemoteModule.java | 379 -- .../ccvs/core/resources/RemoteResource.java | 238 -- .../resources/SessionPropertySyncInfoCache.java | 490 --- .../ccvs/core/resources/SyncInfoCache.java | 149 - .../core/resources/SynchronizerSyncInfoCache.java | 337 -- .../internal/ccvs/core/syncinfo/BaserevInfo.java | 86 - .../core/syncinfo/CVSBaseResourceVariantTree.java | 66 - .../CVSDescendantResourceVariantByteStore.java | 132 - .../ccvs/core/syncinfo/CVSResourceVariantTree.java | 336 -- .../syncinfo/DeferredResourceChangeHandler.java | 111 - .../ccvs/core/syncinfo/FolderSyncInfo.java | 324 -- .../core/syncinfo/MultiTagResourceVariantTree.java | 44 - .../ccvs/core/syncinfo/MutableFolderSyncInfo.java | 63 - .../core/syncinfo/MutableResourceSyncInfo.java | 166 - .../internal/ccvs/core/syncinfo/NotifyInfo.java | 181 - .../internal/ccvs/core/syncinfo/ReentrantLock.java | 75 - .../ccvs/core/syncinfo/ResourceSyncInfo.java | 962 ----- .../team/internal/ccvs/core/util/Assert.java | 104 - .../ccvs/core/util/AssertionFailedException.java | 35 - .../ccvs/core/util/BuildCleanupListener.java | 153 - .../internal/ccvs/core/util/CVSDateFormatter.java | 106 - .../internal/ccvs/core/util/FileNameMatcher.java | 72 - .../internal/ccvs/core/util/KnownRepositories.java | 252 -- .../internal/ccvs/core/util/MoveDeleteHook.java | 340 -- .../ccvs/core/util/PrepareForReplaceVisitor.java | 111 - .../ccvs/core/util/ReplaceWithBaseVisitor.java | 119 - .../core/util/ResourceStateChangeListeners.java | 155 - .../internal/ccvs/core/util/StringMatcher.java | 398 -- .../ccvs/core/util/SyncFileChangeListener.java | 277 -- .../internal/ccvs/core/util/SyncFileWriter.java | 688 ---- .../eclipse/team/internal/ccvs/core/util/Util.java | 591 --- bundles/org.eclipse.team.cvs.ssh/.classpath | 7 - bundles/org.eclipse.team.cvs.ssh/.cvsignore | 1 - bundles/org.eclipse.team.cvs.ssh/.options | 7 - bundles/org.eclipse.team.cvs.ssh/.project | 33 - bundles/org.eclipse.team.cvs.ssh/about.html | 92 - bundles/org.eclipse.team.cvs.ssh/build.properties | 14 - bundles/org.eclipse.team.cvs.ssh/plugin.properties | 12 - bundles/org.eclipse.team.cvs.ssh/plugin.xml | 39 - .../eclipse/team/internal/ccvs/ssh/Blowfish.java | 1220 ------ .../org/eclipse/team/internal/ccvs/ssh/Cipher.java | 25 - .../org/eclipse/team/internal/ccvs/ssh/Client.java | 707 ---- .../team/internal/ccvs/ssh/ClientPacket.java | 53 - .../eclipse/team/internal/ccvs/ssh/KnownHosts.java | 160 - .../org/eclipse/team/internal/ccvs/ssh/Misc.java | 471 --- .../org/eclipse/team/internal/ccvs/ssh/Packet.java | 20 - .../org/eclipse/team/internal/ccvs/ssh/Policy.java | 76 - .../eclipse/team/internal/ccvs/ssh/SSHMethod.java | 34 - .../eclipse/team/internal/ccvs/ssh/SSHPlugin.java | 51 - .../internal/ccvs/ssh/SSHServerConnection.java | 86 - .../team/internal/ccvs/ssh/ServerPacket.java | 164 - .../team/internal/ccvs/ssh/messages.properties | 39 - bundles/org.eclipse.team.cvs.ssh2/.classpath | 8 - bundles/org.eclipse.team.cvs.ssh2/.cvsignore | 1 - bundles/org.eclipse.team.cvs.ssh2/.project | 35 - bundles/org.eclipse.team.cvs.ssh2/about.html | 76 - bundles/org.eclipse.team.cvs.ssh2/build.properties | 18 - bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar | Bin 101612 -> 0 bytes bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar | Bin 102070 -> 0 bytes bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar | Bin 105657 -> 0 bytes .../org.eclipse.team.cvs.ssh2/plugin.properties | 14 - bundles/org.eclipse.team.cvs.ssh2/plugin.xml | 60 - .../team/internal/ccvs/ssh2/CVSSSH2Method.java | 34 - .../team/internal/ccvs/ssh2/CVSSSH2Plugin.java | 80 - .../internal/ccvs/ssh2/CVSSSH2PreferencePage.java | 1350 ------ .../ccvs/ssh2/CVSSSH2ServerConnection.java | 175 - .../team/internal/ccvs/ssh2/ISSHContants.java | 39 - .../team/internal/ccvs/ssh2/JSchSession.java | 361 -- .../team/internal/ccvs/ssh2/PServerSSH2Method.java | 26 - .../ccvs/ssh2/PServerSSH2ServerConnection.java | 142 - .../eclipse/team/internal/ccvs/ssh2/Policy.java | 73 - .../team/internal/ccvs/ssh2/messages.properties | 105 - bundles/org.eclipse.team.cvs.ui/.classpath | 7 - bundles/org.eclipse.team.cvs.ui/.cvsignore | 2 - bundles/org.eclipse.team.cvs.ui/.options | 7 - bundles/org.eclipse.team.cvs.ui/.project | 42 - bundles/org.eclipse.team.cvs.ui/about.html | 30 - bundles/org.eclipse.team.cvs.ui/build.properties | 14 - .../icons/full/dlcl16/clear_co.gif | Bin 328 -> 0 bytes .../icons/full/dlcl16/collapseall.gif | Bin 155 -> 0 bytes .../icons/full/dlcl16/filter_history.gif | Bin 142 -> 0 bytes .../icons/full/dlcl16/newstream_wiz.gif | Bin 146 -> 0 bytes .../icons/full/dlcl16/refresh.gif | Bin 209 -> 0 bytes .../icons/full/dlcl16/synced.gif | Bin 149 -> 0 bytes .../icons/full/dtool16/annotate.gif | Bin 350 -> 0 bytes .../icons/full/dtool16/checkout.gif | Bin 344 -> 0 bytes .../icons/full/dtool16/cvs_synch.gif | Bin 321 -> 0 bytes .../icons/full/dtool16/history.gif | Bin 335 -> 0 bytes .../icons/full/dtool16/ignorefiles.gif | Bin 228 -> 0 bytes .../icons/full/dtool16/newconnect_wiz.gif | Bin 235 -> 0 bytes .../icons/full/dtool16/newlocation_wiz.gif | Bin 361 -> 0 bytes .../icons/full/dtool16/share_prj_wiz.gif | Bin 326 -> 0 bytes .../icons/full/elcl16/clear_co.gif | Bin 545 -> 0 bytes .../icons/full/elcl16/collapseall.gif | Bin 157 -> 0 bytes .../icons/full/elcl16/filter_history.gif | Bin 219 -> 0 bytes .../icons/full/elcl16/newstream_wiz.gif | Bin 211 -> 0 bytes .../icons/full/elcl16/refresh.gif | Bin 327 -> 0 bytes .../icons/full/elcl16/synced.gif | Bin 160 -> 0 bytes .../icons/full/etool16/annotate.gif | Bin 592 -> 0 bytes .../icons/full/etool16/checkout.gif | Bin 363 -> 0 bytes .../icons/full/etool16/cvs_synch.gif | Bin 353 -> 0 bytes .../icons/full/etool16/history.gif | Bin 564 -> 0 bytes .../icons/full/etool16/newconnect_wiz.gif | Bin 362 -> 0 bytes .../icons/full/etool16/newlocation_wiz.gif | Bin 597 -> 0 bytes .../icons/full/etool16/share_prj_wiz.gif | Bin 348 -> 0 bytes .../icons/full/eview16/annotate_view.gif | Bin 594 -> 0 bytes .../icons/full/eview16/compare_view.gif | Bin 224 -> 0 bytes .../icons/full/eview16/console_view.gif | Bin 617 -> 0 bytes .../icons/full/eview16/cvs_persp.gif | Bin 366 -> 0 bytes .../icons/full/eview16/history_view.gif | Bin 564 -> 0 bytes .../icons/full/eview16/rep_editors_view.gif | Bin 597 -> 0 bytes .../icons/full/eview16/repo_rep.gif | Bin 588 -> 0 bytes .../icons/full/glyphs/glyph1.gif | Bin 585 -> 0 bytes .../icons/full/glyphs/glyph2.gif | Bin 220 -> 0 bytes .../icons/full/glyphs/glyph3.gif | Bin 203 -> 0 bytes .../icons/full/glyphs/glyph4.gif | Bin 327 -> 0 bytes .../icons/full/glyphs/glyph5.gif | Bin 307 -> 0 bytes .../icons/full/glyphs/glyph6.gif | Bin 323 -> 0 bytes .../icons/full/glyphs/glyph7.gif | Bin 328 -> 0 bytes .../icons/full/glyphs/glyph8.gif | Bin 330 -> 0 bytes .../icons/full/obj16/branches_rep.gif | Bin 121 -> 0 bytes .../icons/full/obj16/changelog_obj.gif | Bin 596 -> 0 bytes .../icons/full/obj16/date.gif | Bin 181 -> 0 bytes .../icons/full/obj16/dates.gif | Bin 181 -> 0 bytes .../icons/full/obj16/module_rep.gif | Bin 585 -> 0 bytes .../icons/full/obj16/prjversions_rep.gif | Bin 377 -> 0 bytes .../icons/full/obj16/repository_rep.gif | Bin 545 -> 0 bytes .../icons/full/obj16/tag.gif | Bin 109 -> 0 bytes .../icons/full/obj16/versions_rep.gif | Bin 364 -> 0 bytes .../icons/full/ovr16/confauto_ov.gif | Bin 194 -> 0 bytes .../icons/full/ovr16/edited_ov.gif | Bin 167 -> 0 bytes .../icons/full/ovr16/merged_ov.gif | Bin 164 -> 0 bytes .../icons/full/ovr16/no_remotedir_ov.gif | Bin 107 -> 0 bytes .../icons/full/ovr16/question_ov.gif | Bin 79 -> 0 bytes .../icons/full/wizban/createpatch_wizban.gif | Bin 3330 -> 0 bytes .../icons/full/wizban/keywordsub_wizban.gif | Bin 3571 -> 0 bytes .../icons/full/wizban/mergestream_wizban.gif | Bin 2881 -> 0 bytes .../icons/full/wizban/newconnect_wizban.gif | Bin 2965 -> 0 bytes .../icons/full/wizban/newlocation_wizban.gif | Bin 3343 -> 0 bytes bundles/org.eclipse.team.cvs.ui/plugin.properties | 203 - bundles/org.eclipse.team.cvs.ui/plugin.xml | 1066 ----- .../ccvs/ui/AdaptableHierarchicalResourceList.java | 102 - .../internal/ccvs/ui/AdaptableResourceList.java | 62 - .../ccvs/ui/AddToVersionControlDialog.java | 218 - .../ccvs/ui/AlternateUserValidationDialog.java | 235 -- .../team/internal/ccvs/ui/AnnotateView.java | 396 -- .../internal/ccvs/ui/AvoidableMessageDialog.java | 63 - .../internal/ccvs/ui/CVSCompareEditorInput.java | 457 --- .../internal/ccvs/ui/CVSCompareRevisionsInput.java | 453 --- .../team/internal/ccvs/ui/CVSDecoration.java | 427 -- .../ccvs/ui/CVSDecoratorConfiguration.java | 142 - .../ccvs/ui/CVSDecoratorPreferencesPage.java | 619 --- .../ccvs/ui/CVSFieldEditorPreferencePage.java | 92 - .../internal/ccvs/ui/CVSFilePropertiesPage.java | 144 - .../internal/ccvs/ui/CVSFolderPropertiesPage.java | 179 - .../internal/ccvs/ui/CVSLightweightDecorator.java | 452 -- .../team/internal/ccvs/ui/CVSPerspective.java | 64 - .../team/internal/ccvs/ui/CVSPreferencesPage.java | 477 --- .../internal/ccvs/ui/CVSProjectPropertiesPage.java | 473 --- .../internal/ccvs/ui/CVSProjectSetSerializer.java | 219 - .../team/internal/ccvs/ui/CVSPropertiesPage.java | 44 - .../eclipse/team/internal/ccvs/ui/CVSUIPlugin.java | 756 ---- .../team/internal/ccvs/ui/CommitCommentArea.java | 235 -- .../internal/ccvs/ui/ComparePreferencePage.java | 75 - .../team/internal/ccvs/ui/DateTagDialog.java | 263 -- .../team/internal/ccvs/ui/EditorsDialog.java | 67 - .../eclipse/team/internal/ccvs/ui/EditorsView.java | 207 - .../internal/ccvs/ui/ExtMethodPreferencePage.java | 283 -- .../ccvs/ui/FileModificationValidator.java | 168 - .../team/internal/ccvs/ui/HistoryDropAdapter.java | 66 - .../team/internal/ccvs/ui/HistoryFilter.java | 74 - .../team/internal/ccvs/ui/HistoryFilterAction.java | 55 - .../team/internal/ccvs/ui/HistoryFilterDialog.java | 265 -- .../internal/ccvs/ui/HistoryTableProvider.java | 428 -- .../eclipse/team/internal/ccvs/ui/HistoryView.java | 880 ---- .../team/internal/ccvs/ui/ICVSUIConstants.java | 170 - .../team/internal/ccvs/ui/IHelpContextIds.java | 150 - .../team/internal/ccvs/ui/IRepositoryListener.java | 20 - .../internal/ccvs/ui/IgnoreResourcesDialog.java | 248 -- .../ccvs/ui/KeyboardInteractiveDialog.java | 177 - .../team/internal/ccvs/ui/ListSelectionArea.java | 191 - .../team/internal/ccvs/ui/OverlayIconCache.java | 50 - .../ccvs/ui/PasswordManagementPreferencePage.java | 206 - .../org/eclipse/team/internal/ccvs/ui/Policy.java | 129 - .../internal/ccvs/ui/ReleaseCommentDialog.java | 151 - .../ccvs/ui/RemoteAnnotationEditorInput.java | 42 - .../internal/ccvs/ui/RemoteAnnotationStorage.java | 79 - .../internal/ccvs/ui/RemoteFileEditorInput.java | 224 - .../ccvs/ui/RemoteRevisionQuickDiffProvider.java | 351 -- .../internal/ccvs/ui/ResizableWizardDialog.java | 27 - .../team/internal/ccvs/ui/ResourceEditionNode.java | 186 - .../internal/ccvs/ui/ResourcePropertiesPage.java | 111 - .../internal/ccvs/ui/SimpleContentProvider.java | 47 - .../ccvs/ui/TagetLocationSelectionDialog.java | 438 -- .../team/internal/ccvs/ui/TextViewerAction.java | 41 - .../ccvs/ui/TimeoutProgressMonitorDialog.java | 88 - .../internal/ccvs/ui/UserValidationDialog.java | 286 -- .../team/internal/ccvs/ui/VersionCollator.java | 64 - .../internal/ccvs/ui/WatchEditPreferencePage.java | 110 - .../ccvs/ui/WorkInProgressPreferencePage.java | 147 - .../ccvs/ui/WorkbenchUserAuthenticator.java | 244 -- .../internal/ccvs/ui/WorkingSetSelectionArea.java | 304 -- .../eclipse/team/internal/ccvs/ui/XMLWriter.java | 116 - .../team/internal/ccvs/ui/actions/AddAction.java | 92 - .../internal/ccvs/ui/actions/BranchAction.java | 31 - .../team/internal/ccvs/ui/actions/CVSAction.java | 483 --- .../internal/ccvs/ui/actions/CheckoutAction.java | 51 - .../internal/ccvs/ui/actions/CheckoutAsAction.java | 50 - .../ccvs/ui/actions/CheckoutWizardAction.java | 54 - .../internal/ccvs/ui/actions/CommitAction.java | 67 - .../ui/actions/CompareRemoteResourcesAction.java | 65 - .../ui/actions/CompareRemoteWithTagAction.java | 65 - .../ccvs/ui/actions/CompareWithRemoteAction.java | 49 - .../ccvs/ui/actions/CompareWithRevisionAction.java | 149 - .../ccvs/ui/actions/CompareWithTagAction.java | 64 - .../actions/ConfigureTagsFromRepoViewOnFolder.java | 102 - .../team/internal/ccvs/ui/actions/EditAction.java | 70 - .../internal/ccvs/ui/actions/EditorsAction.java | 104 - .../ccvs/ui/actions/GenerateDiffFileAction.java | 58 - .../internal/ccvs/ui/actions/IgnoreAction.java | 136 - .../team/internal/ccvs/ui/actions/MergeAction.java | 34 - .../ccvs/ui/actions/MoveRemoteTagAction.java | 60 - .../ccvs/ui/actions/NewRepositoryAction.java | 56 - .../ccvs/ui/actions/OpenLogEntryAction.java | 109 - .../ccvs/ui/actions/OpenRemoteFileAction.java | 109 - .../ccvs/ui/actions/ReplaceWithRemoteAction.java | 108 - .../ccvs/ui/actions/ReplaceWithRevisionAction.java | 92 - .../ccvs/ui/actions/ReplaceWithTagAction.java | 104 - .../ui/actions/RestoreFromRepositoryAction.java | 198 - .../ui/actions/SetKeywordSubstitutionAction.java | 39 - .../ccvs/ui/actions/ShowAnnotationAction.java | 130 - .../ccvs/ui/actions/ShowCVSPerspectiveAction.java | 37 - .../ccvs/ui/actions/ShowEditorsAction.java | 69 - .../ccvs/ui/actions/ShowHistoryAction.java | 86 - .../ui/actions/ShowResourceInHistoryAction.java | 76 - .../team/internal/ccvs/ui/actions/SyncAction.java | 110 - .../team/internal/ccvs/ui/actions/TagAction.java | 161 - .../ccvs/ui/actions/TagInRepositoryAction.java | 50 - .../internal/ccvs/ui/actions/TagLocalAction.java | 70 - .../internal/ccvs/ui/actions/UneditAction.java | 78 - .../internal/ccvs/ui/actions/UnmanageAction.java | 147 - .../internal/ccvs/ui/actions/UpdateAction.java | 50 - .../ccvs/ui/actions/UpdateSilentAction.java | 27 - .../internal/ccvs/ui/actions/WorkspaceAction.java | 616 --- .../ccvs/ui/console/CVSConsoleFactory.java | 58 - .../ccvs/ui/console/CVSConsolePageParticipant.java | 55 - .../internal/ccvs/ui/console/CVSOutputConsole.java | 424 -- .../internal/ccvs/ui/console/ConsoleDocument.java | 93 - .../ccvs/ui/console/ConsolePreferencesPage.java | 133 - .../ccvs/ui/console/ConsoleRemoveAction.java | 32 - .../team/internal/ccvs/ui/messages.properties | 1327 ------ .../internal/ccvs/ui/model/AllRootsElement.java | 42 - .../internal/ccvs/ui/model/BranchCategory.java | 59 - .../internal/ccvs/ui/model/CVSAdapterFactory.java | 96 - .../internal/ccvs/ui/model/CVSModelElement.java | 133 - .../ccvs/ui/model/CVSRemoteFilePropertySource.java | 159 - .../ui/model/CVSRemoteFolderPropertySource.java | 101 - .../model/CVSRepositoryLocationPropertySource.java | 124 - .../ccvs/ui/model/CVSRepositoryRootElement.java | 74 - .../internal/ccvs/ui/model/CVSResourceElement.java | 39 - .../team/internal/ccvs/ui/model/CVSTagElement.java | 157 - .../internal/ccvs/ui/model/DateTagCategory.java | 60 - .../ccvs/ui/model/GroupedByVersionCategory.java | 118 - .../internal/ccvs/ui/model/ModulesCategory.java | 93 - .../ccvs/ui/model/RemoteContentProvider.java | 130 - .../internal/ccvs/ui/model/RemoteFileElement.java | 48 - .../ccvs/ui/model/RemoteFolderElement.java | 95 - .../team/internal/ccvs/ui/model/RemoteModule.java | 147 - .../ccvs/ui/model/RemoteProjectsElement.java | 87 - .../ccvs/ui/model/RemoteResourceElement.java | 32 - .../ccvs/ui/model/RemoteVersionModule.java | 103 - .../ui/model/RepositoryLocationSchedulingRule.java | 33 - .../team/internal/ccvs/ui/model/TagCategory.java | 72 - .../internal/ccvs/ui/model/VersionCategory.java | 154 - .../internal/ccvs/ui/operations/AddOperation.java | 205 - .../ccvs/ui/operations/BranchOperation.java | 320 -- .../internal/ccvs/ui/operations/CVSOperation.java | 366 -- .../ccvs/ui/operations/CheckoutIntoOperation.java | 442 -- .../CheckoutMultipleProjectsOperation.java | 53 - .../ccvs/ui/operations/CheckoutOperation.java | 86 - .../ui/operations/CheckoutProjectOperation.java | 481 --- .../operations/CheckoutSingleProjectOperation.java | 63 - .../CheckoutToRemoteFolderOperation.java | 213 - .../ccvs/ui/operations/CommitOperation.java | 179 - .../ccvs/ui/operations/DisconnectOperation.java | 81 - .../ccvs/ui/operations/FetchMembersOperation.java | 147 - .../ui/operations/HasProjectMetaFileOperation.java | 96 - .../internal/ccvs/ui/operations/ITagOperation.java | 27 - .../ui/operations/OverrideAndUpdateOperation.java | 52 - .../ui/operations/ReconcileProjectOperation.java | 175 - .../ccvs/ui/operations/RemoteCompareOperation.java | 381 -- .../ccvs/ui/operations/RemoteLogOperation.java | 282 -- .../ccvs/ui/operations/RemoteOperation.java | 42 - .../ccvs/ui/operations/ReplaceOperation.java | 135 - .../ui/operations/RepositoryLocationOperation.java | 72 - .../ui/operations/RepositoryProviderOperation.java | 211 - .../ccvs/ui/operations/ShareProjectOperation.java | 208 - .../ui/operations/ShowAnnotationOperation.java | 232 -- .../ccvs/ui/operations/SingleCommandOperation.java | 81 - .../ui/operations/TagInRepositoryOperation.java | 125 - .../internal/ccvs/ui/operations/TagOperation.java | 167 - .../ui/operations/UpdateOnlyMergableOperation.java | 77 - .../ccvs/ui/operations/UpdateOperation.java | 132 - .../internal/ccvs/ui/repo/AddToBranchAction.java | 93 - .../internal/ccvs/ui/repo/CVSRepoViewAction.java | 48 - .../ccvs/ui/repo/CVSRepositoryPropertiesPage.java | 595 --- .../ccvs/ui/repo/CommentHistoryContentHandler.java | 85 - .../ccvs/ui/repo/CopyRepositoryNameAction.java | 61 - .../ccvs/ui/repo/NewCVSRepositoryAction.java | 39 - .../internal/ccvs/ui/repo/NewDateTagAction.java | 57 - .../ui/repo/RefreshRemoteProjectSelectionPage.java | 174 - .../ccvs/ui/repo/RefreshRemoteProjectWizard.java | 182 - .../internal/ccvs/ui/repo/RefreshTagsAction.java | 37 - .../internal/ccvs/ui/repo/RemoteProjectsView.java | 79 - .../team/internal/ccvs/ui/repo/RemoteTagsView.java | 66 - .../team/internal/ccvs/ui/repo/RemoteViewPart.java | 429 -- .../internal/ccvs/ui/repo/RemoveDateTagAction.java | 86 - .../internal/ccvs/ui/repo/RemoveRootAction.java | 152 - .../internal/ccvs/ui/repo/RepositoriesView.java | 327 -- .../ui/repo/RepositoriesViewContentHandler.java | 248 -- .../ui/repo/RepositoryEncodingPropertyPage.java | 419 -- .../internal/ccvs/ui/repo/RepositoryManager.java | 813 ---- .../team/internal/ccvs/ui/repo/RepositoryRoot.java | 633 --- .../internal/ccvs/ui/repo/RepositorySorter.java | 116 - .../ui/subscriber/CVSActionDelegateWrapper.java | 43 - .../ui/subscriber/CVSChangeSetActionGroup.java | 40 - .../ccvs/ui/subscriber/CVSChangeSetCapability.java | 54 - .../ccvs/ui/subscriber/CVSChangeSetCollector.java | 441 -- .../ccvs/ui/subscriber/CVSParticipant.java | 177 - .../ccvs/ui/subscriber/CVSParticipantAction.java | 63 - .../subscriber/CVSParticipantLabelDecorator.java | 128 - .../ccvs/ui/subscriber/CVSSubscriberOperation.java | 334 -- .../ccvs/ui/subscriber/CVSSynchronizeWizard.java | 70 - .../ccvs/ui/subscriber/CommitSetDialog.java | 228 -- .../ccvs/ui/subscriber/CompareParticipant.java | 218 - .../ccvs/ui/subscriber/CompareRevertAction.java | 33 - .../ccvs/ui/subscriber/CompareRevertOperation.java | 108 - .../ccvs/ui/subscriber/ConfirmMergedAction.java | 39 - .../ccvs/ui/subscriber/ConfirmMergedOperation.java | 92 - .../ui/subscriber/LogEntryCacheUpdateHandler.java | 666 --- .../ui/subscriber/MergeSynchronizeParticipant.java | 280 -- .../ccvs/ui/subscriber/MergeUpdateAction.java | 56 - .../ccvs/ui/subscriber/MergeUpdateOperation.java | 170 - .../ccvs/ui/subscriber/OpenChangeSetAction.java | 215 - .../ui/subscriber/OverrideAndCommitAction.java | 40 - .../ui/subscriber/OverrideAndUpdateAction.java | 41 - .../OverrideAndUpdateSubscriberOperation.java | 73 - .../ui/subscriber/RefreshDirtyStateAction.java | 49 - .../ui/subscriber/RefreshDirtyStateOperation.java | 78 - .../ccvs/ui/subscriber/SafeUpdateOperation.java | 434 -- .../ui/subscriber/SyncInfoSetDetailsDialog.java | 194 - .../internal/ccvs/ui/subscriber/UpdateDialog.java | 72 - .../ccvs/ui/subscriber/WorkspaceCommitAction.java | 44 - .../ui/subscriber/WorkspaceCommitOperation.java | 354 -- .../WorkspaceSynchronizeParticipant.java | 259 -- .../ccvs/ui/subscriber/WorkspaceUpdateAction.java | 50 - .../ui/subscriber/WorkspaceUpdateOperation.java | 101 - .../ccvs/ui/sync/ToolTipMessageDialog.java | 40 - .../internal/ccvs/ui/tags/BranchPromptDialog.java | 231 -- .../team/internal/ccvs/ui/tags/CVSFileElement.java | 75 - .../internal/ccvs/ui/tags/CVSFolderElement.java | 82 - .../internal/ccvs/ui/tags/FilteredTagList.java | 108 - .../ccvs/ui/tags/LocalProjectTagSource.java | 136 - .../ccvs/ui/tags/MultiFolderTagSource.java | 53 - .../internal/ccvs/ui/tags/SingleFileTagSource.java | 98 - .../ccvs/ui/tags/SingleFolderTagSource.java | 142 - .../internal/ccvs/ui/tags/TagAsVersionDialog.java | 182 - .../ccvs/ui/tags/TagConfigurationDialog.java | 763 ---- .../ccvs/ui/tags/TagContentAssistProcessor.java | 160 - .../team/internal/ccvs/ui/tags/TagElement.java | 89 - .../ccvs/ui/tags/TagRefreshButtonArea.java | 175 - .../team/internal/ccvs/ui/tags/TagRootElement.java | 75 - .../internal/ccvs/ui/tags/TagSelectionArea.java | 612 --- .../internal/ccvs/ui/tags/TagSelectionDialog.java | 247 -- .../ccvs/ui/tags/TagSelectionWizardPage.java | 181 - .../team/internal/ccvs/ui/tags/TagSource.java | 234 -- .../ccvs/ui/tags/TagSourceResourceAdapter.java | 88 - .../ccvs/ui/tags/TagSourceWorkbenchAdapter.java | 157 - .../internal/ccvs/ui/wizards/CVSWizardPage.java | 382 -- .../wizards/CheckoutAsLocationSelectionPage.java | 316 -- .../ccvs/ui/wizards/CheckoutAsMainPage.java | 233 -- .../ui/wizards/CheckoutAsProjectSelectionPage.java | 272 -- .../internal/ccvs/ui/wizards/CheckoutAsWizard.java | 265 -- .../internal/ccvs/ui/wizards/CheckoutWizard.java | 287 -- .../ConfigurationWizardAutoconnectPage.java | 141 - .../ui/wizards/ConfigurationWizardMainPage.java | 616 --- .../ccvs/ui/wizards/GenerateDiffFileOperation.java | 142 - .../ccvs/ui/wizards/GenerateDiffFileWizard.java | 775 ---- .../team/internal/ccvs/ui/wizards/ICVSWizard.java | 37 - .../internal/ccvs/ui/wizards/KSubstWizard.java | 428 -- .../ui/wizards/KSubstWizardCommitCommentPage.java | 75 - .../ui/wizards/KSubstWizardDirtyFilesPage.java | 95 - .../ccvs/ui/wizards/KSubstWizardSelectionPage.java | 157 - .../ui/wizards/KSubstWizardSharedFilesPage.java | 95 - .../ccvs/ui/wizards/KSubstWizardSummaryPage.java | 291 -- .../team/internal/ccvs/ui/wizards/MergeWizard.java | 95 - .../internal/ccvs/ui/wizards/MergeWizardPage.java | 254 -- .../ccvs/ui/wizards/ModuleSelectionPage.java | 325 -- .../ccvs/ui/wizards/NewLocationWizard.java | 137 - .../ccvs/ui/wizards/RepositorySelectionPage.java | 141 - .../RestoreFromRepositoryFileSelectionPage.java | 558 --- .../ui/wizards/RestoreFromRepositoryWizard.java | 57 - .../internal/ccvs/ui/wizards/SharingWizard.java | 548 --- .../ui/wizards/SharingWizardPageActionGroup.java | 82 - .../ccvs/ui/wizards/SharingWizardSyncPage.java | 279 -- .../internal/ccvs/ui/wizards/UpdateWizard.java | 90 - 1059 files changed, 165713 deletions(-) delete mode 100644 bundles/org.eclipse.compare/.classpath delete mode 100644 bundles/org.eclipse.compare/.cvsignore delete mode 100644 bundles/org.eclipse.compare/.project delete mode 100644 bundles/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs delete mode 100644 bundles/org.eclipse.compare/about.html delete mode 100644 bundles/org.eclipse.compare/build.properties delete mode 100644 bundles/org.eclipse.compare/buildnotes_compare.html delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextMergeViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/package.html delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java delete mode 100644 bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/next_nav.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/next_nav.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/prev_nav.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/etool16/conflict_edit.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/eview16/compare_view.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/obj16/day_obj.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/obj16/resource_obj.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/add_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/chg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/del_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/error_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/indel_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif delete mode 100644 bundles/org.eclipse.compare/old_buildnotes_compare_3_0.html delete mode 100644 bundles/org.eclipse.compare/plugin.properties delete mode 100644 bundles/org.eclipse.compare/plugin.xml delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/.classpath delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/.cvsignore delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/.project delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/about.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/build.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextMergeViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Attic/LineReader.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/package.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/next_nav.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/next_nav.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/prev_nav.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/conflict_edit.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/eview16/compare_view.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/day_obj.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/resource_obj.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/add_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/chg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/del_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/error_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/indel_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/old_buildnotes_compare_3_0.html delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd delete mode 100644 bundles/org.eclipse.compare/plugins/org.eclipse.compare/scripts/exportplugin.xml delete mode 100644 bundles/org.eclipse.compare/schema/contentMergeViewers.exsd delete mode 100644 bundles/org.eclipse.compare/schema/contentViewers.exsd delete mode 100644 bundles/org.eclipse.compare/schema/streamMergers.exsd delete mode 100644 bundles/org.eclipse.compare/schema/structureCreators.exsd delete mode 100644 bundles/org.eclipse.compare/schema/structureMergeViewers.exsd delete mode 100644 bundles/org.eclipse.compare/scripts/exportplugin.xml delete mode 100644 bundles/org.eclipse.team.core/.classpath delete mode 100644 bundles/org.eclipse.team.core/.cvsignore delete mode 100644 bundles/org.eclipse.team.core/.options delete mode 100644 bundles/org.eclipse.team.core/.project delete mode 100644 bundles/org.eclipse.team.core/about.html delete mode 100644 bundles/org.eclipse.team.core/build.properties delete mode 100644 bundles/org.eclipse.team.core/buildnotes_team.html delete mode 100644 bundles/org.eclipse.team.core/plugin.properties delete mode 100644 bundles/org.eclipse.team.core/plugin.xml delete mode 100644 bundles/org.eclipse.team.core/schema/defaultFileModificationValidator.exsd delete mode 100644 bundles/org.eclipse.team.core/schema/fileTypes.exsd delete mode 100644 bundles/org.eclipse.team.core/schema/ignore.exsd delete mode 100644 bundles/org.eclipse.team.core/schema/projectSets.exsd delete mode 100644 bundles/org.eclipse.team.core/schema/repository.exsd delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileTypeInfo.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/IIgnoreInfo.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/IProjectSetSerializer.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/ITeamStatus.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetSerializationContext.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamStatus.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/package.html delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ActiveChangeSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSetCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/CheckedInChangeSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/IChangeSetChangeListener.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeListener.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/package.html delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/FastSyncInfoFilter.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeListener.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoTreeChangeEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoFilter.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/package.html delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/package.html delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Assert.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultMoveDeleteHook.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultProjectSetCapability.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/IJobListener.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/MoveDeleteManager.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/NullSubProgressMonitor.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PessimisticResourceRuleFactory.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Sorter.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StringMatcher.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamHookDispatcher.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/simpleAccess/SimpleAccessOperations.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/CRLFtoLFInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutInputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ContentComparator.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncByteConverter.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoStatistics.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoWorkingSetFilter.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetChangedEvent.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java delete mode 100644 bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java delete mode 100644 bundles/org.eclipse.team.cvs.core/.classpath delete mode 100644 bundles/org.eclipse.team.cvs.core/.cvsignore delete mode 100644 bundles/org.eclipse.team.cvs.core/.options delete mode 100644 bundles/org.eclipse.team.cvs.core/.project delete mode 100644 bundles/org.eclipse.team.cvs.core/about.html delete mode 100644 bundles/org.eclipse.team.cvs.core/asl-v20.txt delete mode 100644 bundles/org.eclipse.team.cvs.core/build.properties delete mode 100644 bundles/org.eclipse.team.cvs.core/buildnotes_cvs.html delete mode 100644 bundles/org.eclipse.team.cvs.core/doc/hglegal.htm delete mode 100644 bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif delete mode 100644 bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html delete mode 100644 bundles/org.eclipse.team.cvs.core/plugin.properties delete mode 100644 bundles/org.eclipse.team.cvs.core/plugin.xml delete mode 100644 bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd delete mode 100644 bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd delete mode 100644 bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateWithOverwrite.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/CompareDiffListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java delete mode 100644 bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/.classpath delete mode 100644 bundles/org.eclipse.team.cvs.ssh/.cvsignore delete mode 100644 bundles/org.eclipse.team.cvs.ssh/.options delete mode 100644 bundles/org.eclipse.team.cvs.ssh/.project delete mode 100644 bundles/org.eclipse.team.cvs.ssh/about.html delete mode 100644 bundles/org.eclipse.team.cvs.ssh/build.properties delete mode 100644 bundles/org.eclipse.team.cvs.ssh/plugin.properties delete mode 100644 bundles/org.eclipse.team.cvs.ssh/plugin.xml delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Blowfish.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Cipher.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Client.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ClientPacket.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/KnownHosts.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Misc.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Packet.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Policy.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHMethod.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHPlugin.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHServerConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ServerPacket.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/messages.properties delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/.classpath delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/.cvsignore delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/.project delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/about.html delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/build.properties delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar delete mode 100755 bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/plugin.properties delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/plugin.xml delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java delete mode 100644 bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties delete mode 100644 bundles/org.eclipse.team.cvs.ui/.classpath delete mode 100644 bundles/org.eclipse.team.cvs.ui/.cvsignore delete mode 100644 bundles/org.eclipse.team.cvs.ui/.options delete mode 100644 bundles/org.eclipse.team.cvs.ui/.project delete mode 100644 bundles/org.eclipse.team.cvs.ui/about.html delete mode 100644 bundles/org.eclipse.team.cvs.ui/build.properties delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/clear_co.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/collapseall.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/filter_history.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/newstream_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/refresh.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/synced.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/annotate.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/checkout.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/cvs_synch.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/history.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/ignorefiles.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newconnect_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newlocation_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/share_prj_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/clear_co.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/collapseall.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/filter_history.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/newstream_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/refresh.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/synced.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/annotate.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/checkout.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/cvs_synch.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/history.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newconnect_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newlocation_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/etool16/share_prj_wiz.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/annotate_view.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/compare_view.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/console_view.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/cvs_persp.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/history_view.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/rep_editors_view.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/eview16/repo_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph1.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph2.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph3.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph4.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph5.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph6.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph7.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph8.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/branches_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/changelog_obj.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/date.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/dates.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/module_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/prjversions_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/repository_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/tag.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/obj16/versions_rep.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/confauto_ov.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/edited_ov.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/merged_ov.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/no_remotedir_ov.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/question_ov.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/wizban/createpatch_wizban.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/wizban/keywordsub_wizban.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/wizban/mergestream_wizban.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newconnect_wizban.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newlocation_wizban.gif delete mode 100644 bundles/org.eclipse.team.cvs.ui/plugin.properties delete mode 100644 bundles/org.eclipse.team.cvs.ui/plugin.xml delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableHierarchicalResourceList.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableResourceList.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFieldEditorPreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryDropAdapter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/OverlayIconCache.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationEditorInput.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationStorage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResizableWizardDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/SimpleContentProvider.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagetLocationSelectionDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TextViewerAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/VersionCollator.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/XMLWriter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutWizardAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/NewRepositoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowCVSPerspectiveAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UneditAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsoleFactory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleDocument.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleRemoveAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/AllRootsElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFolderPropertySource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryLocationPropertySource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryRootElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSResourceElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/GroupedByVersionCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/ModulesCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteResourceElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteVersionModule.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RepositoryLocationSchedulingRule.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/TagCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepoViewAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CopyRepositoryNameAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewCVSRepositoryAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewDateTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSActionDelegateWrapper.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndCommitAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateSubscriberOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SyncInfoSetDetailsDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/UpdateDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ToolTipMessageDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFileElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFolderElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ICVSWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardDirtyFilesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSharedFilesPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSummaryPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java (limited to 'bundles') diff --git a/bundles/org.eclipse.compare/.classpath b/bundles/org.eclipse.compare/.classpath deleted file mode 100644 index 3e86ace7d..000000000 --- a/bundles/org.eclipse.compare/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.compare/.cvsignore b/bundles/org.eclipse.compare/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/bundles/org.eclipse.compare/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/bundles/org.eclipse.compare/.project b/bundles/org.eclipse.compare/.project deleted file mode 100644 index f0d1e74ed..000000000 --- a/bundles/org.eclipse.compare/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - org.eclipse.compare - - - org.eclipse.core.boot - org.eclipse.core.resources - org.eclipse.core.runtime - org.eclipse.core.runtime.compatibility - org.eclipse.jface.text - org.eclipse.ui - org.eclipse.ui.ide - org.eclipse.ui.views - org.eclipse.ui.workbench.texteditor - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7d97357dd..000000000 --- a/bundles/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,70 +0,0 @@ -#Tue Nov 30 15:51:47 CET 2004 -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error -org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=error -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.source=1.3 -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -eclipse.preferences.version=1 -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled diff --git a/bundles/org.eclipse.compare/about.html b/bundles/org.eclipse.compare/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/bundles/org.eclipse.compare/about.html +++ /dev/null @@ -1,30 +0,0 @@ - - - -About - - - -

About This Content

- -

20th June, 2002

-

License

-

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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

- -

Contributions

- -

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.

- -

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.

- - - \ No newline at end of file diff --git a/bundles/org.eclipse.compare/build.properties b/bundles/org.eclipse.compare/build.properties deleted file mode 100644 index 22bed075e..000000000 --- a/bundles/org.eclipse.compare/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 -############################################################################### -source.compare.jar = compare/ -bin.includes = icons/,\ - plugin.xml,\ - *.jar,\ - plugin.properties,\ - about.html -src.includes = about.html,\ - schema/ diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html deleted file mode 100644 index 93116b578..000000000 --- a/bundles/org.eclipse.compare/buildnotes_compare.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - Eclipse Platform Release Notes - Desktop - - - -

-Eclipse Platform Build Notes
-Compare

- -Eclipse Build Input December 7th 2004 - -

Problem reports fixed

-Eliminated all compiler warnings
-Removed dependency on core.runtime.compatibility - - -


- -Eclipse Build Input November 30th 2004 - -

Problem reports fixed

-79414: states with same time stamps may appear in the wrong order
-79566: NPE when closing JUnit compare view
- - -


- -Eclipse Build Input November 23rd 2004 - -

Problem reports fixed

-47786: Possible leak in TextMergeViewer
-Added translatable attribute to extension point schemas. - - -


- -Eclipse Build Input November 16th 2004 - -

Problem reports fixed

- 78679: Prefs Filtered Members field does not restore defaults
- -


- -Eclipse Build Input November 9th 2004 - -

Problem reports fixed

- (partial fix; awaits fix in jdt.ui): - 77599: [5.0] Structure comparing of enums does not work
- - -


- -Eclipse Build Input November 1st 2004 - -

Problem reports fixed

-65981: empty compare viewer has no focus
- - -


- -Eclipse Build Input September 21th 2004 - -

Problem reports fixed

-74450: AbstractUIPlugin.initializeDefaultPreferences no longer called?
- - -


-Eclipse Build Input August 24th 2004 - -

Problem reports fixed

-Eliminated compiler warnings - - -


-Eclipse Build Input July 27th 2004 - -

Problem reports fixed

-Updated version number in plugin.xml and export script to 3.1 - - - - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java deleted file mode 100644 index 5e352752a..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.internal.Utilities; - -/** - * Abstract implementation for a buffered IStreamContentAccessor. - *

- * Subclasses must implement the createStream method - * to connect the buffered content with a streamable source (e.g., a file). - *

- * As long as the contents of BufferedContent is only retrieved as an input stream - * (by means of getContents) and the BufferedContent is not modified (with - * setContent) no buffering takes place. - * Buffering starts when either method getContent or setContent is called. - * - * @see IContentChangeNotifier - * @see IStreamContentAccessor - */ -public abstract class BufferedContent implements IContentChangeNotifier, IStreamContentAccessor { - - byte[] fContent; - private ListenerList fListenerList; - - /** - * Creates a buffered stream content accessor. - */ - protected BufferedContent() { - // empty implementation - } - - /* (non-Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - if (fContent != null) - return new ByteArrayInputStream(fContent); - return createStream(); - } - - /** - * Creates and returns a stream for reading the contents. - *

- * Subclasses must implement this method. - *

- * - * @return the stream from which the content is read - * @exception CoreException if the contents could not be accessed - */ - protected abstract InputStream createStream() throws CoreException; - - /** - * Sets the contents. Registered content change listeners are notified. - * - * @param contents the new contents - */ - public void setContent(byte[] contents) { - fContent= contents; - fireContentChanged(); - } - - /** - * Returns the contents as an array of bytes. - * - * @return the contents as an array of bytes, or null if - * the contents could not be accessed - */ - public byte[] getContent() { - if (fContent == null) { - try { - InputStream is= createStream(); - fContent= Utilities.readBytes(is); - } catch(CoreException ex) { - // NeedWork - } - } - return fContent; - } - - /** - * Discards the buffered content. - */ - public void discardBuffer() { - fContent= null; - } - - /* (non-Javadoc) - * see IContentChangeNotifier.addChangeListener - */ - public void addContentChangeListener(IContentChangeListener listener) { - if (fListenerList == null) - fListenerList= new ListenerList(); - fListenerList.add(listener); - } - - /* (non-Javadoc) - * see IContentChangeNotifier.removeChangeListener - */ - public void removeContentChangeListener(IContentChangeListener listener) { - if (fListenerList != null) { - fListenerList.remove(listener); - if (fListenerList.isEmpty()) - fListenerList= null; - } - } - - /** - * Notifies all registered IContentChangeListeners of a content change. - */ - protected void fireContentChanged() { - if (fListenerList != null) { - Object[] listeners= fListenerList.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IContentChangeListener)listeners[i]).contentChanged(this); - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java deleted file mode 100644 index 8a5e89b1f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.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 - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.HashMap; - -import org.eclipse.swt.graphics.*; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.preference.IPreferenceStore; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.Differencer; - -/** - * A CompareConfiguration object - * controls various UI aspects of compare/merge viewers like - * title labels and images, or whether a side of a merge viewer is editable. - * In addition to these fixed properties ICompareConfiguration provides - * API for an open ended set of properties. Different viewers which share the same - * configuration can communicate via this mechanism. E.g. if a compare editor - * has a button for controlling whether compare viewers ignore white space, - * the button would trigger a change of the boolean IGNORE_WHITESPACE property - * and all interested viewers would receive notification. - *

- * Suitable default labels are provided (without images); both the left and right sides - * are editable. - *

- *

- * Clients may use this class as is, or subclass to add new state and behavior. - *

- */ -public class CompareConfiguration { - - /** - * Name of the ignore whitespace property (value "IGNORE_WHITESPACE"). - */ - public static final String IGNORE_WHITESPACE= "IGNORE_WHITESPACE"; //$NON-NLS-1$ - /** - * Name of the show pseudo conflicts property (value "SHOW_PSEUDO_CONFLICTS"). - */ - public static final String SHOW_PSEUDO_CONFLICTS= "SHOW_PSEUDO_CONFLICTS"; //$NON-NLS-1$ - /** - * Name of the use outline view property (value "USE_OUTLINE_VIEW"). - * @since 3.0 - */ - public static final String USE_OUTLINE_VIEW= "USE_OUTLINE_VIEW"; //$NON-NLS-1$ - - - private static final int WIDTH= 22; - - private static ImageDescriptor[] fgImages= new ImageDescriptor[16]; - private static Object fgDummy= new Object(); - private static HashMap fgMap= new HashMap(20); - private static boolean fLeftIsLocal= true; - - static { - if (fLeftIsLocal) { - fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_inadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outadd_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_indel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outdel_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_inchg_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_outchg_ov.gif"); //$NON-NLS-1$ - } else { - fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/inadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/outadd_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/indel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/outdel_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/inchg_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/outchg_ov.gif"); //$NON-NLS-1$ - } - - fgImages[Differencer.CONFLICTING + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/confadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.CONFLICTING + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/confdel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.gif"); //$NON-NLS-1$ - } - - private IPreferenceStore fPreferenceStore; - private ListenerList fListeners= new ListenerList(); - private HashMap fProperties= new HashMap(); - private boolean fLeftEditable= true; - private boolean fRightEditable= true; - private String fAncestorLabel; - private String fLeftLabel; - private String fRightLabel; - private Image fAncestorImage; - private Image fRightImage; - private Image fLeftImage; - private Image[] fImages= new Image[16]; - - /** - * Creates a new configuration with editable left and right sides, - * suitable default labels, and no images. - * The given preference store is used to connect this configuration - * with the Compare preference page properties ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, - * and CompareConfiguration.IGNORE_WHITESPACE. - * - * @param prefStore the preference store which this configuration holds onto. - * @since 2.0 - */ - public CompareConfiguration(IPreferenceStore prefStore) { - - setProperty("LEFT_IS_LOCAL", new Boolean(fLeftIsLocal)); //$NON-NLS-1$ - - fPreferenceStore= prefStore; - if (fPreferenceStore != null) { - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE); - setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b)); - - b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE); - setProperty(CompareConfiguration.IGNORE_WHITESPACE, new Boolean(b)); - } - } - - /** - * Creates a new configuration with editable left and right sides, - * suitable default labels, and no images. - * This configuration uses the preference store of the Compare plugin - * (CompareUIPlugin.getDefault().getPreferenceStore()). - */ - public CompareConfiguration() { - this(CompareUIPlugin.getDefault().getPreferenceStore()); - } - - /** - * Returns the preference store of this configuration. - * @return the preference store of this configuration. - * @since 2.0 - */ - public IPreferenceStore getPreferenceStore() { - return fPreferenceStore; - } - - /** - * Returns an image showing the specified change kind. - * The different kind of changes are defined in the Differencer. - * Newly created images are remembered by this class and - * disposed when the dispose method is called. - * - * @param kind the kind of change as defined in Differencer. - * @return an modification of the base image reflecting the kind of change. - * @see org.eclipse.compare.structuremergeviewer.Differencer - * @since 2.0 - */ - public Image getImage(int kind) { - Image image= fImages[kind & 15]; - if (image == null) { - ImageDescriptor id= fgImages[kind & 15]; - if (id != null) - image= id.createImage(); - fImages[kind & 15]= image; - } - return image; - } - - /** - * Returns an image showing the specified change kind applied to a - * given base image. The different kind of changes are defined in the Differencer. - * Typically an implementation would build a composite image - * from the given base image and an image representing the change kind. - * Newly created images are remembered by this class and - * disposed when the dispose method is called. - * - * @param base the image which is modified to reflect the kind of change - * @param kind the kind of change as defined in Differencer. - * @return an modification of the base image reflecting the kind of change. - * @see org.eclipse.compare.structuremergeviewer.Differencer - */ - public Image getImage(Image base, int kind) { - - Object key= base; - if (key == null) - key= fgDummy; - - kind &= 15; - - Image[] a= (Image[]) fgMap.get(key); - if (a == null) { - a= new Image[16]; - fgMap.put(key, a); - } - Image b= a[kind]; - if (b == null) { - b= new DiffImage(base, fgImages[kind], WIDTH, !fLeftIsLocal).createImage(); - CompareUI.disposeOnShutdown(b); - a[kind]= b; - } - return b; - } - - /** - * Dispose of this compare configuration. - * This method is called if the compare configuration is no longer used. - * An implementation must dispose of all resources. - */ - public void dispose() { - if (fImages != null) { - for (int i= 0; i < fImages.length; i++){ - Image image= fImages[i]; - if (image != null && !image.isDisposed()) - image.dispose(); - } - } - fImages= null; - } - - /** - * Fires a PropertyChangeEvent to registered listeners. - * - * @param propertyName the name of the property that has changed - * @param oldValue the property's old value - * @param newValue the property's new value - */ - private void fireChange(String propertyName, Object oldValue, Object newValue) { - PropertyChangeEvent event= null; - Object[] listeners= fListeners.getListeners(); - if (listeners != null) { - for (int i= 0; i < listeners.length; i++) { - IPropertyChangeListener l= (IPropertyChangeListener) listeners[i]; - if (event == null) - event= new PropertyChangeEvent(this, propertyName, oldValue, newValue); - l.propertyChange(event); - } - } - } - - /* (non javadoc) - * see IPropertyChangeNotifier.addListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - fListeners.add(listener); - } - - /* (non javadoc) - * see IPropertyChangeNotifier.removeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - } - - /** - * Sets the property with the given name. - * If the new value differs from the old a PropertyChangeEvent - * is sent to registered listeners. - * - * @param key the name of the property to set - * @param newValue the new value of the property - */ - public void setProperty(String key, Object newValue) { - Object oldValue= fProperties.get(key); - fProperties.put(key, newValue); - if (oldValue == null || !oldValue.equals(newValue)) - fireChange(key, oldValue, newValue); - } - - /** - * Returns the property with the given name, or null - * if no such property exists. - * - * @param key the name of the property to retrieve - * @return the property with the given name, or null if not found - */ - public Object getProperty(String key) { - return fProperties.get(key); - } - - //---- ancestor - - /** - * Sets the label to use for the ancestor of compare/merge viewers. - * - * @param label the new label for the ancestor of compare/merge viewers - */ - public void setAncestorLabel(String label) { - fAncestorLabel= label; - } - - /** - * Returns the label for the ancestor side of compare/merge viewers. - * This label is typically shown in the title of the ancestor area in a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the ancestor side or null - */ - public String getAncestorLabel(Object element) { - return fAncestorLabel; - } - - /** - * Sets the image to use for the ancestor of compare/merge viewers. - * The CompareConfiguration does not automatically dispose the old image. - * - * @param image the new image for the ancestor of compare/merge viewers - */ - public void setAncestorImage(Image image) { - fAncestorImage= image; - } - - /** - * Returns the image for the ancestor side of compare/merge viewers. - * This image is typically shown in the title of the ancestor area in a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the ancestor side or null - */ - public Image getAncestorImage(Object element) { - return fAncestorImage; - } - - //---- left side - - /** - * Controls whether the left side of a merge viewer is editable. - * - * @param editable if the value is true left side is editable - */ - public void setLeftEditable(boolean editable) { - fLeftEditable= editable; - } - - /** - * Returns whether the left hand side of a merge viewer is editable. - * - * @return true if the left hand side is editable - */ - public boolean isLeftEditable() { - return fLeftEditable; - } - - /** - * Sets the label to use for the left side of compare/merge viewers. - * - * @param label the new label for the left side of compare/merge viewers - */ - public void setLeftLabel(String label) { - fLeftLabel= label; - } - - /** - * Returns the label for the left hand side of compare/merge viewers. - * This label is typically shown in the title of the left side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the left hand side or null - */ - public String getLeftLabel(Object element) { - return fLeftLabel; - } - - /** - * Sets the image to use for the left side of compare/merge viewers. - * The compare configuration does not automatically dispose the old image. - * - * @param image the new image for the left side of compare/merge viewers - */ - public void setLeftImage(Image image) { - fLeftImage= image; - } - - /** - * Returns the image for the left hand side of compare/merge viewers. - * This image is typically shown in the title of the left side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the left hand side or null - */ - public Image getLeftImage(Object element) { - return fLeftImage; - } - - //---- right side - - /** - * Controls whether the right side of a merge viewer is editable. - * - * @param editable if the value is true right side is editable - */ - public void setRightEditable(boolean editable) { - fRightEditable= editable; - } - - /** - * Returns whether the right hand side of a merge viewer is editable. - * - * @return true if the right hand side is editable - */ - public boolean isRightEditable() { - return fRightEditable; - } - - /** - * Sets the label to use for the right side of compare/merge viewers. - * - * @param label the new label for the right side of compare/merge viewers - */ - public void setRightLabel(String label) { - fRightLabel= label; - } - - /** - * Returns the label for the right hand side of compare/merge viewers. - * This label is typically shown in the title of the right side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the right hand side or null - */ - public String getRightLabel(Object element) { - return fRightLabel; - } - - /** - * Sets the image to use for the right side of compare/merge viewers. - * The compare configuration does not automatically dispose the old image. - * - * @param image the new image for the right side of compare/merge viewers - */ - public void setRightImage(Image image) { - fRightImage= image; - } - - /** - * Returns the image for the right hand side of compare/merge viewers. - * This image is typically shown in the title of the right side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the right hand side or null - */ - public Image getRightImage(Object element) { - return fRightImage; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java deleted file mode 100644 index 9cfb91b88..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java +++ /dev/null @@ -1,815 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.lang.reflect.InvocationTargetException; - -import java.util.ArrayList; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.custom.BusyIndicator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.*; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.IEditorInput; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A compare operation which can present its results in a special editor. - * Running the compare operation and presentating the results in a compare editor - * are combined in one class because it allows a client to keep the implementation - * all in one place while separating it from the innards of a specific UI implementation of compare/merge. - *

- * A CompareEditorInput defines methods for the following sequence steps: - *

- * The Compare plug-in's openCompareEditor method takes an ICompareEditorInput - * and starts sequencing through the above steps. If the compare result is not empty a new compare editor - * is opened and takes over the sequence until eventually closed. - *

- * The prepareInput method should contain the - * code of the compare operation. It is executed under control of a progress monitor - * and can be canceled. If the result of the compare is not empty, that is if there are differences - * that needs to be presented, the ICompareEditorInput should hold onto them and return them with - * the getCompareResult method. - * If the value returned from getCompareResult is not null - * a compare editor is opened on the ICompareEditorInput with title and title image initialized by the - * corresponding methods of the ICompareEditorInput. - *

- * Creation of the editor's SWT controls is delegated to the createContents method. - * Here the SWT controls must be created and initialized with the result of the compare operation. - *

- * If merging is allowed, the modification state of the compared constituents must be tracked and the dirty - * state returned from method isSaveNeeded. The value true triggers a subsequent call - * to save where the modified resources can be saved. - *

- * The most important part of this implementation is the setup of the compare/merge UI. - * The UI uses a simple browser metaphor to present compare results. - * The top half of the layout shows the structural compare results (e.g. added, deleted, and changed files), - * the bottom half the content compare results (e.g. textual differences between two files). - * A selection in the top pane is fed to the bottom pane. If a content viewer is registered - * for the type of the selected object, this viewer is installed in the pane. - * In addition if a structure viewer is registered for the selection type the top pane - * is split horizontally to make room for another pane and the structure viewer is installed - * in it. When comparing Java files this second structure viewer would show the structural - * differences within a Java file, e.g. added, deleted or changed methods and fields. - *

- * Subclasses provide custom setups, e.g. for a Catchup/Release operation - * by passing a subclass of CompareConfiguration and by implementing the prepareInput method. - * If a subclass cannot use the DiffTreeViewer which is installed by default in the - * top left pane, method createDiffViewer can be overridden. - * - * @see CompareUI - * @see CompareEditorInput - */ -public abstract class CompareEditorInput implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress { - - private static final boolean DEBUG= false; - - /** - * The name of the "dirty" property (value "DIRTY_STATE"). - */ - public static final String DIRTY_STATE= "DIRTY_STATE"; //$NON-NLS-1$ - - private static final String COMPARE_EDITOR_IMAGE_NAME= "eview16/compare_view.gif"; //$NON-NLS-1$ - private static Image fgTitleImage; - - private Splitter fComposite; - private CompareConfiguration fCompareConfiguration; - private CompareViewerSwitchingPane fStructureInputPane; - private CompareViewerSwitchingPane fStructurePane1; - private CompareViewerSwitchingPane fStructurePane2; - private CompareViewerSwitchingPane fContentInputPane; - private CompareViewerSwitchingPane fFocusPane; - private String fMessage; - private Object fInput; - private String fTitle; - private ListenerList fListenerList= new ListenerList(); - private CompareNavigator fNavigator; - private boolean fDirty= false; - private ArrayList fDirtyViewers= new ArrayList(); - private IPropertyChangeListener fDirtyStateListener; - - private IgnoreWhiteSpaceAction fIgnoreWhitespace; - private ShowPseudoConflicts fShowPseudoConflicts; - - boolean fStructureCompareOnSingleClick= true; - boolean fUseOutlineView= false; - - /** - * Creates a CompareEditorInput which is initialized with the given - * compare configuration. - * The compare configuration is passed to subsequently created viewers. - * - * @param configuration the compare configuration - */ - public CompareEditorInput(CompareConfiguration configuration) { - fCompareConfiguration= configuration; - Assert.isNotNull(configuration); - - Object object= fCompareConfiguration.getProperty(CompareConfiguration.USE_OUTLINE_VIEW); - if (object instanceof Boolean) - fUseOutlineView= ((Boolean) object).booleanValue(); - - ResourceBundle bundle= CompareUI.getResourceBundle(); - fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, configuration); - fShowPseudoConflicts= new ShowPseudoConflicts(bundle, configuration); - - fDirtyStateListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - String propertyName= e.getProperty(); - if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) { - boolean changed= false; - Object newValue= e.getNewValue(); - if (newValue instanceof Boolean) - changed= ((Boolean)newValue).booleanValue(); - setDirty(e.getSource(), changed); - } - } - }; - - IPreferenceStore ps= configuration.getPreferenceStore(); - if (ps != null) - fStructureCompareOnSingleClick= ps.getBoolean(ComparePreferencePage.OPEN_STRUCTURE_COMPARE); - } - - private boolean structureCompareOnSingleClick() { - return fStructureCompareOnSingleClick; - } - - /* (non Javadoc) - * see IAdaptable.getAdapter - */ - public Object getAdapter(Class adapter) { - if (ICompareNavigator.class.equals(adapter) || CompareNavigator.class.equals(adapter)) { - if (fNavigator == null) - fNavigator= new CompareNavigator( - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - return fNavigator; - } - if (IFile.class.equals(adapter)) { - IProgressMonitor pm= new NullProgressMonitor(); - // flush changes in any dirty viewer - try { - flushViewer(fStructureInputPane, pm); - flushViewer(fStructurePane1, pm); - flushViewer(fStructurePane2, pm); - flushViewer(fContentInputPane, pm); - } catch (CoreException e) { - CompareUIPlugin.log(e); - } - IFile[] files= (IFile[]) getAdapter(IFile[].class); - if (files.length > 0) - return files[0]; // can only return one: limitation on IDE.saveAllEditors; see #64617 - return null; - } - return null; - } - - /* (non Javadoc) - * see IEditorInput.getImageDescriptor - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* (non Javadoc) - * see IEditorInput.getToolTipText - */ - public String getToolTipText() { - return getTitle(); - } - - /* (non Javadoc) - * see IEditorInput.getName - */ - public String getName() { - return getTitle(); - } - - /** - * Returns null since this editor cannot be persisted. - * - * @return null because this editor cannot be persisted - */ - public IPersistableElement getPersistable() { - return null; - } - - /** - * Returns false to indicate that this input - * should not appear in the "File Most Recently Used" menu. - * - * @return false - */ - public boolean exists() { - return false; - } - - /* - * FIXME! - */ - protected void setMessage(String message) { - fMessage= message; - } - - /* - * FIXME! - */ - public String getMessage() { - return fMessage; - } - - /** - * Returns the title which will be used in the compare editor's title bar. - * It can be set with setTitle. - * - * @return the title - */ - public String getTitle() { - if (fTitle == null) - return Utilities.getString("CompareEditorInput.defaultTitle"); //$NON-NLS-1$ - return fTitle; - } - - /** - * Sets the title which will be used when presenting the compare result. - * This method must be called before the editor is opened. - * - * @param title the title to use for the CompareEditor - */ - public void setTitle(String title) { - fTitle= title; - } - - /** - * Returns the title image which will be used in the compare editor's title bar. - * Returns the title image which will be used when presenting the compare result. - * This implementation returns a generic compare icon. - * Subclasses can override. - * - * @return the title image, or null if none - */ - public Image getTitleImage() { - if (fgTitleImage == null) { - fgTitleImage= CompareUIPlugin.getImageDescriptor(COMPARE_EDITOR_IMAGE_NAME).createImage(); - CompareUI.disposeOnShutdown(fgTitleImage); - } - return fgTitleImage; - } - - /** - * Returns the configuration object for the viewers within the compare editor. - * Returns the configuration which was passed to the constructor. - * - * @return the compare configuration - */ - public CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * Adds standard actions to the given ToolBarManager. - *

- * Subclasses may override to add their own actions. - *

- * - * @param toolBarManager the ToolBarManager to which to contribute - */ - public void contributeToToolBar(ToolBarManager toolBarManager) { - - toolBarManager.add(new Separator()); - toolBarManager.add(fIgnoreWhitespace); - toolBarManager.add(fShowPseudoConflicts); - } - - /** - * Runs the compare operation and stores the compare result. - * - * @param monitor the progress monitor to use to display progress and receive - * requests for cancelation - * @exception InvocationTargetException if the prepareInput method must propagate a checked exception, - * it should wrap it inside an InvocationTargetException; runtime exceptions are automatically - * wrapped in an InvocationTargetException by the calling context - * @exception InterruptedException if the operation detects a request to cancel, - * using IProgressMonitor.isCanceled(), it should exit by throwing - * InterruptedException - */ - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - fInput= prepareInput(monitor); - } - - /** - * Runs the compare operation and returns the compare result. - * If null is returned no differences were found and no compare editor needs to be opened. - * Progress should be reported to the given progress monitor. - * A request to cancel the operation should be honored and acknowledged - * by throwing InterruptedException. - *

- * Note: this method is typically called in a modal context thread which doesn't have a Display assigned. - * Implementors of this method shouldn't therefore allocated any SWT resources in this method. - *

- * - * @param monitor the progress monitor to use to display progress and receive - * requests for cancelation - * @return the result of the compare operation, or null if there are no differences - * @exception InvocationTargetException if the prepareInput method must propagate a checked exception, - * it should wrap it inside an InvocationTargetException; runtime exceptions are automatically - * wrapped in an InvocationTargetException by the calling context - * @exception InterruptedException if the operation detects a request to cancel, - * using IProgressMonitor.isCanceled(), it should exit by throwing - * InterruptedException - */ - protected abstract Object prepareInput(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException; - - /** - * Returns the compare result computed by the most recent call to the - * run method. Returns null if no - * differences were found. - * - * @return the compare result prepared in method prepareInput - * or null if there were no differences - */ - public Object getCompareResult() { - return fInput; - } - - /** - * Create the SWT controls that are used to display the result of the compare operation. - * Creates the SWT Controls and sets up the wiring between the individual panes. - * This implementation creates all four panes but makes only the necessary ones visible. - * Finally it feeds the compare result into the top left structure viewer - * and the content viewer. - *

- * Subclasses may override if they need to change the layout or wiring between panes. - * - * @param parent the parent control under which the control must be created - * @return the SWT control hierarchy for the compare editor - */ - public Control createContents(Composite parent) { - - fComposite= new Splitter(parent, SWT.VERTICAL); - fComposite.setData(this); - - Control outline= null; - if (!fUseOutlineView) - outline= createOutlineContents(fComposite, SWT.HORIZONTAL); - - fContentInputPane= new CompareViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findContentViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - if (fFocusPane == null) - fFocusPane= fContentInputPane; - if (outline != null) - fComposite.setVisible(outline, false); - fComposite.setVisible(fContentInputPane, true); - - if (fStructureInputPane != null) - fComposite.setWeights(new int[] { 30, 70 }); - - fComposite.layout(); - - if (fStructureInputPane != null && fInput instanceof ICompareInput) { - fStructureInputPane.setInput(fInput); - ISelection sel= fStructureInputPane.getSelection(); - if (sel == null || sel.isEmpty()) - feed1(sel); // we only feed downstream viewers if the top left pane is empty - } - - fComposite.setData("Nav", //$NON-NLS-1$ - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - - return fComposite; - } - - /** - * @param parent the parent control under which the control must be created - * @param direction the layout direction of the contents, either SWT.HORIZONTAL or SWT.VERTICAL - * @return the SWT control hierarchy for the outline part of the compare editor - * @since 3.0 - */ - public Control createOutlineContents(Composite parent, int direction) { - final Splitter h= new Splitter(parent, direction); - - fStructureInputPane= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof DiffNode) { - DiffNode dn= (DiffNode) input; - if (dn.hasChildren()) - return createDiffViewer(this); - } - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - fFocusPane= fStructureInputPane; - - fStructurePane1= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - h.setVisible(fStructurePane1, false); - - fStructurePane2= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - h.setVisible(fStructurePane2, false); - - // setup the wiring for top left pane - fStructureInputPane.addOpenListener( - new IOpenListener() { - public void open(OpenEvent oe) { - feed1(oe.getSelection()); - } - } - ); - fStructureInputPane.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - ISelection s= e.getSelection(); - if (s == null || s.isEmpty()) - feed1(s); - } - } - ); - fStructureInputPane.addDoubleClickListener( - new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - feedDefault1(event.getSelection()); - } - } - ); - - fStructurePane1.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feed2(e.getSelection()); - } - } - ); - - fStructurePane2.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feed3(e.getSelection()); - } - } - ); - - if (fUseOutlineView) { - if (fInput instanceof ICompareInput) { - fStructureInputPane.setInput(fInput); - ISelection sel= fStructureInputPane.getSelection(); - if (sel == null || sel.isEmpty()) - feed1(sel); // we only feed downstream viewers if the top left pane is empty - } - - fComposite.setData("Nav", //$NON-NLS-1$ - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - } - - return h; - } - - private void feed1(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection == null || selection.isEmpty()) { - Object input= fStructureInputPane.getInput(); - fContentInputPane.setInput(input); - fStructurePane2.setInput(null); // clear downstream pane - fStructurePane1.setInput(null); - } else { - Object input= getElement(selection); - fContentInputPane.setInput(input); - if (structureCompareOnSingleClick()) - fStructurePane1.setInput(input); - fStructurePane2.setInput(null); // clear downstream pane - if (fStructurePane1.getInput() != input) - fStructurePane1.setInput(null); - } - } - } - ); - } - - private void feedDefault1(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (!selection.isEmpty()) - fStructurePane1.setInput(getElement(selection)); - } - } - ); - } - - private void feed2(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection.isEmpty()) { - Object input= fStructurePane1.getInput(); - fContentInputPane.setInput(input); - fStructurePane2.setInput(null); - } else { - Object input= getElement(selection); - fContentInputPane.setInput(input); - fStructurePane2.setInput(input); - } - } - } - ); - } - - private void feed3(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection.isEmpty()) - fContentInputPane.setInput(fStructurePane2.getInput()); - else - fContentInputPane.setInput(getElement(selection)); - } - } - ); - - } - - /** - * Returns the first element of the given selection if the selection - * is a IStructuredSelection with exactly one element. Returns - * null otherwise. - * - * @param selection the selection - * @return the first element of the selection, or null - */ - private static Object getElement(ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - if (ss.size() == 1) - return ss.getFirstElement(); - } - return null; - } - - /** - * Asks this input to take focus within its container (editor). - *

- * Clients should not call this method but they may - * override if they implement a different layout with different visual - * components. Clients are free to call the inherited method. - *

- */ - public void setFocus() { - if (fFocusPane != null) { - Viewer v= fFocusPane.getViewer(); - if (v != null) { - Control c= v.getControl(); - if (c != null) - c.setFocus(); - } - } else if (fComposite != null) - fComposite.setFocus(); - } - - /** - * Factory method for creating a differences viewer for the top left pane. - * It is called from createContents and returns a DiffTreeViewer. - *

- * Subclasses may override if they need a different viewer. - *

- * - * @param parent the SWT parent control under which to create the viewer's SWT controls - * @return a compare viewer for the top left pane - */ - public Viewer createDiffViewer(Composite parent) { - return new DiffTreeViewer(parent, fCompareConfiguration); - } - - /** - * Implements the dynamic viewer switching for structure viewers. - * The method must return a compare viewer based on the old (or current) viewer - * and a new input object. If the old viewer is suitable for showing the new input the old viewer - * can be returned. Otherwise a new viewer must be created under the given parent composite or - * null can be returned to indicate that no viewer could be found. - *

- * This implementation forwards the request to CompareUI.findStructureViewer. - *

- * Subclasses may override to implement a different strategy. - *

- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @return a compare viewer which is suitable for the given input object or null - */ - public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - return CompareUI.findStructureViewer(oldViewer, input, parent, fCompareConfiguration); - } - - /** - * Implements the dynamic viewer switching for content viewers. - * The method must return a compare viewer based on the old (or current) viewer - * and a new input object. If the old viewer is suitable for showing the new input the old viewer - * can be returned. Otherwise a new viewer must be created under the given parent composite or - * null can be returned to indicate that no viewer could be found. - *

- * This implementation forwards the request to CompareUI.findContentViewer. - *

- * Subclasses may override to implement a different strategy. - *

- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @return a compare viewer which is suitable for the given input object or null - */ - public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - - Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, parent, fCompareConfiguration); - - boolean isNewViewer= newViewer != oldViewer; - if (DEBUG) System.out.println("CompareEditorInput.findContentViewer: " + isNewViewer); //$NON-NLS-1$ - - if (isNewViewer && newViewer instanceof IPropertyChangeNotifier) { - final IPropertyChangeNotifier dsp= (IPropertyChangeNotifier) newViewer; - dsp.addPropertyChangeListener(fDirtyStateListener); - - Control c= newViewer.getControl(); - c.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - dsp.removePropertyChangeListener(fDirtyStateListener); - } - } - ); - } - - return newViewer; - } - - /** - * Returns true if there are unsaved changes. - * The value returned is the value of the DIRTY_STATE property of this input object. - - * Returns true if this input has unsaved changes, - * that is if setDirty(true) has been called. - * Subclasses don't have to override if the functionality provided by setDirty
- * is sufficient. - * - * @return true if there are changes that need to be saved - */ - public boolean isSaveNeeded() { - return fDirty || fDirtyViewers.size() > 0; - } - - /** - * Sets the dirty state of this input to the given - * value and sends out a PropertyChangeEvent if the new value differs from the old value. - * - * @param dirty the dirty state for this compare input - */ - public void setDirty(boolean dirty) { - - boolean confirmSave= true; - Object o= fCompareConfiguration.getProperty(CompareEditor.CONFIRM_SAVE_PROPERTY); - if (o instanceof Boolean) - confirmSave= ((Boolean)o).booleanValue(); - - if (!confirmSave) { - fDirty= dirty; - if (!fDirty) - fDirtyViewers.clear(); - } - } - - private void setDirty(Object source, boolean dirty) { - Assert.isNotNull(source); - boolean oldDirty= fDirtyViewers.size() > 0; - if (dirty) - fDirtyViewers.add(source); - else - fDirtyViewers.remove(source); - boolean newDirty= fDirty || fDirtyViewers.size() > 0; - if (DEBUG) System.out.println("setDirty("+source+", "+dirty+"): " + newDirty); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (oldDirty != newDirty) - Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, new Boolean(oldDirty), new Boolean(newDirty)); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.addListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (listener != null) - fListenerList.add(listener); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.removeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - if (listener != null) - fListenerList.remove(listener); - } - - /** - * Save any unsaved changes. - * Empty implementation. - * Subclasses must override to save any changes. - * - * @param pm an IProgressMonitor that the implementation of save may use to show progress - * @deprecated Override method saveChanges instead. - */ - public void save(IProgressMonitor pm) { - // empty default implementation - } - - /** - * Save any unsaved changes. - * Subclasses must override to save any changes. - * This implementation tries to flush changes in all viewers by - * calling ISavable.save on them. - * - * @param pm an IProgressMonitor that the implementation of save may use to show progress - * @throws CoreException - * @since 2.0 - */ - public void saveChanges(IProgressMonitor pm) throws CoreException { - - // flush changes in any dirty viewer - flushViewer(fStructureInputPane, pm); - flushViewer(fStructurePane1, pm); - flushViewer(fStructurePane2, pm); - flushViewer(fContentInputPane, pm); - - save(pm); - } - - private static void flushViewer(CompareViewerSwitchingPane pane, IProgressMonitor pm) throws CoreException { - if (pane != null) { - Viewer v= pane.getViewer(); - if (v instanceof ISavable) - ((ISavable)v).save(pm); - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java deleted file mode 100644 index 222de63ac..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.ResourceBundle; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.content.IContentType; - -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -/** - * The class CompareUI defines the entry point to initiate a configurable - * compare operation on arbitrary resources. The result of the compare - * is opened into a compare editor where the details can be browsed and - * edited in dynamically selected structure and content viewers. - *

- * The Compare UI provides a registry for content and structure compare viewers, - * which is initialized from extensions contributed to extension points - * declared by this plug-in. - */ -public final class CompareUI { - - /** - * Compare Plug-in ID (value "org.eclipse.compare"). - * @since 2.0 - */ - public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$ - - /** - * Image descriptor for the disabled icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_DTOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.DTOOL_NEXT); - /** - * Image descriptor for the normal icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_CTOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.CTOOL_NEXT); - /** - * Image descriptor for the roll-over icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_ETOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.ETOOL_NEXT); - - /** - * Image descriptor for the disabled icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_DTOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.DTOOL_PREV); - /** - * Image descriptor for the normal icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_CTOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.CTOOL_PREV); - /** - * Image descriptor for the roll-over icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_ETOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.ETOOL_PREV); - - /** - * Name of the title property of a compare viewer. - * If a property with this name is set - * on the top level SWT control of a viewer, it is used as a title in the pane's - * title bar. - */ - public static final String COMPARE_VIEWER_TITLE= "org.eclipse.compare.CompareUI.CompareViewerTitle"; //$NON-NLS-1$ - - private CompareUI() { - // empty implementation - } - - public static AbstractUIPlugin getPlugin() { - return CompareUIPlugin.getDefault(); - } - - /** - * Returns this plug-in's resource bundle. - * - * @return the plugin's resource bundle - */ - public static ResourceBundle getResourceBundle() { - return CompareUIPlugin.getDefault().getResourceBundle(); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result in the currently active workbench page. - * - * @param input the input on which to open the compare editor - */ - public static void openCompareEditor(CompareEditorInput input) { - openCompareEditorOnPage(input, null); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result in the given workbench page. - * - * @param input the input on which to open the compare editor - * @param page the workbench page in which to open the compare editor - * @since 2.1 - */ - public static void openCompareEditorOnPage(CompareEditorInput input, IWorkbenchPage page) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareEditor(input, page, null); - } - - /** - * Performs the comparison described by the given input and - * shows the result in the given editor. - * - * @param input the input on which to open the compare editor - * @param editor the compare editor to reuse or null to create a new one - * @since 3.0 - */ - public static void reuseCompareEditor(CompareEditorInput input, IReusableEditor editor) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareEditor(input, null, editor); - } - - /** - * Performs the comparison described by the given input and opens a - * modal compare dialog on the result. - * - * @param input the input on which to open the compare dialog - */ - public static void openCompareDialog(CompareEditorInput input) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareDialog(input); - } - - /** - * Registers an image descriptor for the given type. - * - * @param type the type - * @param descriptor the image descriptor - */ - public static void registerImageDescriptor(String type, ImageDescriptor descriptor) { - CompareUIPlugin.registerImageDescriptor(type, descriptor); - } - - /** - * Returns a shared image for the given type, or a generic image if none - * has been registered for the given type. - *

- * Note: Images returned from this method will be automatically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param type the type - * @return the image - */ - public static Image getImage(String type) { - return CompareUIPlugin.getImage(type); - } - - /** - * Registers the given image for being disposed when this plug-in is shutdown. - * - * @param image the image to register for disposal - */ - public static void disposeOnShutdown(Image image) { - CompareUIPlugin.disposeOnShutdown(image); - } - - /** - * Returns a shared image for the given adaptable. - * This convenience method queries the given adaptable - * for its IWorkbenchAdapter.getImageDescriptor, which it - * uses to create an image if it does not already have one. - *

- * Note: Images returned from this method will be automatically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param adaptable the adaptable for which to find an image - * @return an image - */ - public static Image getImage(IAdaptable adaptable) { - return CompareUIPlugin.getImage(adaptable); - } - - - /** - * Creates a stream merger for the given content type. - * If no stream merger is registered for the given content type null is returned. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public static IStreamMerger createStreamMerger(IContentType type) { - return CompareUIPlugin.getDefault().createStreamMerger(type); - } - - /** - * Creates a stream merger for the given file extension. - * If no stream merger is registered for the file extension null is returned. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public static IStreamMerger createStreamMerger(String type) { - return CompareUIPlugin.getDefault().createStreamMerger(type); - } - - /** - * Returns a structure compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input, the old viewer - * is returned. Otherwise, the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a structure compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - - return CompareUIPlugin.getDefault().findStructureViewer(oldViewer, input, parent, configuration); - } - - /** - * Returns a content compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input the old viewer - * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a content compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a content viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - return CompareUIPlugin.getDefault().findContentViewer(oldViewer, input, parent, configuration); - } - - /** - * Returns a content compare viewer based on an old viewer and an input - * object. If the old viewer is suitable for showing the input the old - * viewer is returned. Otherwise the input's type is used to find a viewer - * descriptor in the registry which in turn is used to create a content - * compare viewer under the given parent composite. In order to determine - * the input's type, the input must either implement IStreamContentAccessor - * and ITypedElement or ICompareInput. If no viewer descriptor can be found - * null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a content viewer. Must - * implement either IStreamContentAccessor and - * ITypedElement or ICompareInput. - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findContentViewer(Viewer oldViewer, Object input, Composite parent, - CompareConfiguration configuration) { - - return CompareUIPlugin.getDefault().findContentViewer(oldViewer, input, parent, configuration); - } - - /** - * Adds an alias for the given type. - * Subsequent calls to findStructureViewer - * treat alias as a synonym for type and return the same viewer. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param type a type name for which a viewer has been registered - * @param alias a type name which should be treated as a synonym of type - * @since 2.0 - */ - public static void addStructureViewerAlias(String type, String alias) { - CompareUIPlugin.getDefault().addStructureViewerAlias(type, alias); - } - - /** - * Remove all aliases for the given type. This method does not affect - * the initial binding between type and viewer. If no aliases exist for the - * given type this method does nothing. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param type the type name for which all synonymes are removed. - * @since 2.0 - */ - public static void removeAllStructureViewerAliases(String type) { - CompareUIPlugin.getDefault().removeAllStructureViewerAliases(type); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java deleted file mode 100644 index 646f99092..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.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.compare; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.action.ToolBarManager; - -/** - * A CompareViewerPane is a convenience class which installs a - * CLabel and a Toolbar in a ViewForm. - *

- * Double clicking onto the CompareViewerPane's title bar maximizes - * the CompareViewerPane to the size of an enclosing Splitter - * (if there is one). - * If more Splitters are nested maximizing walks up and - * maximizes to the outermost Splitter. - * - * @since 2.0 - */ -public class CompareViewerPane extends ViewForm { - - private ToolBarManager fToolBarManager; - - /** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * - * @param container a widget which will be the container of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException

- * @exception org.eclipse.swt.SWTException - */ - public CompareViewerPane(Composite container, int style) { - super(container, style); - - marginWidth= 0; - marginHeight= 0; - - CLabel label= new CLabel(this, SWT.NONE) { - public Point computeSize(int wHint, int hHint, boolean changed) { - return super.computeSize(wHint, Math.max(24, hHint), changed); - } - }; - setTopLeft(label); - - MouseAdapter ml= new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - Control content= getContent(); - if (content != null && content.getBounds().contains(e.x, e.y)) - return; - Control parent= getParent(); - if (parent instanceof Splitter) - ((Splitter)parent).setMaximizedControl(CompareViewerPane.this); - } - }; - - addMouseListener(ml); - label.addMouseListener(ml); - - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fToolBarManager != null) { - fToolBarManager.removeAll(); - fToolBarManager= null; - } - } - }); - } - - /** - * Set the pane's title text. - * The value null clears it. - * - * @param label the text to be displayed in the pane or null - */ - public void setText(String label) { - CLabel cl= (CLabel) getTopLeft(); - if (cl != null) - cl.setText(label); - } - - /** - * Set the pane's title Image. - * The value null clears it. - * - * @param image the image to be displayed in the pane or null - */ - public void setImage(Image image) { - CLabel cl= (CLabel) getTopLeft(); - if (cl != null) - cl.setImage(image); - } - - /** - * Returns a ToolBarManager if the given parent is a - * CompareViewerPane or null otherwise. - * - * @param parent a Composite or null - * @return a ToolBarManager if the given parent is a CompareViewerPane otherwise null - */ - public static ToolBarManager getToolBarManager(Composite parent) { - if (parent instanceof CompareViewerPane) { - CompareViewerPane pane= (CompareViewerPane) parent; - return pane.getToolBarManager(); - } - return null; - } - - /** - * Clears tool items in the CompareViewerPane's control bar. - * - * @param parent a Composite or null - */ - public static void clearToolBar(Composite parent) { - ToolBarManager tbm= getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - tbm.update(true); - } - } - - //---- private stuff - - private ToolBarManager getToolBarManager() { - if (fToolBarManager == null) { - ToolBar tb= new ToolBar(this, SWT.FLAT); - setTopCenter(tb); - fToolBarManager= new ToolBarManager(tb); - } - return fToolBarManager; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java deleted file mode 100644 index 1b5c92d8f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java +++ /dev/null @@ -1,369 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.text.MessageFormat; - -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -/** - * A custom CompareViewerPane that supports dynamic viewer switching. - * - *

- * Clients must implement the viewer switching strategy by implementing - * the getViewer(Viewer, Object) method. - *

- * If a property with the name CompareUI.COMPARE_VIEWER_TITLE is set - * on the top level SWT control of a viewer, it is used as a title in the CompareViewerPane's - * title bar. - * - * @since 2.0 - */ -public abstract class CompareViewerSwitchingPane extends CompareViewerPane - implements ISelectionChangedListener, ISelectionProvider, IDoubleClickListener { - - private Viewer fViewer; - private Object fInput; - private ListenerList fSelectionListeners= new ListenerList(); - private ListenerList fDoubleClickListener= new ListenerList(); - private ListenerList fOpenListener= new ListenerList(); - private boolean fControlVisibility= false; - private String fTitle; - private String fTitleArgument; - - private IOpenListener fOpenHandler= new IOpenListener() { - public void open(OpenEvent event) { - Object[] listeners= fOpenListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IOpenListener) listeners[i]).open(event); - } - }; - - /** - * Creates a CompareViewerSwitchingPane as a child of the given parent and with the - * specified SWT style bits. - * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException

- * @exception org.eclipse.swt.SWTException - */ - public CompareViewerSwitchingPane(Composite parent, int style) { - this(parent, style, false); - } - - /** - * Creates a CompareViewerSwitchingPane as a child of the given parent and with the - * specified SWT style bits. - * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * @param visibility the initial visibility of the CompareViewerSwitchingPane - * - * @exception IllegalArgumentException - * @exception org.eclipse.swt.SWTException - */ - public CompareViewerSwitchingPane(Composite parent, int style, boolean visibility) { - super(parent, style); - - fControlVisibility= visibility; - - setViewer(new NullViewer(this)); - - addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fViewer != null) - fViewer.removeSelectionChangedListener(CompareViewerSwitchingPane.this); - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.removeDoubleClickListener(CompareViewerSwitchingPane.this); - sv.removeOpenListener(fOpenHandler); - } - fViewer= null; - fInput= null; - fSelectionListeners= null; - } - } - ); - } - - /** - * Returns the current viewer. - * - * @return the current viewer - */ - public Viewer getViewer() { - return fViewer; - } - - private void setViewer(Viewer newViewer) { - - if (newViewer == fViewer) - return; - - boolean oldEmpty= isEmpty(); - - if (fViewer != null) { - - fViewer.removeSelectionChangedListener(this); - - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.removeDoubleClickListener(this); - sv.removeOpenListener(fOpenHandler); - } - - Control content= getContent(); - setContent(null); - - fViewer.setInput(null); - - if (content != null && !content.isDisposed()) - content.dispose(); - - } else - oldEmpty= false; - setContent(null); - - fViewer= newViewer; - - if (fViewer != null) { - // we have to remember and restore the old visibility of the CustomPane - // since setContent changes the visibility - boolean old= getVisible(); - setContent(fViewer.getControl()); - setVisible(old); // restore old visibility - - boolean newEmpty= isEmpty(); - - fViewer.addSelectionChangedListener(this); - - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.addDoubleClickListener(this); - sv.addOpenListener(fOpenHandler); - } - - if (oldEmpty != newEmpty) { // relayout my container - Composite parent= getParent(); - if (parent instanceof Splitter) - ((Splitter)parent).setVisible(this, fControlVisibility ? !newEmpty : true); - } - - layout(true); - } - } - - /** - * Returns the optional title argument that has been set with setTitelArgument - * or null if no optional title argument has been set. - *

- * Note: this method is for internal use only. Clients should not call this method. - * - * @return the optional title argument or null - */ - public String getTitleArgument() { - return fTitleArgument; - } - - /** - * Returns true if no viewer is installed or if the current viewer - * is a NullViewer. - * - * @return true if no viewer is installed or if the current viewer is a NullViewer - */ - public boolean isEmpty() { - return fViewer == null || fViewer instanceof NullViewer; - } - - public void addSelectionChangedListener(ISelectionChangedListener l) { - fSelectionListeners.add(l); - } - - public void removeSelectionChangedListener(ISelectionChangedListener l) { - fSelectionListeners.remove(l); - } - - public void addDoubleClickListener(IDoubleClickListener l) { - fDoubleClickListener.add(l); - } - - public void removeDoubleClickListener(IDoubleClickListener l) { - fDoubleClickListener.remove(l); - } - - public void addOpenListener(IOpenListener l) { - fOpenListener.add(l); - } - - public void removeOpenListener(IOpenListener l) { - fOpenListener.remove(l); - } - - public void doubleClick(DoubleClickEvent event) { - Object[] listeners= fDoubleClickListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IDoubleClickListener) listeners[i]).doubleClick(event); - } - - public ISelection getSelection() { - if (fViewer != null) - return fViewer.getSelection(); - return null; - } - - public void setSelection(ISelection s) { - if (fViewer != null) - fViewer.setSelection(s); - } - - public void selectionChanged(SelectionChangedEvent ev) { - Object[] listeners= fSelectionListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((ISelectionChangedListener) listeners[i]).selectionChanged(ev); - } - - private boolean hasFocus2() { - // do we have focus? - Display display= getDisplay(); - if (display != null) - for (Control focus= display.getFocusControl(); focus != null; focus= focus.getParent()) - if (focus == this) - return true; - return false; - } - - /** - * Sets the input object of this pane. - * For this input object a suitable viewer is determined by calling the abstract - * method getViewer(Viewer, Object). - * If the returned viewer differs from the current one, the old viewer - * is disposed and the new one installed. Then the input object is fed - * into the newly installed viewer by calling its setInput(Object) method. - * If new and old viewer don't differ no new viewer is installed but just - * setInput(Object) is called. - * If the input is null the pane is cleared, - * that is the current viewer is disposed. - * - * @param input the new input object or null - */ - public void setInput(Object input) { - - if (fInput == input) - return; - - boolean hadFocus= hasFocus2(); - - fInput= input; - - // viewer switching - Viewer newViewer= null; - if (input != null) - newViewer= getViewer(fViewer, input); - - if (newViewer == null) { - if (fViewer instanceof NullViewer) - return; - newViewer= new NullViewer(this); - } - - setViewer(newViewer); - - // set input - fViewer.setInput(input); - - Image image= null; - if (!(fViewer instanceof NullViewer) && input instanceof ICompareInput) - image= ((ICompareInput)input).getImage(); - setImage(image); - - String title= null; - if (fViewer != null) { - Control c= fViewer.getControl(); - if (c != null) { - Object data= c.getData(CompareUI.COMPARE_VIEWER_TITLE); - if (data instanceof String) - title= (String) data; - if (hadFocus) - c.setFocus(); - } - } - - fTitle= title; - updateTitle(); - } - - /** - * Sets an additional and optional argument for the pane's title. - * Note: this method is for internal use only. Clients should not call this method. - * - * @param argument an optional argument for the pane's title - */ - public void setTitleArgument(String argument) { - fTitleArgument= argument; - updateTitle(); - } - - private void updateTitle() { - if (fTitle != null) { - if (fTitleArgument != null) { - String format= CompareMessages.getString("CompareViewerSwitchingPane.Titleformat"); //$NON-NLS-1$ - String t= MessageFormat.format(format, new String[] { fTitle, fTitleArgument } ); - setText(t); - } else - setText(fTitle); - } else { - setText(""); //$NON-NLS-1$ - } - } - - /** - * Returns the current input of this pane or null if the pane has no input. - * - * @return an Object that is the input to this pane or null if the pane has no input. - */ - public Object getInput() { - return fInput; - } - - /** - * Returns a viewer which is able to display the given input. - * If no viewer can be found, null is returned. - * The additional argument oldViewer represents the viewer currently installed - * in the pane (or null if no viewer is installed). - * It can be returned from this method if the current viewer can deal with the - * input (and no new viewer must be created). - * - * @param oldViewer the currently installed viewer or null - * @param input the input object for which a viewer must be determined or null - * @return a viewer for the given input, or null if no viewer can be determined - */ - abstract protected Viewer getViewer(Viewer oldViewer, Object input); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java deleted file mode 100644 index 229101703..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java +++ /dev/null @@ -1,1128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.ResourceBundle; -import java.util.Date; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.HashSet; -import java.util.Calendar; -import java.util.Comparator; -import java.text.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Button; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.dialogs.*; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A dialog where one input element can be compared against - * a list of historic variants (editions) of the same input element. - * The dialog can be used to implement functions like "Compare/Replace with Version" or - * "Compare/Replace from Local History" on workspace resources. - *

- * In addition it is possible to specify a subsection of the input element - * (e.g. a method in a Java source file) by means of a "path". - * In this case the dialog compares only the subsection (as specified by the path) - * with the corresponding subsection in the list of editions. - * Only those editions are shown where the subsection differs from the same subsection in - * another edition thereby minimizing the number of presented variants. - * This functionality can be used to implement "Replace from Local History" - * for the Java language. - *

- * Subsections of an input element are determined by first finding an - * IStructureCreator for the input's type. - * Then the method locate is used to extract the subsection. - *

- * Each edition (variant in the list of variants) must implement the IModificationDate interface - * so that the dialog can sort the editions and present them in a tree structure where every - * node corresponds one day. - *

- * The functionality is surfaced in a single function selectEdition. - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * - * @see IModificationDate - * @see ITypedElement - */ -public class EditionSelectionDialog extends ResizableDialog { - - /** - * An item in an underlying edition. - */ - private static class Pair { - - private ITypedElement fEdition; - private ITypedElement fItem; - private String fContent; - private IStructureCreator fStructureCreator; - private boolean fHasError= false; - - Pair(IStructureCreator structureCreator, ITypedElement edition, ITypedElement item) { - fStructureCreator= structureCreator; - fEdition= edition; - fItem= item; - } - - Pair(IStructureCreator structureCreator, ITypedElement edition) { - this(structureCreator, edition, edition); - } - - ITypedElement getEdition() { - return fEdition; - } - - ITypedElement getItem() { - return fItem; - } - - /* - * The content is lazily loaded - */ - private String getContent() { - if (fContent == null) { - if (fStructureCreator != null) - fContent= fStructureCreator.getContents(fItem, false); - else { - if (fItem instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) fItem; - try { - fContent= Utilities.readString(sca); - } catch (CoreException ex) { - // NeedWork - } - } - } - if (fContent == null) - fContent= ""; //$NON-NLS-1$ - } - return fContent; - } - - public boolean equals(Object other) { - if (other != null && other.getClass() == getClass()) { - if (getContent().equals(((Pair)other).getContent())) - return true; - } - return super.equals(other); - } - } - - // Configuration options - private CompareConfiguration fCompareConfiguration; - private ArrayList fArrayList= new ArrayList(); - /** use a side-by-side compare viewer */ - private boolean fCompare= true; - /** show target on right hand side */ - private boolean fTargetIsRight= false; - /** hide entries which have identical content */ - private boolean fHideIdentical= true; - /** add mode if true, otherwise replace mode */ - private boolean fAddMode= false; - /** compare mode if true, otherwise replace/add mode */ - private boolean fCompareMode= false; - /** perform structure compare on editions */ - private boolean fStructureCompare= false; - /** allow for multiple selection */ - private boolean fMultiSelect= false; - - /** - * Maps from members to their corresponding editions. - * Has only a single entry if dialog is used in "Replace" (and not "Add") mode. - */ - private HashMap fMemberEditions; - /** - * Maps from members to their corresponding selected edition. - */ - private HashMap fMemberSelection; - /** The editions of the current selected member */ - private List fCurrentEditions; - private Thread fThread; - private Pair fTargetPair; - /** The selected edition in the edition viewer */ - private ITypedElement fSelectedItem; - private String fTitleArg; - private Image fTitleImage; - - // SWT controls - private CompareViewerSwitchingPane fContentPane; - private Button fCommitButton; - private Table fMemberTable; - private CompareViewerPane fMemberPane; - private Tree fEditionTree; - private CompareViewerPane fEditionPane; - private Image fDateImage; - private Image fTimeImage; - private CompareViewerSwitchingPane fStructuredComparePane; - - /** - * Creates a new modal, resizable dialog. - * Various titles, icons, and labels are configured from the given resource bundle. - * The following resource keys are used: - *
-	 *	key         type          description
-	 *	title       String        dialog title
-	 *	width       Integer       initial width of dialog
-	 *	height      Integer       initial height of dialog
-	 *	treeTitleFormat   MessageFormat pane title for edition tree; arg 0 is the target
-	 *	dateIcon    String        icon for node in edition tree; path relative to plugin
-	 *	timeIcon    String        icon for leaf in edition tree; path relative to plugin
-	 *	todayFormat MessageFormat format string if date is todays date; arg 0 is date
-	 *	yesterdayFormat MessageFormat format string if date is yesterdays date; arg 0 is date
-	 *	dayFormat   MessageFormat format string if date is any other date; arg 0 is date
-	 *	editionLabel String       label for editions side of compare viewer; arg 0 is the date
-	 *	targetLabel  String       label for target side of compare viewer 
-	 *  buttonLabel  String       label for OK button; default is IDialogConstants.OK_LABEL
-	 * 
- * - * @param parent if not null the new dialog stays on top of this parent shell - * @param bundle ResourceBundle to configure the dialog - */ - public EditionSelectionDialog(Shell parent, ResourceBundle bundle) { - super(parent, bundle); - } - - private CompareConfiguration getCompareConfiguration() { - if (fCompareConfiguration == null) { - fCompareConfiguration= new CompareConfiguration(); - fCompareConfiguration.setLeftEditable(false); - fCompareConfiguration.setRightEditable(false); - } - return fCompareConfiguration; - } - - /** - * Sets an additional and optional argument for the edition pane's title. - * - * @param titleArgument an optional argument for the edition pane's title - * @since 2.0 - */ - public void setEditionTitleArgument(String titleArgument) { - fTitleArg= titleArgument; - } - - /** - * Sets an optional image for the edition pane's title. - * - * @param titleImage an optional image for the edition pane's title - * @since 2.0 - */ - public void setEditionTitleImage(Image titleImage) { - fTitleImage= titleImage; - } - - /** - * Select the previous edition (presenting a UI). - * - * @param target the input object against which the editions are compared; must not be null - * @param inputEditions the list of editions (element type: ITypedElements) - * @param ppath If null dialog shows full input; if non null it extracts a subsection - * @return returns the selected edition or null if error occurred. - * The returned ITypedElement is one of the original editions - * if path was null; otherwise - * it is an ITypedElement returned from IStructureCreator.locate(path, item) - * @since 2.0 - */ - public ITypedElement selectPreviousEdition(final ITypedElement target, ITypedElement[] inputEditions, Object ppath) { - Assert.isNotNull(target); - fTargetPair= new Pair(null, target); - - // sort input editions - final int count= inputEditions.length; - final IModificationDate[] editions= new IModificationDate[count]; - for (int i= 0; i < count; i++) - editions[i]= (IModificationDate) inputEditions[i]; - if (count > 1) - internalSort(editions); - - // find StructureCreator if ppath is not null - IStructureCreator structureCreator= null; - if (ppath != null) { - String type= target.getType(); - StructureCreatorDescriptor scd= CompareUIPlugin.getDefault().getStructureCreator(type); - if (scd != null) - structureCreator= scd.createStructureCreator(); - } - - if (fAddMode) { - // does not work in add mode - return null; - } - - if (structureCreator != null) { - Pair pair= createPair(structureCreator, ppath, target); - if (pair != null) - fTargetPair= pair; - else - ppath= null; // couldn't extract item because of error - } - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - ITypedElement edition= (ITypedElement) editions[i]; - Pair pair= null; - - if (structureCreator != null && ppath != null) { - // extract sub element from edition - pair= createPair(structureCreator, ppath, edition); - } else { - pair= new Pair(null, edition); - } - - if (pair != null && pair.fHasError) - return null; - - if (pair != null && !fTargetPair.equals(pair)) { - return pair.fItem; - } - } - - // nothing found - return null; - } - - /** - * Presents this modal dialog with the functionality described in the class comment above. - * - * @param target the input object against which the editions are compared; must not be null - * @param inputEditions the list of editions (element type: ITypedElements) - * @param ppath If null dialog shows full input; if non null it extracts a subsection - * @return returns the selected edition or null if dialog was cancelled. - * The returned ITypedElement is one of the original editions - * if path was null; otherwise - * it is an ITypedElement returned from IStructureCreator.locate(path, item) - */ - public ITypedElement selectEdition(final ITypedElement target, ITypedElement[] inputEditions, Object ppath) { - - Assert.isNotNull(target); - fTargetPair= new Pair(null, target); - - // sort input editions - final int count= inputEditions.length; - final IModificationDate[] editions= new IModificationDate[count]; - for (int i= 0; i < count; i++) - editions[i]= (IModificationDate) inputEditions[i]; - if (count > 1) - internalSort(editions); - - // find StructureCreator if ppath is not null - IStructureCreator structureCreator= null; - if (ppath != null) { - String type= target.getType(); - StructureCreatorDescriptor scd= CompareUIPlugin.getDefault().getStructureCreator(type); - if (scd != null) - structureCreator= scd.createStructureCreator(); - } - - if (!fAddMode) { - // replace mode - - if (structureCreator != null) { - Pair pair= createPair(structureCreator, ppath, target); - if (pair != null) - fTargetPair= pair; - else - ppath= null; // couldn't extract item because of error - } - - // set the left and right labels for the compare viewer - String targetLabel= getTargetLabel(target, fTargetPair.getItem()); - if (fTargetIsRight) - getCompareConfiguration().setRightLabel(targetLabel); - else - getCompareConfiguration().setLeftLabel(targetLabel); - - if (structureCreator != null && ppath != null) { // extract sub element - - final IStructureCreator sc= structureCreator; - final Object path= ppath; - - // construct the comparer thread - // and perform the background extract - fThread= new Thread() { - public void run() { - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - if (fEditionTree == null || fEditionTree.isDisposed()) - break; - ITypedElement edition= (ITypedElement) editions[i]; - - // extract sub element from edition - Pair pair= createPair(sc, path, edition); - if (pair != null) - sendPair(pair); - } - sendPair(null); - } - }; - } else { - // create tree widget - create(); - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) - addMemberEdition(new Pair(null, (ITypedElement) editions[i])); - } - - } else { - // add mode - final Object container= ppath; - Assert.isNotNull(container); - - if (structureCreator == null) - return null; // error - - // extract all elements of container - final HashSet current= new HashSet(); - IStructureComparator sco= structureCreator.locate(container, target); - if (sco != null) { - Object[] children= sco.getChildren(); - if (children != null) - for (int i= 0; i < children.length; i++) - current.add(children[i]); - } - - final IStructureCreator sc= structureCreator; - - // construct the comparer thread - // and perform the background extract - fThread= new Thread() { - public void run() { - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - if (fEditionTree == null || fEditionTree.isDisposed()) - break; - ITypedElement edition= (ITypedElement) editions[i]; - - IStructureComparator sco2= sc.locate(container, edition); - if (sco2 != null) { - Object[] children= sco2.getChildren(); - if (children != null) { - for (int i2= 0; i2 < children.length; i2++) { - ITypedElement child= (ITypedElement) children[i2]; - if (!current.contains(child)) - sendPair(new Pair(sc, edition, child)); - } - } - } - } - sendPair(null); - } - }; - } - - open(); - - if (getReturnCode() == OK) - return fSelectedItem; - return null; - } - - private Pair createPair(IStructureCreator sc, Object path, ITypedElement input) { - IStructureComparator scmp= sc.locate(path, input); - if (scmp == null && sc.getStructure(input) == null) { // parse error - Pair p= new Pair(sc, input); - p.fHasError= true; - return p; - } - if (scmp instanceof ITypedElement) - return new Pair(sc, input, (ITypedElement) scmp); - return null; - } - - /** - * Controls whether identical entries are shown or not (default). - * This method must be called before selectEdition. - * - * @param hide if true identical entries are hidden; otherwise they are shown. - * @since 2.0 - */ - public void setHideIdenticalEntries(boolean hide) { - fHideIdentical= hide; - } - - /** - * Controls whether workspace target is on the left (the default) or right hand side. - * - * @param isRight if true target is shown on right hand side. - * @since 2.0 - */ - public void setTargetIsRight(boolean isRight) { - fTargetIsRight= isRight; - } - - /** - * Controls whether the EditionSelectionDialog is in 'add' mode - * or 'replace' mode (the default). - * - * @param addMode if true dialog is in 'add' mode. - * @since 2.0 - */ - public void setAddMode(boolean addMode) { - fAddMode= addMode; - fMultiSelect= addMode; - } - - /** - * Controls whether the EditionSelectionDialog is in 'compare' mode - * or 'add/replace' (the default) mode. - * - * @param compareMode if true dialog is in 'add' mode. - * @since 2.0 - */ - public void setCompareMode(boolean compareMode) { - fCompareMode= compareMode; - fStructureCompare= fCompareMode && !fAddMode; - } - - /** - * Returns the input target that has been specified with the most recent call - * to selectEdition. If a not null path was specified this method - * returns a subsection of this target (IStructureCreator.locate(path, target)) - * instead of the input target. - *

- * For example if the target is a Java compilation unit and path specifies - * a method, the value returned from getTarget will be the method not the compilation unit. - * - * @return the last specified target or a subsection thereof. - */ - public ITypedElement getTarget() { - return fTargetPair.getItem(); - } - - /** - * Returns the editions that have been selected with the most - * recent call to selectEdition. - * - * @return the selected editions as an array. - * @since 2.1 - */ - public ITypedElement[] getSelection() { - ArrayList result= new ArrayList(); - if (fMemberSelection != null) { - Iterator iter= fArrayList.iterator(); - for (int i= 0; iter.hasNext(); i++) { - Object edition= iter.next(); - Object item= fMemberSelection.get(edition); - if (item != null) - result.add(item); - } - } else if (fSelectedItem != null) - result.add(fSelectedItem); - return (ITypedElement[]) result.toArray(new ITypedElement[result.size()]); - } - - /** - * Returns a label for identifying the target side of a compare viewer. - * This implementation extracts the value for the key "targetLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the name of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param target the target element for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given target; otherwise the same as target - * @return a label the target side of a compare viewer - */ - protected String getTargetLabel(ITypedElement target, ITypedElement item) { - String format= null; - if (target instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceTargetLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "targetLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - return MessageFormat.format(format, new Object[] { target.getName() }); - } - - /** - * Returns a label for identifying the edition side of a compare viewer. - * This implementation extracts the value for the key "editionLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param selectedEdition the selected edition for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given selectedEdition; otherwise the same as selectedEdition - * @return a label for the edition side of a compare viewer - */ - protected String getEditionLabel(ITypedElement selectedEdition, ITypedElement item) { - String format= null; - if (selectedEdition instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceEditionLabel", null); //$NON-NLS-1$ - else if (selectedEdition instanceof HistoryItem) - format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - - String date= ""; //$NON-NLS-1$ - if (selectedEdition instanceof IModificationDate) { - long modDate= ((IModificationDate)selectedEdition).getModificationDate(); - date= DateFormat.getDateTimeInstance().format(new Date(modDate)); - } - - return MessageFormat.format(format, new Object[] { date }); - } - - /** - * Returns a label for identifying a node in the edition tree viewer. - * This implementation extracts the value for the key "workspaceTreeFormat" or - * "treeFormat" (in that order) from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param edition the edition for which a label must be returned - * @param item if a path has been specified in edition a sub element of the given edition; otherwise the same as edition - * @param date this date will be returned as part of the formatted string - * @return a label of a node in the edition tree viewer - * @since 2.0 - */ - protected String getShortEditionLabel(ITypedElement edition, ITypedElement item, Date date) { - String format= null; - if (edition instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceTreeFormat", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "treeFormat", null); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - String ds= DateFormat.getTimeInstance().format(date); - return MessageFormat.format(format, new Object[] { ds }); - } - - /** - * Returns an image for identifying the edition side of a compare viewer. - * This implementation extracts the value for the key "editionLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param selectedEdition the selected edition for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given selectedEdition; otherwise the same as selectedEdition - * @return a label the edition side of a compare viewer - * @since 2.0 - */ - protected Image getEditionImage(ITypedElement selectedEdition, ITypedElement item) { - if (selectedEdition instanceof ResourceNode) - return selectedEdition.getImage(); - if (selectedEdition instanceof HistoryItem) { - if (fTimeImage == null) { - String iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fTimeImage= id.createImage(); - } - return fTimeImage; - } - return null; - } - - /* (non Javadoc) - * Creates SWT control tree. - */ - protected synchronized Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - Splitter vsplitter= new Splitter(parent, SWT.VERTICAL); - vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - vsplitter.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fCompareConfiguration != null) { - fCompareConfiguration.dispose(); - fCompareConfiguration= null; - } - if (fDateImage != null) { - fDateImage.dispose(); - fDateImage= null; - } - if (fTimeImage != null) { - fTimeImage.dispose(); - fTimeImage= null; - } - } - } - ); - - if (fAddMode) { - // we need two panes: the left for the elements, the right one for the editions - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - fMemberPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - fMemberPane.setText(Utilities.getString(fBundle, "memberPaneTitle")); //$NON-NLS-1$ - - int flags= SWT.H_SCROLL + SWT.V_SCROLL; - if (fMultiSelect) - flags|= SWT.CHECK; - fMemberTable= new Table(fMemberPane, flags); - fMemberTable.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (e.detail == SWT.CHECK) { - if (e.item instanceof TableItem) { - TableItem ti= (TableItem) e.item; - Object data= ti.getData(); - if (ti.getChecked()) - fArrayList.add(data); - else - fArrayList.remove(data); - - if (fCommitButton != null) - fCommitButton.setEnabled(fArrayList.size() > 0); - - fMemberTable.setSelection(new TableItem[] { ti }); - } - } - handleMemberSelect(e.item); - } - } - ); - fMemberPane.setContent(fMemberTable); - fMemberTable.setFocus(); - - fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - } else { - if (fStructureCompare) { - // we need two panes: the left for the elements, the right one for the structured diff - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - fStructuredComparePane= new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return CompareUI.findStructureViewer(oldViewer, (ICompareInput)input, this, getCompareConfiguration()); - return null; - } - }; - fStructuredComparePane.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feedInput2(e.getSelection()); - } - } - ); - } else { - // only a single pane showing the editions - fEditionPane= new CompareViewerPane(vsplitter, SWT.BORDER | SWT.FLAT); - } - if (fTitleArg == null) - fTitleArg= fTargetPair.getItem().getName(); - String titleFormat= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(titleFormat, new String[] { fTitleArg }); - fEditionPane.setText(title); - if (fTitleImage != null) - fEditionPane.setImage(fTitleImage); - } - - fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL + SWT.V_SCROLL); - fEditionTree.addSelectionListener( - new SelectionAdapter() { -// public void widgetDefaultSelected(SelectionEvent e) { -// handleDefaultSelected(); -// } - public void widgetSelected(SelectionEvent e) { - feedInput(e.item); - } - } - ); - fEditionPane.setContent(fEditionTree); - - // now start the thread (and forget about it) - if (fThread != null) { - fThread.start(); - fThread= null; - } - - fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, input, this, getCompareConfiguration()); - } - }; - vsplitter.setWeights(new int[] { 30, 70 }); - - applyDialogFont(parent); - return parent; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$ - if (fCompareMode) { - // only a 'Done' button - createButton(parent, IDialogConstants.CANCEL_ID, buttonLabel, false); - } else { - // a 'Cancel' and a 'Add/Replace' button - fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true); - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - } - - /** - * Overidden to disable dismiss on double click in compare mode. - * @since 2.0 - */ - protected void okPressed() { - if (fCompareMode) { - // don't dismiss dialog - } else - super.okPressed(); - } - - //---- private stuff ---------------------------------------------------------------------------------------- - - /* - * Asynchroneously sends a Pair (or null) to the UI thread. - */ - private void sendPair(final Pair pair) { - if (fEditionTree != null && !fEditionTree.isDisposed()) { - Display display= fEditionTree.getDisplay(); - display.asyncExec( - new Runnable() { - public void run() { - addMemberEdition(pair); - } - } - ); - } - } - - private static void internalSort(IModificationDate[] keys) { - Arrays.sort(keys, new Comparator() { - public int compare(Object o1, Object o2) { - IModificationDate d1= (IModificationDate) o1; - IModificationDate d2= (IModificationDate) o2; - long d= d2.getModificationDate() - d1.getModificationDate(); - if (d < 0) - return -1; - if (d > 0) - return 1; - return 0; - } - }); - } - - /* - * Adds the given Pair to the member editions. - * If HIDE_IDENTICAL is true the new Pair is only added if its contents - * is different from the preceeding Pair. - * If the argument is null the message "No Editions found" is shown - * in the member or edition viewer. - */ - private void addMemberEdition(Pair pair) { - - if (pair == null) { // end of list of pairs - if (fMemberTable != null) { - if (!fMemberTable.isDisposed() && fMemberTable.getItemCount() == 0) { - if (fMultiSelect) { - fMemberTable.dispose(); - fMemberTable= new Table(fMemberPane, SWT.NONE); - fMemberPane.setContent(fMemberTable); - } - TableItem ti= new TableItem(fMemberTable, SWT.NONE); - ti.setText(Utilities.getString(fBundle, "noAdditionalMembersMessage")); //$NON-NLS-1$ - } - return; - } - if (fEditionTree != null && !fEditionTree.isDisposed() && fEditionTree.getItemCount() == 0) { - TreeItem ti= new TreeItem(fEditionTree, SWT.NONE); - ti.setText(Utilities.getString(fBundle, "notFoundInLocalHistoryMessage")); //$NON-NLS-1$ - } - return; - } - - if (fMemberEditions == null) - fMemberEditions= new HashMap(); - if (fMultiSelect && fMemberSelection == null) - fMemberSelection= new HashMap(); - - ITypedElement item= pair.getItem(); - List editions= (List) fMemberEditions.get(item); - if (editions == null) { - editions= new ArrayList(); - fMemberEditions.put(item, editions); - if (fMemberTable != null && !fMemberTable.isDisposed()) { - ITypedElement te= item; - String name= te.getName(); - - // find position - TableItem[] items= fMemberTable.getItems(); - int where= items.length; - for (int i= 0; i < where; i++) { - String n= items[i].getText(); - if (n.compareTo(name) > 0) { - where= i; - break; - } - } - - TableItem ti= new TableItem(fMemberTable, where, SWT.NULL); - ti.setImage(te.getImage()); - ti.setText(name); - ti.setData(editions); - } - } - if (fHideIdentical) { - Pair last= fTargetPair; - int size= editions.size(); - if (size > 0) - last= (Pair) editions.get(size-1); - if (last != null && last.equals(pair)) - return; // don't add since the new one is equal to old - } - editions.add(pair); - - if (!fAddMode || editions == fCurrentEditions) - addEdition(pair); - } - - /* - * Returns the number of s since Jan 1st, 1970. - * The given date is converted to GMT and daylight saving is taken into account too. - */ - private long dayNumber(long date) { - int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds - - Calendar calendar= Calendar.getInstance(); - long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); - - return (date + localTimeOffset) / ONE_DAY_MS; - } - - /* - * Adds the given Pair to the edition tree. - * It takes care of creating tree nodes for different dates. - */ - private void addEdition(Pair pair) { - if (fEditionTree == null || fEditionTree.isDisposed()) - return; - - // find last day - TreeItem[] days= fEditionTree.getItems(); - TreeItem lastDay= null; - if (days.length > 0) - lastDay= days[days.length-1]; - - boolean first= lastDay == null; - - ITypedElement edition= pair.getEdition(); - ITypedElement item= pair.getItem(); - - long ldate= ((IModificationDate)edition).getModificationDate(); - long day= dayNumber(ldate); - Date date= new Date(ldate); - if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) { - lastDay= new TreeItem(fEditionTree, SWT.NONE); - if (fDateImage == null) { - String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fDateImage= id.createImage(); - } - lastDay.setImage(fDateImage); - String df= DateFormat.getDateInstance().format(date); - long today= dayNumber(System.currentTimeMillis()); - - String formatKey; - if (day == today) - formatKey= "todayFormat"; //$NON-NLS-1$ - else if (day == today-1) - formatKey= "yesterdayFormat"; //$NON-NLS-1$ - else - formatKey= "dayFormat"; //$NON-NLS-1$ - String pattern= Utilities.getString(fBundle, formatKey); - if (pattern != null) - df= MessageFormat.format(pattern, new String[] { df }); - lastDay.setText(df); - lastDay.setData(date); - } - TreeItem ti= new TreeItem(lastDay, SWT.NONE); - ti.setImage(getEditionImage(edition, item)); - - String s= getShortEditionLabel(edition, item, date); - if (pair.fHasError) { - String pattern= Utilities.getString(fBundle, "parseErrorFormat"); //$NON-NLS-1$ - s= MessageFormat.format(pattern, new String[] { s } ); - } - ti.setText(s); - - ti.setData(pair); - - // determine selected TreeItem - TreeItem selection= first ? ti : null; - if (fMemberSelection != null) { - Object selected= fMemberSelection.get(fCurrentEditions); - if (selected != null) { - if (selected == pair.getItem()) - selection= ti; - else - selection= null; - } - } - if (selection != null) { - fEditionTree.setSelection(new TreeItem[] { selection }); - if (!fAddMode) - fEditionTree.setFocus(); - feedInput(selection); - } - - if (first) // expand first node - lastDay.setExpanded(true); - } - - /* - * Feeds selection from member viewer to edition viewer. - */ - private void handleMemberSelect(Widget w) { - Object data= w.getData(); - if (data instanceof List) { - List editions= (List) data; - if (editions != fCurrentEditions) { - fCurrentEditions= editions; - fEditionTree.removeAll(); - - String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(pattern, new Object[] { ((Item)w).getText() }); - fEditionPane.setText(title); - - Iterator iter= editions.iterator(); - while (iter.hasNext()) { - Object item= iter.next(); - if (item instanceof Pair) - addEdition((Pair) item); - } - } - } - } - - private void setInput(Object input) { - if (!fCompare && input instanceof ICompareInput) { - ICompareInput ci= (ICompareInput) input; - if (fTargetIsRight) - input= ci.getLeft(); - else - input= ci.getRight(); - } - fContentPane.setInput(input); - if (fStructuredComparePane != null) - fStructuredComparePane.setInput(input); - } - - /* - * Feeds selection from edition viewer to content (and structure) viewer. - */ - private void feedInput(Widget w) { - Object input= w.getData(); - boolean isOK= false; - if (input instanceof Pair) { - Pair pair= (Pair) input; - fSelectedItem= pair.getItem(); - isOK= !pair.fHasError; - - ITypedElement edition= pair.getEdition(); - String editionLabel= getEditionLabel(edition, fSelectedItem); - Image editionImage= getEditionImage(edition, fSelectedItem); - - if (fAddMode) { - if (fMemberSelection != null) - fMemberSelection.put(fCurrentEditions, fSelectedItem); - setInput(fSelectedItem); - fContentPane.setText(editionLabel); - fContentPane.setImage(editionImage); - } else { - getCompareConfiguration(); - if (fTargetIsRight) { - fCompareConfiguration.setLeftLabel(editionLabel); - fCompareConfiguration.setLeftImage(editionImage); - setInput(new DiffNode(fSelectedItem, fTargetPair.getItem())); - } else { - fCompareConfiguration.setRightLabel(editionLabel); - fCompareConfiguration.setRightImage(editionImage); - setInput(new DiffNode(fTargetPair.getItem(), fSelectedItem)); - } - } - } else { - fSelectedItem= null; - setInput(null); - } - if (fCommitButton != null) { - if (fMultiSelect) - fCommitButton.setEnabled(isOK && fSelectedItem != null && fArrayList.size() > 0); - else - fCommitButton.setEnabled(isOK && fSelectedItem != null && fTargetPair.getItem() != fSelectedItem); - } - } - - /* - * Feeds selection from structure viewer to content viewer. - */ - private void feedInput2(ISelection sel) { - if (sel instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) sel; - if (ss.size() == 1) - fContentPane.setInput(ss.getFirstElement()); - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java deleted file mode 100644 index 3c9dff749..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.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.compare; - -import java.io.InputStream; -import java.io.BufferedInputStream; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.compare.internal.IResourceProvider; -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IFileState; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; - -/** - * A combination IFileState and ITypedElement that can be used as - * an input to a compare viewer or other places where an IStreamContentAccessor - * is needed. - *

- *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- */ -public class HistoryItem implements IEncodedStreamContentAccessor, ITypedElement, IModificationDate, IResourceProvider { - - private ITypedElement fBase; - private IFileState fFileState; - - /** - * Creates a HistoryItem object which combines the given IFileState - * and ITypedElement into an object - * which is suitable as input for a compare viewer or ReplaceWithEditionDialog. - * - * @param base the implementation of the ITypedElement interface delegates to this base ITypedElement - * @param fileState the IFileState from which the streamable contents and the modification time is derived from - */ - public HistoryItem(ITypedElement base, IFileState fileState) { - fBase= base; - fFileState= fileState; - } - - /* (non-Javadoc) - * see ITypedElement.getName - */ - public String getName() { - return fBase.getName(); - } - - /* (non-Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - return fBase.getImage(); - } - - /* (non-Javadoc) - * see ITypedElement.getType - */ - public String getType() { - return fBase.getType(); - } - - /* (non-Javadoc) - * see IModificationDate.getModificationDate - */ - public long getModificationDate() { - return fFileState.getModificationTime(); - } - - /* (non-Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - return new BufferedInputStream(fFileState.getContents()); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() throws CoreException { - String charset= fFileState.getCharset(); - if (charset == null) { - IResource resource= getResource(); - if (resource instanceof IEncodedStorage) - charset= ((IEncodedStorage)resource).getCharset(); - } - return charset; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.IResourceProvider#getResource() - */ - public IResource getResource() { - IPath fullPath= fFileState.getFullPath(); - return ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java deleted file mode 100644 index d0d3e06a1..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * A ICompareNavigator is used to navigate through the individual - * differences of a CompareEditorInput. - *

- * Please note: the following might change before the final release of Eclipse 3.0. - * You can retrieve an object implementing the ICompareNavigator from a - * CompareEditorInput by calling getAdapter(ICompareNavigator) - * on the CompareEditorInput. - *

- * @since 3.0 - */ -public interface ICompareNavigator { - - /** - * Starting from the current selection selectChange selects and reveals the next (previous) change. - * If the end (or beginning) is reached, the method returns true. - * - * @param next if true the next change is selected, otherwise the previous change - * @return returns true if end (beginning) is reached, false otherwise - */ - public boolean selectChange(boolean next); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java deleted file mode 100644 index 16aa27c0b..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.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.compare; - -/** - * An IContentChangeListener is informed about content changes of a - * IContentChangeNotifier. - *

- * Clients may implement this interface. - *

- * - * @see IContentChangeNotifier - */ -public interface IContentChangeListener { - - /** - * Called whenever the content of the given source has changed. - * - * @param source the source whose contents has changed - */ - void contentChanged(IContentChangeNotifier source); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java deleted file mode 100644 index 55641c97d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * Interface common to all objects that provide a means for registering - * for content change notification. - *

- * Clients may implement this interface. - *

- * - * @see IContentChangeListener - */ -public interface IContentChangeNotifier { - - /** - * Adds a content change listener to this notifier. - * Has no effect if an identical listener is already registered. - * - * @param listener a content changed listener - */ - void addContentChangeListener(IContentChangeListener listener); - - /** - * Removes the given content changed listener from this notifier. - * Has no effect if the listener is not registered. - * - * @param listener a content changed listener - */ - void removeContentChangeListener(IContentChangeListener listener); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java deleted file mode 100644 index 4d031e69c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.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.compare; - -/** - * Common interface for objects with editable contents. - * Typically it is implemented by objects that also implement - * the IStreamContentAccessor interface. - *

- * Clients may implement this interface. - *

- * Note that implementing IEditableContent does not - * automatically mean that it is editable. An object is only editable if - * it implements IEditableContent and the isEditable method returns true. - * - * @see IStreamContentAccessor - */ -public interface IEditableContent { - - /** - * Returns true if this object can be modified. - * If it returns false the other methods of this API must not be called. - * - * @return true if this object can be modified - */ - boolean isEditable(); - - /** - * Replaces the current content with the given new bytes. - * - * @param newContent this new contents replaces the old contents - */ - void setContent(byte[] newContent); - - /** - * This method is called on a parent to add or remove a child, - * or to copy the contents of a child. - * - * What to do is encoded in the two arguments as follows: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
add:dest == nullsrc != null
remove:dest != nullsrc == null
copy:dest != nullsrc != null
- * @param dest the existing child of this object to be replaced; if null a new child can be added. - * @param src the new child to be added or replaced; if null an existing child can be removed. - * @return the argument dest - */ - ITypedElement replace(ITypedElement dest, ITypedElement src); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java deleted file mode 100644 index 95aa6f5c9..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.core.runtime.CoreException; - -/** - * Extension for IStreamContentAccessor. Extends the original - * concept of a IStreamContentAccessor to answer the Charset (encoding) used for the stream. - * - * @since 3.0 - */ -public interface IEncodedStreamContentAccessor extends IStreamContentAccessor { - - /** - * Returns the name of a charset encoding to be used when decoding this - * stream accessor's contents into characters. Returns null if a proper - * encoding cannot be determined. - *

- * Note: this method does not check whether the result is a supported - * charset name. Callers should be prepared to handle - * UnsupportedEncodingException where this charset is used. - *

- * @return the name of a charset, or null - * @exception CoreException if an error happens while determining - * the charset. See any refinements for more information. - * @see IStreamContentAccessor#getContents - * @since 3.0 - */ - String getCharset() throws CoreException; -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java deleted file mode 100644 index 1ddeb2b78..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * Common interface for objects with a modification date. The modification date - * can be used in the UI to give the user a general idea of how old an object is. - *

- * Clients may implement this interface. - *

- */ -public interface IModificationDate { - - /** - * Returns the modification time of this object. - *

- * Note that this value should only be used to give the user a general idea of how - * old the object is. - * - * @return the time of last modification, in milliseconds since January 1, 1970, 00:00:00 GMT - */ - long getModificationDate(); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java deleted file mode 100644 index f4ed5212c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.jface.util.IPropertyChangeListener; - -/** - * Interface common to all objects that provide a means for registering - * for property change notification. - *

- * Clients may implement this interface. - *

- * - * @see org.eclipse.jface.util.IPropertyChangeListener - */ -public interface IPropertyChangeNotifier { - - /** - * Adds a listener for property changes to this notifier. - * Has no effect if an identical listener is already registered. - * - * @param listener a property change listener - */ - void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Removes the given content change listener from this notifier. - * Has no effect if the identical listener is not registered. - * - * @param listener a property change listener - */ - void removePropertyChangeListener(IPropertyChangeListener listener); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java deleted file mode 100644 index 453bc6a4e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.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.compare; - -import java.io.InputStream; - -import org.eclipse.core.runtime.CoreException; - -/** - * An IStreamContentAccessor object represents a set of bytes which can be - * accessed by means of a stream. - *

- * Clients may implement this interface, or use the standard implementation, - * BufferedContent. - * - * @see BufferedContent - */ -public interface IStreamContentAccessor { - /** - * Returns an open InputStream for this object which can be used to retrieve the object's content. - * The client is responsible for closing the stream when finished. - * Returns null if this object has no streamable contents. - * - * @return an input stream containing the contents of this object - * @exception CoreException if the contents of this object could not be accessed - */ - InputStream getContents() throws CoreException; -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java deleted file mode 100644 index bf4c6b072..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -/** - * This interface defines a single operation for performing a three-way merge on three - * input streams. The merged result is written to an output stream. - *

- * Clients must implement this interface when contributing new mergers to the - * org.eclipse.compare.streamMergers extension point. - *

- * - * @since 3.0 - */ -public interface IStreamMerger { - - /** - * Indicates the successful completion of the merge operation (value IStatus.OK) - */ - public static final int OK= IStatus.OK; - - /** - * Indicates that a change conflict prevented the merge from successful completion (value 1) - */ - public static final int CONFLICT= 1; - - /** - * Status code describing an internal error (value 2) - */ - public static final int INTERNAL_ERROR= 2; - - /** - * Performs a merge operation on the given input streams and writes the merge result to the output stream. - * On success a status IStatus.OK is returned, on error a status IStatus.ERROR. - * If the merge operation cannot deal with conflicts, the code of the error status has the value IStreamMerger.CONFLICT. - * For text oriented mergers the encoding for the input and output streams is honored. - * It is the responsibility of callers to close input and output streams. - * - * @param output the byte stream to which the merge result is written; the merger will not close the stream - * @param outputEncoding the encoding to use when writing to the output stream - * @param ancestor the byte stream from which the common ancestor is read - * @param ancestorEncoding the encoding of the ancestor input byte stream - * @param target the byte stream containing the target of the merge - * @param targetEncoding the encoding of the target input byte stream - * @param other the byte stream containing the target of the merge - * @param otherEncoding the encoding of the other input byte stream - * @param monitor reports progress of the merge operation - * @return returns the completion status of the operation - */ - IStatus merge(OutputStream output, String outputEncoding, - InputStream ancestor, String ancestorEncoding, - InputStream target, String targetEncoding, - InputStream other, String otherEncoding, - IProgressMonitor monitor); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java deleted file mode 100644 index 6717c8da2..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.graphics.Image; - -/** - * Interface for getting the name, image, and type for an object. - *

- * These methods are typically used to present an input object in the compare UI - * (getName and getImage) - * and for finding a viewer for a given input type (getType). - *

- * Clients may implement this interface. - */ -public interface ITypedElement { - - /** - * Type for a folder input (value "FOLDER"). - * Folders are comparison elements that have no contents, only a name and children. - */ - public static final String FOLDER_TYPE= "FOLDER"; //$NON-NLS-1$ - - /** - * Type for an element whose actual type is text (value "txt"). - */ - public static final String TEXT_TYPE= "txt"; //$NON-NLS-1$ - - /** - * Type for an element whose actual type could not - * be determined. (value "???"). - */ - public static final String UNKNOWN_TYPE= "???"; //$NON-NLS-1$ - - /** - * Returns the name of this object. - * The name is used when displaying this object in the UI. - * - * @return the name of this object - */ - String getName(); - - /** - * Returns an image for this object. - * This image is used when displaying this object in the UI. - * - * @return the image of this object or null if this type of input has no image - */ - Image getImage(); - - /** - * Returns the type of this object. For objects with a file name - * this is typically the file extension. For folders its the constant - * FOLDER_TYPE. - * The type is used for determining a suitable viewer for this object. - * - * @return the type of this object - */ - String getType(); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java deleted file mode 100644 index 91433c80c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; - -/** - * A factory object for Viewer. - *

- * This interface is only required when creating a Viewer from a plugin.xml file. - * Since Viewers have no default constructor they cannot be - * instantiated directly with Class.forName. - */ -public interface IViewerCreator { - - /** - * Creates a new viewer under the given SWT parent control. - * - * @param parent the SWT parent control under which to create the viewer's SWT control - * @param config a compare configuration the newly created viewer might want to use - * @return a new viewer - */ - Viewer createViewer(Composite parent, CompareConfiguration config); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java deleted file mode 100644 index 69d3df826..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.ResourceBundle; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.compare.internal.CompareMessages; -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.internal.Utilities; - - -/** - * A NavigationAction is used to navigate through the individual - * differences of a CompareEditorInput. - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * @since 2.0 - */ -public class NavigationAction extends Action { - - private boolean fNext; - private CompareEditorInput fCompareEditorInput; - - - /** - * Creates a NavigationAction. - * - * @param next if true action goes to the next difference; otherwise to the previous difference. - */ - public NavigationAction(boolean next) { - this(CompareUI.getResourceBundle(), next); - } - - /** - * Creates a NavigationAction that initializes its attributes - * from the given ResourceBundle. - * - * @param bundle is used to initialize the action - * @param next if true action goes to the next difference; otherwise to the previous difference. - */ - public NavigationAction(ResourceBundle bundle, boolean next) { - Utilities.initAction(this, bundle, next ? "action.Next." : "action.Previous."); //$NON-NLS-2$ //$NON-NLS-1$ - fNext= next; - } - - public void run() { - if (fCompareEditorInput != null) { - Object adapter= fCompareEditorInput.getAdapter(ICompareNavigator.class); - if (adapter instanceof ICompareNavigator) { - boolean atEnd= ((ICompareNavigator)adapter).selectChange(fNext); - Shell shell= CompareUIPlugin.getShell(); - if (atEnd && shell != null) { - - Display display= shell.getDisplay(); - if (display != null) - display.beep(); - - String title; - String message; - if (fNext) { - title= CompareMessages.getString("CompareNavigator.atEnd.title"); //$NON-NLS-1$ - message= CompareMessages.getString("CompareNavigator.atEnd.message"); //$NON-NLS-1$ - } else { - title= CompareMessages.getString("CompareNavigator.atBeginning.title"); //$NON-NLS-1$ - message= CompareMessages.getString("CompareNavigator.atBeginning.message"); //$NON-NLS-1$ - } - MessageDialog.openInformation(shell, title, message); - } - } - } - } - - /** - * Sets the CompareEditorInput on which this action operates. - * - * @param input the CompareEditorInput on which this action operates; if null action does nothing - */ - public void setCompareEditorInput(CompareEditorInput input) { - fCompareEditorInput= input; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java deleted file mode 100644 index 36380c4ae..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import java.util.ArrayList; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.compare.internal.IResourceProvider; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; - -/** - * A ResourceNode wrappers an IResources so that it can be used - * as input for the differencing engine (interfaces IStructureComparator and ITypedElement) - * and the ReplaceWithEditionDialog (interfaces ITypedElement and IModificationDate). - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * - * @see EditionSelectionDialog - */ -public class ResourceNode extends BufferedContent - implements IEncodedStreamContentAccessor, IStructureComparator, ITypedElement, - IEditableContent, IModificationDate, IResourceProvider { - - private IResource fResource; - private ArrayList fChildren; - - - /** - * Creates a ResourceNode for the given resource. - * - * @param resource the resource - */ - public ResourceNode(IResource resource) { - fResource= resource; - Assert.isNotNull(resource); - } - - /** - * Returns the corresponding resource for this object. - * - * @return the corresponding resource - */ - public IResource getResource() { - return fResource; - } - - /* (non Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - if (fResource instanceof IStorage) - return super.getContents(); - return null; - } - - /* (non Javadoc) - * see IModificationDate.getModificationDate - */ - public long getModificationDate() { - IPath path= fResource.getLocation(); - File file= path.toFile(); - return file.lastModified(); - } - - /* (non Javadoc) - * see ITypedElement.getName - */ - public String getName() { - if (fResource != null) - return fResource.getName(); - return null; - } - - /* (non Javadoc) - * see ITypedElement.getType - */ - public String getType() { - if (fResource instanceof IContainer) - return ITypedElement.FOLDER_TYPE; - if (fResource != null) { - String s= fResource.getFileExtension(); - if (s != null) - return s; - } - return ITypedElement.UNKNOWN_TYPE; - } - - /* (non Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - return CompareUI.getImage(fResource); - } - - /* - * Returns true if the other object is of type ITypedElement - * and their names are identical. The content is not considered. - */ - public boolean equals(Object other) { - if (other instanceof ITypedElement) { - String otherName= ((ITypedElement)other).getName(); - return getName().equals(otherName); - } - return super.equals(other); - } - - /** - * Returns the hash code of the name. - * @return a hash code value for this object. - */ - public int hashCode() { - return getName().hashCode(); - } - - /* (non Javadoc) - * see IStructureComparator.getChildren - */ - public Object[] getChildren() { - if (fChildren == null) { - fChildren= new ArrayList(); - if (fResource instanceof IContainer) { - try { - IResource members[]= ((IContainer)fResource).members(); - for (int i= 0; i < members.length; i++) { - IStructureComparator child= createChild(members[i]); - if (child != null) - fChildren.add(child); - } - } catch (CoreException ex) { - // NeedWork - } - } - } - return fChildren.toArray(); - } - - /** - * This hook method is called from getChildren once for every - * member of a container resource. This implementation - * creates a new ResourceNode for the given child resource. - * Clients may override this method to create a different type of - * IStructureComparator or to filter children by returning null. - * - * @param child the child resource for which a IStructureComparator must be returned - * @return a ResourceNode for the given child or null - */ - protected IStructureComparator createChild(IResource child) { - return new ResourceNode(child); - } - - /** - * Returns an open stream if the corresponding resource implements the - * IStorage interface. Otherwise the value null is returned. - * - * @return a buffered input stream containing the contents of this storage - * @exception CoreException if the contents of this storage could not be accessed - */ - protected InputStream createStream() throws CoreException { - if (fResource instanceof IStorage) { - InputStream is= null; - IStorage storage= (IStorage) fResource; - try { - is= storage.getContents(); - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { - fResource.refreshLocal(IResource.DEPTH_INFINITE, null); - is= storage.getContents(); - } else - throw e; - } - if (is != null) - return new BufferedInputStream(is); - } - return null; - } - - /* (non Javadoc) - * see IEditableContent.isEditable - */ - public boolean isEditable() { - return true; - } - - /* (non Javadoc) - * see IEditableContent.replace - */ - public ITypedElement replace(ITypedElement child, ITypedElement other) { - return child; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() { - return Utilities.getCharset(fResource); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java deleted file mode 100644 index 4fb46d6b1..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.SashForm; - -/** - * The Splitter adds support for nesting to a SashForm. - *

- * If Splitters are nested directly: - *

- * - * @since 2.1 - */ -public class Splitter extends SashForm { - - private static final String VISIBILITY= "org.eclipse.compare.internal.visibility"; //$NON-NLS-1$ - - /** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - *

- * The style value is either one of the style constants defined in - * class SWT which is applicable to instances of this - * class, or must be built by bitwise OR'ing together - * (that is, using the int "|" operator) two or more - * of those SWT style constants. The class description - * lists the style constants that are applicable to the class. - * Style bits are also inherited from superclasses. - *

- * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException - * @exception org.eclipse.swt.SWTException - */ - public Splitter(Composite parent, int style) { - super(parent, style); - } - - /** - * Sets the visibility of the given child in this Splitter. If this change - * affects the visibility state of the whole Splitter, and if the Splitter - * is directly nested in one or more Splitters, this method recursively - * propagates the new state upward. - * - * @param child the child control for which the visibility is changed - * @param visible the new visibility state - */ - public void setVisible(Control child, boolean visible) { - - boolean wasEmpty= isEmpty(); - - child.setVisible(visible); - child.setData(VISIBILITY, new Boolean(visible)); - - if (wasEmpty != isEmpty()) { - // recursively walk up - Composite parent= getParent(); - if (parent instanceof Splitter) { - Splitter sp= (Splitter) parent; - sp.setVisible(this, visible); - sp.layout(); - } - } else { - layout(); - } - } - - /* (non-Javadoc) - * Recursively calls setMaximizedControl for all direct parents that are - * itself Splitters. - */ - public void setMaximizedControl(Control control) { - if (control == null || control == getMaximizedControl()) - super.setMaximizedControl(null); - else - super.setMaximizedControl(control); - - // recursively walk upward - Composite parent= getParent(); - if (parent instanceof Splitter) - ((Splitter) parent).setMaximizedControl(this); - else - layout(true); - } - - /* (non-Javadoc) - * Returns true if Splitter has no children or if all children are invisible. - */ - private boolean isEmpty() { - Control[] controls= getChildren(); - for (int i= 0; i < controls.length; i++) - if (isVisible(controls[i])) - return false; - return true; - } - - /* (non-Javadoc) - * Returns the visibility state of the given child control. If the - * control is a Sash, this method always returns false. - */ - private boolean isVisible(Control child) { - if (child instanceof Sash) - return false; - Object data= child.getData(VISIBILITY); - if (data instanceof Boolean) - return ((Boolean)data).booleanValue(); - return true; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java deleted file mode 100644 index 15a1851dc..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import java.util.*; -import java.util.zip.*; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * This implementation of the IStructureCreator interface - * makes the contents of a zip archive available as a - * hierarchical structure of IStructureComparators. - *

- * It is used when comparing the internal structure of a zip archive. - * - * @since 2.0 - */ -public class ZipFileStructureCreator implements IStructureCreator { - - /** - * Common base class for ZipFolder and ZipFile - */ - static abstract class ZipResource implements IStructureComparator, ITypedElement { - - private String fName; - - ZipResource(String name) { - fName= name; - } - - public String getName() { - return fName; - } - - public Image getImage() { - return CompareUI.getImage(getType()); - } - - /* - * Returns true if other is ITypedElement and names are equal. - * @see IComparator#equals - */ - public boolean equals(Object other) { - if (other instanceof ITypedElement) - return fName.equals(((ITypedElement) other).getName()); - return super.equals(other); - } - - public int hashCode() { - return fName.hashCode(); - } - } - - static class ZipFolder extends ZipResource { - - private HashMap fChildren= new HashMap(10); - - ZipFolder(String name) { - super(name); - } - - public String getType() { - return ITypedElement.FOLDER_TYPE; - } - - public Object[] getChildren() { - Object[] children= new Object[fChildren.size()]; - Iterator iter= fChildren.values().iterator(); - for (int i= 0; iter.hasNext(); i++) - children[i]= iter.next(); - return children; - } - - ZipFile createContainer(String path) { - String entry= path; - int pos= path.indexOf('/'); - if (pos < 0) - pos= path.indexOf('\\'); - if (pos >= 0) { - entry= path.substring(0, pos); - path= path.substring(pos + 1); - } else if (entry.length() > 0) { - if (CompareUIPlugin.getDefault().filter(path, false, true)) - return null; - ZipFile ze= new ZipFile(entry); - fChildren.put(entry, ze); - return ze; - } else - return null; - - ZipFolder folder= null; - if (fChildren != null) { - Object o= fChildren.get(entry); - if (o instanceof ZipFolder) - folder= (ZipFolder) o; - } - - if (folder == null) { - if (path.length() > 0 && CompareUIPlugin.getDefault().filter(path, true, true)) - return null; - folder= new ZipFolder(entry); - fChildren.put(entry, folder); - } - - return folder.createContainer(path); - } - } - - static class ZipFile extends ZipResource implements IStreamContentAccessor { - - private byte[] fContents; - - ZipFile(String name) { - super(name); - } - - public String getType() { - String s= this.getName(); - int pos= s.lastIndexOf('.'); - if (pos >= 0) - return s.substring(pos + 1); - return ITypedElement.UNKNOWN_TYPE; - } - - public Object[] getChildren() { - return null; - } - - public InputStream getContents() { - if (fContents == null) - fContents= new byte[0]; - return new ByteArrayInputStream(fContents); - } - - byte[] getBytes() { - return fContents; - } - - void setBytes(byte[] buffer) { - fContents= buffer; - } - - void appendBytes(byte[] buffer, int length) { - if (length > 0) { - int oldLen= 0; - if (fContents != null) - oldLen= fContents.length; - byte[] newBuf= new byte[oldLen + length]; - if (oldLen > 0) - System.arraycopy(fContents, 0, newBuf, 0, oldLen); - System.arraycopy(buffer, 0, newBuf, oldLen, length); - fContents= newBuf; - } - } - } - - private String fTitle; - - /** - * Create a new ZipFileStructureCreator. - */ - public ZipFileStructureCreator() { - this(Utilities.getString("ZipStructureCreator.name")); //$NON-NLS-1$ - } - - /** - * Create a new ZipFileStructureCreator with the given title. - * The title is returned by the method getName(). - * @param title the title of this strcuture creator - */ - public ZipFileStructureCreator(String title) { - fTitle= title; - } - - public String getName() { - return fTitle; - } - - public IStructureComparator getStructure(Object input) { - - InputStream is= null; - - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - try { - is= sca.getContents(); - } catch (CoreException ex) { - // NeedWork - } - } - - if (is == null) - return null; - - ZipInputStream zip= new ZipInputStream(is); - ZipFolder root= new ZipFolder(""); //$NON-NLS-1$ - try { - for (;;) { - ZipEntry entry= zip.getNextEntry(); - if (entry == null) - break; - - ZipFile ze= root.createContainer(entry.getName()); - if (ze != null) { - int length= (int) entry.getSize(); - if (length >= 0) { - byte[] buffer= new byte[length]; - int offset= 0; - - do { - int n= zip.read(buffer, offset, length); - offset += n; - length -= n; - } while (length > 0); - - ze.setBytes(buffer); - } else { - byte[] buffer= new byte[1024]; - int n; - do { - n= zip.read(buffer, 0, 1024); - ze.appendBytes(buffer, n); - } while (n >= 0); - } - } - zip.closeEntry(); - } - } catch (IOException ex) { - return null; - } finally { - try { - zip.close(); - } catch (IOException ex) { - // silently ignored - } - } - - if (root.fChildren.size() == 1) { - Iterator iter= root.fChildren.values().iterator(); - return (IStructureComparator) iter.next(); - } - return root; - } - - public String getContents(Object o, boolean ignoreWhitespace) { - if (o instanceof ZipFile) { - byte[] bytes= ((ZipFile)o).getBytes(); - if (bytes != null) - return new String(bytes); - return ""; //$NON-NLS-1$ - } - return null; - } - - /** - * Returns false since we cannot update a zip archive. - * @return false - */ - public boolean canSave() { - return false; - } - - /** - * Called whenever a copy operation has been performed on a tree node. - * This implementation throws an AssertionFailedException - * since we cannot update a zip archive. - * - * @param structure the node for which to save the new content - * @param input the object from which the structure tree was created in getStructure - */ - public void save(IStructureComparator structure, Object input) { - Assert.isTrue(false); // Cannot update zip archive - } - - public IStructureComparator locate(Object path, Object source) { - return null; - } - - /** - * Returns false since this IStructureCreator - * cannot rewrite the diff tree in order to fold certain combinations of - * additons and deletions. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @return false - */ - public boolean canRewriteTree() { - return false; - } - - /** - * Empty implementation since this IStructureCreator - * cannot rewrite the diff tree in order to fold certain combinations of - * additons and deletions. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param differencer - * @param root - */ - public void rewriteTree(Differencer differencer, IDiffContainer root) { - // empty default implementation - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java deleted file mode 100644 index b5a54ba89..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java +++ /dev/null @@ -1,1043 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.compare.contentmergeviewer; - -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.IWorkbenchPartSite; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.viewers.ContentViewer; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.compare.internal.*; - -/** - * An abstract compare and merge viewer with two side-by-side content areas - * and an optional content area for the ancestor. The implementation makes no - * assumptions about the content type. - *

- * ContentMergeViewer - *

- * A ContentMergeViewer accesses its - * model by means of a content provider which must implement the - * IMergeViewerContentProvider interface. - *

- *

- * Clients may wish to use the standard concrete subclass TextMergeViewer, - * or define their own subclass. - * - * @see IMergeViewerContentProvider - * @see TextMergeViewer - */ -public abstract class ContentMergeViewer extends ContentViewer - implements IPropertyChangeNotifier, ISavable { - - class SaveAction extends MergeViewerAction { - - SaveAction(boolean left) { - super(true, false, false); - Utilities.initAction(this, getResourceBundle(), "action.save."); //$NON-NLS-1$ - } - - public void run() { - saveContent(getInput()); - } - } - - /** - * Property names. - */ - private static final String ANCESTOR_ENABLED= ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE; - - /* package */ static final int HORIZONTAL= 1; - /* package */ static final int VERTICAL= 2; - - static final double HSPLIT= 0.5; - static final double VSPLIT= 0.3; - - private class ContentMergeViewerLayout extends Layout { - - public Point computeSize(Composite c, int w, int h, boolean force) { - return new Point(100, 100); - } - - public void layout(Composite composite, boolean force) { - - // determine some derived sizes - int headerHeight= fLeftLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y; - Rectangle r= composite.getClientArea(); - - int centerWidth= getCenterWidth(); - int width1= (int)((r.width-centerWidth)*fHSplit); - int width2= r.width-width1-centerWidth; - - int height1= 0; - int height2= 0; - if (fAncestorEnabled && fShowAncestor) { - height1= (int)((r.height-(2*headerHeight))*fVSplit); - height2= r.height-(2*headerHeight)-height1; - } else { - height1= 0; - height2= r.height-headerHeight; - } - - int y= 0; - - if (fAncestorEnabled && fShowAncestor) { - fAncestorLabel.setBounds(0, y, r.width, headerHeight); - fAncestorLabel.setVisible(true); - y+= headerHeight; - handleResizeAncestor(0, y, r.width, height1); - y+= height1; - } else { - fAncestorLabel.setVisible(false); - handleResizeAncestor(0, 0, 0, 0); - } - - fLeftLabel.getSize(); // without this resizing would not always work - - if (centerWidth > 3) { - fLeftLabel.setBounds(0, y, width1+1, headerHeight); - fDirectionLabel.setVisible(true); - fDirectionLabel.setBounds(width1+1, y, centerWidth-1, headerHeight); - fRightLabel.setBounds(width1+centerWidth, y, width2, headerHeight); - } else { - fLeftLabel.setBounds(0, y, width1, headerHeight); - fDirectionLabel.setVisible(false); - fRightLabel.setBounds(width1, y, r.width-width1, headerHeight); - } - - y+= headerHeight; - - if (fCenter != null && !fCenter.isDisposed()) - fCenter.setBounds(width1, y, centerWidth, height2); - - handleResizeLeftRight(0, y, width1, centerWidth, width2, height2); - } - } - - class Resizer extends MouseAdapter implements MouseMoveListener { - - Control fControl; - int fX, fY; - int fWidth1, fWidth2; - int fHeight1, fHeight2; - int fDirection; - boolean fLiveResize; - boolean fIsDown; - - public Resizer(Control c, int dir) { - fDirection= dir; - fControl= c; - fLiveResize= !(fControl instanceof Sash); - updateCursor(c, dir); - fControl.addMouseListener(this); - fControl.addMouseMoveListener(this); - fControl.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fControl= null; - } - } - ); - } - - public void mouseDoubleClick(MouseEvent e) { - if ((fDirection & HORIZONTAL) != 0) - fHSplit= HSPLIT; - if ((fDirection & VERTICAL) != 0) - fVSplit= VSPLIT; - fComposite.layout(true); - } - - public void mouseDown(MouseEvent e) { - Composite parent= fControl.getParent(); - - Point s= parent.getSize(); - Point as= fAncestorLabel.getSize(); - Point ys= fLeftLabel.getSize(); - Point ms= fRightLabel.getSize(); - - fWidth1= ys.x; - fWidth2= ms.x; - fHeight1= fLeftLabel.getLocation().y-as.y; - fHeight2= s.y-(fLeftLabel.getLocation().y+ys.y); - - fX= e.x; - fY= e.y; - fIsDown= true; - } - - public void mouseUp(MouseEvent e) { - fIsDown= false; - if (!fLiveResize) - resize(e); - } - - public void mouseMove(MouseEvent e) { - if (fIsDown && fLiveResize) - resize(e); - } - - private void resize(MouseEvent e) { - int dx= e.x-fX; - int dy= e.y-fY; - - int centerWidth= fCenter.getSize().x; - - if (fWidth1 + dx > centerWidth && fWidth2 - dx > centerWidth) { - fWidth1+= dx; - fWidth2-= dx; - if ((fDirection & HORIZONTAL) != 0) - fHSplit= (double)fWidth1/(double)(fWidth1+fWidth2); - } - if (fHeight1 + dy > centerWidth && fHeight2 - dy > centerWidth) { - fHeight1+= dy; - fHeight2-= dy; - if ((fDirection & VERTICAL) != 0) - fVSplit= (double)fHeight1/(double)(fHeight1+fHeight2); - } - - fComposite.layout(true); - fControl.getDisplay().update(); - } - } - - /** Style bits for top level composite */ - private int fStyles; - private ResourceBundle fBundle; - private CompareConfiguration fCompareConfiguration; - private IPropertyChangeListener fPropertyChangeListener; - private ICompareInputChangeListener fCompareInputChangeListener; - private ListenerList fListenerList; - boolean fConfirmSave= true; - - private double fHSplit= HSPLIT; // width ratio of left and right panes - private double fVSplit= VSPLIT; // height ratio of ancestor and bottom panes - - private boolean fAncestorEnabled= true; // show ancestor in case of conflicts - /* package */ boolean fShowAncestor= false; // if current input has conflicts - private boolean fIsThreeWay= false; - private ActionContributionItem fAncestorItem; - - private Action fCopyLeftToRightAction; // copy from left to right - private Action fCopyRightToLeftAction; // copy from right to left - - MergeViewerAction fLeftSaveAction; - MergeViewerAction fRightSaveAction; - - private IKeyBindingService fKeyBindingService; - - // SWT widgets - /* package */ Composite fComposite; - private CLabel fAncestorLabel; - private CLabel fLeftLabel; - private CLabel fRightLabel; - /* package */ CLabel fDirectionLabel; - /* package */ Control fCenter; - - //---- SWT resources to be disposed - private Image fRightArrow; - private Image fLeftArrow; - private Image fBothArrow; - Cursor fNormalCursor; - private Cursor fHSashCursor; - private Cursor fVSashCursor; - private Cursor fHVSashCursor; - - //---- end - - /** - * Creates a new content merge viewer and initializes with a resource bundle and a - * configuration. - * - * @param style SWT style bits - * @param bundle the resource bundle - * @param cc the configuration object - */ - protected ContentMergeViewer(int style, ResourceBundle bundle, CompareConfiguration cc) { - fStyles= style; - fBundle= bundle; - - fAncestorEnabled= Utilities.getBoolean(cc, ANCESTOR_ENABLED, fAncestorEnabled); - fConfirmSave= Utilities.getBoolean(cc, CompareEditor.CONFIRM_SAVE_PROPERTY, fConfirmSave); - - setContentProvider(new MergeViewerContentProvider(cc)); - - fCompareInputChangeListener= new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput input) { - ContentMergeViewer.this.internalRefresh(input); - } - }; - - fCompareConfiguration= cc; - if (fCompareConfiguration != null) { - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - ContentMergeViewer.this.propertyChange(event); - } - }; - fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); - } - - fLeftSaveAction= new SaveAction(true); - fLeftSaveAction.setEnabled(false); - fRightSaveAction= new SaveAction(false); - fRightSaveAction.setEnabled(false); - } - - //---- hooks --------------------- - - /** - * Returns the viewer's name. - * - * @return the viewer's name - */ - public String getTitle() { - return Utilities.getString(getResourceBundle(), "title"); //$NON-NLS-1$ - } - - /** - * Creates the SWT controls for the ancestor, left, and right - * content areas of this compare viewer. - * Implementations typically hold onto the controls - * so that they can be initialized with the input objects in method - * updateContent. - * - * @param composite the container for the three areas - */ - abstract protected void createControls(Composite composite); - - /** - * Lays out the ancestor area of the compare viewer. - * It is called whenever the viewer is resized or when the sashes between - * the areas are moved to adjust the size of the areas. - * - * @param x the horizontal position of the ancestor area within its container - * @param y the vertical position of the ancestor area within its container - * @param width the width of the ancestor area - * @param height the height of the ancestor area - */ - abstract protected void handleResizeAncestor(int x, int y, int width, int height); - - /** - * Lays out the left and right areas of the compare viewer. - * It is called whenever the viewer is resized or when the sashes between - * the areas are moved to adjust the size of the areas. - * - * @param x the horizontal position of the left area within its container - * @param y the vertical position of the left and right area within its container - * @param leftWidth the width of the left area - * @param centerWidth the width of the gap between the left and right areas - * @param rightWidth the width of the right area - * @param height the height of the left and right areas - */ - abstract protected void handleResizeLeftRight(int x, int y, int leftWidth, int centerWidth, - int rightWidth, int height); - - /** - * Contributes items to the given ToolBarManager. - * It is called when this viewer is installed in its container and if the container - * has a ToolBarManager. - * The ContentMergeViewer implementation of this method does nothing. - * Subclasses may reimplement. - * - * @param toolBarManager the toolbar manager to contribute to - */ - protected void createToolItems(ToolBarManager toolBarManager) { - // empty implementation - } - - /** - * Initializes the controls of the three content areas with the given input objects. - * - * @param ancestor the input for the ancestor area - * @param left the input for the left area - * @param right the input for the right area - */ - abstract protected void updateContent(Object ancestor, Object left, Object right); - - /** - * Copies the content of one side to the other side. - * Called from the (internal) actions for copying the sides of the viewer's input object. - * - * @param leftToRight if true, the left side is copied to the right side; - * if false, the right side is copied to the left side - */ - abstract protected void copy(boolean leftToRight); - - /** - * Returns the byte contents of the left or right side. If the viewer - * has no editable content null can be returned. - * - * @param left if true, the byte contents of the left area is returned; - * if false, the byte contents of the right area - * @return the content as an array of bytes, or null - */ - abstract protected byte[] getContents(boolean left); - - //---------------------------- - - /** - * Returns the resource bundle of this viewer. - * - * @return the resource bundle - */ - protected ResourceBundle getResourceBundle() { - return fBundle; - } - - /** - * Returns the compare configuration of this viewer, - * or null if this viewer does not yet have a configuration. - * - * @return the compare configuration, or null if none - */ - protected CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * The ContentMergeViewer implementation of this - * ContentViewer method - * checks to ensure that the content provider is an IMergeViewerContentProvider. - * @param contentProvider the contentprovider to set. Must implement IMergeViewerContentProvider. - */ - public void setContentProvider(IContentProvider contentProvider) { - Assert.isTrue(contentProvider instanceof IMergeViewerContentProvider); - super.setContentProvider(contentProvider); - } - - /* package */ IMergeViewerContentProvider getMergeContentProvider() { - return (IMergeViewerContentProvider) getContentProvider(); - } - - /** - * The ContentMergeViewer implementation of this - * Viewer method returns the empty selection. Subclasses may override. - * @return empty selection. - */ - public ISelection getSelection() { - return new ISelection() { - public boolean isEmpty() { - return true; - } - }; - } - - /* - * The ContentMergeViewer implementation of this - * Viewer method does nothing. Subclasses may reimplement. - */ - public void setSelection(ISelection selection, boolean reveal) { - // empty implementation - } - - /* package */ void propertyChange(PropertyChangeEvent event) { - - String key= event.getProperty(); - - if (key.equals(ANCESTOR_ENABLED)) { - fAncestorEnabled= Utilities.getBoolean(getCompareConfiguration(), ANCESTOR_ENABLED, fAncestorEnabled); - fComposite.layout(true); - - updateCursor(fLeftLabel, VERTICAL); - updateCursor(fDirectionLabel, HORIZONTAL | VERTICAL); - updateCursor(fRightLabel, VERTICAL); - - return; - } - } - - void updateCursor(Control c, int dir) { - if (!(c instanceof Sash)) { - Cursor cursor= null; - switch (dir) { - case VERTICAL: - if (fAncestorEnabled) { - if (fVSashCursor == null) fVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZENS); - cursor= fVSashCursor; - } else { - if (fNormalCursor == null) fNormalCursor= new Cursor(c.getDisplay(), SWT.CURSOR_ARROW); - cursor= fNormalCursor; - } - break; - case HORIZONTAL: - if (fHSashCursor == null) fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE); - cursor= fHSashCursor; - break; - case VERTICAL + HORIZONTAL: - if (fAncestorEnabled) { - if (fHVSashCursor == null) fHVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEALL); - cursor= fHVSashCursor; - } else { - if (fHSashCursor == null) fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE); - cursor= fHSashCursor; - } - break; - } - if (cursor != null) - c.setCursor(cursor); - } - } - - void setAncestorVisibility(boolean visible, boolean enabled) { - if (fAncestorItem != null) { - Action action= (Action) fAncestorItem.getAction(); - if (action != null) { - action.setChecked(visible); - action.setEnabled(enabled); - } - } - if (fCompareConfiguration != null) - fCompareConfiguration.setProperty(ANCESTOR_ENABLED, new Boolean(visible)); - } - - //---- input - - /* package */ boolean isThreeWay() { - return fIsThreeWay; - } - - /** - * Internal hook method called when the input to this viewer is - * initially set or subsequently changed. - *

- * The ContentMergeViewer implementation of this Viewer - * method tries to save the old input by calling doSave(...) and - * then calls internalRefresh(...). - * - * @param input the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - */ - protected final void inputChanged(Object input, Object oldInput) { - - if (input != oldInput) - if (oldInput instanceof ICompareInput) - ((ICompareInput)oldInput).removeCompareInputChangeListener(fCompareInputChangeListener); - - boolean success= doSave(input, oldInput); - - if (input != oldInput) - if (input instanceof ICompareInput) - ((ICompareInput)input).addCompareInputChangeListener(fCompareInputChangeListener); - - if (success) { - setLeftDirty(false); - setRightDirty(false); - } - - if (input != oldInput) - internalRefresh(input); - } - - /** - * This method is called from the Viewer method inputChanged - * to save any unsaved changes of the old input. - *

- * The ContentMergeViewer implementation of this - * method calls saveContent(...). If confirmation has been turned on - * with setConfirmSave(true), a confirmation alert is posted before saving. - *

- * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * @param newInput the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - * @return true if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). - * @since 2.0 - */ - protected boolean doSave(Object newInput, Object oldInput) { - - // before setting the new input we have to save the old - if (fLeftSaveAction.isEnabled() || fRightSaveAction.isEnabled()) { - - // post alert - if (fConfirmSave) { - Shell shell= fComposite.getShell(); - - MessageDialog dialog= new MessageDialog(shell, - Utilities.getString(getResourceBundle(), "saveDialog.title"), //$NON-NLS-1$ - null, // accept the default window icon - Utilities.getString(getResourceBundle(), "saveDialog.message"), //$NON-NLS-1$ - MessageDialog.QUESTION, - new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.NO_LABEL, - }, - 0); // default button index - - switch (dialog.open()) { // open returns index of pressed button - case 0: - saveContent(oldInput); - break; - case 1: - setLeftDirty(false); - setRightDirty(false); - break; - case 2: - throw new ViewerSwitchingCancelled(); - } - } else - saveContent(oldInput); - return true; - } - return false; - } - - /** - * Controls whether doSave(Object, Object) asks for confirmation before saving - * the old input with saveContent(Object). - * @param enable a value of true enables confirmation - * @since 2.0 - */ - public void setConfirmSave(boolean enable) { - fConfirmSave= enable; - } - - /* (non Javadoc) - * see Viewer.refresh - */ - public void refresh() { - internalRefresh(getInput()); - } - - private void internalRefresh(Object input) { - - IMergeViewerContentProvider content= getMergeContentProvider(); - if (content != null) { - Object ancestor= content.getAncestorContent(input); - if (input instanceof ICompareInput) - fIsThreeWay= (((ICompareInput)input).getKind() & Differencer.DIRECTION_MASK) != 0; - else - fIsThreeWay= ancestor != null; - - if (fAncestorItem != null) - fAncestorItem.setVisible(fIsThreeWay); - - boolean oldFlag= fShowAncestor; - fShowAncestor= fIsThreeWay && content.showAncestor(input); - - if (fAncestorEnabled && oldFlag != fShowAncestor) - fComposite.layout(true); - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(fComposite.getParent()); - if (tbm != null) { - updateToolItems(); - tbm.update(true); - tbm.getControl().getParent().layout(true); - } - - updateHeader(); - - Object left= content.getLeftContent(input); - Object right= content.getRightContent(input); - updateContent(ancestor, left, right); - } - } - - //---- layout & SWT control creation - - /** - * Builds the SWT controls for the three areas of a compare/merge viewer. - *

- * Calls the hooks createControls and createToolItems - * to let subclasses build the specific content areas and to add items to - * an enclosing toolbar. - *

- * This method must only be called in the constructor of subclasses. - * - * @param parent the parent control - * @return the new control - */ - protected final Control buildControl(Composite parent) { - - fComposite= new Composite(parent, fStyles) { - public boolean setFocus() { - return internalSetFocus(); - } - }; - fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - - hookControl(fComposite); // hook help & dispose listener - - fComposite.setLayout(new ContentMergeViewerLayout()); - - int style= SWT.SHADOW_OUT; - fAncestorLabel= new CLabel(fComposite, style); - - fLeftLabel= new CLabel(fComposite, style); - new Resizer(fLeftLabel, VERTICAL); - - fDirectionLabel= new CLabel(fComposite, style); - fDirectionLabel.setAlignment(SWT.CENTER); - new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL); - - fRightLabel= new CLabel(fComposite, style); - new Resizer(fRightLabel, VERTICAL); - - if (fCenter == null || fCenter.isDisposed()) - fCenter= createCenter(fComposite); - - createControls(fComposite); - - IWorkbenchPartSite ps= Utilities.findSite(fComposite); - fKeyBindingService= ps != null ? ps.getKeyBindingService() : null; - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - - // define groups - tbm.add(new Separator("modes")); //$NON-NLS-1$ - tbm.add(new Separator("merge")); //$NON-NLS-1$ - tbm.add(new Separator("navigation")); //$NON-NLS-1$ - - CompareConfiguration cc= getCompareConfiguration(); - - if (cc.isRightEditable()) { - fCopyLeftToRightAction= - new Action() { - public void run() { - copy(true); - } - }; - Utilities.initAction(fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); //$NON-NLS-1$ - tbm.appendToGroup("merge", fCopyLeftToRightAction); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); //$NON-NLS-1$ - } - - if (cc.isLeftEditable()) { - fCopyRightToLeftAction= - new Action() { - public void run() { - copy(false); - } - }; - Utilities.initAction(fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); //$NON-NLS-1$ - tbm.appendToGroup("merge", fCopyRightToLeftAction); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$ - } - - Action a= new ChangePropertyAction(fBundle, fCompareConfiguration, "action.EnableAncestor.", ANCESTOR_ENABLED); //$NON-NLS-1$ - a.setChecked(fAncestorEnabled); - fAncestorItem= new ActionContributionItem(a); - fAncestorItem.setVisible(false); - tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$ - - createToolItems(tbm); - updateToolItems(); - - tbm.update(true); - } - - return fComposite; - } - - /* package */ boolean internalSetFocus() { - return false; - } - - /* package */ int getCenterWidth() { - return 3; - } - - /* package */ boolean getAncestorEnabled() { - return fAncestorEnabled; - } - - /* package */ Control createCenter(Composite parent) { - Sash sash= new Sash(parent, SWT.VERTICAL); - new Resizer(sash, HORIZONTAL); - return sash; - } - - /* package */ Control getCenter() { - return fCenter; - } - - /* - * @see Viewer.getControl() - */ - public Control getControl() { - return fComposite; - } - - /* - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - */ - protected void handleDispose(DisposeEvent event) { - - if (fKeyBindingService != null) { - if (fCopyLeftToRightAction != null) - fKeyBindingService.unregisterAction(fCopyLeftToRightAction); - if (fCopyRightToLeftAction != null) - fKeyBindingService.unregisterAction(fCopyRightToLeftAction); - fKeyBindingService= null; - } - - Object input= getInput(); - if (input instanceof ICompareInput) - ((ICompareInput)input).removeCompareInputChangeListener(fCompareInputChangeListener); - - if (fCompareConfiguration != null && fPropertyChangeListener != null) { - fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener); - fPropertyChangeListener= null; - } - - fAncestorLabel= null; - fLeftLabel= null; - fDirectionLabel= null; - fRightLabel= null; - fCenter= null; - - if (fRightArrow != null) { - fRightArrow.dispose(); - fRightArrow= null; - } - if (fLeftArrow != null) { - fLeftArrow.dispose(); - fLeftArrow= null; - } - if (fBothArrow != null) { - fBothArrow.dispose(); - fBothArrow= null; - } - - if (fNormalCursor != null) { - fNormalCursor.dispose(); - fNormalCursor= null; - } - if (fHSashCursor != null) { - fHSashCursor.dispose(); - fHSashCursor= null; - } - if (fVSashCursor != null) { - fVSashCursor.dispose(); - fVSashCursor= null; - } - if (fHVSashCursor != null) { - fHVSashCursor.dispose(); - fHVSashCursor= null; - } - - super.handleDispose(event); - } - - /** - * Updates the enabled state of the toolbar items. - *

- * This method is called whenever the state of the items needs updating. - *

- * Subclasses may extend this method, although this is generally not required. - */ - protected void updateToolItems() { - - IMergeViewerContentProvider content= getMergeContentProvider(); - - Object input= getInput(); - - if (fCopyLeftToRightAction != null) { - boolean enable= content.isRightEditable(input); -// if (enable && input instanceof ICompareInput) { -// ITypedElement e= ((ICompareInput) input).getLeft(); -// if (e == null) -// enable= false; -// } - fCopyLeftToRightAction.setEnabled(enable); - } - - if (fCopyRightToLeftAction != null) { - boolean enable= content.isLeftEditable(input); -// if (enable && input instanceof ICompareInput) { -// ITypedElement e= ((ICompareInput) input).getRight(); -// if (e == null) -// enable= false; -// } - fCopyRightToLeftAction.setEnabled(enable); - } - } - - /** - * Updates the headers of the three areas - * by querying the content provider for a name and image for - * the three sides of the input object. - *

- * This method is called whenever the header must be updated. - *

- * Subclasses may extend this method, although this is generally not required. - */ - protected void updateHeader() { - - IMergeViewerContentProvider content= getMergeContentProvider(); - Object input= getInput(); - - if (fAncestorLabel != null) { - fAncestorLabel.setImage(content.getAncestorImage(input)); - fAncestorLabel.setText(content.getAncestorLabel(input)); - } - if (fLeftLabel != null) { - fLeftLabel.setImage(content.getLeftImage(input)); - fLeftLabel.setText(content.getLeftLabel(input)); - } - if (fRightLabel != null) { - fRightLabel.setImage(content.getRightImage(input)); - fRightLabel.setText(content.getRightLabel(input)); - } - } - -// private Image loadImage(String name) { -// ImageDescriptor id= ImageDescriptor.createFromFile(ContentMergeViewer.class, name); -// if (id != null) -// return id.createImage(); -// return null; -// } - - /* - * Calculates the height of the header. - */ - /* package */ int getHeaderHeight() { - int headerHeight= fLeftLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y; - headerHeight= Math.max(headerHeight, fDirectionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y); - return headerHeight; - } - - //---- merge direction - - /* - * Returns true if both sides are editable. - */ - /* package */ boolean canToggleMergeDirection() { - IMergeViewerContentProvider content= getMergeContentProvider(); - Object input= getInput(); - return content.isLeftEditable(input) && content.isRightEditable(input); - } - - //---- dirty state & saving state - - /* (non Javadoc) - * see IPropertyChangeNotifier.addPropertyChangeListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListenerList == null) - fListenerList= new ListenerList(); - fListenerList.add(listener); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.removePropertyChangeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - if (fListenerList != null) { - fListenerList.remove(listener); - if (fListenerList.isEmpty()) - fListenerList= null; - } - } - - /* package */ void fireDirtyState(boolean state) { - Utilities.firePropertyChange(fListenerList, this, CompareEditorInput.DIRTY_STATE, null, new Boolean(state)); - } - - /** - * Sets the dirty state of the left side of this viewer. - * If the new value differs from the old - * all registered listener are notified with - * a PropertyChangeEvent with the - * property name CompareEditorInput.DIRTY_STATE. - * - * @param dirty the state of the left side dirty flag - */ - protected void setLeftDirty(boolean dirty) { - if (fLeftSaveAction.isEnabled() != dirty) { - fLeftSaveAction.setEnabled(dirty); - fireDirtyState(dirty); - } - } - - /** - * Sets the dirty state of the right side of this viewer. - * If the new value differs from the old - * all registered listener are notified with - * a PropertyChangeEvent with the - * property name CompareEditorInput.DIRTY_STATE. - * - * @param dirty the state of the right side dirty flag - */ - protected void setRightDirty(boolean dirty) { - if (fRightSaveAction.isEnabled() != dirty) { - fRightSaveAction.setEnabled(dirty); - fireDirtyState(dirty); - } - } - - /* - * Save the viewers's content. - * Note: this method is for internal use only. Clients should not call this method. - * @since 2.0 - */ - public void save(IProgressMonitor pm) throws CoreException { - saveContent(getInput()); - } - - /* - * Save modified content back to input elements via the content provider. - */ - /* package */ void saveContent(Object oldInput) { - - // write back modified contents - IMergeViewerContentProvider content= (IMergeViewerContentProvider) getContentProvider(); - - boolean leftEmpty= content.getLeftContent(oldInput) == null; - boolean rightEmpty= content.getRightContent(oldInput) == null; - - if (fCompareConfiguration.isLeftEditable() && fLeftSaveAction.isEnabled()) { - byte[] bytes= getContents(true); - if (leftEmpty && bytes != null && bytes.length == 0) - bytes= null; - setLeftDirty(false); - content.saveLeftContent(oldInput, bytes); - } - - if (fCompareConfiguration.isRightEditable() && fRightSaveAction.isEnabled()) { - byte[] bytes= getContents(false); - if (rightEmpty && bytes != null && bytes.length == 0) - bytes= null; - setRightDirty(false); - content.saveRightContent(oldInput, bytes); - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java deleted file mode 100644 index fedb53161..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.IDocument; - - -/** - * Defines a subrange in a document. - *

- * It is used by text viewers that can work on a subrange of a document. For example, - * a text viewer for Java compilation units might use this to restrict the view - * to a single method. - *

- *

- * Clients may implement this interface. - *

- * - * @see TextMergeViewer - * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode - */ -public interface IDocumentRange { - - /** - * The position category typically used for an IDocumentRange position - * (value "DocumentRangeCategory"). - * @since 2.0 - */ - public static final String RANGE_CATEGORY= "DocumentRangeCategory"; //$NON-NLS-1$ - - /** - * Returns the underlying document. - * - * @return the underlying document - */ - IDocument getDocument(); - - /** - * Returns a position that specifies a subrange in the underlying document, - * or null if this document range spans the whole underlying document. - * - * @return a position that specifies a subrange in the underlying document, or null - */ - Position getRange(); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java deleted file mode 100644 index 31d78b570..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.jface.viewers.IContentProvider; - - -/** - * A content provider that mediates between a ContentMergeViewer's model - * and the viewer itself. - *

- * Clients may implement this interface. - *

- * - * @see ContentMergeViewer - */ -public interface IMergeViewerContentProvider extends IContentProvider { - - //---- ancestor side - - /** - * Returns the label for the ancestor side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the ancestor side of a ContentMergeViewer - */ - String getAncestorLabel(Object input); - - /** - * Returns an optional image for the ancestor side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the ancestor side of a ContentMergeViewer, - * or null if none - */ - Image getAncestorImage(Object input); - - /** - * Returns the contents for the ancestor side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the ancestor side of a ContentMergeViewer, - * or null if none - */ - Object getAncestorContent(Object input); - - /** - * Returns whether the ancestor side of the given input element should be shown. - * @param input the merge viewer's input - * @return true if the ancestor side of the given input element should be shown - */ - boolean showAncestor(Object input); - - //---- left side - - /** - * Returns the label for the left side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the left side of a ContentMergeViewer - */ - String getLeftLabel(Object input); - - /** - * Returns an optional image for the left side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the left side of a ContentMergeViewer, - * or null if none - */ - Image getLeftImage(Object input); - - /** - * Returns the contents for the left side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the left side of a ContentMergeViewer, - * or null if none - */ - Object getLeftContent(Object input); - - /** - * Returns whether the left side is editable. - * - * @param input the input object of the ContentMergeViewer - * @return true if the left side of a ContentMergeViewer is editable - */ - boolean isLeftEditable(Object input); - - /** - * Saves new contents for the left side of the ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @param bytes the new contents to save for the left side - */ - void saveLeftContent(Object input, byte[] bytes); - - //---- right side - - /** - * Returns the label for the right side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the right side of a ContentMergeViewer - */ - String getRightLabel(Object input); - - /** - * Returns an optional image for the right side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the right side of a ContentMergeViewer, - * or null if none - */ - Image getRightImage(Object input); - - /** - * Returns the contents for the right side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the right side of a ContentMergeViewer, - * or null if none - */ - Object getRightContent(Object input); - - /** - * Returns whether the right side is editable. - * - * @param input the input object of the ContentMergeViewer - * @return true if the right side of a ContentMergeViewer is editable - */ - boolean isRightEditable(Object input); - - /** - * Saves new contents for the right side of the ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @param bytes the new contents to save for the right side - */ - void saveRightContent(Object input, byte[] bytes); -} - - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java deleted file mode 100644 index 43f03f1f4..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/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.compare.contentmergeviewer; - -import org.eclipse.compare.rangedifferencer.IRangeComparator; - - -/** - * For performing a so-called "token compare" on a line of text. - * This interface extends the IRangeComparator interface - * so that it can be used by the TextMergeViewer. - *

- * TextMergeViewer 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. - *

- * TextMergeViewer'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 - * TextMergeViewer.createTokenComparator factory method). - *

- * - * @see TextMergeViewer - */ -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/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java deleted file mode 100644 index f145e12e1..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java +++ /dev/null @@ -1,4303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * channingwalton@mac.com - curved line code - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; -import java.util.ResourceBundle; -import java.text.MessageFormat; - -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.*; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.resource.ColorRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.*; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.progress.IProgressService; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.MergeSourceViewer; -import org.eclipse.compare.internal.BufferedCanvas; -import org.eclipse.compare.internal.MergeViewerContentProvider; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.internal.TokenComparator; -import org.eclipse.compare.internal.DocLineComparator; -import org.eclipse.compare.internal.ComparePreferencePage; -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.compare.internal.CompareNavigator; -import org.eclipse.compare.internal.DocumentManager; -import org.eclipse.compare.internal.CompareMessages; -import org.eclipse.compare.rangedifferencer.*; -import org.eclipse.compare.structuremergeviewer.*; - -/** - * A text merge viewer uses the RangeDifferencer to perform a - * textual, line-by-line comparison of two (or three) input documents. - * It is based on the ContentMergeViewer and uses TextViewers - * to implement the ancestor, left, and right content areas. - *

- * In the three-way compare case ranges of differing lines are highlighted and framed - * with different colors to show whether the difference is an incoming, outgoing, or conflicting change. - * The TextMergeViewer supports the notion of a current "differing range" - * and provides toolbar buttons to navigate from one range to the next (or previous). - *

- * If there is a current "differing range" and the underlying document is editable - * the TextMergeViewer enables actions in context menu and toolbar to - * copy a range from one side to the other side, thereby performing a merge operation. - *

- * In addition to a line-by-line comparison the TextMergeViewer - * uses a token based compare on differing lines. - * The token compare is activated 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. - *

- * The TextMergeViewer's default token compare works on characters separated - * by whitespace. If a different strategy is needed (for example, Java tokens in - * a Java-aware merge viewer), clients can create their own token - * comparators by implementing the ITokenComparator interface and overriding the - * TextMergeViewer.createTokenComparator factory method). - *

- * Access to the TextMergeViewer's model is by means of an - * IMergeViewerContentProvider. Its getXContent methods must return - * either an IDocument, an IDocumentRange, or an IStreamContentAccessor. - * In the IDocumentRange case the TextMergeViewer - * works on a subrange of a document. In the IStreamContentAccessor case - * a document is created internally and initialized from the stream. - *

- * A TextMergeViewer can be used as is. However clients may subclass - * to customize the behavior. For example a MergeTextViewer for Java would override - * the configureTextViewer method to configure the TextViewer for Java source code, - * the createTokenComparator method to create a Java specific tokenizer. - * - * @see org.eclipse.compare.rangedifferencer.RangeDifferencer - * @see org.eclipse.jface.text.TextViewer - * @see ITokenComparator - * @see IDocumentRange - * @see org.eclipse.compare.IStreamContentAccessor - */ -public class TextMergeViewer extends ContentMergeViewer { - - private static final boolean DEBUG= false; - - private static final boolean FIX_47640= true; - - private static final String[] GLOBAL_ACTIONS= { - ActionFactory.UNDO.getId(), - ActionFactory.REDO.getId(), - ActionFactory.CUT.getId(), - ActionFactory.COPY.getId(), - ActionFactory.PASTE.getId(), - ActionFactory.DELETE.getId(), - ActionFactory.SELECT_ALL.getId(), - ActionFactory.SAVE.getId() - }; - private static final String[] TEXT_ACTIONS= { - MergeSourceViewer.UNDO_ID, - MergeSourceViewer.REDO_ID, - MergeSourceViewer.CUT_ID, - MergeSourceViewer.COPY_ID, - MergeSourceViewer.PASTE_ID, - MergeSourceViewer.DELETE_ID, - MergeSourceViewer.SELECT_ALL_ID, - MergeSourceViewer.SAVE_ID - }; - - private static final String BUNDLE_NAME= "org.eclipse.compare.contentmergeviewer.TextMergeViewerResources"; //$NON-NLS-1$ - - // the following symbolic constants must match the IDs in Compare's plugin.xml - private static final String INCOMING_COLOR= "INCOMING_COLOR"; //$NON-NLS-1$ - private static final String OUTGOING_COLOR= "OUTGOING_COLOR"; //$NON-NLS-1$ - private static final String CONFLICTING_COLOR= "CONFLICTING_COLOR"; //$NON-NLS-1$ - private static final String RESOLVED_COLOR= "RESOLVED_COLOR"; //$NON-NLS-1$ - - // constants - /** Width of left and right vertical bar */ - private static final int MARGIN_WIDTH= 6; - /** Width of center bar */ - private static final int CENTER_WIDTH= 34; - /** Width of birds eye view */ - private static final int BIRDS_EYE_VIEW_WIDTH= 12; - /** Width of birds eye view */ - private static final int BIRDS_EYE_VIEW_INSET= 2; - /** */ - private static final int RESOLVE_SIZE= 5; - /** if true copying conflicts from one side to other concatenates both sides */ - private static final boolean APPEND_CONFLICT= true; - - /** line width of change borders */ - private static final int LW= 1; - /** Selects between smartTokenDiff and mergingTokenDiff */ - private static final boolean USE_MERGING_TOKEN_DIFF= false; - - // determines whether a change between left and right is considered incoming or outgoing - private boolean fLeftIsLocal; - private boolean fShowCurrentOnly= false; - private boolean fShowCurrentOnly2= false; - private int fMarginWidth= MARGIN_WIDTH; - private int fTopInset; - - // Colors - private RGB fBackground; - private RGB fForeground; - private boolean fPollSystemForeground= true; - private boolean fPollSystemBackground= true; - - private RGB SELECTED_INCOMING; - private RGB INCOMING; - private RGB INCOMING_FILL; - - private RGB SELECTED_CONFLICT; - private RGB CONFLICT; - private RGB CONFLICT_FILL; - - private RGB SELECTED_OUTGOING; - private RGB OUTGOING; - private RGB OUTGOING_FILL; - - private RGB RESOLVED; - - private boolean fEndOfDocReached; - private IDocumentListener fDocumentListener; - - private IPreferenceStore fPreferenceStore; - private IPropertyChangeListener fPreferenceChangeListener; - - /** All diffs for calculating scrolling position (includes line ranges without changes) */ - private ArrayList fAllDiffs; - /** Subset of above: just real differences. */ - private ArrayList fChangeDiffs; - /** The current diff */ - private Diff fCurrentDiff; - - private HashMap fNewAncestorRanges= new HashMap(); - private HashMap fNewLeftRanges= new HashMap(); - private HashMap fNewRightRanges= new HashMap(); - - private MergeSourceViewer fAncestor; - private MergeSourceViewer fLeft; - private MergeSourceViewer fRight; - - private int fLeftLineCount; - private int fRightLineCount; - - private String fLeftEncoding; - private String fRightEncoding; - - private boolean fInScrolling; - - private int fPts[]= new int[8]; // scratch area for polygon drawing - - private boolean fIgnoreAncestor= false; - private ActionContributionItem fIgnoreAncestorItem; - private boolean fHighlightRanges; - - private boolean fShowPseudoConflicts= false; - - private boolean fUseSplines= true; - private boolean fUseSingleLine= true; - private boolean fUseResolveUI= true; - - private String fSymbolicFontName; - - private ActionContributionItem fNextItem; // goto next difference - private ActionContributionItem fPreviousItem; // goto previous difference - private ActionContributionItem fCopyDiffLeftToRightItem; - private ActionContributionItem fCopyDiffRightToLeftItem; - - private IKeyBindingService fKeyBindingService; - - private boolean fSynchronizedScrolling= true; - private boolean fShowMoreInfo= false; - - private MergeSourceViewer fFocusPart; - - private boolean fSubDoc= true; - private IPositionUpdater fPositionUpdater; - private boolean fIsMotif; - private boolean fIsCarbon; - - private boolean fHasErrors; - - - // SWT widgets - private BufferedCanvas fAncestorCanvas; - private BufferedCanvas fLeftCanvas; - private BufferedCanvas fRightCanvas; - private Canvas fScrollCanvas; - private ScrollBar fVScrollBar; - private Canvas fBirdsEyeCanvas; - private Canvas fSummaryHeader; - private HeaderPainter fHeaderPainter; - - // SWT resources to be disposed - private Map fColors; - private Cursor fBirdsEyeCursor; - - // points for center curves - private double[] fBasicCenterCurve; - - private Button fCenterButton; - private Diff fButtonDiff; - - class HeaderPainter implements PaintListener { - - private static final int INSET= BIRDS_EYE_VIEW_INSET; - - private RGB fIndicatorColor; - private Color fSeparatorColor; - - public HeaderPainter() { - fSeparatorColor= fSummaryHeader.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); - } - - /* - * Returns true on color change - */ - public boolean setColor(RGB color) { - RGB oldColor= fIndicatorColor; - fIndicatorColor= color; - if (color == null) - return oldColor != null; - if (oldColor != null) - return !color.equals(oldColor); - return true; - } - - private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) { - gc.setForeground(topLeft); - gc.drawLine(x, y, x + w -1, y); - gc.drawLine(x, y, x, y + h -1); - - gc.setForeground(bottomRight); - gc.drawLine(x + w, y, x + w, y + h); - gc.drawLine(x, y + h, x + w, y + h); - } - - public void paintControl(PaintEvent e) { - - Point s= fSummaryHeader.getSize(); - - if (fIndicatorColor != null) { - Display d= fSummaryHeader.getDisplay(); - e.gc.setBackground(getColor(d, fIndicatorColor)); - int min= Math.min(s.x, s.y)-2*INSET; - Rectangle r= new Rectangle((s.x-min)/2, (s.y-min)/2, min, min); - e.gc.fillRectangle(r); - if (d != null) - drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); - - e.gc.setForeground(fSeparatorColor); - e.gc.setLineWidth(1); - e.gc.drawLine(0+1, s.y-1, s.x-1-1, s.y-1); - } - } - } - - /* - * The position updater used to adapt the positions representing - * the child document ranges to changes of the parent document. - */ - class ChildPositionUpdater extends DefaultPositionUpdater { - - /* - * Creates the position updated. - */ - protected ChildPositionUpdater(String category) { - super(category); - } - - /* - * Child document ranges cannot be deleted other then by calling - * freeChildDocument. - */ - protected boolean notDeleted() { - return true; - } - - /* - * If an insertion happens at a child document's start offset, the - * position is extended rather than shifted. Also, if something is added - * right behind the end of the position, the position is extended rather - * than kept stable. - */ - protected void adaptToInsert() { - - if (fPosition == fLeft.getRegion() || fPosition == fRight.getRegion()) { - int myStart= fPosition.offset; - int myEnd= fPosition.offset + fPosition.length; - myEnd= Math.max(myStart, myEnd); - - int yoursStart= fOffset; - int yoursEnd= fOffset + fReplaceLength -1; - yoursEnd= Math.max(yoursStart, yoursEnd); - - if (myEnd < yoursStart) - return; - - if (myStart <= yoursStart) - fPosition.length += fReplaceLength; - else - fPosition.offset += fReplaceLength; - } else { - super.adaptToInsert(); - } - } - } - - /* - * A Diff represents synchronized character ranges in two or three Documents. - * The MergeTextViewer uses Diffs to find differences in line and token ranges. - */ - /* package */ class Diff { - /** character range in ancestor document */ - Position fAncestorPos; - /** character range in left document */ - Position fLeftPos; - /** character range in right document */ - Position fRightPos; - /** if this is a TokenDiff fParent points to the enclosing LineDiff */ - Diff fParent; - /** if Diff has been resolved */ - boolean fResolved; - int fDirection; - boolean fIsToken= false; - /** child token diffs */ - ArrayList fDiffs; - boolean fIsWhitespace= false; - - /* - * Create Diff from two ranges and an optional parent diff. - */ - Diff(Diff parent, int dir, IDocument ancestorDoc, Position aRange, int ancestorStart, int ancestorEnd, - IDocument leftDoc, Position lRange, int leftStart, int leftEnd, - IDocument rightDoc, Position rRange, int rightStart, int rightEnd) { - fParent= parent != null ? parent : this; - fDirection= dir; - - fLeftPos= createPosition(leftDoc, lRange, leftStart, leftEnd); - fRightPos= createPosition(rightDoc, rRange, rightStart, rightEnd); - if (ancestorDoc != null) - fAncestorPos= createPosition(ancestorDoc, aRange, ancestorStart, ancestorEnd); - } - - Position getPosition(char type) { - switch (type) { - case 'A': - return fAncestorPos; - case 'L': - return fLeftPos; - case 'R': - return fRightPos; - } - return null; - } - - boolean isInRange(char type, int pos) { - Position p= getPosition(type); - return (pos >= p.offset) && (pos < (p.offset+p.length)); - } - - String changeType() { - boolean leftEmpty= fLeftPos.length == 0; - boolean rightEmpty= fRightPos.length == 0; - - if (fDirection == RangeDifference.LEFT) { - if (!leftEmpty && rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.addition"); //$NON-NLS-1$ - if (leftEmpty && !rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.deletion"); //$NON-NLS-1$ - } else { - if (leftEmpty && !rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.addition"); //$NON-NLS-1$ - if (!leftEmpty && rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.deletion"); //$NON-NLS-1$ - } - return CompareMessages.getString("TextMergeViewer.changeType.change"); //$NON-NLS-1$ - } - - Image getImage() { - int code= Differencer.CHANGE; - switch (fDirection) { - case RangeDifference.RIGHT: - code+= Differencer.LEFT; - break; - case RangeDifference.LEFT: - code+= Differencer.RIGHT; - break; - case RangeDifference.ANCESTOR: - case RangeDifference.CONFLICT: - code+= Differencer.CONFLICTING; - break; - } - if (code != 0) - return getCompareConfiguration().getImage(code); - return null; - } - - Position createPosition(IDocument doc, Position range, int start, int end) { - try { - int l= end-start; - if (range != null) { - int dl= range.length; - if (l > dl) - l= dl; - } else { - int dl= doc.getLength(); - if (start+l > dl) - l= dl-start; - } - - Position p= null; - try { - p= new Position(start, l); - } catch (RuntimeException ex) { - // silently ignored - } - - try { - doc.addPosition(IDocumentRange.RANGE_CATEGORY, p); - } catch (BadPositionCategoryException ex) { - // silently ignored - } - return p; - } catch (BadLocationException ee) { - // silently ignored - } - return null; - } - - void add(Diff d) { - if (fDiffs == null) - fDiffs= new ArrayList(); - fDiffs.add(d); - } - - boolean isDeleted() { - if (fAncestorPos != null && fAncestorPos.isDeleted()) - return true; - return fLeftPos.isDeleted() || fRightPos.isDeleted(); - } - - void setResolved(boolean r) { - fResolved= r; - if (r) - fDiffs= null; - } - - boolean isResolved() { - if (!fResolved && fDiffs != null) { - Iterator e= fDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - if (!d.isResolved()) - return false; - } - return true; - } - return fResolved; - } - -// private boolean isIncoming() { -// switch (fDirection) { -// case RangeDifference.RIGHT: -// if (fLeftIsLocal) -// return true; -// break; -// case RangeDifference.LEFT: -// if (!fLeftIsLocal) -// return true; -// break; -// } -// return false; -// } - - private boolean isIncomingOrConflicting() { - switch (fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return true; - break; - case RangeDifference.LEFT: - if (!fLeftIsLocal) - return true; - break; - case RangeDifference.CONFLICT: - return true; - } - return false; - } - -// private boolean isUnresolvedIncoming() { -// if (fResolved) -// return false; -// return isIncoming(); -// } - - private boolean isUnresolvedIncomingOrConflicting() { - if (fResolved) - return false; - return isIncomingOrConflicting(); - } - - Position getPosition(MergeSourceViewer w) { - if (w == fLeft) - return fLeftPos; - if (w == fRight) - return fRightPos; - if (w == fAncestor) - return fAncestorPos; - return null; - } - - /* - * Returns true if given character range overlaps with this Diff. - */ - boolean overlaps(MergeSourceViewer w, int start, int end) { - Position h= getPosition(w); - if (h != null) { - int ds= h.getOffset(); - int de= ds + h.getLength(); - if ((start < de) && (end >= ds)) - return true; - } - return false; - } - - int getMaxDiffHeight(boolean withAncestor) { - Point region= new Point(0, 0); - int h= fLeft.getLineRange(fLeftPos, region).y; - if (withAncestor) - h= Math.max(h, fAncestor.getLineRange(fAncestorPos, region).y); - return Math.max(h, fRight.getLineRange(fRightPos, region).y); - } - - int getAncestorHeight() { - Point region= new Point(0, 0); - return fAncestor.getLineRange(fAncestorPos, region).y; - } - - int getLeftHeight() { - Point region= new Point(0, 0); - return fLeft.getLineRange(fLeftPos, region).y; - } - - int getRightHeight() { - Point region= new Point(0, 0); - return fRight.getLineRange(fRightPos, region).y; - } - } - - //---- MergeTextViewer - - /** - * Creates a text merge viewer under the given parent control. - * - * @param parent the parent control - * @param configuration the configuration object - */ - public TextMergeViewer(Composite parent, CompareConfiguration configuration) { - this(parent, SWT.NULL, configuration); - } - - /** - * Creates a text merge viewer under the given parent control. - * - * @param parent the parent control - * @param style SWT style bits for top level composite of this viewer - * @param configuration the configuration object - */ - public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { - super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); - - fSymbolicFontName= getClass().getName(); - - String platform= SWT.getPlatform(); - fIsMotif= "motif".equals(platform); //$NON-NLS-1$ - fIsCarbon= "carbon".equals(platform); //$NON-NLS-1$ - - if (fIsMotif) - fMarginWidth= 0; - - Display display= parent.getDisplay(); - - fPreferenceChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - TextMergeViewer.this.propertyChange(event); - } - }; - - fPreferenceStore= configuration.getPreferenceStore(); - if (fPreferenceStore != null) { - fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); - - checkForColorUpdate(display); - - fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - fSynchronizedScrolling= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); - fShowMoreInfo= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO); - fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); - //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); - fUseSingleLine= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); - //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); - } - - fDocumentListener= new IDocumentListener() { - - public void documentAboutToBeChanged(DocumentEvent e) { - // nothing to do - } - - public void documentChanged(DocumentEvent e) { - TextMergeViewer.this.documentChanged(e); - } - }; - - buildControl(parent); - - INavigatable nav= new INavigatable() { - public boolean gotoDifference(boolean next) { - return navigate(next, false, false); - } - }; - fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); - - fBirdsEyeCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); - - JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); - JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); - updateFont(); - } - - private void updateFont() { - Font f= JFaceResources.getFont(fSymbolicFontName); - if (f != null) { - if (fAncestor != null) - fAncestor.setFont(f); - if (fLeft != null) - fLeft.setFont(f); - if (fRight != null) - fRight.setFont(f); - } - } - - private void checkForColorUpdate(Display display) { - if (fPollSystemForeground) { - RGB fg= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(); - if (fForeground == null || !fg.equals(fForeground)) { - fForeground= fg; - updateColors(display); - } - } - if (fPollSystemBackground) { - RGB bg= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); - if (fBackground == null || !bg.equals(fBackground)) { - fBackground= bg; - updateColors(display); - } - } - } - - /** - * Sets the viewer's background color to the given RGB value. - * If the value is null the system's default background color is used. - * @param background the background color or null to use the system's default background color - * @since 2.0 - */ - public void setBackgroundColor(RGB background) { - fPollSystemBackground= (background == null); - fBackground= background; - updateColors(null); - } - - private RGB getBackground(Display display) { - if (fBackground != null) - return fBackground; - if (display == null) - display= fComposite.getDisplay(); - return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); - } - - /** - * Sets the viewer's foreground color to the given RGB value. - * If the value is null the system's default foreground color is used. - * @param foreground the foreground color or null to use the system's default foreground color - * @since 2.0 - */ - public void setForegroundColor(RGB foreground) { - fPollSystemForeground= (foreground == null); - fForeground= foreground; - updateColors(null); - } - - private void updateColors(Display display) { - - if (display == null) - display= fComposite.getDisplay(); - - Color color= null; - if (fBackground != null) - color= getColor(display, fBackground); - - if (fAncestor != null) - fAncestor.setBackgroundColor(color); - if (fLeft != null) - fLeft.setBackgroundColor(color); - if (fRight != null) - fRight.setBackgroundColor(color); - - ColorRegistry registry= JFaceResources.getColorRegistry(); - - RGB bg= getBackground(display); - SELECTED_INCOMING= registry.getRGB(INCOMING_COLOR); - if (SELECTED_INCOMING == null) - SELECTED_INCOMING= new RGB(0, 0, 255); // BLUE - INCOMING= interpolate(SELECTED_INCOMING, bg, 0.6); - INCOMING_FILL= interpolate(SELECTED_INCOMING, bg, 0.97); - - SELECTED_OUTGOING= registry.getRGB(OUTGOING_COLOR); - if (SELECTED_OUTGOING == null) - SELECTED_OUTGOING= new RGB(0, 0, 0); // BLACK - OUTGOING= interpolate(SELECTED_OUTGOING, bg, 0.6); - OUTGOING_FILL= interpolate(SELECTED_OUTGOING, bg, 0.97); - - SELECTED_CONFLICT= registry.getRGB(CONFLICTING_COLOR); - if (SELECTED_CONFLICT == null) - SELECTED_CONFLICT= new RGB(255, 0, 0); // RED - CONFLICT= interpolate(SELECTED_CONFLICT, bg, 0.6); - CONFLICT_FILL= interpolate(SELECTED_CONFLICT, bg, 0.97); - - RESOLVED= registry.getRGB(RESOLVED_COLOR); - if (RESOLVED == null) - RESOLVED= new RGB(0, 255, 0); // GREEN - - refreshBirdsEyeView(); - invalidateLines(); - - updateAllDiffBackgrounds(display); - } - - /** - * Invalidates the current presentation by invalidating the three text viewers. - * @since 2.0 - */ - public void invalidateTextPresentation() { - if (fAncestor != null) - fAncestor.invalidateTextPresentation(); - if (fLeft != null) - fLeft.invalidateTextPresentation(); - if (fRight != null) - fRight.invalidateTextPresentation(); - } - - /** - * Configures the passed text viewer. - * This method is called after the three text viewers have been created for the - * content areas. - * The TextMergeViewer implementation of this method does nothing. - * Subclasses may reimplement to provide a specific configuration for the text viewer. - * - * @param textViewer the text viewer to configure - */ - protected void configureTextViewer(TextViewer textViewer) { - // empty impl - } - - /** - * Creates an ITokenComparator which is used to show the - * intra line differences. - * The TextMergeViewer implementation of this method returns a - * tokenizer that breaks a line into words separated by whitespace. - * Subclasses may reimplement to provide a specific tokenizer. - * @param line the line for which to create the ITokenComparator - * @return a ITokenComparator which is used for a second level token compare. - */ - protected ITokenComparator createTokenComparator(String line) { - return new TokenComparator(line); - } - - /** - * Returns a document partitioner which is suitable for the underlying content type. - * This method is only called if the input provided by the content provider is a - * IStreamContentAccessor and an internal document must be created. This - * document is initialized with the partitioner returned from this method. - *

- * The TextMergeViewer implementation of this method returns - * null. Subclasses may reimplement to create a partitioner for a - * specific content type. - * - * @return a document partitioner, or null - */ - protected IDocumentPartitioner getDocumentPartitioner() { - return null; - } - - /** - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - * @param event - */ - protected void handleDispose(DisposeEvent event) { - - if (fKeyBindingService != null) { - IAction a; - if (fNextItem != null) { - a= fNextItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fPreviousItem != null) { - a= fPreviousItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fCopyDiffLeftToRightItem != null) { - a= fCopyDiffLeftToRightItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fCopyDiffRightToLeftItem != null) { - a= fCopyDiffRightToLeftItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - fKeyBindingService= null; - } - - Object input= getInput(); - DocumentManager.remove(getDocument2('A', input)); - DocumentManager.remove(getDocument2('L', input)); - DocumentManager.remove(getDocument2('R', input)); - - if (DEBUG) - DocumentManager.dump(); - - if (fPreferenceChangeListener != null) { - JFaceResources.getFontRegistry().removeListener(fPreferenceChangeListener); - JFaceResources.getColorRegistry().removeListener(fPreferenceChangeListener); - if (fPreferenceStore != null) - fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); - fPreferenceChangeListener= null; - } - - fLeftCanvas= null; - fRightCanvas= null; - fVScrollBar= null; - fBirdsEyeCanvas= null; - fSummaryHeader= null; - - unsetDocument(fAncestor); - unsetDocument(fLeft); - unsetDocument(fRight); - - if (fColors != null) { - Iterator i= fColors.values().iterator(); - while (i.hasNext()) { - Color color= (Color) i.next(); - if (!color.isDisposed()) - color.dispose(); - } - fColors= null; - } - - if (fBirdsEyeCursor != null) { - fBirdsEyeCursor.dispose(); - fBirdsEyeCursor= null; - } - - super.handleDispose(event); - } - - //------------------------------------------------------------------------------------------------------------- - //--- internal ------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------- - - /* - * Creates the specific SWT controls for the content areas. - * Clients must not call or override this method. - */ - protected void createControls(Composite composite) { - - WorkbenchHelp.setHelp(composite, ICompareContextIds.TEXT_MERGE_VIEW); - - // 1st row - if (fMarginWidth > 0) { - fAncestorCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fAncestor, fAncestorCanvas, false); - } - }; - fAncestorCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fAncestorCanvas, fAncestor, e.y), false); - } - } - ); - } - - fAncestor= createPart(composite); - fAncestor.setEditable(false); - - fSummaryHeader= new Canvas(composite, SWT.NONE); - fHeaderPainter= new HeaderPainter(); - fSummaryHeader.addPaintListener(fHeaderPainter); - updateResolveStatus(); - - // 2nd row - if (fMarginWidth > 0) { - fLeftCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fLeft, fLeftCanvas, false); - } - }; - fLeftCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fLeftCanvas, fLeft, e.y), false); - } - } - ); - } - - fLeft= createPart(composite); - fLeft.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fLeft.addAction(MergeSourceViewer.SAVE_ID, fLeftSaveAction); - - fRight= createPart(composite); - fRight.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fRight.addAction(MergeSourceViewer.SAVE_ID, fRightSaveAction); - - hsynchViewport(fAncestor, fLeft, fRight); - hsynchViewport(fLeft, fAncestor, fRight); - hsynchViewport(fRight, fAncestor, fLeft); - - if (fMarginWidth > 0) { - fRightCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fRight, fRightCanvas, fSynchronizedScrolling); - } - }; - fRightCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fRightCanvas, fRight, e.y), false); - } - } - ); - } - - fScrollCanvas= new Canvas(composite, SWT.V_SCROLL); - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - fTopInset= trim.y; - - fVScrollBar= fScrollCanvas.getVerticalBar(); - fVScrollBar.setIncrement(1); - fVScrollBar.setVisible(true); - fVScrollBar.addListener(SWT.Selection, - new Listener() { - public void handleEvent(Event e) { - int vpos= ((ScrollBar)e.widget).getSelection(); - scrollVertical(vpos, vpos, vpos, null); - workaround65205(); - } - } - ); - - fBirdsEyeCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintBirdsEyeView(this, gc); - } - }; - fBirdsEyeCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handlemouseInBirdsEyeView(fBirdsEyeCanvas, e.y), true); - } - } - ); - fBirdsEyeCanvas.addMouseMoveListener( - new MouseMoveListener() { - - private Cursor fLastCursor; - - public void mouseMove(MouseEvent e) { - Cursor cursor= null; - Diff diff= handlemouseInBirdsEyeView(fBirdsEyeCanvas, e.y); - if (diff != null && diff.fDirection != RangeDifference.NOCHANGE) - cursor= fBirdsEyeCursor; - if (fLastCursor != cursor) { - fBirdsEyeCanvas.setCursor(cursor); - fLastCursor= cursor; - } - } - } - ); - } - - private void hsynchViewport(final TextViewer tv1, final TextViewer tv2, final TextViewer tv3) { - final StyledText st1= tv1.getTextWidget(); - final StyledText st2= tv2.getTextWidget(); - final StyledText st3= tv3.getTextWidget(); - final ScrollBar sb1= st1.getHorizontalBar(); - sb1.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (fSynchronizedScrolling) { - int max= sb1.getMaximum()-sb1.getThumb(); - double v= 0.0; - if (max > 0) - v= (float)sb1.getSelection() / (float)max; - if (st2.isVisible()) { - ScrollBar sb2= st2.getHorizontalBar(); - st2.setHorizontalPixel((int)((sb2.getMaximum()-sb2.getThumb()) * v)); - } - if (st3.isVisible()) { - ScrollBar sb3= st3.getHorizontalBar(); - st3.setHorizontalPixel((int)((sb3.getMaximum()-sb3.getThumb()) * v)); - } - workaround65205(); - } - } - }); - } - - /** - * A workaround for bug #65205. - * On MacOS X a Display.update() is required to flush pending paint requests after - * programmatical scolling. - */ - private void workaround65205() { - if (fIsCarbon && fComposite != null && !fComposite.isDisposed()) - fComposite.getDisplay().update(); - } - - private void setCurrentDiff2(Diff diff, boolean reveal) { - if (diff != null && diff.fDirection != RangeDifference.NOCHANGE) { - //fCurrentDiff= null; - setCurrentDiff(diff, reveal); - } - } - - private Diff handleMouseInSides(Canvas canvas, MergeSourceViewer tp, int my) { - - int lineHeight= tp.getTextWidget().getLineHeight(); - int visibleHeight= tp.getViewportHeight(); - - if (! fHighlightRanges) - return null; - - if (fChangeDiffs != null) { - int shift= tp.getVerticalScrollOffset() + (2-LW); - - Point region= new Point(0, 0); - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), region); - int y= (region.x * lineHeight) + shift; - int h= region.y * lineHeight; - - if (y+h < 0) - continue; - if (y >= visibleHeight) - break; - - if (my >= y && my < y+h) - return diff; - } - } - return null; - } - - private Diff getDiffUnderMouse(Canvas canvas, int mx, int my, Rectangle r) { - - if (! fSynchronizedScrolling) - return null; - - int lineHeight= fLeft.getTextWidget().getLineHeight(); - int visibleHeight= fRight.getViewportHeight(); - - Point size= canvas.getSize(); - int w= size.x; - - if (! fHighlightRanges) - return null; - - if (fChangeDiffs != null) { - int lshift= fLeft.getVerticalScrollOffset(); - int rshift= fRight.getVerticalScrollOffset(); - - Point region= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - fLeft.getLineRange(diff.fLeftPos, region); - int ly= (region.x * lineHeight) + lshift; - int lh= region.y * lineHeight; - - fRight.getLineRange(diff.fRightPos, region); - int ry= (region.x * lineHeight) + rshift; - int rh= region.y * lineHeight; - - if (Math.max(ly+lh, ry+rh) < 0) - continue; - if (Math.min(ly, ry) >= visibleHeight) - break; - - int cx= (w-RESOLVE_SIZE)/2; - int cy= ((ly+lh/2) + (ry+rh/2) - RESOLVE_SIZE)/2; - if (my >= cy && my < cy+RESOLVE_SIZE && mx >= cx && mx < cx+RESOLVE_SIZE) { - if (r != null) { - int SIZE= fIsCarbon ? 30 : 20; - r.x= cx+(RESOLVE_SIZE-SIZE)/2; - r.y= cy+(RESOLVE_SIZE-SIZE)/2; - r.width= SIZE; - r.height= SIZE; - } - return diff; - } - } - } - return null; - } - - private Diff handlemouseInBirdsEyeView(Canvas canvas, int my) { - int yy, hh; - - Point size= canvas.getSize(); - - int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight(); - if (virtualHeight < getViewportHeight()) - return null; - - int y= 0; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor) - : diff.getRightHeight(); - if (useChange(diff.fDirection) && !diff.fIsWhitespace) { - - yy= (y*size.y)/virtualHeight; - hh= (h*size.y)/virtualHeight; - if (hh < 3) - hh= 3; - - if (my >= yy && my < yy+hh) - return diff; - } - y+= h; - } - } - return null; - } - - private void paintBirdsEyeView(Canvas canvas, GC gc) { - - Color c; - Rectangle r= new Rectangle(0, 0, 0, 0); - int yy, hh; - - Point size= canvas.getSize(); - - int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight(); - if (virtualHeight < getViewportHeight()) - return; - - Display display= canvas.getDisplay(); - int y= 0; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor) - : diff.getRightHeight(); - - if (useChange(diff.fDirection) && !diff.fIsWhitespace) { - - yy= (y*size.y)/virtualHeight; - hh= (h*size.y)/virtualHeight; - if (hh < 3) - hh= 3; - - c= getColor(display, getFillColor(diff)); - if (c != null) { - gc.setBackground(c); - gc.fillRectangle(BIRDS_EYE_VIEW_INSET, yy, size.x-(2*BIRDS_EYE_VIEW_INSET),hh); - } - c= getColor(display, getStrokeColor(diff)); - if (c != null) { - gc.setForeground(c); - r.x= BIRDS_EYE_VIEW_INSET; - r.y= yy; - r.width= size.x-(2*BIRDS_EYE_VIEW_INSET)-1; - r.height= hh; - if (diff == fCurrentDiff || - (fCurrentDiff != null && diff == fCurrentDiff.fParent)) { - gc.setLineWidth(2); - r.x++; - r.y++; - r.width--; - r.height--; - } else { - gc.setLineWidth(1); - } - gc.drawRectangle(r); - } - } - - y+= h; - } - } - } - - private void refreshBirdsEyeView() { - if (fBirdsEyeCanvas != null) - fBirdsEyeCanvas.redraw(); - } - - /* - * Called whenever setFocus() is called on the ContentViewer's top level SWT Composite. - * This implementation sets the focus to the first enabled text widget. - */ - /* package */ boolean internalSetFocus() { - if (fFocusPart == null) { - if (fLeft != null && fLeft.getEnabled()) { - fFocusPart= fLeft; - } else if (fRight != null && fRight.getEnabled()) { - fFocusPart= fRight; - } else if (fAncestor != null && fAncestor.getEnabled()) { - fFocusPart= fAncestor; - } - } - if (fFocusPart != null) { - StyledText st= fFocusPart.getTextWidget(); - if (st != null) - return st.setFocus(); - } - return false; // could not set focus - } - - - class HoverResizer extends Resizer { - Canvas fCanvas; - public HoverResizer(Canvas c, int dir) { - super(c, dir); - fCanvas= c; - } - public void mouseMove(MouseEvent e) { - if (!fIsDown && fUseSingleLine && showResolveUI() && handleMouseMoveOverCenter(fCanvas, e.x, e.y)) - return; - super.mouseMove(e); - } - } - - /* - * Creates the central Canvas. - * Called from ContentMergeViewer. - */ - /* package */ Control createCenter(Composite parent) { - if (fSynchronizedScrolling) { - final Canvas canvas= new BufferedCanvas(parent, SWT.NONE) { - public void doPaint(GC gc) { - paintCenter(this, gc); - } - }; - if (fUseResolveUI) { - - new HoverResizer(canvas, HORIZONTAL); - - fCenterButton= new Button(canvas, fIsCarbon ? SWT.FLAT : SWT.PUSH); - if (fNormalCursor == null) fNormalCursor= new Cursor(canvas.getDisplay(), SWT.CURSOR_ARROW); - fCenterButton.setCursor(fNormalCursor); - fCenterButton.setText("<"); //$NON-NLS-1$ - fCenterButton.pack(); - fCenterButton.setVisible(false); - fCenterButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fCenterButton.setVisible(false); - if (fButtonDiff != null) { - setCurrentDiff(fButtonDiff, false); - copy(fCurrentDiff, false, fCurrentDiff.fDirection == RangeDifference.CONFLICT); - } - } - } - ); - } else { - new Resizer(canvas, HORIZONTAL); - } - - return canvas; - } - return super.createCenter(parent); - } - - private boolean handleMouseMoveOverCenter(Canvas canvas, int x, int y) { - Rectangle r= new Rectangle(0, 0, 0, 0); - Diff diff= getDiffUnderMouse(canvas, x, y, r); - if (diff != null && !diff.isUnresolvedIncomingOrConflicting()) - diff= null; - if (diff != fButtonDiff) { - if (diff != null) { - if (fLeft.isEditable()) { - fButtonDiff= diff; - fCenterButton.setText("<"); //$NON-NLS-1$ - String tt= fCopyDiffRightToLeftItem.getAction().getToolTipText(); - fCenterButton.setToolTipText(tt); - fCenterButton.setBounds(r); - fCenterButton.setVisible(true); - } else if (fRight.isEditable()) { - fButtonDiff= diff; - fCenterButton.setText(">"); //$NON-NLS-1$ - String tt= fCopyDiffLeftToRightItem.getAction().getToolTipText(); - fCenterButton.setToolTipText(tt); - fCenterButton.setBounds(r); - fCenterButton.setVisible(true); - } else - fButtonDiff= null; - } else { - fCenterButton.setVisible(false); - fButtonDiff= null; - } - } - return fButtonDiff != null; - } - - /* - * Returns width of central canvas. - * Overridden from ContentMergeViewer. - */ - /* package */ int getCenterWidth() { - if (fSynchronizedScrolling) - return CENTER_WIDTH; - return super.getCenterWidth(); - } - - /* - * Creates and initializes a text part. - */ - private MergeSourceViewer createPart(Composite parent) { - - final MergeSourceViewer part= new MergeSourceViewer(parent, getResourceBundle()); - final StyledText te= part.getTextWidget(); - - if (!fConfirmSave) - part.hideSaveAction(); - - te.addPaintListener( - new PaintListener() { - public void paintControl(PaintEvent e) { - paint(e, part); - } - } - ); - te.addKeyListener( - new KeyAdapter() { - public void keyPressed(KeyEvent e) { - handleSelectionChanged(part); - } - } - ); - te.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - //syncViewport(part); - handleSelectionChanged(part); - } - } - ); - - te.addFocusListener( - new FocusAdapter() { - public void focusGained(FocusEvent fe) { - fFocusPart= part; - connectGlobalActions(fFocusPart); - } - public void focusLost(FocusEvent fe) { - connectGlobalActions(null); - } - } - ); - - part.addViewportListener( - new IViewportListener() { - public void viewportChanged(int verticalPosition) { - syncViewport(part); - } - } - ); - - Font font= JFaceResources.getFont(fSymbolicFontName); - if (font != null) - te.setFont(font); - - if (fBackground != null) // not default - te.setBackground(getColor(parent.getDisplay(), fBackground)); - - configureTextViewer(part); - - return part; - } - - private void connectGlobalActions(MergeSourceViewer part) { - IActionBars actionBars= Utilities.findActionBars(fComposite); - if (actionBars != null) { - for (int i= 0; i < GLOBAL_ACTIONS.length; i++) { - IAction action= null; - if (part != null) { - action= part.getAction(TEXT_ACTIONS[i]); - if (action == null && TEXT_ACTIONS[i].equals(MergeSourceViewer.SAVE_ID)) { - if (part == fLeft) - action= fLeftSaveAction; - else - action= fRightSaveAction; - } - } - actionBars.setGlobalActionHandler(GLOBAL_ACTIONS[i], action); - } - actionBars.updateActionBars(); - } - } - - ITypedElement getLeg(char type, Object input) { - if (input instanceof ICompareInput) { - switch (type) { - case 'A': - return ((ICompareInput)input).getAncestor(); - case 'L': - return ((ICompareInput)input).getLeft(); - case 'R': - return ((ICompareInput)input).getRight(); - } - } - return null; - } - - IDocument getDocument(char type, Object input) { - ITypedElement te= getLeg(type, input); - if (te instanceof IDocument) - return (IDocument) te; - if (te instanceof IDocumentRange) - return ((IDocumentRange) te).getDocument(); - if (te instanceof IStreamContentAccessor) - return DocumentManager.get(te); - return null; - } - - IDocument getDocument2(char type, Object input) { - IDocument doc= getDocument(type, input); - if (doc != null) - return doc; - - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - return getDocument(type, parent); - } - return null; - } - - /* - * Returns true if the given inputs map to the same documents - */ - boolean sameDoc(char type, Object newInput, Object oldInput) { - IDocument newDoc= getDocument2(type, newInput); - IDocument oldDoc= getDocument2(type, oldInput); - return newDoc == oldDoc; - } - - /** - * Overridden to prevent save confirmation if new input is sub document of current input. - * @param newInput the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - * @return true if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). - * @since 2.0 - */ - protected boolean doSave(Object newInput, Object oldInput) { - - if (oldInput != null && newInput != null) { - // check whether underlying documents have changed. - if (sameDoc('A', newInput, oldInput) && - sameDoc('L', newInput, oldInput) && - sameDoc('R', newInput, oldInput)) { - if (DEBUG) System.out.println("----- Same docs !!!!"); //$NON-NLS-1$ - return false; - } - } - - if (DEBUG) System.out.println("***** New docs !!!!"); //$NON-NLS-1$ - - IDocument aDoc= getDocument2('A', oldInput); - DocumentManager.remove(aDoc); - IDocument lDoc= getDocument2('L', oldInput); - DocumentManager.remove(lDoc); - IDocument rDoc= getDocument2('R', oldInput); - DocumentManager.remove(rDoc); - - if (DEBUG) - DocumentManager.dump(); - - return super.doSave(newInput, oldInput); - } - - private ITypedElement getParent(char type) { - Object input= getInput(); - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - return getLeg(type, parent); - } - return null; - } - - /* - * Initializes the text viewers of the three content areas with the given input objects. - * Subclasses may extend. - */ - protected void updateContent(Object ancestor, Object left, Object right) { - - boolean emptyInput= (ancestor == null && left == null && right == null); - - Object input= getInput(); - - Position leftRange= null; - Position rightRange= null; - - // if one side is empty use container - if (FIX_47640 && !emptyInput && (left == null || right == null)) { - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - if (parent instanceof ICompareInput) { - ICompareInput ci= (ICompareInput) parent; - - if (ci.getAncestor() instanceof IDocumentRange - || ci.getLeft() instanceof IDocumentRange - || ci.getRight() instanceof IDocumentRange) { - - if (left instanceof IDocumentRange) - leftRange= ((IDocumentRange)left).getRange(); - if (right instanceof IDocumentRange) - rightRange= ((IDocumentRange)right).getRange(); - - ancestor= ci.getAncestor(); - left= ci.getLeft(); - right= ci.getRight(); - } - } - } - } - - int n= 0; - if (left != null) - n++; - if (right != null) - n++; - fHighlightRanges= n > 1; - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - fEndOfDocReached= false; - fHasErrors= false; // start with no errors - - CompareConfiguration cc= getCompareConfiguration(); - IMergeViewerContentProvider cp= getMergeContentProvider(); - - if (cp instanceof MergeViewerContentProvider) { - MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp; - mcp.setAncestorError(null); - mcp.setLeftError(null); - mcp.setRightError(null); - } - - // set new documents - setDocument(fLeft, 'L', left); - fLeftLineCount= fLeft.getLineCount(); - fLeftEncoding= getEncoding(left); - - setDocument(fRight, 'R', right); - fRightLineCount= fRight.getLineCount(); - fRightEncoding= getEncoding(right); - - setDocument(fAncestor, 'A', ancestor); - - updateHeader(); - updateControls(); - updateToolItems(); - - if (!fHasErrors) - doDiff(); - - fRight.setEditable(cc.isRightEditable() && cp.isRightEditable(input)); - fLeft.setEditable(cc.isLeftEditable() && cp.isLeftEditable(input)); - - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - if (!fHasErrors && !emptyInput && !fComposite.isDisposed()) { - Diff selectDiff= null; - if (FIX_47640) { - if (leftRange != null) - selectDiff= findDiff('L', leftRange); - else if (rightRange != null) - selectDiff= findDiff('R', rightRange); - } - if (selectDiff != null) - setCurrentDiff(selectDiff, true); - else - selectFirstDiff(); - } - } - - private Diff findDiff(char c, Position range) { - - MergeSourceViewer v; - int start= range.getOffset(); - int end= start + range.getLength(); - if (c == 'L') - v= fLeft; - else if (c == 'R') - v= fRight; - else - return null; - - if (fChangeDiffs != null) { - Iterator iter= fChangeDiffs.iterator(); - while (iter.hasNext()) { - Diff diff= (Diff) iter.next(); - if (diff.isDeleted() || diff.fDirection == RangeDifference.NOCHANGE) - continue; - if (diff.overlaps(v, start, end)) - return diff; - } - } - return null; - } - - private static String getEncoding(Object o) { - String encoding= null; - if (o instanceof IEncodedStreamContentAccessor) { - try { - encoding= ((IEncodedStreamContentAccessor)o).getCharset(); - } catch (CoreException e) { - // ignored - } - } - if (encoding == null) - encoding= ResourcesPlugin.getEncoding(); - return encoding; - } - - private void updateDiffBackground(Diff diff) { - - if (! fHighlightRanges) - return; - - if (diff == null || diff.fIsToken) - return; - - if (fShowCurrentOnly && !isCurrentDiff(diff)) - return; - - Color c= getColor(null, getFillColor(diff)); - if (c == null) - return; - - if (isThreeWay()) - fAncestor.setLineBackground(diff.fAncestorPos, c); - fLeft.setLineBackground(diff.fLeftPos, c); - fRight.setLineBackground(diff.fRightPos, c); - } - - private void updateAllDiffBackgrounds(Display display) { - if (fChangeDiffs != null) { - boolean threeWay= isThreeWay(); - Iterator iter= fChangeDiffs.iterator(); - while (iter.hasNext()) { - Diff diff= (Diff) iter.next(); - Color c= getColor(display, getFillColor(diff)); - if (threeWay) - fAncestor.setLineBackground(diff.fAncestorPos, c); - fLeft.setLineBackground(diff.fLeftPos, c); - fRight.setLineBackground(diff.fRightPos, c); - } - } - } - - boolean isCurrentDiff(Diff diff) { - if (diff == null) - return false; - if (diff == fCurrentDiff) - return true; - if (fCurrentDiff != null && fCurrentDiff.fParent == diff) - return true; - return false; - } - - /* - * Called whenver one of the documents changes. - * Sets the dirty state of this viewer and updates the lines. - * Implements IDocumentListener. - */ - private void documentChanged(DocumentEvent e) { - - IDocument doc= e.getDocument(); - - if (doc == fLeft.getDocument()) { - setLeftDirty(true); - } else if (doc == fRight.getDocument()) { - setRightDirty(true); - } - - updateLines(doc); - } - - /* - * This method is called if a range of text on one side is copied into an empty subdocument - * on the other side. The method returns the position where the subdocument is placed into the base document. - * This default implementation determines the position by using the text range differencer. - * However this position is not always optimal for specific types of text. - * So subclasses (which are aware of the type of text they are dealing with) - * may override this method to find a better position where to insert a newly added - * piece of text. - * @param type the side for which the insertion position should be determined: 'A' for ancestor, 'L' for left hand side, 'R' for right hand side. - * @param input the current input object of this viewer - * @since 2.0 - */ - protected int findInsertionPosition(char type, ICompareInput input) { - - ITypedElement other= null; - char otherType= 0; - - switch (type) { - case 'A': - other= input.getLeft(); - otherType= 'L'; - if (other == null) { - other= input.getRight(); - otherType= 'R'; - } - break; - case 'L': - other= input.getRight(); - otherType= 'R'; - if (other == null) { - other= input.getAncestor(); - otherType= 'A'; - } - break; - case 'R': - other= input.getLeft(); - otherType= 'L'; - if (other == null) { - other= input.getAncestor(); - otherType= 'A'; - } - break; - } - - if (other instanceof IDocumentRange) { - IDocumentRange dr= (IDocumentRange) other; - Position p= dr.getRange(); - Diff diff= findDiff(otherType, p.offset); - if (diff != null) { - switch (type) { - case 'A': - if (diff.fAncestorPos != null) - return diff.fAncestorPos.offset; - break; - case 'L': - if (diff.fLeftPos != null) - return diff.fLeftPos.offset; - break; - case 'R': - if (diff.fRightPos != null) - return diff.fRightPos.offset; - break; - } - } - } - return 0; - } - - private void setError(char type, String message) { - IMergeViewerContentProvider cp= getMergeContentProvider(); - if (cp instanceof MergeViewerContentProvider) { - MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp; - switch (type) { - case 'A': - mcp.setAncestorError(message); - break; - case 'L': - mcp.setLeftError(message); - break; - case 'R': - mcp.setRightError(message); - break; - } - } - fHasErrors= true; - } - - /* - * Returns true if a new Document could be installed. - */ - private boolean setDocument(MergeSourceViewer tp, char type, Object o) { - - if (tp == null) - return false; - - IDocument newDoc= null; - Position range= null; - - if (o instanceof IDocumentRange) { - newDoc= ((IDocumentRange)o).getDocument(); - range= ((IDocumentRange)o).getRange(); - - } else if (o instanceof IDocument) { - newDoc= (IDocument) o; - - } else if (o instanceof IStreamContentAccessor) { - - newDoc= DocumentManager.get(o); - if (newDoc == null) { - IStreamContentAccessor sca= (IStreamContentAccessor) o; - String s= null; - - try { - s= Utilities.readString(sca); - } catch (CoreException ex) { - setError(type, ex.getMessage()); - } - - newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$ - DocumentManager.put(o, newDoc); - IDocumentPartitioner partitioner= getDocumentPartitioner(); - if (partitioner != null) { - newDoc.setDocumentPartitioner(partitioner); - partitioner.connect(newDoc); - } - } - } else if (o == null) { // deletion on one side - - ITypedElement parent= getParent(type); // we try to find an insertion position within the deletion's parent - - if (parent instanceof IDocumentRange) { - newDoc= ((IDocumentRange)parent).getDocument(); - newDoc.addPositionCategory(IDocumentRange.RANGE_CATEGORY); - Object input= getInput(); - range= getNewRange(type, input); - if (range == null) { - int pos= 0; - if (input instanceof ICompareInput) - pos= findInsertionPosition(type, (ICompareInput)input); - range= new Position(pos, 0); - try { - newDoc.addPosition(IDocumentRange.RANGE_CATEGORY, range); - } catch (BadPositionCategoryException ex) { - // silently ignored - if (DEBUG) System.out.println("BadPositionCategoryException: " + ex); //$NON-NLS-1$ - } catch (BadLocationException ex) { - // silently ignored - if (DEBUG) System.out.println("BadLocationException: " + ex); //$NON-NLS-1$ - } - addNewRange(type, input, range); - } - } else if (parent instanceof IDocument) { - newDoc= ((IDocumentRange)o).getDocument(); - } - } - - boolean enabled= true; - if (newDoc == null) { - //System.out.println("setDocument: create new Document"); - newDoc= new Document(""); //$NON-NLS-1$ - enabled= false; - } - - IDocument oldDoc= tp.getDocument(); - - if (newDoc != oldDoc) { - - // got a new document - - unsetDocument(tp); - - if (newDoc != null) { - newDoc.addPositionCategory(IDocumentRange.RANGE_CATEGORY); - if (fPositionUpdater == null) - fPositionUpdater= new ChildPositionUpdater(IDocumentRange.RANGE_CATEGORY); - else - newDoc.removePositionUpdater(fPositionUpdater); - newDoc.addPositionUpdater(fPositionUpdater); - } - - // install new document - if (newDoc != null) { - - tp.setRegion(range); - if (fSubDoc) { - if (range != null) { - IRegion r= normalizeDocumentRegion(newDoc, toRegion(range)); - tp.setDocument(newDoc, r.getOffset(), r.getLength()); - } else - tp.setDocument(newDoc); - } else - tp.setDocument(newDoc); - - tp.rememberDocument(newDoc); - newDoc.addDocumentListener(fDocumentListener); - //LeakTester.add(newDoc); - } - - } else { // same document but different range - - tp.setRegion(range); - if (fSubDoc) { - if (range != null) { - IRegion r= normalizeDocumentRegion(newDoc, toRegion(range)); - tp.setVisibleRegion(r.getOffset(), r.getLength()); - } else - tp.resetVisibleRegion(); - } else - tp.resetVisibleRegion(); - } - - tp.setEnabled(enabled); - - return enabled; - } - - private Position getNewRange(char type, Object input) { - switch (type) { - case 'A': - return (Position) fNewAncestorRanges.get(input); - case 'L': - return (Position) fNewLeftRanges.get(input); - case 'R': - return (Position) fNewRightRanges.get(input); - } - return null; - } - - private void addNewRange(char type, Object input, Position range) { - switch (type) { - case 'A': - fNewAncestorRanges.put(input, range); - break; - case 'L': - fNewLeftRanges.put(input, range); - break; - case 'R': - fNewRightRanges.put(input, range); - break; - } - } - - private void unsetDocument(MergeSourceViewer tp) { - IDocument oldDoc= tp.getDocument(); - if (oldDoc == null) { - oldDoc= tp.getRememberedDocument(); -// if (oldDoc != null) -// System.err.println("TextMergeViewer.unsetDocument: would leak"); - } - if (oldDoc != null) { - tp.rememberDocument(null); - // deinstall old positions - if (fPositionUpdater != null) - oldDoc.removePositionUpdater(fPositionUpdater); - try { - oldDoc.removePositionCategory(IDocumentRange.RANGE_CATEGORY); - } catch (BadPositionCategoryException ex) { - // NeedWork - } - - oldDoc.removeDocumentListener(fDocumentListener); - //LeakTester.remove(oldDoc); - } - } - - /** - * Returns the contents of the underlying document as an array of bytes using the current workbench encoding. - * - * @param left if true the contents of the left side is returned; otherwise the right side - * @return the contents of the left or right document or null - */ - protected byte[] getContents(boolean left) { - MergeSourceViewer v= left ? fLeft : fRight; - if (v != null) { - IDocument d= v.getDocument(); - if (d != null) { - String contents= d.get(); - if (contents != null) { - byte[] bytes; - try { - bytes= contents.getBytes(left ? fLeftEncoding : fRightEncoding); - } catch(UnsupportedEncodingException ex) { - // use default encoding - bytes= contents.getBytes(); - } - return bytes; - } - } - } - return null; - } - - private IRegion normalizeDocumentRegion(IDocument doc, IRegion region) { - - if (region == null || doc == null) - return region; - - int maxLength= doc.getLength(); - - int start= region.getOffset(); - if (start < 0) - start= 0; - else if (start > maxLength) - start= maxLength; - - int length= region.getLength(); - if (length < 0) - length= 0; - else if (start + length > maxLength) - length= maxLength - start; - - return new Region(start, length); - } - - protected final void handleResizeAncestor(int x, int y, int width, int height) { - if (width > 0) { - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height; - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.setVisible(true); - if (fAncestor.isControlOkToUse()) - fAncestor.getTextWidget().setVisible(true); - - if (fAncestorCanvas != null) { - fAncestorCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - width-= fMarginWidth; - } - fAncestor.getTextWidget().setBounds(x, y, width, height); - } else { - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.setVisible(false); - if (fAncestor.isControlOkToUse()) { - StyledText t= fAncestor.getTextWidget(); - t.setVisible(false); - t.setBounds(0, 0, 0, 0); - if (fFocusPart == fAncestor) { - fFocusPart= fLeft; - fFocusPart.getTextWidget().setFocus(); - } - } - } - } - - /* - * Lays out everything. - */ - protected final void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height) { - - if (fBirdsEyeCanvas != null) - width2-= BIRDS_EYE_VIEW_WIDTH; - - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height + trim.x; - - Composite composite= (Composite) getControl(); - - int leftTextWidth= width1; - if (fLeftCanvas != null) { - fLeftCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - leftTextWidth-= fMarginWidth; - } - - fLeft.getTextWidget().setBounds(x, y, leftTextWidth, height); - x+= leftTextWidth; - - if (fCenter == null || fCenter.isDisposed()) - fCenter= createCenter(composite); - fCenter.setBounds(x, y, centerWidth, height-scrollbarHeight); - x+= centerWidth; - - if (!fSynchronizedScrolling) { // canvas is to the left of text - if (fRightCanvas != null) { - fRightCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - fRightCanvas.redraw(); - x+= fMarginWidth; - } - // we draw the canvas to the left of the text widget - } - - int scrollbarWidth= 0; - if (fSynchronizedScrolling && fScrollCanvas != null) { - trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - scrollbarWidth= trim.width + 2*trim.x; - } - int rightTextWidth= width2-scrollbarWidth; - if (fRightCanvas != null) - rightTextWidth-= fMarginWidth; - fRight.getTextWidget().setBounds(x, y, rightTextWidth, height); - x+= rightTextWidth; - - if (fSynchronizedScrolling) { - if (fRightCanvas != null) { // canvas is to the right of the text - fRightCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - } - if (fScrollCanvas != null) - fScrollCanvas.setBounds(x, y, scrollbarWidth, height-scrollbarHeight); - } - - if (fBirdsEyeCanvas != null) { - int verticalScrollbarButtonHeight= scrollbarWidth; - int horizontalScrollbarButtonHeight= scrollbarHeight; - if (fIsCarbon) { - verticalScrollbarButtonHeight+= 2; - horizontalScrollbarButtonHeight= 18; - } - if (fSummaryHeader != null) - fSummaryHeader.setBounds(x+scrollbarWidth, y, BIRDS_EYE_VIEW_WIDTH, verticalScrollbarButtonHeight); - y+= verticalScrollbarButtonHeight; - fBirdsEyeCanvas.setBounds(x+scrollbarWidth, y, BIRDS_EYE_VIEW_WIDTH, height-(2*verticalScrollbarButtonHeight+horizontalScrollbarButtonHeight)); - } - - // doesn't work since TextEditors don't have their correct size yet. - updateVScrollBar(); - refreshBirdsEyeView(); - } - - /* - * Track selection changes to update the current Diff. - */ - private void handleSelectionChanged(MergeSourceViewer tw) { - Point p= tw.getSelectedRange(); - Diff d= findDiff(tw, p.x, p.x+p.y); - updateStatus(d); - setCurrentDiff(d, false); // don't select or reveal - } - - private static IRegion toRegion(Position position) { - if (position != null) - return new Region(position.getOffset(), position.getLength()); - return null; - } - - //---- the differencing - - private static int maxWork(IRangeComparator a, IRangeComparator l, IRangeComparator r) { - int ln= l.getRangeCount(); - int rn= r.getRangeCount(); - if (a != null) { - int an= a.getRangeCount(); - return (2 * Math.max(an, ln)) + (2 * Math.max(an, rn)); - } - return 2 * Math.max(ln, rn); - } - - /** - * Perform a two level 2- or 3-way diff. - * The first level is based on line comparison, the second level on token comparison. - */ - private void doDiff() { - - fAllDiffs= new ArrayList(); - fChangeDiffs= new ArrayList(); - fCurrentDiff= null; - - IDocument aDoc= null; - IDocument lDoc= fLeft.getDocument(); - IDocument rDoc= fRight.getDocument(); - if (lDoc == null || rDoc == null) - return; - - Position aRegion= null; - Position lRegion= fLeft.getRegion(); - Position rRegion= fRight.getRegion(); - - boolean threeWay= isThreeWay(); - - if (threeWay && !fIgnoreAncestor) { - aDoc= fAncestor.getDocument(); - aRegion= fAncestor.getRegion(); - } - - fAncestor.resetLineBackground(); - fLeft.resetLineBackground(); - fRight.resetLineBackground(); - - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - - DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); - DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); - DocLineComparator sancestor= null; - if (aDoc != null) - sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); - - if (!fSubDoc && rRegion != null && lRegion != null) { - // we have to add a diff for the ignored lines - - int astart= 0; - int as= 0; - if (aRegion != null) { - astart= aRegion.getOffset(); - as= Math.max(0, astart-1); - } - int ys= Math.max(0, lRegion.getOffset()-1); - int ms= Math.max(0, rRegion.getOffset()-1); - - if (as > 0 || ys > 0 || ms > 0) { - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, 0, astart, - lDoc, lRegion, 0, lRegion.getOffset(), - rDoc, rRegion, 0, rRegion.getOffset()); - fAllDiffs.add(diff); - } - } - - final ResourceBundle bundle= getResourceBundle(); - - final Object[] result= new Object[1]; - final DocLineComparator sa= sancestor, sl= sleft, sr= sright; - IRunnableWithProgress runnable= new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - String progressTitle= Utilities.getString(bundle, "compareProgressTask.title"); //$NON-NLS-1$ - monitor.beginTask(progressTitle, maxWork(sa, sl, sr)); - try { - result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); - } catch (OutOfMemoryError ex) { - System.gc(); - throw new InvocationTargetException(ex); - } - if (monitor.isCanceled()) { // cancelled - throw new InterruptedException(); - } - monitor.done(); - } - }; - IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); - - RangeDifference[] e= null; - try { - progressService.run(true, true, runnable); - e= (RangeDifference[]) result[0]; - } catch (InvocationTargetException ex) { - String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ - String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ - String msg= MessageFormat.format(format, new Object[] { Integer.toString(progressService.getLongOperationTime()/1000) } ); - MessageDialog.openError(fComposite.getShell(), title, msg); - e= null; - } catch (InterruptedException ex) { - // - } - - if (e == null) { - // we create a NOCHANGE range for the whole document - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, 0, aDoc != null ? aDoc.getLength() : 0, - lDoc, lRegion, 0, lDoc.getLength(), - rDoc, rRegion, 0, rDoc.getLength()); - - fAllDiffs.add(diff); - } else { - for (int i= 0; i < e.length; i++) { - String a= null, s= null, d= null; - RangeDifference es= e[i]; - - int kind= es.kind(); - - int ancestorStart= 0; - int ancestorEnd= 0; - if (sancestor != null) { - ancestorStart= sancestor.getTokenStart(es.ancestorStart()); - ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart= sleft.getTokenStart(es.leftStart()); - int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - - int rightStart= sright.getTokenStart(es.rightStart()); - int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(null, kind, - aDoc, aRegion, ancestorStart, ancestorEnd, - lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); - - fAllDiffs.add(diff); // remember all range diffs for scrolling - - if (ignoreWhiteSpace) { - if (sancestor != null) - a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength()); - s= extract2(lDoc, sleft, es.leftStart(), es.leftLength()); - d= extract2(rDoc, sright, es.rightStart(), es.rightLength()); - - if ((a == null || a.trim().length() == 0) && s.trim().length() == 0 && d.trim().length() == 0) { - diff.fIsWhitespace= true; - continue; - } - } - - if (useChange(kind)) { - fChangeDiffs.add(diff); // here we remember only the real diffs - updateDiffBackground(diff); - - if (s == null) - s= extract2(lDoc, sleft, es.leftStart(), es.leftLength()); - if (d == null) - d= extract2(rDoc, sright, es.rightStart(), es.rightLength()); - - if (s.length() > 0 && d.length() > 0) { - if (a == null && sancestor != null) - a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength()); - if (USE_MERGING_TOKEN_DIFF) - mergingTokenDiff(diff, aDoc, a, rDoc, d, lDoc, s); - else - simpleTokenDiff(diff, aDoc, a, rDoc, d, lDoc, s); - } - } - } - } - - if (!fSubDoc && rRegion != null && lRegion != null) { - // we have to add a diff for the ignored lines - - int aEnd= 0; - int aLen= 0; - if (aRegion != null && aDoc != null) { - aEnd= aRegion.getOffset()+aRegion.getLength(); - aLen= aDoc.getLength(); - } - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, aEnd, aLen, - lDoc, lRegion, lRegion.getOffset()+lRegion.getLength(), lDoc.getLength(), - rDoc, rRegion, rRegion.getOffset()+rRegion.getLength(), rDoc.getLength()); - fAllDiffs.add(diff); - } - } - - private Diff findDiff(char type, int pos) { - - IDocument aDoc= null; - IDocument lDoc= fLeft.getDocument(); - IDocument rDoc= fRight.getDocument(); - if (lDoc == null || rDoc == null) - return null; - - Position aRegion= null; - Position lRegion= null; - Position rRegion= null; - - boolean threeWay= isThreeWay(); - - if (threeWay && !fIgnoreAncestor) - aDoc= fAncestor.getDocument(); - - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - - DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); - DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); - DocLineComparator sancestor= null; - if (aDoc != null) - sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); - - final ResourceBundle bundle= getResourceBundle(); - - final Object[] result= new Object[1]; - final DocLineComparator sa= sancestor, sl= sleft, sr= sright; - IRunnableWithProgress runnable= new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - String progressTitle= Utilities.getString(bundle, "compareProgressTask.title"); //$NON-NLS-1$ - monitor.beginTask(progressTitle, maxWork(sa, sl, sr)); - try { - result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); - } catch (OutOfMemoryError ex) { - System.gc(); - throw new InvocationTargetException(ex); - } - if (monitor.isCanceled()) { // cancelled - throw new InterruptedException(); - } - monitor.done(); - } - }; - IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); - - RangeDifference[] e= null; - try { - progressService.run(true, true, runnable); - e= (RangeDifference[]) result[0]; - } catch (InvocationTargetException ex) { - String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ - String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ - String msg= MessageFormat.format(format, new Object[] { Integer.toString(progressService.getLongOperationTime()/1000) } ); - MessageDialog.openError(fComposite.getShell(), title, msg); - e= null; - } catch (InterruptedException ex) { - // - } - - if (e != null) { - for (int i= 0; i < e.length; i++) { - RangeDifference es= e[i]; - - int kind= es.kind(); - - int ancestorStart= 0; - int ancestorEnd= 0; - if (sancestor != null) { - ancestorStart= sancestor.getTokenStart(es.ancestorStart()); - ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart= sleft.getTokenStart(es.leftStart()); - int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - - int rightStart= sright.getTokenStart(es.rightStart()); - int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(null, kind, - aDoc, aRegion, ancestorStart, ancestorEnd, - lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); - - if (diff.isInRange(type, pos)) - return diff; - } - } - - return null; - } - - /* - * Returns true if kind of change should be shown. - */ - private boolean useChange(int kind) { - if (kind == RangeDifference.NOCHANGE) - return false; - if (kind == RangeDifference.ANCESTOR) - return fShowPseudoConflicts; - return true; - } - - private int getTokenEnd(ITokenComparator tc, int start, int count) { - if (count <= 0) - return tc.getTokenStart(start); - int index= start + count - 1; - return tc.getTokenStart(index) + tc.getTokenLength(index); - } - - private static int getTokenEnd2(ITokenComparator tc, int start, int length) { - return tc.getTokenStart(start + length); - } - - /* - * Returns the content of lines in the specified range as a String. - * This includes the line separators. - * - * @param doc the document from which to extract the characters - * @param start index of first line - * @param length number of lines - * @return the contents of the specified line range as a String - */ - private String extract2(IDocument doc, ITokenComparator tc, int start, int length) { - int count= tc.getRangeCount(); - if (length > 0 && count > 0) { - -// -// int startPos= tc.getTokenStart(start); -// int endPos= startPos; -// -// if (length > 1) -// endPos= tc.getTokenStart(start + (length-1)); -// endPos+= tc.getTokenLength(start + (length-1)); -// - - int startPos= tc.getTokenStart(start); - int endPos; - - if (length == 1) { - endPos= startPos + tc.getTokenLength(start); - } else { - endPos= tc.getTokenStart(start + length); - } - - try { - return doc.get(startPos, endPos - startPos); - } catch (BadLocationException e) { - // silently ignored - } - - } - return ""; //$NON-NLS-1$ - } - - /* - * Performs a token based 3-way diff on the character range specified by the given baseDiff. - */ - private void simpleTokenDiff(final Diff baseDiff, - IDocument ancestorDoc, String a, - IDocument rightDoc, String d, - IDocument leftDoc, String s) { - - int ancestorStart= 0; - ITokenComparator sa= null; - if (ancestorDoc != null) { - ancestorStart= baseDiff.fAncestorPos.getOffset(); - sa= createTokenComparator(a); - } - - int rightStart= baseDiff.fRightPos.getOffset(); - ITokenComparator sm= createTokenComparator(d); - - int leftStart= baseDiff.fLeftPos.getOffset(); - ITokenComparator sy= createTokenComparator(s); - - RangeDifference[] e= RangeDifferencer.findRanges(sa, sy, sm); - for (int i= 0; i < e.length; i++) { - RangeDifference es= e[i]; - int kind= es.kind(); - if (kind != RangeDifference.NOCHANGE) { - - int ancestorStart2= ancestorStart; - int ancestorEnd2= ancestorStart; - if (ancestorDoc != null) { - ancestorStart2 += sa.getTokenStart(es.ancestorStart()); - ancestorEnd2 += getTokenEnd(sa, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart2= leftStart + sy.getTokenStart(es.leftStart()); - int leftEnd2= leftStart + getTokenEnd(sy, es.leftStart(), es.leftLength()); - - int rightStart2= rightStart + sm.getTokenStart(es.rightStart()); - int rightEnd2= rightStart + getTokenEnd(sm, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(baseDiff, kind, - ancestorDoc, null, ancestorStart2, ancestorEnd2, - leftDoc, null, leftStart2, leftEnd2, - rightDoc, null, rightStart2, rightEnd2); - - // ensure that token diff is smaller than basediff - int leftS= baseDiff.fLeftPos.offset; - int leftE= baseDiff.fLeftPos.offset+baseDiff.fLeftPos.length; - int rightS= baseDiff.fRightPos.offset; - int rightE= baseDiff.fRightPos.offset+baseDiff.fRightPos.length; - if (leftS != leftStart2 || leftE != leftEnd2 || - rightS != rightStart2 || rightE != rightEnd2) { - diff.fIsToken= true; - // add to base Diff - baseDiff.add(diff); - } - } - } - } - - /* - * Performs a "smart" token based 3-way diff on the character range specified by the given baseDiff. - * It is "smart" because it tries to minimize the number of token diffs by merging them. - */ - private void mergingTokenDiff(Diff baseDiff, - IDocument ancestorDoc, String a, - IDocument rightDoc, String d, - IDocument leftDoc, String s) { - ITokenComparator sa= null; - int ancestorStart= 0; - if (ancestorDoc != null) { - sa= createTokenComparator(a); - ancestorStart= baseDiff.fAncestorPos.getOffset(); - } - - int rightStart= baseDiff.fRightPos.getOffset(); - ITokenComparator sm= createTokenComparator(d); - - int leftStart= baseDiff.fLeftPos.getOffset(); - ITokenComparator sy= createTokenComparator(s); - - RangeDifference[] r= RangeDifferencer.findRanges(sa, sy, sm); - for (int i= 0; i < r.length; i++) { - RangeDifference es= r[i]; - // determine range of diffs in one line - int start= i; - int leftLine= -1; - int rightLine= -1; - try { - leftLine= leftDoc.getLineOfOffset(leftStart+sy.getTokenStart(es.leftStart())); - rightLine= rightDoc.getLineOfOffset(rightStart+sm.getTokenStart(es.rightStart())); - } catch (BadLocationException e) { - // silently ignored - } - i++; - for (; i < r.length; i++) { - es= r[i]; - try { - if (leftLine != leftDoc.getLineOfOffset(leftStart+sy.getTokenStart(es.leftStart()))) - break; - if (rightLine != rightDoc.getLineOfOffset(rightStart+sm.getTokenStart(es.rightStart()))) - break; - } catch (BadLocationException e) { - // silently ignored - } - } - int end= i; - - // find first diff from left - RangeDifference first= null; - for (int ii= start; ii < end; ii++) { - es= r[ii]; - if (useChange(es.kind())) { - first= es; - break; - } - } - - // find first diff from mine - RangeDifference last= null; - for (int ii= end-1; ii >= start; ii--) { - es= r[ii]; - if (useChange(es.kind())) { - last= es; - break; - } - } - - if (first != null && last != null) { - - int ancestorStart2= 0; - int ancestorEnd2= 0; - if (ancestorDoc != null) { - ancestorStart2= ancestorStart+sa.getTokenStart(first.ancestorStart()); - ancestorEnd2= ancestorStart+getTokenEnd(sa, last.ancestorStart(), last.ancestorLength()); - } - - int leftStart2= leftStart+sy.getTokenStart(first.leftStart()); - int leftEnd2= leftStart+getTokenEnd(sy, last.leftStart(), last.leftLength()); - - int rightStart2= rightStart+sm.getTokenStart(first.rightStart()); - int rightEnd2= rightStart+getTokenEnd(sm, last.rightStart(), last.rightLength()); - Diff diff= new Diff(baseDiff, first.kind(), - ancestorDoc, null, ancestorStart2, ancestorEnd2+1, - leftDoc, null, leftStart2, leftEnd2+1, - rightDoc, null, rightStart2, rightEnd2+1); - diff.fIsToken= true; - baseDiff.add(diff); - } - } - } - - //---- update UI stuff - - private void updateControls() { - - boolean leftToRight= false; - boolean rightToLeft= false; - - updateStatus(fCurrentDiff); - updateResolveStatus(); - - if (fCurrentDiff != null) { - IMergeViewerContentProvider cp= getMergeContentProvider(); - if (cp != null) { - rightToLeft= cp.isLeftEditable(getInput()); - leftToRight= cp.isRightEditable(getInput()); - } - } - - if (fDirectionLabel != null) { - if (fHighlightRanges && fCurrentDiff != null && isThreeWay() && !fIgnoreAncestor) { - fDirectionLabel.setImage(fCurrentDiff.getImage()); - } else { - fDirectionLabel.setImage(null); - } - } - - if (fCopyDiffLeftToRightItem != null) - ((Action)fCopyDiffLeftToRightItem.getAction()).setEnabled(leftToRight); - if (fCopyDiffRightToLeftItem != null) - ((Action)fCopyDiffRightToLeftItem.getAction()).setEnabled(rightToLeft); - - boolean enableNavigation= false; - if (fCurrentDiff == null && fChangeDiffs != null && fChangeDiffs.size() > 0) - enableNavigation= true; - else if (fChangeDiffs != null && fChangeDiffs.size() > 1) - enableNavigation= true; - else if (fCurrentDiff != null && fCurrentDiff.fDiffs != null) - enableNavigation= true; - else if (fCurrentDiff != null && fCurrentDiff.fIsToken) - enableNavigation= true; - - if (fNextItem != null) { - IAction a= fNextItem.getAction(); - a.setEnabled(enableNavigation); - } - if (fPreviousItem != null) { - IAction a= fPreviousItem.getAction(); - a.setEnabled(enableNavigation); - } - } - - private void updateResolveStatus() { - - RGB rgb= null; - - if (showResolveUI()) { - // we only show red or green if there is at least one incoming or conflicting change - int incomingOrConflicting= 0; - int unresolvedIncoming= 0; - int unresolvedConflicting= 0; - - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - if (d.isIncomingOrConflicting() /* && useChange(d.fDirection) && !d.fIsWhitespace */) { - incomingOrConflicting++; - if (!d.fResolved) { - if (d.fDirection == RangeDifference.CONFLICT) { - unresolvedConflicting++; - break; // we can stop here because a conflict has the maximum priority - } - unresolvedIncoming++; - } - } - } - } - - if (incomingOrConflicting > 0) { - if (unresolvedConflicting > 0) - rgb= SELECTED_CONFLICT; - else if (unresolvedIncoming > 0) - rgb= SELECTED_INCOMING; - else - rgb= RESOLVED; - } - } - - if (fHeaderPainter.setColor(rgb)) - fSummaryHeader.redraw(); - } - - private void updateStatus(Diff diff) { - - if (! fShowMoreInfo) - return; - - IActionBars bars= Utilities.findActionBars(fComposite); - if (bars == null) - return; - IStatusLineManager slm= bars.getStatusLineManager(); - if (slm == null) - return; - - String diffDescription; - - if (diff == null) { - diffDescription= CompareMessages.getString("TextMergeViewer.diffDescription.noDiff.format"); //$NON-NLS-1$ - } else { - - if (diff.fIsToken) // we don't show special info for token diffs - diff= diff.fParent; - - String format= CompareMessages.getString("TextMergeViewer.diffDescription.diff.format"); //$NON-NLS-1$ - diffDescription= MessageFormat.format(format, - new String[] { - getDiffType(diff), // 0: diff type - getDiffNumber(diff), // 1: diff number - getDiffRange(fLeft, diff.fLeftPos), // 2: left start line - getDiffRange(fRight, diff.fRightPos) // 3: left end line - } - ); - } - - String format= CompareMessages.getString("TextMergeViewer.statusLine.format"); //$NON-NLS-1$ - String s= MessageFormat.format(format, - new String[] { - getCursorPosition(fLeft), // 0: left column - getCursorPosition(fRight), // 1: right column - diffDescription // 2: diff description - } - ); - - slm.setMessage(s); - } - - private void clearStatus() { - - IActionBars bars= Utilities.findActionBars(fComposite); - if (bars == null) - return; - IStatusLineManager slm= bars.getStatusLineManager(); - if (slm == null) - return; - - slm.setMessage(null); - } - - private String getDiffType(Diff diff) { - String s= ""; //$NON-NLS-1$ - switch(diff.fDirection) { - case RangeDifference.LEFT: - s= CompareMessages.getString("TextMergeViewer.direction.outgoing"); //$NON-NLS-1$ - break; - case RangeDifference.RIGHT: - s= CompareMessages.getString("TextMergeViewer.direction.incoming"); //$NON-NLS-1$ - break; - case RangeDifference.CONFLICT: - s= CompareMessages.getString("TextMergeViewer.direction.conflicting"); //$NON-NLS-1$ - break; - } - String format= CompareMessages.getString("TextMergeViewer.diffType.format"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] { s, diff.changeType() } ); - } - - private String getDiffNumber(Diff diff) { - // find the diff's number - int diffNumber= 0; - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - diffNumber++; - if (d == diff) - break; - } - } - return Integer.toString(diffNumber); - } - - private String getDiffRange(MergeSourceViewer v, Position pos) { - Point p= v.getLineRange(pos, new Point(0, 0)); - int startLine= p.x+1; - int endLine= p.x+p.y; - - String format; - if (endLine < startLine) - format= CompareMessages.getString("TextMergeViewer.beforeLine.format"); //$NON-NLS-1$ - else - format= CompareMessages.getString("TextMergeViewer.range.format"); //$NON-NLS-1$ - return MessageFormat.format(format, - new String[] { Integer.toString(startLine), - Integer.toString(endLine) } ); - } - - /* - * Returns a description of the cursor position. - * - * @return a description of the cursor position - */ - private String getCursorPosition(MergeSourceViewer v) { - if (v != null) { - StyledText styledText= v.getTextWidget(); - - IDocument document= v.getDocument(); - if (document != null) { - int offset= v.getVisibleRegion().getOffset(); - int caret= offset + styledText.getCaretOffset(); - - try { - - int line=document.getLineOfOffset(caret); - - int lineOffset= document.getLineOffset(line); - int occurrences= 0; - for (int i= lineOffset; i < caret; i++) - if ('\t' == document.getChar(i)) - ++ occurrences; - - int tabWidth= styledText.getTabs(); - int column= caret - lineOffset + (tabWidth -1) * occurrences; - - String format= CompareMessages.getString("TextMergeViewer.cursorPosition.format"); //$NON-NLS-1$ - return MessageFormat.format(format, - new String[] { Integer.toString(line + 1), Integer.toString(column + 1) } ); - - } catch (BadLocationException x) { - // silently ignored - } - } - } - return ""; //$NON-NLS-1$ - } - - protected void updateHeader() { - - super.updateHeader(); - - updateControls(); - } - - /* - * Creates the two items for copying a difference range from one side to the other - * and adds them to the given toolbar manager. - */ - protected void createToolItems(ToolBarManager tbm) { - - IWorkbenchPartSite ps= Utilities.findSite(fComposite); - fKeyBindingService= ps != null ? ps.getKeyBindingService() : null; - - final String ignoreAncestorActionKey= "action.IgnoreAncestor."; //$NON-NLS-1$ - Action ignoreAncestorAction= new Action() { - public void run() { - setIgnoreAncestor(! fIgnoreAncestor); - Utilities.initToggleAction(this, getResourceBundle(), ignoreAncestorActionKey, fIgnoreAncestor); - } - }; - ignoreAncestorAction.setChecked(fIgnoreAncestor); - Utilities.initAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey); - Utilities.initToggleAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey, fIgnoreAncestor); - - fIgnoreAncestorItem= new ActionContributionItem(ignoreAncestorAction); - fIgnoreAncestorItem.setVisible(false); - tbm.appendToGroup("modes", fIgnoreAncestorItem); //$NON-NLS-1$ - - tbm.add(new Separator()); - - Action a= new Action() { - public void run() { - navigate(true, true, true); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.NextDiff."); //$NON-NLS-1$ - fNextItem= new ActionContributionItem(a); - tbm.appendToGroup("navigation", fNextItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.selectNextChange"); //$NON-NLS-1$ - - a= new Action() { - public void run() { - navigate(false, true, true); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.PrevDiff."); //$NON-NLS-1$ - fPreviousItem= new ActionContributionItem(a); - tbm.appendToGroup("navigation", fPreviousItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.selectPreviousChange"); //$NON-NLS-1$ - - - CompareConfiguration cc= getCompareConfiguration(); - - if (cc.isRightEditable()) { - a= new Action() { - public void run() { - copyDiffLeftToRight(); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.CopyDiffLeftToRight."); //$NON-NLS-1$ - fCopyDiffLeftToRightItem= new ActionContributionItem(a); - fCopyDiffLeftToRightItem.setVisible(true); - tbm.appendToGroup("merge", fCopyDiffLeftToRightItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.copyLeftToRight"); //$NON-NLS-1$ - } - - if (cc.isLeftEditable()) { - a= new Action() { - public void run() { - copyDiffRightToLeft(); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.CopyDiffRightToLeft."); //$NON-NLS-1$ - fCopyDiffRightToLeftItem= new ActionContributionItem(a); - fCopyDiffRightToLeftItem.setVisible(true); - tbm.appendToGroup("merge", fCopyDiffRightToLeftItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.copyRightToLeft"); //$NON-NLS-1$ - } - } - - /* package */ void propertyChange(PropertyChangeEvent event) { - - String key= event.getProperty(); - - if (key.equals(CompareConfiguration.IGNORE_WHITESPACE) - || key.equals(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS)) { - - fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - - doDiff(); - - updateControls(); - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - selectFirstDiff(); - -// } else if (key.equals(ComparePreferencePage.USE_SPLINES)) { -// fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); -// invalidateLines(); - - } else if (key.equals(ComparePreferencePage.USE_SINGLE_LINE)) { - fUseSingleLine= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); -// fUseResolveUI= fUseSingleLine; - fBasicCenterCurve= null; - updateResolveStatus(); - invalidateLines(); - -// } else if (key.equals(ComparePreferencePage.USE_RESOLVE_UI)) { -// fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); -// updateResolveStatus(); -// invalidateLines(); - - } else if (key.equals(fSymbolicFontName)) { - updateFont(); - invalidateLines(); - - } else if (key.equals(INCOMING_COLOR) || key.equals(OUTGOING_COLOR) || key.equals(CONFLICTING_COLOR) || key.equals(RESOLVED_COLOR)) { - updateColors(null); - invalidateLines(); - - } else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) { - - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); - if (b != fSynchronizedScrolling) - toggleSynchMode(); - - } else if (key.equals(ComparePreferencePage.SHOW_MORE_INFO)) { - - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO); - if (b != fShowMoreInfo) { - fShowMoreInfo= b; - if (fShowMoreInfo) - updateStatus(fCurrentDiff); - else - clearStatus(); - } - - } else - super.propertyChange(event); - } - - private void setIgnoreAncestor(boolean ignore) { - if (ignore != fIgnoreAncestor) { - fIgnoreAncestor= ignore; - setAncestorVisibility(false, !fIgnoreAncestor); - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - - doDiff(); - - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - selectFirstDiff(); - } - } - - private void selectFirstDiff() { - - if (fLeft == null || fRight == null) { - return; - } - if (fLeft.getDocument() == null || fRight.getDocument() == null) { - return; - } - - Diff firstDiff= null; - if (CompareNavigator.getDirection(fComposite)) - firstDiff= findNext(fRight, fChangeDiffs, -1, -1, false); - else - firstDiff= findPrev(fRight, fChangeDiffs, 9999999, 9999999, false); - setCurrentDiff(firstDiff, true); - } - - private void toggleSynchMode() { - fSynchronizedScrolling= ! fSynchronizedScrolling; - - scrollVertical(0, 0, 0, null); - - // throw away central control (Sash or Canvas) - Control center= getCenter(); - if (center != null && !center.isDisposed()) - center.dispose(); - - fLeft.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fRight.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - - fComposite.layout(true); - } - - protected void updateToolItems() { - - if (fIgnoreAncestorItem != null) - fIgnoreAncestorItem.setVisible(isThreeWay()); - - if (fCopyDiffLeftToRightItem != null) { - IAction a= fCopyDiffLeftToRightItem.getAction(); - if (a != null) - a.setEnabled(a.isEnabled() && !fHasErrors); - } - if (fCopyDiffRightToLeftItem != null) { - IAction a= fCopyDiffRightToLeftItem.getAction(); - if (a != null) - a.setEnabled(a.isEnabled() && !fHasErrors); - } - - super.updateToolItems(); - } - - //---- painting lines - - private void updateLines(IDocument d) { - - boolean left= false; - boolean right= false; - - // FIXME: this optimization is incorrect because - // it doesn't take replace operations into account where - // the old and new line count does not differ - if (d == fLeft.getDocument()) { - int l= fLeft.getLineCount(); - left= fLeftLineCount != l; - fLeftLineCount= l; - } else if (d == fRight.getDocument()) { - int l= fRight.getLineCount(); - right= fRightLineCount != l; - fRightLineCount= l; - } - - if (left || right) { - - if (left) { - if (fLeftCanvas != null) - fLeftCanvas.redraw(); - } else { - if (fRightCanvas != null) - fRightCanvas.redraw(); - } - Control center= getCenter(); - if (center != null) - center.redraw(); - - updateVScrollBar(); - refreshBirdsEyeView(); - } - } - - private void invalidateLines() { - if (isThreeWay()) { - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.redraw(); - if (fAncestor != null && fAncestor.isControlOkToUse()) - fAncestor.getTextWidget().redraw(); - } - - if (Utilities.okToUse(fLeftCanvas)) - fLeftCanvas.redraw(); - - if (fLeft != null && fLeft.isControlOkToUse()) - fLeft.getTextWidget().redraw(); - - if (Utilities.okToUse(getCenter())) - getCenter().redraw(); - - if (fRight != null && fRight.isControlOkToUse()) - fRight.getTextWidget().redraw(); - - if (Utilities.okToUse(fRightCanvas)) - fRightCanvas.redraw(); - } - - private boolean showResolveUI() { - if (!fUseResolveUI || !isThreeWay() || fIgnoreAncestor) - return false; - CompareConfiguration cc= getCompareConfiguration(); - if (cc == null) - return false; - // we only enable the new resolve ui if exactly one side is editable - boolean l= cc.isLeftEditable(); - boolean r= cc.isRightEditable(); - //return (l && !r) || (r && !l); - return l || r; - } - - private void paintCenter(Canvas canvas, GC g) { - - Display display= canvas.getDisplay(); - - checkForColorUpdate(display); - - if (! fSynchronizedScrolling) - return; - - int lineHeight= fLeft.getTextWidget().getLineHeight(); - int visibleHeight= fRight.getViewportHeight(); - - Point size= canvas.getSize(); - int x= 0; - int w= size.x; - - g.setBackground(canvas.getBackground()); - g.fillRectangle(x+1, 0, w-2, size.y); - - if (!fIsMotif) { - // draw thin line between center ruler and both texts - g.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); - g.fillRectangle(0, 0, 1, size.y); - g.fillRectangle(w-1, 0, 1, size.y); - } - - if (! fHighlightRanges) - return; - - boolean showResolveUI= showResolveUI(); - - if (fChangeDiffs != null) { - int lshift= fLeft.getVerticalScrollOffset(); - int rshift= fRight.getVerticalScrollOffset(); - - Point region= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - fLeft.getLineRange(diff.fLeftPos, region); - int ly= (region.x * lineHeight) + lshift; - int lh= region.y * lineHeight; - - fRight.getLineRange(diff.fRightPos, region); - int ry= (region.x * lineHeight) + rshift; - int rh= region.y * lineHeight; - - if (Math.max(ly+lh, ry+rh) < 0) - continue; - if (Math.min(ly, ry) >= visibleHeight) - break; - - fPts[0]= x; fPts[1]= ly; fPts[2]= w; fPts[3]= ry; - fPts[6]= x; fPts[7]= ly+lh; fPts[4]= w; fPts[5]= ry+rh; - - Color fillColor= getColor(display, getFillColor(diff)); - Color strokeColor= getColor(display, getStrokeColor(diff)); - - if (fUseSingleLine) { - int w2= 3; - - g.setBackground(fillColor); - g.fillRectangle(0, ly, w2, lh); // left - g.fillRectangle(w-w2, ry, w2, rh); // right - - g.setLineWidth(LW); - g.setForeground(strokeColor); - g.drawRectangle(0-1, ly, w2, lh); // left - g.drawRectangle(w-w2, ry, w2, rh); // right - - if (fUseSplines) { - int[] points= getCenterCurvePoints(w2, ly+lh/2, w-w2, ry+rh/2); - for (int i= 1; i < points.length; i++) - g.drawLine(w2+i-1, points[i-1], w2+i, points[i]); - } else { - g.drawLine(w2, ly+lh/2, w-w2, ry+rh/2); - } - } else { - // two lines - if (fUseSplines) { - g.setBackground(fillColor); - - g.setLineWidth(LW); - g.setForeground(strokeColor); - - int[] topPoints= getCenterCurvePoints(fPts[0], fPts[1], fPts[2], fPts[3]); - int[] bottomPoints= getCenterCurvePoints(fPts[6], fPts[7], fPts[4], fPts[5]); - g.setForeground(fillColor); - g.drawLine(0, bottomPoints[0], 0, topPoints[0]); - for (int i= 1; i < bottomPoints.length; i++) { - g.setForeground(fillColor); - g.drawLine(i, bottomPoints[i], i, topPoints[i]); - g.setForeground(strokeColor); - g.drawLine(i-1, topPoints[i-1], i, topPoints[i]); - g.drawLine(i-1, bottomPoints[i-1], i, bottomPoints[i]); - } - } else { - g.setBackground(fillColor); - g.fillPolygon(fPts); - - g.setLineWidth(LW); - g.setForeground(strokeColor); - g.drawLine(fPts[0], fPts[1], fPts[2], fPts[3]); - g.drawLine(fPts[6], fPts[7], fPts[4], fPts[5]); - } - } - - if (fUseSingleLine && showResolveUI && diff.isUnresolvedIncomingOrConflicting()) { - // draw resolve state - int cx= (w-RESOLVE_SIZE)/2; - int cy= ((ly+lh/2) + (ry+rh/2) - RESOLVE_SIZE)/2; - - g.setBackground(fillColor); - g.fillRectangle(cx, cy, RESOLVE_SIZE, RESOLVE_SIZE); - - g.setForeground(strokeColor); - g.drawRectangle(cx, cy, RESOLVE_SIZE, RESOLVE_SIZE); - } - } - } - } - - private int[] getCenterCurvePoints(int startx, int starty, int endx, int endy) { - if (fBasicCenterCurve == null) - buildBaseCenterCurve(endx-startx); - double height= endy - starty; - height= height/2; - int width= endx-startx; - int[] points= new int[width]; - for (int i= 0; i < width; i++) { - points[i]= (int) (-height * fBasicCenterCurve[i] + height + starty); - } - return points; - } - - private void buildBaseCenterCurve(int w) { - double width= w; - fBasicCenterCurve= new double[getCenterWidth()]; - for (int i= 0; i < getCenterWidth(); i++) { - double r= i / width; - fBasicCenterCurve[i]= Math.cos(Math.PI * r); - } - } - - private void paintSides(GC g, MergeSourceViewer tp, Canvas canvas, boolean right) { - - Display display= canvas.getDisplay(); - - int lineHeight= tp.getTextWidget().getLineHeight(); - int visibleHeight= tp.getViewportHeight(); - - Point size= canvas.getSize(); - int x= 0; - int w= fMarginWidth; - int w2= w/2; - - g.setBackground(canvas.getBackground()); - g.fillRectangle(x, 0, w, size.y); - - if (!fIsMotif) { - // draw thin line between ruler and text - g.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); - if (right) - g.fillRectangle(0, 0, 1, size.y); - else - g.fillRectangle(size.x-1, 0, 1, size.y); - } - - if (! fHighlightRanges) - return; - - if (fChangeDiffs != null) { - int shift= tp.getVerticalScrollOffset() + (2-LW); - - Point region= new Point(0, 0); - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), region); - int y= (region.x * lineHeight) + shift; - int h= region.y * lineHeight; - - if (y+h < 0) - continue; - if (y >= visibleHeight) - break; - - g.setBackground(getColor(display, getFillColor(diff))); - if (right) - g.fillRectangle(x, y, w2, h); - else - g.fillRectangle(x+w2, y, w2, h); - - g.setLineWidth(LW); - g.setForeground(getColor(display, getStrokeColor(diff))); - if (right) - g.drawRectangle(x-1, y-1, w2, h); - else - g.drawRectangle(x+w2, y-1, w2, h); - } - } - } - - private void paint(PaintEvent event, MergeSourceViewer tp) { - - if (! fHighlightRanges) - return; - if (fChangeDiffs == null) - return; - - Control canvas= (Control) event.widget; - GC g= event.gc; - - Display display= canvas.getDisplay(); - - int lineHeight= tp.getTextWidget().getLineHeight(); - int w= canvas.getSize().x; - int shift= tp.getVerticalScrollOffset() + (2-LW); - int maxh= event.y+event.height; // visibleHeight - - //if (fIsMotif) - shift+= fTopInset; - - Point range= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), range); - int y= (range.x * lineHeight) + shift; - int h= range.y * lineHeight; - - if (y+h < event.y) - continue; - if (y > maxh) - break; - - g.setBackground(getColor(display, getStrokeColor(diff))); - g.fillRectangle(0, y-1, w, LW); - g.fillRectangle(0, y+h-1, w, LW); - } - } - - private RGB getFillColor(Diff diff) { - boolean selected= fCurrentDiff != null && fCurrentDiff.fParent == diff; - - RGB selected_fill= getBackground(null); - - if (isThreeWay() && !fIgnoreAncestor) { - switch (diff.fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return selected ? selected_fill : INCOMING_FILL; - return selected ? selected_fill : OUTGOING_FILL; - case RangeDifference.ANCESTOR: - return selected ? selected_fill : CONFLICT_FILL; - case RangeDifference.LEFT: - if (fLeftIsLocal) - return selected ? selected_fill : OUTGOING_FILL; - return selected ? selected_fill : INCOMING_FILL; - case RangeDifference.CONFLICT: - return selected ? selected_fill : CONFLICT_FILL; - } - return null; - } - return selected ? selected_fill : OUTGOING_FILL; - } - - private RGB getStrokeColor(Diff diff) { - boolean selected= fCurrentDiff != null && fCurrentDiff.fParent == diff; - - if (isThreeWay() && !fIgnoreAncestor) { - switch (diff.fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return selected ? SELECTED_INCOMING : INCOMING; - return selected ? SELECTED_OUTGOING : OUTGOING; - case RangeDifference.ANCESTOR: - return selected ? SELECTED_CONFLICT : CONFLICT; - case RangeDifference.LEFT: - if (fLeftIsLocal) - return selected ? SELECTED_OUTGOING : OUTGOING; - return selected ? SELECTED_INCOMING : INCOMING; - case RangeDifference.CONFLICT: - return selected ? SELECTED_CONFLICT : CONFLICT; - } - return null; - } - return selected ? SELECTED_OUTGOING : OUTGOING; - } - - private Color getColor(Display display, RGB rgb) { - if (rgb == null) - return null; - if (fColors == null) - fColors= new HashMap(20); - Color c= (Color) fColors.get(rgb); - if (c == null) { - c= new Color(display, rgb); - fColors.put(rgb, c); - } - return c; - } - - static RGB interpolate(RGB fg, RGB bg, double scale) { - if (fg != null && bg != null) - return new RGB( - (int)((1.0-scale) * fg.red + scale * bg.red), - (int)((1.0-scale) * fg.green + scale * bg.green), - (int)((1.0-scale) * fg.blue + scale * bg.blue) - ); - if (fg != null) - return fg; - if (bg != null) - return bg; - return new RGB(128, 128, 128); // a gray - } - - //---- Navigating and resolving Diffs - - /* - * Returns true if end (or beginning) of document reached. - */ - private boolean navigate(boolean down, boolean wrap, boolean deep) { - - Diff diff= null; - - for (;;) { - - if (fChangeDiffs != null) { - MergeSourceViewer part= fFocusPart; - if (part == null) - part= fRight; - - if (part != null) { - Point s= part.getSelectedRange(); - if (down) - diff= findNext(part, fChangeDiffs, s.x, s.x+s.y, deep); - else - diff= findPrev(part, fChangeDiffs, s.x, s.x+s.y, deep); - } - } - - if (diff == null) { // at end or beginning - if (wrap) { - if (!fEndOfDocReached) { - fEndOfDocReached= true; - if (! endOfDocumentReached(down)) - return true; - } - fEndOfDocReached= false; - if (fChangeDiffs != null && fChangeDiffs.size() > 0) { - if (down) - diff= (Diff) fChangeDiffs.get(0); - else - diff= (Diff) fChangeDiffs.get(fChangeDiffs.size()-1); - } - } else { - fEndOfDocReached= false; - return true; - } - } - - setCurrentDiff(diff, true); - - if (diff != null && diff.fDirection == RangeDifference.ANCESTOR - && !getAncestorEnabled()) - continue; - - break; - } - - return false; - } - - private boolean endOfDocumentReached(boolean down) { - Control c= getControl(); - if (Utilities.okToUse(c)) { - - c.getDisplay().beep(); - - String key= down ? "atEnd" : "atBeginning"; //$NON-NLS-1$ //$NON-NLS-2$ - return MessageDialog.openQuestion(c.getShell(), - CompareMessages.getString("TextMergeViewer."+key+".title"), //$NON-NLS-1$ //$NON-NLS-2$ - CompareMessages.getString("TextMergeViewer."+key+".message")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return false; - } - - /* - * Find the Diff that overlaps with the given TextPart's text range. - * If the range doesn't overlap with any range null - * is returned. - */ - private Diff findDiff(MergeSourceViewer tp, int rangeStart, int rangeEnd) { - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.overlaps(tp, rangeStart, rangeEnd)) - return diff; - } - } - return null; - } - - private static Diff findNext(MergeSourceViewer tp, List v, int start, int end, boolean deep) { - for (int i= 0; i < v.size(); i++) { - Diff diff= (Diff) v.get(i); - Position p= diff.getPosition(tp); - if (p != null) { - int startOffset= p.getOffset(); - if (end < startOffset) // <= - return diff; - if (deep && diff.fDiffs != null) { - Diff d= null; - int endOffset= startOffset + p.getLength(); - if (start == startOffset && (end == endOffset || end == endOffset-1)) { - d= findNext(tp, diff.fDiffs, start-1, start-1, deep); - } else if (end < endOffset) { - d= findNext(tp, diff.fDiffs, start, end, deep); - } - if (d != null) - return d; - } - } - } - return null; - } - - private static Diff findPrev(MergeSourceViewer tp, List v, int start, int end, boolean deep) { - for (int i= v.size()-1; i >= 0; i--) { - Diff diff= (Diff) v.get(i); - Position p= diff.getPosition(tp); - if (p != null) { - int startOffset= p.getOffset(); - int endOffset= startOffset + p.getLength(); - if (start > endOffset) - return diff; - if (deep && diff.fDiffs != null) { - Diff d= null; - if (start == startOffset && end == endOffset) { - d= findPrev(tp, diff.fDiffs, end, end, deep); - } else if (start >= startOffset) { - d= findPrev(tp, diff.fDiffs, start, end, deep); - } - if (d != null) - return d; - } - } - } - return null; - } - - /* - * Set the currently active Diff and update the toolbars controls and lines. - * If revealAndSelect is true the Diff is revealed and - * selected in both TextParts. - */ - private void setCurrentDiff(Diff d, boolean revealAndSelect) { - -// if (d == fCurrentDiff) -// return; - - if (fCenterButton != null) - fCenterButton.setVisible(false); - - fEndOfDocReached= false; - - Diff oldDiff= fCurrentDiff; - - if (d != null && revealAndSelect) { - - // before we set fCurrentDiff we change the selection - // so that the paint code uses the old background colors - // otherwise selection isn't drawn correctly - if (isThreeWay() && !fIgnoreAncestor) - fAncestor.setSelection(d.fAncestorPos); - fLeft.setSelection(d.fLeftPos); - fRight.setSelection(d.fRightPos); - - // now switch diffs - fCurrentDiff= d; - revealDiff(d, d.fIsToken); - } else { - fCurrentDiff= d; - } - - Diff d1= oldDiff != null ? oldDiff.fParent : null; - Diff d2= fCurrentDiff != null ? fCurrentDiff.fParent : null; - if (d1 != d2) { - updateDiffBackground(d1); - updateDiffBackground(d2); - } - - updateControls(); - invalidateLines(); - refreshBirdsEyeView(); - } - - /* - * Smart determines whether - */ - private void revealDiff(Diff d, boolean smart) { - - boolean ancestorIsVisible= false; - boolean leftIsVisible= false; - boolean rightIsVisible= false; - - if (smart) { - Point region= new Point(0, 0); - // find the starting line of the diff in all text widgets - int ls= fLeft.getLineRange(d.fLeftPos, region).x; - int rs= fRight.getLineRange(d.fRightPos, region).x; - - if (isThreeWay() && !fIgnoreAncestor) { - int as= fAncestor.getLineRange(d.fAncestorPos, region).x; - if (as >= fAncestor.getTopIndex() && as <= fAncestor.getBottomIndex()) - ancestorIsVisible= true; - } - - if (ls >= fLeft.getTopIndex() && ls <= fLeft.getBottomIndex()) - leftIsVisible= true; - - if (rs >= fRight.getTopIndex() && rs <= fRight.getBottomIndex()) - rightIsVisible= true; - } - - // vertical scrolling - if (!leftIsVisible || !rightIsVisible) { - int avpos= 0, lvpos= 0, rvpos= 0; - - MergeSourceViewer allButThis= null; - if (leftIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fLeft, fLeft.getTopIndex()); - allButThis= fLeft; - } else if (rightIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fRight, fRight.getTopIndex()); - allButThis= fRight; - } else if (ancestorIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex()); - allButThis= fAncestor; - } else { - if (fAllDiffs != null) { - int vpos= 0; - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - if (diff == d) - break; - if (fSynchronizedScrolling) { - vpos+= diff.getMaxDiffHeight(fShowAncestor); - } else { - avpos+= diff.getAncestorHeight(); - lvpos+= diff.getLeftHeight(); - rvpos+= diff.getRightHeight(); - } - } - if (fSynchronizedScrolling) - avpos= lvpos= rvpos= vpos; - } - int delta= fRight.getViewportLines()/4; - avpos-= delta; - if (avpos < 0) - avpos= 0; - lvpos-= delta; - if (lvpos < 0) - lvpos= 0; - rvpos-= delta; - if (rvpos < 0) - rvpos= 0; - } - - scrollVertical(avpos, lvpos, rvpos, allButThis); - - if (fVScrollBar != null) - fVScrollBar.setSelection(avpos); - } - - // horizontal scrolling - if (d.fIsToken) { - // we only scroll horizontally for token diffs - reveal(fAncestor, d.fAncestorPos); - reveal(fLeft, d.fLeftPos); - reveal(fRight, d.fRightPos); - } else { - // in all other cases we reset the horizontal offset - hscroll(fAncestor); - hscroll(fLeft); - hscroll(fRight); - } - } - - private static void reveal(MergeSourceViewer v, Position p) { - if (v != null && p != null) { - StyledText st= v.getTextWidget(); - if (st != null) { - Rectangle r= st.getClientArea(); - if (!r.isEmpty()) // workaround for #7320: Next diff scrolls when going into current diff - v.revealRange(p.offset, p.length); - } - } - } - - private static void hscroll(MergeSourceViewer v) { - if (v != null) { - StyledText st= v.getTextWidget(); - if (st != null) - st.setHorizontalIndex(0); - } - } - - //-------------------------------------------------------------------------------- - - void copyAllUnresolved(boolean leftToRight) { - if (fChangeDiffs != null && isThreeWay() && !fIgnoreAncestor) { - IRewriteTarget target= leftToRight ? fRight.getRewriteTarget() : fLeft.getRewriteTarget(); - boolean compoundChangeStarted= false; - Iterator e= fChangeDiffs.iterator(); - try { - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - switch (diff.fDirection) { - case RangeDifference.LEFT: - if (leftToRight) { - if (!compoundChangeStarted) { - target.beginCompoundChange(); - compoundChangeStarted= true; - } - copy(diff, leftToRight); - } - break; - case RangeDifference.RIGHT: - if (!leftToRight) { - if (!compoundChangeStarted) { - target.beginCompoundChange(); - compoundChangeStarted= true; - } - copy(diff, leftToRight); - } - break; - default: - continue; - } - } - } finally { - if (compoundChangeStarted) { - target.endCompoundChange(); - } - } - } - } - - /* - * Copy whole document from one side to the other. - */ - protected void copy(boolean leftToRight) { - - if (showResolveUI()) { - copyAllUnresolved(leftToRight); - invalidateLines(); - return; - } - - if (leftToRight) { - if (fLeft.getEnabled()) { - // copy text - String text= fLeft.getTextWidget().getText(); - fRight.getTextWidget().setText(text); - fRight.setEnabled(true); - } else { - // delete - fRight.getTextWidget().setText(""); //$NON-NLS-1$ - fRight.setEnabled(false); - } - fRightLineCount= fRight.getLineCount(); - setRightDirty(true); - } else { - if (fRight.getEnabled()) { - // copy text - String text= fRight.getTextWidget().getText(); - fLeft.getTextWidget().setText(text); - fLeft.setEnabled(true); - } else { - // delete - fLeft.getTextWidget().setText(""); //$NON-NLS-1$ - fLeft.setEnabled(false); - } - fLeftLineCount= fLeft.getLineCount(); - setLeftDirty(true); - } - doDiff(); - invalidateLines(); - updateVScrollBar(); - selectFirstDiff(); - refreshBirdsEyeView(); - } - - private void copyDiffLeftToRight() { - copy(fCurrentDiff, true, false); - } - - private void copyDiffRightToLeft() { - copy(fCurrentDiff, false, false); - } - - /* - * Copy the contents of the given diff from one side to the other. - */ - private void copy(Diff diff, boolean leftToRight, boolean gotoNext) { - if (copy(diff, leftToRight)) { - if (gotoNext) { - navigate(true, true, true); - } else { - revealDiff(diff, true); - updateControls(); - } - } - } - - /* - * Copy the contents of the given diff from one side to the other but - * doesn't reveal anything. - * Returns true if copy was succesful. - */ - private boolean copy(Diff diff, boolean leftToRight) { - - if (diff != null && !diff.isResolved()) { - - Position fromPos= null; - Position toPos= null; - IDocument fromDoc= null; - IDocument toDoc= null; - - if (leftToRight) { - fRight.setEnabled(true); - fromPos= diff.fLeftPos; - toPos= diff.fRightPos; - fromDoc= fLeft.getDocument(); - toDoc= fRight.getDocument(); - } else { - fLeft.setEnabled(true); - fromPos= diff.fRightPos; - toPos= diff.fLeftPos; - fromDoc= fRight.getDocument(); - toDoc= fLeft.getDocument(); - } - - if (fromDoc != null) { - - int fromStart= fromPos.getOffset(); - int fromLen= fromPos.getLength(); - - int toStart= toPos.getOffset(); - int toLen= toPos.getLength(); - - try { - String s= null; - - switch (diff.fDirection) { - case RangeDifference.RIGHT: - case RangeDifference.LEFT: - s= fromDoc.get(fromStart, fromLen); - break; - case RangeDifference.ANCESTOR: - break; - case RangeDifference.CONFLICT: - if (APPEND_CONFLICT) { - s= toDoc.get(toStart, toLen); - s+= fromDoc.get(fromStart, fromLen); - } else - s= fromDoc.get(fromStart, fromLen); - break; - } - if (s != null) { - toDoc.replace(toStart, toLen, s); - toPos.setOffset(toStart); - toPos.setLength(s.length()); - } - - } catch (BadLocationException e) { - // silently ignored - } - } - - diff.setResolved(true); - updateResolveStatus(); - - return true; - } - return false; - } - - //---- scrolling - - /* - * Calculates virtual height (in lines) of views by adding the maximum of corresponding diffs. - */ - private int getVirtualHeight() { - int h= 1; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - h+= diff.getMaxDiffHeight(fShowAncestor); - } - } - return h; - } - - /* - * Calculates height (in lines) of right view by adding the height of the right diffs. - */ - private int getRightHeight() { - int h= 1; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - h+= diff.getRightHeight(); - } - } - return h; - } - - /* - * The height of the TextEditors in lines. - */ - private int getViewportHeight() { - StyledText te= fLeft.getTextWidget(); - - int vh= te.getClientArea().height; - if (vh == 0) { - Rectangle trim= te.computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height; - - int headerHeight= getHeaderHeight(); - - Composite composite= (Composite) getControl(); - Rectangle r= composite.getClientArea(); - - vh= r.height-headerHeight-scrollbarHeight; - } - - return vh / te.getLineHeight(); - } - - /* - * Returns the virtual position for the given view position. - */ - private int realToVirtualPosition(MergeSourceViewer w, int vpos) { - - if (! fSynchronizedScrolling || fAllDiffs == null) - return vpos; - - int viewPos= 0; // real view position - int virtualPos= 0; // virtual position - Point region= new Point(0, 0); - - Iterator e= fAllDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - Position pos= diff.getPosition(w); - w.getLineRange(pos, region); - int realHeight= region.y; - int virtualHeight= diff.getMaxDiffHeight(fShowAncestor); - if (vpos <= viewPos + realHeight) { // OK, found! - vpos-= viewPos; // make relative to this slot - // now scale position within this slot to virtual slot - if (realHeight <= 0) - vpos= 0; - else - vpos= (vpos*virtualHeight)/realHeight; - return virtualPos+vpos; - } - viewPos+= realHeight; - virtualPos+= virtualHeight; - } - return virtualPos; - } - - private void scrollVertical(int avpos, int lvpos, int rvpos, MergeSourceViewer allBut) { - - int s= 0; - - if (fSynchronizedScrolling) { - s= getVirtualHeight() - rvpos; - int height= fRight.getViewportLines()/4; - if (s < 0) - s= 0; - if (s > height) - s= height; - } - - fInScrolling= true; - - if (isThreeWay() && allBut != fAncestor) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fAncestor, avpos+s)-s; - fAncestor.vscroll(y); - } - } - - if (allBut != fLeft) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fLeft, lvpos+s)-s; - fLeft.vscroll(y); - } - } - - if (allBut != fRight) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fRight, rvpos+s)-s; - fRight.vscroll(y); - } - } - - fInScrolling= false; - - if (isThreeWay() && fAncestorCanvas != null) - fAncestorCanvas.repaint(); - - if (fLeftCanvas != null) - fLeftCanvas.repaint(); - - Control center= getCenter(); - if (center instanceof BufferedCanvas) - ((BufferedCanvas)center).repaint(); - - if (fRightCanvas != null) - fRightCanvas.repaint(); - } - - /* - * Updates Scrollbars with viewports. - */ - private void syncViewport(MergeSourceViewer w) { - - if (fInScrolling) - return; - - int ix= w.getTopIndex(); - int ix2= w.getDocumentRegionOffset(); - - int viewPosition= realToVirtualPosition(w, ix-ix2); - - scrollVertical(viewPosition, viewPosition, viewPosition, w); // scroll all but the given views - - if (fVScrollBar != null) { - int value= Math.max(0, Math.min(viewPosition, getVirtualHeight() - getViewportHeight())); - fVScrollBar.setSelection(value); - //refreshBirdEyeView(); - } - } - - /** - */ - private void updateVScrollBar() { - - if (Utilities.okToUse(fVScrollBar) && fSynchronizedScrolling) { - int virtualHeight= getVirtualHeight(); - int viewPortHeight= getViewportHeight(); - int pageIncrement= viewPortHeight-1; - int thumb= (viewPortHeight > virtualHeight) ? virtualHeight : viewPortHeight; - - fVScrollBar.setPageIncrement(pageIncrement); - fVScrollBar.setMaximum(virtualHeight); - fVScrollBar.setThumb(thumb); - } - } - - /* - * maps given virtual position into a real view position of this view. - */ - private int virtualToRealPosition(MergeSourceViewer part, int v) { - - if (! fSynchronizedScrolling || fAllDiffs == null) - return v; - - int virtualPos= 0; - int viewPos= 0; - Point region= new Point(0, 0); - - Iterator e= fAllDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - Position pos= diff.getPosition(part); - int viewHeight= part.getLineRange(pos, region).y; - int virtualHeight= diff.getMaxDiffHeight(fShowAncestor); - if (v < (virtualPos + virtualHeight)) { - v-= virtualPos; // make relative to this slot - if (viewHeight <= 0) { - v= 0; - } else { - v= (v*viewHeight)/virtualHeight; - } - return viewPos+v; - } - virtualPos+= virtualHeight; - viewPos+= viewHeight; - } - return viewPos; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties deleted file mode 100644 index e9ea13317..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties +++ /dev/null @@ -1,98 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)TextMergeViewerResources.properties -# -# Resource strings for TextMergeViewer.java - -title= Text Compare - -saveDialog.title= Save Resource -saveDialog.message= Resource has been modified. Save changes? - -compareProgressTask.title= Computing Differences... - -tooComplexError.title= Error -tooComplexError.format= Too many differences. Turn on the ''Ignore White Space'' option or do a structure compare first. - -##################################################### -# Toolbar actions -##################################################### - -action.CopyLeftToRight.label=Copy Left to Right -action.CopyLeftToRight.tooltip=Copy All from Left to Right -action.CopyLeftToRight.image=copy_r_co.gif - -action.CopyRightToLeft.label=Copy Right to Left -action.CopyRightToLeft.tooltip=Copy All Non-Conflicting Changes from Right to Left -action.CopyRightToLeft.image=copy_l_co.gif - -action.CopyDiffLeftToRight.label=Copy Current Change to Right -action.CopyDiffLeftToRight.tooltip=Copy Current Change from Left to Right -action.CopyDiffLeftToRight.image=copycont_r_co.gif - -action.CopyDiffRightToLeft.label=Copy Current Change to Left -action.CopyDiffRightToLeft.tooltip=Copy Current Change from Right to Left -action.CopyDiffRightToLeft.image=copycont_l_co.gif - -action.NextDiff.label=Next -action.NextDiff.tooltip=Select Next Change -action.NextDiff.image=next_nav.gif - -action.PrevDiff.label=Previous -action.PrevDiff.tooltip=Select Previous Change -action.PrevDiff.image=prev_nav.gif - -action.EnableAncestor.label=Enable Ancestor Pane -action.EnableAncestor.tooltip.unchecked=Show Ancestor Pane -action.EnableAncestor.tooltip.checked=Hide Ancestor Pane -action.EnableAncestor.description.unchecked=Show Ancestor Pane -action.EnableAncestor.description.checked=Hide Ancestor Pane -action.EnableAncestor.image=ancestorpane_co.gif - -action.IgnoreAncestor.label=Ignore Ancestor -action.IgnoreAncestor.tooltip.unchecked=Two-Way Compare (Ignore Ancestor) -action.IgnoreAncestor.tooltip.checked=Three-Way Compare -action.IgnoreAncestor.description.unchecked=Two-Way Compare (Ignore Ancestor) -action.IgnoreAncestor.description.checked=Three-Way Compare -action.IgnoreAncestor.image=twowaycompare_co.gif - - -##################################################### -# Context menu actions -##################################################### - -action.undo.label=Undo@Ctrl+Z -action.undo.tooltip=Undo Last Operation - -action.redo.label=Redo@Ctrl+Y -action.redo.tooltip=Redo Last Operation - -action.cut.label=Cut@Ctrl+X -action.cut.tooltip=Cut Text Selection to Clipboard - -action.copy.label=Copy@Ctrl+C -action.copy.tooltip=Copy Text Selection to Clipboard - -action.paste.label=Paste@Ctrl+V -action.paste.tooltip=Replace Text Selection with Clipboard Contents - -action.delete.label=Delete -action.delete.tooltip=Delete Current Text Selection - -action.find.label=Find...@Ctrl+F -action.find.tooltip=Find Occurrence - -action.selectAll.label=Select All@Ctrl+A -action.selectAll.tooltip=Select All Changes - -action.save.label=Save@Ctrl+S -action.save.tooltip=Save Changes diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html deleted file mode 100644 index 9f606fb95..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - Package-level Javadoc - - -Support for compare and merge viewers which show the -content side-by-side. -

-Package Specification

- -The ContentMergeViewer is an abstract compare and merge viewer -with two side-by-side content areas and an optional content area for a -common ancestor (for three-way compare). Because the implementation makes -no assumptions about the content type it is a subclass responsibility to -deal with a specific type. Its subclass ImageMergeViewer in -package org.eclipse.compare.internal shows how to base a simple -mergeviewer for images on ContentMergeViewer. -

- -A ContentMergeViewer accesses its model by means of a content -provider which must implement the IMergeViewerContentProvider interface. -

- -The TextMergeViewer is the standard concrete subclass of -ContentMergeViewer for comparing and merging text content. -
-A text merge viewer uses the org.eclipse.compare.rangedifferencer.RangeDifferencer -to perform a textual, line-by-line comparison of two (or three) input documents. -For text lines that differ the TextMergeViewer uses an ITokenComparator -to find longest sequences of matching and non-matching tokens. -The TextMergeViewer's -default token compare works on characters separated by whitespace. If a -different strategy is needed (for example, Java tokens in a Java-aware -merge viewer), clients can create their own token comparators by implementing -the ITokenComparator interface. -

The TextMergeViewer not only works on whole documents but on -subranges of documents too. In this case the viewer's input must be an -IDocumentRange instead of an IDocument. - - - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java deleted file mode 100644 index 84e8f945c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.Viewer; - - -public abstract class AbstractViewer extends Viewer { - - public void setInput(Object input) { - // empty default implementation - } - - public Object getInput() { - return null; - } - - public ISelection getSelection() { - return null; - } - - public void setSelection(ISelection s, boolean reveal) { - // empty default implementation - } - - public void refresh() { - // empty default implementation - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java deleted file mode 100644 index 6708a0f69..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - - -public class AddFromHistoryAction extends BaseCompareAction { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.AddFromHistoryAction"; //$NON-NLS-1$ - - public AddFromHistoryAction() { - // empty default implementation - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getResources(selection).length == 1; - } - - protected void run(ISelection selection) { - - ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME); - String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - - Shell parentShell= CompareUIPlugin.getShell(); - AddFromHistoryDialog dialog= null; - - Object[] s= Utilities.getResources(selection); - - for (int i= 0; i < s.length; i++) { - Object o= s[i]; - if (o instanceof IContainer) { - IContainer container= (IContainer) o; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); - IProgressMonitor pm= pmdialog.getProgressMonitor(); - IFile[] states= null; - try { - states= container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, pm); - } catch (CoreException ex) { - pm.done(); - } - - if (states == null || states.length <= 0) { - String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ - MessageDialog.openInformation(parentShell, title, msg); - return; - } - - if (dialog == null) { - dialog= new AddFromHistoryDialog(parentShell, bundle); - dialog.setHelpContextId(ICompareContextIds.ADD_FROM_HISTORY_DIALOG); - } - - if (dialog.select(container, states)) { - - AddFromHistoryDialog.HistoryInput[] selected= dialog.getSelected(); - - if (selected != null && selected.length > 0) { - try { - updateWorkspace(bundle, parentShell, selected); - - } catch (InterruptedException x) { - // Do nothing. Operation has been canceled by user. - - } catch (InvocationTargetException x) { - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$ - } - } - } - } - } - } - - void createContainers(IResource resource) throws CoreException { - IContainer container= resource.getParent(); - if (container instanceof IFolder) { - IFolder parent= (IFolder) container; - if (parent != null && !parent.exists()) { - createContainers(parent); - parent.create(false, true, null); - } - } - } - - private void updateWorkspace(final ResourceBundle bundle, Shell shell, - final AddFromHistoryDialog.HistoryInput[] selected) - throws InvocationTargetException, InterruptedException { - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws InvocationTargetException { - try { - String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$ - pm.beginTask(taskName, selected.length); - - for (int i= 0; i < selected.length; i++) { - IFile file= selected[i].fFile; - IFileState fileState= selected[i].fFileState; - createContainers(file); - - SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 1); - try { - file.create(fileState.getContents(), false, subMonitor); - } finally { - subMonitor.done(); - } - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - pm.done(); - } - } - }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties deleted file mode 100644 index 2b5c046ea..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)AddFromHistoryAction.properties -# -# Resources for AddFromHistoryAction.java - -title= Restore from Local History - -memberPaneTitle= {0} - Available Files in Local History: - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -memberDescription= Check files to restore from local history: -editionDescription= Select an edition of a file: - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= {0} - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -buttonLabel= Restore - -noLocalHistoryError= No deleted resources in local history for selected container. -replaceError=Cannot replace resource (reason: {0}). - -taskName=Restoring diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java deleted file mode 100644 index 642c682f3..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java +++ /dev/null @@ -1,475 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.text.*; -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; - - -public class AddFromHistoryDialog extends ResizableDialog { - - static class HistoryInput implements ITypedElement, IEncodedStreamContentAccessor, IModificationDate { - IFile fFile; - IFileState fFileState; - - HistoryInput(IFile file, IFileState fileState) { - fFile= file; - fFileState= fileState; - } - public InputStream getContents() throws CoreException { - return new BufferedInputStream(fFileState.getContents()); - } - public String getCharset() { - String charset= null; - try { - charset= fFileState.getCharset(); - } catch (CoreException e) { - // fall through - } - if (charset == null) - charset= Utilities.getCharset(fFile); - return charset; - } - public String getName() { - return fFile.getName(); - } - public String getType() { - return fFile.getFileExtension(); - } - public Image getImage() { - return CompareUI.getImage(fFile); - } - public long getModificationDate() { - return fFileState.getModificationTime(); - } - } - - static class FileHistory { - private IFile fFile; - private IFileState[] fStates; - private int fSelected; - - FileHistory(IFile file) { - fFile= file; - } - - IFile getFile() { - return fFile; - } - - IFileState[] getStates() { - if (fStates == null) { - try { - fStates= fFile.getHistory(new NullProgressMonitor()); - } catch (CoreException ex) { - // NeedWork - } - } - return fStates; - } - - IFileState getSelectedState() { - return getStates()[fSelected]; - } - - void setSelected(IFileState state) { - for (int i= 0; i < fStates.length; i++) { - if (fStates[i] == state) { - fSelected= i; - return; - } - } - } - - HistoryInput getHistoryInput() { - return new HistoryInput(fFile, getSelectedState()); - } - - boolean isSelected(int index) { - return index == fSelected; - } - } - - private CompareConfiguration fCompareConfiguration; - private ArrayList fArrayList= new ArrayList(); - private FileHistory fCurrentFileHistory; - - // SWT controls - private CompareViewerSwitchingPane fContentPane; - private Button fCommitButton; - private Table fMemberTable; - private CompareViewerPane fMemberPane; - private Tree fEditionTree; - private CompareViewerPane fEditionPane; - private Image fDateImage; - private Image fTimeImage; - - - public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) { - super(parent, bundle); - - String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fDateImage= id.createImage(); - iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fTimeImage= id.createImage(); - } - - public boolean select(IContainer root, IFile[] inputFiles) { - - create(); // create widgets - - String format= Utilities.getString(fBundle, "memberPaneTitle"); //$NON-NLS-1$ - String title= MessageFormat.format(format, new Object[] { root.getName() }); - fMemberPane.setImage(CompareUI.getImage(root)); - fMemberPane.setText(title); - - // sort input files - final int count= inputFiles.length; - final IFile[] files= new IFile[count]; - for (int i= 0; i < count; i++) - files[i]= inputFiles[i]; - if (count > 1) - internalSort(files, 0, count-1); - - - String prefix= root.getFullPath().toString(); - - if (fMemberTable != null && !fMemberTable.isDisposed()) { - for (int i= 0; i < files.length; i++) { - IFile file= files[i]; - String path= file.getFullPath().toString(); - if (path.startsWith(prefix)) - path= path.substring(prefix.length()+1); - TableItem ti= new TableItem(fMemberTable, SWT.NONE); - ti.setImage(CompareUI.getImage(file)); - ti.setText(path); - ti.setData(new FileHistory(file)); - } - } - - open(); - - return (getReturnCode() == OK) && (fArrayList.size() > 0); - } - - HistoryInput[] getSelected() { - HistoryInput[] selected= new HistoryInput[fArrayList.size()]; - Iterator iter= fArrayList.iterator(); - for (int i= 0; iter.hasNext(); i++) { - FileHistory h= (FileHistory) iter.next(); - selected[i]= h.getHistoryInput(); - } - return selected; - } - - protected synchronized Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - org.eclipse.compare.Splitter vsplitter= new org.eclipse.compare.Splitter(parent, SWT.VERTICAL); - vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - vsplitter.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fDateImage != null) - fDateImage.dispose(); - if (fTimeImage != null) - fTimeImage.dispose(); - } - } - ); - - // we need two panes: the left for the elements, the right one for the editions - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - Composite c= new Composite(hsplitter, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 2; - layout.verticalSpacing= 2; - layout.numColumns= 1; - c.setLayout(layout); - Label l1= new Label(c, SWT.NONE); - l1.setText(Utilities.getString(fBundle, "memberDescription")); //$NON-NLS-1$ - fMemberPane= new CompareViewerPane(c, SWT.BORDER | SWT.FLAT); - GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - fMemberPane.setLayoutData(gd); - - fMemberTable= new Table(fMemberPane, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL); - fMemberTable.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (e.detail == SWT.CHECK) { - if (e.item instanceof TableItem) { - TableItem ti= (TableItem) e.item; - if (ti.getChecked()) - fArrayList.add(ti.getData()); - else - fArrayList.remove(ti.getData()); - - if (fCommitButton != null) - fCommitButton.setEnabled(fArrayList.size() > 0); - } - } else { - handleMemberSelect(e.item); - } - } - } - ); - - fMemberPane.setContent(fMemberTable); - - c= new Composite(hsplitter, SWT.NONE); - layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 2; - layout.verticalSpacing= 2; - layout.numColumns= 1; - c.setLayout(layout); - Label l2= new Label(c, SWT.NONE); - l2.setText(Utilities.getString(fBundle, "editionDescription")); //$NON-NLS-1$ - fEditionPane= new CompareViewerPane(c, SWT.BORDER | SWT.FLAT); - gd= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - fEditionPane.setLayoutData(gd); - - fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL | SWT.V_SCROLL); - fEditionTree.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - feedContent(e.item); - } - } - ); - fEditionPane.setContent(fEditionTree); - - applyDialogFont(parent); // to avoid applying font to compare viewer - fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, input, this, fCompareConfiguration); - } - }; - vsplitter.setWeights(new int[] { 30, 70 }); - - return parent; - } - - /* - * Feeds selection from member viewer to edition viewer. - */ - private void handleMemberSelect(Widget w) { - Object data= null; - if (w != null) - data= w.getData(); - if (data instanceof FileHistory) { - - FileHistory h= (FileHistory) data; - fCurrentFileHistory= h; - - IFile file= h.getFile(); - IFileState[] states= h.getStates(); - - fEditionPane.setImage(CompareUI.getImage(file)); - String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(pattern, new Object[] { file.getName() }); - fEditionPane.setText(title); - - if (fEditionTree != null) { - fEditionTree.setRedraw(false); - fEditionTree.removeAll(); - for (int i= 0; i < states.length; i++) { - addEdition(new HistoryInput(file, states[i]), h.isSelected(i)); - } - fEditionTree.setRedraw(true); - } - } else - fCurrentFileHistory= null; - } - - /* - * Adds the given Pair to the edition tree. - * It takes care of creating tree nodes for different dates. - */ - private void addEdition(HistoryInput input, boolean isSelected) { - if (fEditionTree == null || fEditionTree.isDisposed()) - return; - - IFileState state= input.fFileState; - - // find last day - TreeItem[] days= fEditionTree.getItems(); - TreeItem lastDay= null; - if (days.length > 0) - lastDay= days[days.length-1]; - - long ldate= state.getModificationTime(); - long day= dayNumber(ldate); - Date date= new Date(ldate); - if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) { - lastDay= new TreeItem(fEditionTree, SWT.NONE); - lastDay.setImage(fDateImage); - String df= DateFormat.getDateInstance().format(date); - long today= dayNumber(System.currentTimeMillis()); - - String formatKey; - if (day == today) - formatKey= "todayFormat"; //$NON-NLS-1$ - else if (day == today-1) - formatKey= "yesterdayFormat"; //$NON-NLS-1$ - else - formatKey= "dayFormat"; //$NON-NLS-1$ - String pattern= Utilities.getString(fBundle, formatKey); - if (pattern != null) - df= MessageFormat.format(pattern, new String[] { df }); - lastDay.setText(df); - lastDay.setData(date); - } - TreeItem ti= new TreeItem(lastDay, SWT.NONE); - ti.setImage(fTimeImage); - ti.setText(DateFormat.getTimeInstance().format(date)); - ti.setData(input); - - if (isSelected) { - lastDay.setExpanded(true); - fEditionTree.setSelection(new TreeItem[] { ti }); - feedContent(ti); - } - } - - /* - * Returns the number of s since Jan 1st, 1970. - * The given date is converted to GMT and daylight saving is taken into account too. - */ - private long dayNumber(long date) { - int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds - - Calendar calendar= Calendar.getInstance(); - long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); - - return (date + localTimeOffset) / ONE_DAY_MS; - } - - /* - * Feeds the tree viewer's selection to the contentviewer - */ - private void feedContent(Widget w) { - if (fContentPane != null && !fContentPane.isDisposed()) { - Object o= w.getData(); - if (o instanceof HistoryInput) { - HistoryInput selected= (HistoryInput) o; - fContentPane.setInput(selected); - fContentPane.setText(getEditionLabel(selected)); - fContentPane.setImage(fTimeImage); - - if (fCurrentFileHistory != null) - fCurrentFileHistory.setSelected(selected.fFileState); - } else { - fContentPane.setInput(null); - } - } - } - - protected String getEditionLabel(HistoryInput input) { - String format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - long modDate= input.getModificationDate(); - String date= DateFormat.getDateTimeInstance().format(new Date(modDate)); - - return MessageFormat.format(format, new Object[] { date }); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$ - // a 'Cancel' and a 'Add' button - fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true); - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /* - * Returns true if the pathname of f1 comes after f2 - */ - private static boolean greaterThan(IFile f1, IFile f2) { - String[] ss1= f1.getFullPath().segments(); - String[] ss2= f2.getFullPath().segments(); - int l1= ss1.length; - int l2= ss2.length; - int n= Math.max(l1, l2); - - for (int i= 0; i < n; i++) { - String s1= i < l1 ? ss1[i] : ""; //$NON-NLS-1$ - String s2= i < l2 ? ss2[i] : ""; //$NON-NLS-1$ - int rc= s1.compareToIgnoreCase(s2); - if (rc != 0) - return rc < 0; - } - return false; - } - - private static void internalSort(IFile[] keys, int left, int right) { - - int original_left= left; - int original_right= right; - - IFile mid= keys[(left + right) / 2]; - do { - while (greaterThan(keys[left], mid)) - left++; - - while (greaterThan(mid, keys[right])) - right--; - - if (left <= right) { - IFile tmp= keys[left]; - keys[left]= keys[right]; - keys[right]= tmp; - left++; - right--; - } - } while (left <= right); - - if (original_left < right) - internalSort(keys, original_left, right); - - if (left < original_right) - internalSort(keys, left, original_right); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java deleted file mode 100644 index 7771b93d3..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IActionDelegate; - - -public abstract class BaseCompareAction implements IActionDelegate { - - private ISelection fSelection; - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - final public void run(IAction action) { - run(fSelection); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - final public void selectionChanged(IAction action, ISelection selection) { - fSelection= selection; - if (action != null) - action.setEnabled(isEnabled(fSelection)); - } - - protected boolean isEnabled(ISelection selection) { - return false; - } - - abstract protected void run(ISelection selection); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java deleted file mode 100644 index 708bd181e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.util.ResourceBundle; -import java.text.MessageFormat; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - -/** - * A simple compare viewer for binary files. - * Shows the position of the first non-matching byte. - */ -public class BinaryCompareViewer extends AbstractViewer { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$ - - private static final int EOF= -1; - private Label fControl; - private ICompareInput fInput; - private ResourceBundle fBundle; - private boolean fLeftIsLocal; - - - public BinaryCompareViewer(Composite parent, CompareConfiguration cc) { - - WorkbenchHelp.setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW); - - fBundle= ResourceBundle.getBundle(BUNDLE_NAME); - - fControl= new Label(parent, SWT.WRAP); - fControl.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - } - - public Control getControl() { - return fControl; - } - - public void setInput(Object input) { - if (fControl != null && input instanceof ICompareInput) { - fInput= (ICompareInput) input; - - InputStream left= null; - InputStream right= null; - - String message= null; - try { - left= getStream(fInput.getLeft()); - right= getStream(fInput.getRight()); - - if (left != null && right != null) { - int pos= 0; - while (true) { - int l= left.read(); - int r= right.read(); - if (l != r) { - String format= Utilities.getString(fBundle, "diffMessageFormat"); //$NON-NLS-1$ - message= MessageFormat.format(format, new String[] { Integer.toString(pos) } ); - break; - } - if (l == EOF) - break; - pos++; - } - } else if (left == null && right == null) { - message= Utilities.getString(fBundle, "deleteConflictMessage"); //$NON-NLS-1$ - } else if (left == null) { - if (fLeftIsLocal) - message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ - else - message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ - } else if (right == null) { - if (fLeftIsLocal) - message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ - else - message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ - } - } catch (CoreException ex) { - message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ - } catch (IOException ex) { - message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ - } finally { - Utilities.close(left); - Utilities.close(right); - } - if (message != null) - fControl.setText(message); - } - } - - public Object getInput() { - return fInput; - } - - private InputStream getStream(ITypedElement input) throws CoreException { - if (input instanceof IStreamContentAccessor) - return ((IStreamContentAccessor)input).getContents(); - return null; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java deleted file mode 100644 index 8c98ec6ff..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; - -/** - * A factory object for the BinaryCompareViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class BinaryCompareViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new BinaryCompareViewer(parent, mp); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties deleted file mode 100644 index dbfc7d70e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)BinaryCompareViewerResources.properties -# -# Resource strings for BinaryCompareViewer.java - -title= Binary Compare - -diffMessageFormat= First bytes differ at position {0} -deleteConflictMessage= Delete Conflict -addedMessage= Added Resource -deletedMessage= Removed Resource -errorMessage= Internal Error diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java deleted file mode 100644 index 3e20f3d67..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.events.*; - -/** - * A Canvas which reduces flicker by drawing in an off screen buffer. - */ -public abstract class BufferedCanvas extends Canvas { - - //private static final boolean USE_DOUBLE_BUFFER= !"carbon".equals(SWT.getPlatform()); //$NON-NLS-1$ - private static final boolean USE_DOUBLE_BUFFER= true; - - /** The drawable for double buffering */ - Image fBuffer; - - public BufferedCanvas(Composite parent, int flags) { - super(parent, flags + SWT.NO_BACKGROUND); - - addPaintListener( - new PaintListener() { - public void paintControl(PaintEvent event) { - doubleBufferPaint(event.gc); - } - } - ); - - addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fBuffer != null) { - fBuffer.dispose(); - fBuffer= null; - } - } - } - ); - } - - public void repaint() { - if (!isDisposed()) { - GC gc= new GC(this); - doubleBufferPaint(gc); - gc.dispose(); - } - } - - /* - * Double buffer drawing. - */ - void doubleBufferPaint(GC dest) { - - if (!USE_DOUBLE_BUFFER) { - doPaint(dest); - return; - } - - Point size= getSize(); - - if (size.x <= 1 || size.y <= 1) // we test for <= 1 because on X11 controls have initial size 1,1 - return; - - if (fBuffer != null) { - Rectangle r= fBuffer.getBounds(); - if (r.width != size.x || r.height != size.y) { - fBuffer.dispose(); - fBuffer= null; - } - } - if (fBuffer == null) - fBuffer= new Image(getDisplay(), size.x, size.y); - - GC gc= new GC(fBuffer); - try { - gc.setBackground(getBackground()); - gc.fillRectangle(0, 0, size.x, size.y); - doPaint(gc); - } finally { - gc.dispose(); - } - - dest.drawImage(fBuffer, 0, 0); - } - - abstract public void doPaint(GC gc); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java deleted file mode 100644 index 4ab61058b..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; - -/** - * A buffer for a workspace resource. - */ -public class BufferedResourceNode extends ResourceNode { - - private boolean fDirty= false; - private IFile fDeleteFile; - - /** - * Creates a ResourceNode for the given resource. - * - * @param resource the resource - */ - public BufferedResourceNode(IResource resource) { - super(resource); - } - - /* - * Returns true if buffer contains uncommitted changes. - */ - public boolean isDirty() { - return fDirty; - } - - protected IStructureComparator createChild(IResource child) { - return new BufferedResourceNode(child); - } - - public void setContent(byte[] contents) { - fDirty= true; - super.setContent(contents); - } - - /* - * Commits buffered contents to resource. - */ - public void commit(IProgressMonitor pm) throws CoreException { - if (fDirty) { - - if (fDeleteFile != null) { - fDeleteFile.delete(true, true, pm); - return; - } - - IResource resource= getResource(); - if (resource instanceof IFile) { - - byte[] bytes= getContent(); - ByteArrayInputStream is= new ByteArrayInputStream(bytes); - try { - IFile file= (IFile) resource; - if (file.exists()) - file.setContents(is, false, true, pm); - else - file.create(is, false, pm); - fDirty= false; - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // Silently ignored - } - } - } - } - } - - public ITypedElement replace(ITypedElement child, ITypedElement other) { - - if (child == null) { // add resource - // create a node without a resource behind it! - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(other.getName()); - child= new BufferedResourceNode(file); - } - } - - if (other == null) { // delete resource - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(child.getName()); - if (file != null && file.exists()) { - fDeleteFile= file; - fDirty= true; - } - } - return null; - } - - if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) { - IEditableContent dst= (IEditableContent) child; - - try { - InputStream is= ((IStreamContentAccessor)other).getContents(); - byte[] bytes= Utilities.readBytes(is); - if (bytes != null) - dst.setContent(bytes); - } catch (CoreException ex) { - // NeedWork - } - } - return child; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java deleted file mode 100644 index 824ed3e1c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.jface.action.Action; -import org.eclipse.compare.CompareConfiguration; - -/** - * Toggles a boolean property of an ICompareConfiguration. - */ -public class ChangePropertyAction extends Action { - - private CompareConfiguration fCompareConfiguration; - private String fPropertyKey; - private ResourceBundle fBundle; - private String fPrefix; - - - public ChangePropertyAction(ResourceBundle bundle, CompareConfiguration cc, String rkey, String pkey) { - fPropertyKey= pkey; - fBundle= bundle; - fPrefix= rkey; - Utilities.initAction(this, fBundle, fPrefix); - setCompareConfiguration(cc); - } - - public void run() { - boolean b= !Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false); - setChecked(b); - if (fCompareConfiguration != null) - fCompareConfiguration.setProperty(fPropertyKey, new Boolean(b)); - } - - public void setChecked(boolean state) { - super.setChecked(state); - Utilities.initToggleAction(this, fBundle, fPrefix, state); - } - - public void setCompareConfiguration(CompareConfiguration cc) { - fCompareConfiguration= cc; - setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false)); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java deleted file mode 100644 index 7495c6158..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareUI; - - -/* - * The "Compare with each other" action - */ -public class CompareAction extends BaseCompareAction implements IObjectActionDelegate { - - private ResourceCompareInput fInput; - private IWorkbenchPage fWorkbenchPage; - - - public void run(ISelection selection) { - if (fInput != null) { - fInput.setSelection(selection); - fInput.initializeCompareConfiguration(); - CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage); - fInput= null; // don't reuse this input! - } - } - - protected boolean isEnabled(ISelection selection) { - if (fInput == null) { - CompareConfiguration cc= new CompareConfiguration(); - // buffered merge mode: don't ask for confirmation - // when switching between modified resources - cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false)); - - // uncomment following line to have separate outline view - //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, new Boolean(true)); - - fInput= new ResourceCompareInput(cc); - } - return fInput.isEnabled(selection); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fWorkbenchPage= targetPart.getSite().getPage(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java deleted file mode 100644 index 3116aca44..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -import org.eclipse.swt.layout.GridData; -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.ui.actions.WorkspaceModifyOperation; - - -public class CompareDialog extends ResizableDialog implements IPropertyChangeListener { - - private CompareEditorInput fCompareEditorInput; - private Button fCommitButton; - - - CompareDialog(Shell shell, CompareEditorInput input) { - super(shell, null); - - Assert.isNotNull(input); - fCompareEditorInput= input; - fCompareEditorInput.addPropertyChangeListener(this); - setHelpContextId(ICompareContextIds.COMPARE_DIALOG); - } - - public boolean close() { - if (super.close()) { - if (fCompareEditorInput != null) - fCompareEditorInput.addPropertyChangeListener(this); - return true; - } - return false; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - fCommitButton= createButton(parent, IDialogConstants.OK_ID, Utilities.getString("CompareDialog.commitAction.label"), true); //$NON-NLS-1$ - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - public void propertyChange(PropertyChangeEvent event) { - if (fCommitButton != null && fCompareEditorInput != null) - fCommitButton.setEnabled(fCompareEditorInput.isSaveNeeded()); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - Control c= fCompareEditorInput.createContents(parent); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Shell shell= c.getShell(); - shell.setText(fCompareEditorInput.getTitle()); - shell.setImage(fCompareEditorInput.getTitleImage()); - applyDialogFont(parent); - return parent; - } - - /* (non-Javadoc) - * Method declared on Window. - */ - public int open() { - - int rc= super.open(); - - if (rc == OK && fCompareEditorInput.isSaveNeeded()) { - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws CoreException { - fCompareEditorInput.saveChanges(pm); - } - }; - - Shell shell= getParentShell(); - ProgressMonitorDialog pmd= new ProgressMonitorDialog(shell); - try { - operation.run(pmd.getProgressMonitor()); - - } catch (InterruptedException x) { - // NeedWork - } catch (OperationCanceledException x) { - // NeedWork - } catch (InvocationTargetException x) { - String title= Utilities.getString("CompareDialog.saveErrorTitle"); //$NON-NLS-1$ - String msg= Utilities.getString("CompareDialog.saveErrorMessage"); //$NON-NLS-1$ - MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage()); - } - } - - return rc; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java deleted file mode 100644 index 9be68cb7d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.util.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.EditorPart; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; - - -/** - * A CompareEditor takes a ICompareEditorInput as input. - * Most functionality is delegated to the ICompareEditorInput. - */ -public class CompareEditor extends EditorPart implements IReusableEditor { - - /** - * Internal property change listener for handling changes in the editor's input. - */ - class PropertyChangeListener implements IPropertyChangeListener { - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - CompareEditor.this.propertyChange(event); - } - } - - public final static String CONFIRM_SAVE_PROPERTY= "org.eclipse.compare.internal.CONFIRM_SAVE_PROPERTY"; //$NON-NLS-1$ - - private IActionBars fActionBars; - /** The editor's property change listener. */ - private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener(); - /** the SWT control */ - private Control fControl; - /** the outline page */ - private CompareOutlinePage fOutlinePage; - /** enable outline */ - - - public CompareEditor() { - // empty default implementation - } - - /* (non-Javadoc) - * Method declared on IAdaptable - */ - public Object getAdapter(Class key) { - - if (key.equals(IContentOutlinePage.class)) { - Object object= getCompareConfiguration().getProperty(CompareConfiguration.USE_OUTLINE_VIEW); - if (object instanceof Boolean && ((Boolean)object).booleanValue()) { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) { - fOutlinePage= new CompareOutlinePage((CompareEditorInput) input); - return fOutlinePage; - } - } - } - return super.getAdapter(key); - } - - /* package */ CompareConfiguration getCompareConfiguration() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - return ((CompareEditorInput)input).getCompareConfiguration(); - return null; - } - - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - - if (!(input instanceof CompareEditorInput)) - throw new PartInitException(Utilities.getString("CompareEditor.invalidInput")); //$NON-NLS-1$ - - setSite(site); - setInput(input); - } - - public void setInput(IEditorInput input) { - try { - doSetInput(input); - } catch (CoreException x) { - String title= Utilities.getString("CompareEditor.error.setinput.title"); //$NON-NLS-1$ - String msg= Utilities.getString("CompareEditor.error.setinput.message"); //$NON-NLS-1$ - ErrorDialog.openError(getSite().getShell(), title, msg, x.getStatus()); - } - } - - public void doSetInput(IEditorInput input) throws CoreException { - - if (!(input instanceof CompareEditorInput)) { - IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, Utilities.getString("CompareEditor.invalidInput"), null); //$NON-NLS-1$ - throw new CoreException(s); - } - - IEditorInput oldInput= getEditorInput(); - if (oldInput instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).removePropertyChangeListener(fPropertyChangeListener); - - super.setInput(input); - - CompareEditorInput cei= (CompareEditorInput) input; - - setTitleImage(cei.getTitleImage()); - setPartName(cei.getTitle()); // was setTitle(cei.getTitle()); - - if (input instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).addPropertyChangeListener(fPropertyChangeListener); - - if (oldInput != null) { - if (fControl != null && !fControl.isDisposed()) { - Point oldSize= fControl.getSize(); - Composite parent= fControl.getParent(); - fControl.dispose(); - createPartControl(parent); - if (fControl != null) - fControl.setSize(oldSize); - } - } - } - - public IActionBars getActionBars() { - return fActionBars; - } - - public void setActionBars(IActionBars actionBars) { - fActionBars= actionBars; - } - - /* - * @see IDesktopPart#createPartControl(Composite) - */ - public void createPartControl(Composite parent) { - parent.setData(this); - - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) { - fControl= ((CompareEditorInput) input).createContents(parent); - WorkbenchHelp.setHelp(fControl, ICompareContextIds.COMPARE_EDITOR); - } - } - - /* - * @see DesktopPart#dispose - */ - public void dispose() { - - IEditorInput input= getEditorInput(); - if (input instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).removePropertyChangeListener(fPropertyChangeListener); - - super.dispose(); - - fPropertyChangeListener= null; - } - - /* - * @see IDesktopPart#setFocus - */ - public void setFocus() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - ((CompareEditorInput)input).setFocus(); - } - - /* - * @see IEditorPart#isSaveAsAllowed() - */ - public boolean isSaveAsAllowed() { - return false; - } - - public void gotoMarker(IMarker marker) { - // empty default implemenatation - } - - /** - * Always throws an AssertionFailedException. - */ - /* - * @see IEditorPart#doSaveAs() - */ - public void doSaveAs() { - Assert.isTrue(false); // Save As not supported for CompareEditor - } - - /* - * @see IEditorPart#doSave() - */ - public void doSave(IProgressMonitor progressMonitor) { - - final IEditorInput input= getEditorInput(); - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws CoreException { - if (input instanceof CompareEditorInput) - ((CompareEditorInput)input).saveChanges(pm); - } - }; - - Shell shell= getSite().getShell(); - - try { - - operation.run(progressMonitor); - - firePropertyChange(PROP_DIRTY); - - } catch (InterruptedException x) { - // NeedWork - } catch (OperationCanceledException x) { - // NeedWork - } catch (InvocationTargetException x) { - String title= Utilities.getString("CompareEditor.saveError.title"); //$NON-NLS-1$ - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(shell, title, Utilities.getFormattedString("CompareEditor.cantSaveError", reason)); //$NON-NLS-1$ - } - } - - /* - * @see IEditorPart#isDirty() - */ - public boolean isDirty() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - return ((CompareEditorInput)input).isSaveNeeded(); - return false; - } - - public void propertyChange(PropertyChangeEvent event) { - Object old_value= event.getOldValue(); - Object new_value= event.getNewValue(); - if (old_value == null || new_value == null || !old_value.equals(new_value)) - firePropertyChange(PROP_DIRTY); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java deleted file mode 100644 index 672b1327d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.jface.action.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.EditorActionBarContributor; - -import org.eclipse.compare.*; - - -public class CompareEditorContributor extends EditorActionBarContributor { - - private IEditorPart fActiveEditorPart= null; - - private IgnoreWhiteSpaceAction fIgnoreWhitespace; - private NavigationAction fNext; - private NavigationAction fPrevious; - - private NavigationAction fToolbarNext; - private NavigationAction fToolbarPrevious; - - - public CompareEditorContributor() { - ResourceBundle bundle= CompareUI.getResourceBundle(); - - fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null); - WorkbenchHelp.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION); - - fNext= new NavigationAction(bundle, true); - WorkbenchHelp.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION); - - fPrevious= new NavigationAction(bundle, false); - WorkbenchHelp.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION); - - fToolbarNext= new NavigationAction(bundle, true); - WorkbenchHelp.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION); - - fToolbarPrevious= new NavigationAction(bundle, false); - WorkbenchHelp.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION); - } - - /* - * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public void contributeToToolBar(IToolBarManager tbm) { - tbm.add(new Separator()); - tbm.add(fIgnoreWhitespace); - tbm.add(fToolbarNext); - tbm.add(fToolbarPrevious); - } - - /* - * @see EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public void contributeToMenu(IMenuManager menuManager) { - // empty implementation - } - - public void setActiveEditor(IEditorPart targetEditor) { - - if (fActiveEditorPart == targetEditor) - return; - - fActiveEditorPart= targetEditor; - - if (fActiveEditorPart != null) { - IEditorInput input= fActiveEditorPart.getEditorInput(); - if (input instanceof CompareEditorInput) { - CompareEditorInput compareInput= (CompareEditorInput) input; - fNext.setCompareEditorInput(compareInput); - fPrevious.setCompareEditorInput(compareInput); - // Begin fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105 - fToolbarNext.setCompareEditorInput(compareInput); - fToolbarPrevious.setCompareEditorInput(compareInput); - // End fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105 - } - } - - if (targetEditor instanceof CompareEditor) { - IActionBars actionBars= getActionBars(); - - CompareEditor editor= (CompareEditor) targetEditor; - editor.setActionBars(actionBars); - - actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNext); - actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPrevious); - - CompareConfiguration cc= editor.getCompareConfiguration(); - fIgnoreWhitespace.setCompareConfiguration(cc); - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java deleted file mode 100644 index abcea3bae..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java +++ /dev/null @@ -1,397 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.text.MessageFormat; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.runtime.IStatus; - - -public class CompareFilter { - private static final char[][] NO_CHAR_CHAR= new char[0][]; - - private char[][] fExtraResourceFileFilters; - private String[] fExtraResourceFolderFilters; - - - public CompareFilter() { - // nothing to do - } - - /* - * Returns true if path matches filter, that is if path should be filtered. - */ - public boolean filter(String path0, boolean folder, boolean isArchive) { - if (!folder && fExtraResourceFileFilters != null) { - char[] name= path0.toCharArray(); - for (int i= 0, l= fExtraResourceFileFilters.length; i < l; i++) - if (match(fExtraResourceFileFilters[i], name, true)) - return true; - } - if (folder && fExtraResourceFolderFilters != null) { - for (int i= 0, l= fExtraResourceFolderFilters.length; i < l; i++) - if (fExtraResourceFolderFilters[0].equals(path0)) - return true; - } - return false; - } - - public static String validateResourceFilters(String text) { - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - String[] filters= getTokens(text, ","); //$NON-NLS-1$ - for (int i= 0; i < filters.length; i++) { - String fileName= filters[i].replace('*', 'x'); - int resourceType= IResource.FILE; - int lastCharacter= fileName.length() - 1; - if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') { - fileName= fileName.substring(0, lastCharacter); - resourceType= IResource.FOLDER; - } - IStatus status= workspace.validateName(fileName, resourceType); - if (status.matches(IStatus.ERROR)) { - String format= Utilities.getString("ComparePreferencePage.filter.invalidsegment.error"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] { status.getMessage() } ); - } - } - return null; - } - - public void setFilters(String filterSequence) { - char[][] filters= filterSequence != null && filterSequence.length() > 0 - ? splitAndTrimOn(',', filterSequence.toCharArray()) - : null; - if (filters == null) { - fExtraResourceFileFilters= null; - fExtraResourceFolderFilters= null; - } else { - int fileCount= 0, folderCount= 0; - for (int i= 0, l= filters.length; i < l; i++) { - char[] f= filters[i]; - if (f.length == 0) - continue; - if (f[f.length - 1] == '/') - folderCount++; - else - fileCount++; - } - fExtraResourceFileFilters= new char[fileCount][]; - fExtraResourceFolderFilters= new String[folderCount]; - for (int i= 0, l= filters.length; i < l; i++) { - char[] f= filters[i]; - if (f.length == 0) - continue; - if (f[f.length - 1] == '/') - fExtraResourceFolderFilters[--folderCount]= new String(subarray(f, 0, f.length - 1)); - else - fExtraResourceFileFilters[--fileCount]= f; - } - } - } - - ///////// - - private static String[] getTokens(String text, String separator) { - StringTokenizer tok= new StringTokenizer(text, separator); //$NON-NLS-1$ - int nTokens= tok.countTokens(); - String[] res= new String[nTokens]; - for (int i= 0; i < res.length; i++) - res[i]= tok.nextToken().trim(); - return res; - } - - /** - * Answers true if the pattern matches the given name, false otherwise. - * This char[] pattern matching accepts wild-cards '*' and '?'. - * - * When not case sensitive, the pattern is assumed to already be - * lowercased, the name will be lowercased character per character as - * comparing. If name is null, the answer is false. If pattern is null, the - * answer is true if name is not null.

For example: - *

    - *
  1. - * - *
    -	 *  pattern = { '?', 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => true
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  pattern = { '?', 'b', '?' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  4. - *
  5. - * - *
    -	 *  pattern = { 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  6. - *
- * - * @param pattern - * the given pattern - * @param name - * the given name - * @param isCaseSensitive - * flag to know whether or not the matching should be case - * sensitive - * @return true if the pattern matches the given name, false otherwise - */ - private boolean match(char[] pattern, char[] name, boolean isCaseSensitive) { - if (name == null) - return false; // null name cannot match - if (pattern == null) - return true; // null pattern is equivalent to '*' - return match(pattern, 0, pattern.length, name, 0, name.length, isCaseSensitive); - } - - /** - * Answers true if the a sub-pattern matches the subpart of the given name, - * false otherwise. char[] pattern matching, accepting wild-cards '*' and - * '?'. Can match only subset of name/pattern. end positions are - * non-inclusive. The subpattern is defined by the patternStart and - * pattternEnd positions. When not case sensitive, the pattern is assumed - * to already be lowercased, the name will be lowercased character per - * character as comparing.

For example: - *
    - *
  1. - * - *
    -	 *  pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 3 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 4 isCaseSensitive = true result => true
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 2 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 2 isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  4. - *
- * - * @param pattern - * the given pattern - * @param patternStart - * the given pattern start - * @param patternEnd - * the given pattern end - * @param name - * the given name - * @param nameStart - * the given name start - * @param nameEnd - * the given name end - * @param isCaseSensitive - * flag to know if the matching should be case sensitive - * @return true if the a sub-pattern matches the subpart of the given name, - * false otherwise - */ - private boolean match(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, - boolean isCaseSensitive) { - if (name == null) - return false; // null name cannot match - if (pattern == null) - return true; // null pattern is equivalent to '*' - int iPattern= patternStart; - int iName= nameStart; - if (patternEnd < 0) - patternEnd= pattern.length; - if (nameEnd < 0) - nameEnd= name.length; - /* check first segment */ - char patternChar= 0; - while ((iPattern < patternEnd) && (patternChar= pattern[iPattern]) != '*') { - if (iName == nameEnd) - return false; - if (patternChar != (isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) && patternChar != '?') { - return false; - } - iName++; - iPattern++; - } - /* check sequence of star+segment */ - int segmentStart; - if (patternChar == '*') { - segmentStart= ++iPattern; // skip star - } else { - segmentStart= 0; // force iName check - } - int prefixStart= iName; - checkSegment : while (iName < nameEnd) { - if (iPattern == patternEnd) { - iPattern= segmentStart; // mismatch - restart current segment - iName= ++prefixStart; - continue checkSegment; - } - /* segment is ending */ - if ((patternChar= pattern[iPattern]) == '*') { - segmentStart= ++iPattern; // skip start - if (segmentStart == patternEnd) { - return true; - } - prefixStart= iName; - continue checkSegment; - } - /* check current name character */ - if ((isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) != patternChar && patternChar != '?') { - iPattern= segmentStart; // mismatch - restart current segment - iName= ++prefixStart; - continue checkSegment; - } - iName++; - iPattern++; - } - return (segmentStart == patternEnd) || (iName == nameEnd && iPattern == patternEnd) - || (iPattern == patternEnd - 1 && pattern[iPattern] == '*'); - } - - /** - * Return a new array which is the split of the given array using the given - * divider and triming each subarray to remove whitespaces equals to ' '. - *

For example: - *
    - *
  1. - * - *
    -	 *  divider = 'b' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } }
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  divider = 'c' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
    -	 * 
    - * - * - *
  4. - *
  5. - * - *
    -	 *  divider = 'b' array = { 'a' , ' ', 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } }
    -	 * 
    - * - * - *
  6. - *
  7. - * - *
    -	 *  divider = 'c' array = { ' ', ' ', 'a' , 'b', 'b', 'a', 'b', 'a', ' ' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
    -	 * 
    - * - * - *
  8. - *
- * - * @param divider - * the given divider - * @param array - * the given array - * @return a new array which is the split of the given array using the - * given divider and triming each subarray to remove whitespaces - * equals to ' ' - */ - private char[][] splitAndTrimOn(char divider, char[] array) { - int length= array == null ? 0 : array.length; - if (length == 0) - return NO_CHAR_CHAR; - int wordCount= 1; - for (int i= 0; i < length; i++) - if (array[i] == divider) - wordCount++; - char[][] split= new char[wordCount][]; - int last= 0, currentWord= 0; - for (int i= 0; i < length; i++) { - if (array[i] == divider) { - int start= last, end= i - 1; - while (start < i && array[start] == ' ') - start++; - while (end > start && array[end] == ' ') - end--; - split[currentWord]= new char[end - start + 1]; - System.arraycopy(array, start, split[currentWord++], 0, end - start + 1); - last= i + 1; - } - } - int start= last, end= length - 1; - while (start < length && array[start] == ' ') - start++; - while (end > start && array[end] == ' ') - end--; - split[currentWord]= new char[end - start + 1]; - System.arraycopy(array, start, split[currentWord++], 0, end - start + 1); - return split; - } - - /** - * Answers a new array which is a copy of the given array starting at the - * given start and ending at the given end. The given start is inclusive - * and the given end is exclusive. Answers null if start is greater than - * end, if start is lower than 0 or if end is greater than the length of - * the given array. If end equals -1, it is converted to the array length. - *

For example: - *
    - *
  1. - * - *
    -	 *  array = { 'a' , 'b' } start = 0 end = 1 result => { 'a' }
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  array = { 'a', 'b' } start = 0 end = -1 result => { 'a' , 'b' }
    -	 * 
    - * - * - *
  4. - *
- * - * @param array - * the given array - * @param start - * the given starting index - * @param end - * the given ending index - * @return a new array which is a copy of the given array starting at the - * given start and ending at the given end - * @exception NullPointerException - * if the given array is null - */ - private char[] subarray(char[] array, int start, int end) { - if (end == -1) - end= array.length; - if (start > end) - return null; - if (start < 0) - return null; - if (end > array.length) - return null; - char[] result= new char[end - start]; - System.arraycopy(array, start, result, 0, end - start); - return result; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java deleted file mode 100644 index bc2d1464f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class CompareMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.CompareMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private CompareMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties deleted file mode 100644 index eb3dd5c8f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties +++ /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 -############################################################################### - -ComparePlugin.internal_error= Internal Error -ExceptionDialog.seeErrorLogMessage= See error log for details. - -# -# Title format for CompareViewerSwitchingPane -# -CompareViewerSwitchingPane.Titleformat= {0} ({1}) - -# -# Title message for StructureDiffViewer if no structural differences could be found -# -StructureDiffViewer.NoStructuralDifferences= No Structural Differences -StructureDiffViewer.StructureError= Cannot Compare Structures - -# -# TextMergeViewer -# -TextMergeViewer.cursorPosition.format= {0} : {1} - -TextMergeViewer.beforeLine.format= before line {0} -TextMergeViewer.range.format= {0} : {1} - -TextMergeViewer.changeType.addition= addition -TextMergeViewer.changeType.deletion= deletion -TextMergeViewer.changeType.change= change - -TextMergeViewer.direction.outgoing= outgoing -TextMergeViewer.direction.incoming= incoming -TextMergeViewer.direction.conflicting= conflicting - -TextMergeViewer.diffType.format= {0} {1} - -TextMergeViewer.diffDescription.noDiff.format= no diff -TextMergeViewer.diffDescription.diff.format= {0} #{1} (Left: {2}, Right: {3}) -TextMergeViewer.statusLine.format= Left: {0}, Right: {1}, {2} - -TextMergeViewer.atEnd.title= Go to Next Difference -TextMergeViewer.atEnd.message= End of document reached. Continue from beginning? - -TextMergeViewer.atBeginning.title= Go to Previous Difference -TextMergeViewer.atBeginning.message= Beginning of document reached. Continue from end? - -CompareNavigator.atEnd.title= Go to Next Difference -CompareNavigator.atEnd.message= Last difference reached. - -CompareNavigator.atBeginning.title= Go to Previous Difference -CompareNavigator.atBeginning.message= First difference reached. diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java deleted file mode 100644 index 295f4cc7c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Control; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.*; - -/** - * Supports cross-pane navigation through differences. - * XXX: Design is as it is because the feature had to be added without touching API. - */ -public class CompareNavigator implements ICompareNavigator { - - private boolean fLastDirection= true; - private CompareViewerSwitchingPane[] fPanes; - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - private boolean fNextFirstTime= true; - - public CompareNavigator(CompareViewerSwitchingPane[] panes) { - fPanes= panes; - } - - public CompareViewerSwitchingPane[] getPanes() { - return fPanes; - } - - public boolean selectChange(boolean next) { - - fLastDirection= next; - - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - if (next && fNextFirstTime && mustOpen()) { - fNextFirstTime= false; - openElement(); - } - - // find most down stream CompareViewerPane - int n= 0; - INavigatable[] navigators= new INavigatable[4]; - for (int i= 0; i < fPanes.length; i++) { - navigators[n]= getNavigator(fPanes[i]); - if (navigators[n] != null) - n++; - } - - while (n > 0) { - n--; - if (navigators[n].gotoDifference(next)) { - // at end of this navigator - continue; - } - // not at end - return false; - } - - return true; - } - - private static INavigatable getNavigator(CompareViewerSwitchingPane pane) { - if (pane == null) - return null; - if (pane.isEmpty()) - return null; - Viewer viewer= pane.getViewer(); - if (viewer == null) - return null; - Control control= viewer.getControl(); - if (control == null) - return null; - Object data= control.getData(INavigatable.NAVIGATOR_PROPERTY); - if (data instanceof INavigatable) - return (INavigatable) data; - return null; - } - - private static CompareNavigator findNavigator(Control c) { - while (c != null && !c.isDisposed()) { // PR 1GEUVV2 - Object data= c.getData(); - if (data instanceof CompareEditorInput) { - CompareEditorInput cei= (CompareEditorInput) data; - Object adapter= cei.getAdapter(CompareNavigator.class); - if (adapter instanceof CompareNavigator) - return (CompareNavigator)adapter; - } - c= c.getParent(); - } - return null; - } - - private boolean resetDirection() { - boolean last= fLastDirection; - fLastDirection= true; - return last; - } - - public static boolean getDirection(Control c) { - CompareNavigator nav= findNavigator(c); - if (nav != null) - return nav.resetDirection(); - return true; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private boolean mustOpen() { - if (fPanes == null || fPanes.length == 0) - return false; - for (int i= 1; i < fPanes.length; i++) { - CompareViewerSwitchingPane pane= fPanes[i]; - if (pane != null && pane.getInput() != null) - return false; - } - return true; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private void openElement() { - if (fPanes == null || fPanes.length == 0) - return; - IOpenable openable= getOpenable(fPanes[0]); - if (openable != null) { - openable.openSelected(); - } - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private static IOpenable getOpenable(CompareViewerSwitchingPane pane) { - if (pane == null) - return null; - if (pane.isEmpty()) - return null; - Viewer viewer= pane.getViewer(); - if (viewer == null) - return null; - Control control= viewer.getControl(); - if (control == null) - return null; - Object data= control.getData(IOpenable.OPENABLE_PROPERTY); - if (data instanceof IOpenable) - return (IOpenable) data; - return null; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java deleted file mode 100644 index bc599075d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.CompareEditorInput; - -/** - */ -public class CompareOutlinePage implements IContentOutlinePage { - - private Control fControl; - private ListenerList fListeners= new ListenerList(); - private ISelection fSelection; - //private IActionBars fActionBars; - private CompareEditorInput fCompareEditorInput; - - CompareOutlinePage(CompareEditorInput input) { - fCompareEditorInput= input; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - if (fCompareEditorInput != null) { - fControl= fCompareEditorInput.createOutlineContents(parent, SWT.VERTICAL); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#dispose() - */ - public void dispose() { - if (fControl != null) - fControl.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - public Control getControl() { - return fControl; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - //fActionBars= actionBars; - //if (fControl != null) - // fControl.setData("actionBars", actionBars); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - public void setFocus() { - if (fControl != null) - fControl.setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - fListeners.add(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return fSelection; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - fListeners.remove(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - fSelection= selection; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java deleted file mode 100644 index 3fcd49cf0..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java +++ /dev/null @@ -1,389 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.util.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.texteditor.AbstractTextEditor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.util.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.contentmergeviewer.TextMergeViewer; -import org.eclipse.compare.structuremergeviewer.*; - - -public class ComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - - class FakeInput implements ITypedElement, IEncodedStreamContentAccessor { - static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - String fContent; - - FakeInput(String name) { - fContent= loadPreviewContentFromFile(name); - } - public Image getImage() { - return null; - } - public String getName() { - return "no name"; //$NON-NLS-1$ - } - public String getType() { - return "no type"; //$NON-NLS-1$ - } - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); - } - public String getCharset() { - return UTF_16; - } - } - - private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ - public static final String OPEN_STRUCTURE_COMPARE= PREFIX + "OpenStructureCompare"; //$NON-NLS-1$ - public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$ - public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$ - public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$ - public static final String PREF_SAVE_ALL_EDITORS= PREFIX + "SaveAllEditors"; //$NON-NLS-1$ - public static final String SHOW_MORE_INFO= PREFIX + "ShowMoreInfo"; //$NON-NLS-1$ - public static final String IGNORE_WHITESPACE= PREFIX + "IgnoreWhitespace"; //$NON-NLS-1$ - //public static final String USE_SPLINES= PREFIX + "UseSplines"; //$NON-NLS-1$ - public static final String USE_SINGLE_LINE= PREFIX + "UseSingleLine"; //$NON-NLS-1$ - //public static final String USE_RESOLVE_UI= PREFIX + "UseResolveUI"; //$NON-NLS-1$ - public static final String PATH_FILTER= PREFIX + "PathFilter"; //$NON-NLS-1$ - - - private TextMergeViewer fPreviewViewer; - private IPropertyChangeListener fPreferenceChangeListener; - private CompareConfiguration fCompareConfiguration; - private OverlayPreferenceStore fOverlayStore; - private Map fCheckBoxes= new HashMap(); - private Text fFilters; - private SelectionListener fCheckBoxListener; - - - public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] { - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, OPEN_STRUCTURE_COMPARE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IGNORE_WHITESPACE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PREF_SAVE_ALL_EDITORS), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT), - - //new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SPLINES), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SINGLE_LINE), - //new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_RESOLVE_UI), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PATH_FILTER), - }; - - - public static void initDefaults(IPreferenceStore store) { - store.setDefault(OPEN_STRUCTURE_COMPARE, true); - store.setDefault(SYNCHRONIZE_SCROLLING, true); - store.setDefault(SHOW_PSEUDO_CONFLICTS, false); - store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false); - store.setDefault(SHOW_MORE_INFO, false); - store.setDefault(IGNORE_WHITESPACE, false); - store.setDefault(PREF_SAVE_ALL_EDITORS, false); - //store.setDefault(USE_SPLINES, false); - store.setDefault(USE_SINGLE_LINE, true); - //store.setDefault(USE_RESOLVE_UI, false); - store.setDefault(PATH_FILTER, ""); //$NON-NLS-1$ - - store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true); - } - - public ComparePreferencePage() { - - //setDescription(Utilities.getString("ComparePreferencePage.description")); //$NON-NLS-1$ - - setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore()); - - fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); - fPreferenceChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - String key= event.getProperty(); - if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) { - boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE); - if (fCompareConfiguration != null) { - fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b)); - } - } - } - }; - fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener); - } - - /* - * @see IWorkbenchPreferencePage#init() - */ - public void init(IWorkbench workbench) { - // empty - } - - /* - * @see PreferencePage#performOk() - */ - public boolean performOk() { - fOverlayStore.propagate(); - return true; - } - - /* - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() { - - fOverlayStore.loadDefaults(); - initializeFields(); - - super.performDefaults(); - } - - /* - * @see DialogPage#dispose() - */ - public void dispose() { - - if (fOverlayStore != null) { - if (fPreferenceChangeListener != null) { - fOverlayStore.removePropertyChangeListener(fPreferenceChangeListener); - fPreferenceChangeListener= null; - } - fOverlayStore.stop(); - fOverlayStore= null; - } - - super.dispose(); - } - - static public boolean getSaveAllEditors() { - IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(PREF_SAVE_ALL_EDITORS); - } - - static public void setSaveAllEditors(boolean value) { - IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); - store.setValue(PREF_SAVE_ALL_EDITORS, value); - } - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - - WorkbenchHelp.setHelp(parent, ICompareContextIds.COMPARE_PREFERENCE_PAGE); - - fOverlayStore.load(); - fOverlayStore.start(); - - TabFolder folder= new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); - folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem item= new TabItem(folder, SWT.NONE); - item.setText(Utilities.getString("ComparePreferencePage.generalTab.label")); //$NON-NLS-1$ - //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); - item.setControl(createGeneralPage(folder)); - - item= new TabItem(folder, SWT.NONE); - item.setText(Utilities.getString("ComparePreferencePage.textCompareTab.label")); //$NON-NLS-1$ - //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); - item.setControl(createTextComparePage(folder)); - - initializeFields(); - Dialog.applyDialogFont(folder); - return folder; - } - - private Control createGeneralPage(Composite parent) { - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 1; - composite.setLayout(layout); - - addCheckBox(composite, "ComparePreferencePage.structureCompare.label", OPEN_STRUCTURE_COMPARE, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.ignoreWhitespace.label", IGNORE_WHITESPACE, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - addCheckBox(composite, "ComparePreferencePage.saveBeforePatching.label", PREF_SAVE_ALL_EDITORS, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - Label l= new Label(composite, SWT.WRAP); - l.setText(Utilities.getString("ComparePreferencePage.filter.description")); //$NON-NLS-1$ - - Composite c2= new Composite(composite, SWT.NONE); - c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - layout= new GridLayout(2, false); - layout.marginWidth= 0; - c2.setLayout(layout); - - l= new Label(c2, SWT.NONE); - l.setText(Utilities.getString("ComparePreferencePage.filter.label")); //$NON-NLS-1$ - - fFilters= new Text(c2, SWT.BORDER); - fFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fFilters.setText(fOverlayStore.getString(PATH_FILTER)); - fFilters.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - String filters= fFilters.getText(); - String message= CompareFilter.validateResourceFilters(filters); - setValid(message == null); - setMessage(null); - setErrorMessage(message); - fOverlayStore.setValue(PATH_FILTER, filters); - } - } - ); - - return composite; - } - - private Control createTextComparePage(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 1; - composite.setLayout(layout); - - addCheckBox(composite, "ComparePreferencePage.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$ - - //addCheckBox(composite, "ComparePreferencePage.useSplines.label", USE_SPLINES, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.useSingleLine.label", USE_SINGLE_LINE, 0); //$NON-NLS-1$ - //addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - Label previewLabel= new Label(composite, SWT.NULL); - previewLabel.setText(Utilities.getString("ComparePreferencePage.preview.label")); //$NON-NLS-1$ - - Control previewer= createPreviewer(composite); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.widthHint= convertWidthInCharsToPixels(60); - gd.heightHint= convertHeightInCharsToPixels(13); - previewer.setLayoutData(gd); - - return composite; - } - - private Control createPreviewer(Composite parent) { - - fCompareConfiguration= new CompareConfiguration(fOverlayStore); - fCompareConfiguration.setAncestorLabel(Utilities.getString("ComparePreferencePage.ancestor.label")); //$NON-NLS-1$ - - fCompareConfiguration.setLeftLabel(Utilities.getString("ComparePreferencePage.left.label")); //$NON-NLS-1$ - fCompareConfiguration.setLeftEditable(false); - - fCompareConfiguration.setRightLabel(Utilities.getString("ComparePreferencePage.right.label")); //$NON-NLS-1$ - fCompareConfiguration.setRightEditable(false); - - fPreviewViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration); - - fPreviewViewer.setInput( - new DiffNode(Differencer.CONFLICTING, - new FakeInput("ComparePreferencePage.previewAncestor"), //$NON-NLS-1$ - new FakeInput("ComparePreferencePage.previewLeft"), //$NON-NLS-1$ - new FakeInput("ComparePreferencePage.previewRight") //$NON-NLS-1$ - ) - ); - - Control c= fPreviewViewer.getControl(); - c.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fCompareConfiguration != null) - fCompareConfiguration.dispose(); - } - }); - - return c; - } - - private void initializeFields() { - - Iterator e= fCheckBoxes.keySet().iterator(); - while (e.hasNext()) { - Button b= (Button) e.next(); - String key= (String) fCheckBoxes.get(b); - b.setSelection(fOverlayStore.getBoolean(key)); - } - - if (fFilters != null) - fFilters.setText(fOverlayStore.getString(PATH_FILTER)); - } - - // overlay stuff - - private Button addCheckBox(Composite parent, String labelKey, String key, int indentation) { - - String label= Utilities.getString(labelKey); - - Button checkBox= new Button(parent, SWT.CHECK); - checkBox.setText(label); - - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalIndent= indentation; - gd.horizontalSpan= 2; - checkBox.setLayoutData(gd); - - if (fCheckBoxListener == null) { - fCheckBoxListener= new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - Button button= (Button) e.widget; - fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); - } - }; - } - checkBox.addSelectionListener(fCheckBoxListener); - - fCheckBoxes.put(checkBox, key); - - return checkBox; - } - - private String loadPreviewContentFromFile(String key) { - - String preview= Utilities.getString(key); - String separator= System.getProperty("line.separator"); //$NON-NLS-1$ - StringBuffer buffer= new StringBuffer(); - for (int i= 0; i < preview.length(); i++) { - char c= preview.charAt(i); - if (c == '\n') - buffer.append(separator); - else - buffer.append(c); - } - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java deleted file mode 100644 index d90b72759..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java +++ /dev/null @@ -1,1155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.net.*; -import java.util.*; -import java.util.List; - -import org.eclipse.ui.*; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.content.IContentTypeManager; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.osgi.framework.BundleContext; - - -/** - * The Compare UI plug-in defines the entry point to initiate a configurable - * compare operation on arbitrary resources. The result of the compare - * is opened into a compare editor where the details can be browsed and - * edited in dynamically selected structure and content viewers. - *

- * The Compare UI provides a registry for content and structure compare viewers, - * which is initialized from extensions contributed to extension points - * declared by this plug-in. - *

- * This class is the plug-in runtime class for the - * "org.eclipse.compare" plug-in. - *

- */ -public final class CompareUIPlugin extends AbstractUIPlugin { - - static class CompareRegistry { - - private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$ - - private HashMap fIdMap; - private HashMap fExtensionMap; - private HashMap fContentTypeBindings; // maps content type bindings to datas - - - void register(IConfigurationElement element, Object data) { - String id= element.getAttribute(ID_ATTRIBUTE); - if (id != null) { - if (fIdMap == null) - fIdMap= new HashMap(); - fIdMap.put(id, data); - } - - String types= element.getAttribute(EXTENSIONS_ATTRIBUTE); - if (types != null) { - if (fExtensionMap == null) - fExtensionMap= new HashMap(); - StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreElements()) { - String extension= tokenizer.nextToken().trim(); - fExtensionMap.put(normalizeCase(extension), data); - } - } - } - - void createBinding(IConfigurationElement element, String idAttributeName) { - String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE); - String id= element.getAttribute(idAttributeName); - if (id == null) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$ - if (type != null && id != null && fIdMap != null) { - Object o= fIdMap.get(id); - if (o != null) { - IContentType ct= fgContentTypeManager.getContentType(type); - if (ct != null) { - if (fContentTypeBindings == null) - fContentTypeBindings= new HashMap(); - fContentTypeBindings.put(ct, o); - } else { - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$ - } - } else { - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$ - } - } - } - - Object search(IContentType type) { - if (type != null && fContentTypeBindings != null) { - Object b= fContentTypeBindings.get(type); - if (b != null) - return b; - Iterator iter= fContentTypeBindings.keySet().iterator(); - while (iter.hasNext()) { - IContentType ct= (IContentType) iter.next(); - if (type.isKindOf(ct)) { - return fContentTypeBindings.get(ct); - } - } - } - return null; - } - - Object search(String extension) { - if (fExtensionMap != null) - return fExtensionMap.get(normalizeCase(extension)); - return null; - } - } - - public static final String DTOOL_NEXT= "dlcl16/next_nav.gif"; //$NON-NLS-1$ - public static final String ETOOL_NEXT= "elcl16/next_nav.gif"; //$NON-NLS-1$ - public static final String CTOOL_NEXT= ETOOL_NEXT; - - public static final String DTOOL_PREV= "dlcl16/prev_nav.gif"; //$NON-NLS-1$ - public static final String ETOOL_PREV= "elcl16/prev_nav.gif"; //$NON-NLS-1$ - public static final String CTOOL_PREV= ETOOL_PREV; - - /** Status code describing an internal error */ - public static final int INTERNAL_ERROR= 1; - - private static boolean NORMALIZE_CASE= true; - - public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$ - - private static final String BINARY_TYPE= "binary"; //$NON-NLS-1$ - - private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$ - private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$ - private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$ - - private static final String VIEWER_TAG= "viewer"; //$NON-NLS-1$ - private static final String STRUCTURE_MERGE_VIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$ - private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$ - private static final String CONTENT_MERGE_VIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$ - private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$ - private static final String CONTENT_VIEWER_EXTENSION_POINT= "contentViewers"; //$NON-NLS-1$ - private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$ - - private static final String CONTENT_TYPE_BINDING= "contentTypeBinding"; //$NON-NLS-1$ - - - private static final String COMPARE_EDITOR= PLUGIN_ID + ".CompareEditor"; //$NON-NLS-1$ - - private static final String STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME= "StructureViewerAliases"; //$NON-NLS-1$ - - // content type - private static final IContentTypeManager fgContentTypeManager= Platform.getContentTypeManager(); - - /** - * The plugin singleton. - */ - private static CompareUIPlugin fgComparePlugin; - - /** Maps type to icons */ - private static Map fgImages= new Hashtable(10); - /** Maps type to ImageDescriptors */ - private static Map fgImageDescriptors= new Hashtable(10); - /** Maps ImageDescriptors to Images */ - private static Map fgImages2= new Hashtable(10); - - private static List fgDisposeOnShutdownImages= new ArrayList(); - - private ResourceBundle fResourceBundle; - - private boolean fRegistriesInitialized; - private CompareRegistry fStreamMergers= new CompareRegistry(); - private CompareRegistry fStructureCreators= new CompareRegistry(); - private CompareRegistry fStructureMergeViewers= new CompareRegistry(); - private CompareRegistry fContentViewers= new CompareRegistry(); - private CompareRegistry fContentMergeViewers= new CompareRegistry(); - - private Map fStructureViewerAliases; - private CompareFilter fFilter; - private IPropertyChangeListener fPropertyChangeListener; - - /** - * Creates the CompareUIPlugin object and registers all - * structure creators, content merge viewers, and structure merge viewers - * contributed to this plug-in's extension points. - *

- * Note that instances of plug-in runtime classes are automatically created - * by the platform in the course of plug-in activation. - */ - public CompareUIPlugin() { - super(); - Assert.isTrue(fgComparePlugin == null); - fgComparePlugin= this; - } - - public void start(BundleContext context) throws Exception { - super.start(context); - ComparePreferencePage.initDefaults(getPreferenceStore()); - } - - public void stop(BundleContext context) throws Exception { - - IPreferenceStore ps= getPreferenceStore(); - rememberAliases(ps); - if (fPropertyChangeListener != null) { - ps.removePropertyChangeListener(fPropertyChangeListener); - fPropertyChangeListener= null; - } - - super.stop(context); - - if (fgDisposeOnShutdownImages != null) { - Iterator i= fgDisposeOnShutdownImages.iterator(); - while (i.hasNext()) { - Image img= (Image) i.next(); - if (!img.isDisposed()) - img.dispose(); - } - fgImages= null; - } - } - - /** - * Returns the singleton instance of this plug-in runtime class. - * - * @return the compare plug-in instance - */ - public static CompareUIPlugin getDefault() { - return fgComparePlugin; - } - - /** - * Returns this plug-in's resource bundle. - * - * @return the plugin's resource bundle - */ - public ResourceBundle getResourceBundle() { - if (fResourceBundle == null) - fResourceBundle= Platform.getResourceBundle(getBundle()); - return fResourceBundle; - } - - /** - * Returns this plug-in's unique identifier. - * - * @return the plugin's unique identifier - */ - public static String getPluginId() { - return getDefault().getBundle().getSymbolicName(); - } - - private void initializeRegistries() { - if (!fRegistriesInitialized) { - registerExtensions(); - fRegistriesInitialized= true; - } - } - - /** - * Registers all stream mergers, structure creators, content merge viewers, and structure merge viewers - * that are found in the XML plugin files. - */ - private void registerExtensions() { - IExtensionRegistry registry= Platform.getExtensionRegistry(); - - // collect all IStreamMergers - IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STREAM_MERGER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (STREAM_MERGER.equals(element.getName())) - fStreamMergers.register(element, new StreamMergerDescriptor(element)); - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStreamMergers.createBinding(element, STREAM_MERGER_ID_ATTRIBUTE); - } - - // collect all IStructureCreators - elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!STRUCTURE_CREATOR.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, STRUCTURE_CREATOR)); //$NON-NLS-1$ - fStructureCreators.register(element, new StructureCreatorDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStructureCreators.createBinding(element, STRUCTURE_CREATOR_ID_ATTRIBUTE); - } - - // collect all viewers which define the structure mergeviewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGE_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fStructureMergeViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStructureMergeViewers.createBinding(element, STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE); - } - - // collect all viewers which define the content mergeviewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGE_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fContentMergeViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fContentMergeViewers.createBinding(element, CONTENT_MERGE_VIEWER_ID_ATTRIBUTE); - } - - // collect all viewers which define the content viewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fContentViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fContentViewers.createBinding(element, CONTENT_VIEWER_ID_ATTRIBUTE); - } - } - - public static IWorkbench getActiveWorkbench() { - CompareUIPlugin plugin= getDefault(); - if (plugin == null) - return null; - return plugin.getWorkbench(); - } - - public static IWorkbenchWindow getActiveWorkbenchWindow() { - IWorkbench workbench= getActiveWorkbench(); - if (workbench == null) - return null; - return workbench.getActiveWorkbenchWindow(); - } - - /** - * Returns the active workkbench page or null if - * no active workkbench page can be determined. - * - * @return the active workkbench page or null if - * no active workkbench page can be determined - */ - private static IWorkbenchPage getActivePage() { - IWorkbenchWindow window= getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getActivePage(); - } - - /** - * Returns the SWT Shell of the active workbench window or null if - * no workbench window is active. - * - * @return the SWT Shell of the active workbench window, or null if - * no workbench window is active - */ - public static Shell getShell() { - IWorkbenchWindow window= getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getShell(); - } - - /** - * Registers the given image for being disposed when this plug-in is shutdown. - * - * @param image the image to register for disposal - */ - public static void disposeOnShutdown(Image image) { - if (image != null) - fgDisposeOnShutdownImages.add(image); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result. - * - * @param input the input on which to open the compare editor - * @param page the workbench page on which to create a new compare editor - * @param editor if not null the input is opened in this editor - * @see CompareEditorInput - */ - public void openCompareEditor(CompareEditorInput input, IWorkbenchPage page, IReusableEditor editor) { - - if (compareResultOK(input)) { - - if (editor != null) { // reuse the given editor - editor.setInput(input); - return; - } - - if (page == null) - page= getActivePage(); - if (page != null) { - // open new CompareEditor on page - try { - page.openEditor(input, COMPARE_EDITOR); - } catch (PartInitException e) { - MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), e.getMessage()); //$NON-NLS-1$ - } - } else { - MessageDialog.openError(getShell(), - Utilities.getString("CompareUIPlugin.openEditorError"), //$NON-NLS-1$ - Utilities.getString("CompareUIPlugin.noActiveWorkbenchPage")); //$NON-NLS-1$ - } - } - } - - /** - * Performs the comparison described by the given input and opens a - * compare dialog on the result. - * - * @param input the input on which to open the compare editor - * @see CompareEditorInput - */ - public void openCompareDialog(final CompareEditorInput input) { - - if (compareResultOK(input)) { - CompareDialog dialog= new CompareDialog(getShell(), input); - dialog.open(); - } - } - - /* - * @return true if compare result is OK to show, false otherwise - */ - private boolean compareResultOK(CompareEditorInput input) { - final Shell shell= getShell(); - try { - - // run operation in separate thread and make it canceable - PlatformUI.getWorkbench().getProgressService().run(true, true, input); - - String message= input.getMessage(); - if (message != null) { - MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), message); //$NON-NLS-1$ - return false; - } - - if (input.getCompareResult() == null) { - MessageDialog.openInformation(shell, Utilities.getString("CompareUIPlugin.dialogTitle"), Utilities.getString("CompareUIPlugin.noDifferences")); //$NON-NLS-2$ //$NON-NLS-1$ - return false; - } - - return true; - - } catch (InterruptedException x) { - // cancelled by user - } catch (InvocationTargetException x) { - MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), x.getTargetException().getMessage()); //$NON-NLS-1$ - } - return false; - } - - /* - * Registers an image for the given type. - */ - private static void registerImage(String type, Image image, boolean dispose) { - fgImages.put(normalizeCase(type), image); - if (image != null && dispose) { - fgDisposeOnShutdownImages.add(image); - } - } - - /** - * Registers an image descriptor for the given type. - * - * @param type the type - * @param descriptor the image descriptor - */ - public static void registerImageDescriptor(String type, ImageDescriptor descriptor) { - fgImageDescriptors.put(normalizeCase(type), descriptor); - } - - public static ImageDescriptor getImageDescriptor(String relativePath) { - - URL installURL= null; - if (fgComparePlugin != null) - installURL= fgComparePlugin.getBundle().getEntry("/"); //$NON-NLS-1$ - - if (installURL != null) { - try { - URL url= new URL(installURL, Utilities.getIconPath(null) + relativePath); - return ImageDescriptor.createFromURL(url); - } catch (MalformedURLException e) { - Assert.isTrue(false); - } - } - return null; - } - - /** - * Returns a shared image for the given type, or a generic image if none - * has been registered for the given type. - *

- * Note: Images returned from this method will be automitically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param type the type - * @return the image - */ - public static Image getImage(String type) { - - type= normalizeCase(type); - - boolean dispose= false; - Image image= null; - if (type != null) - image= (Image) fgImages.get(type); - if (image == null) { - ImageDescriptor id= (ImageDescriptor) fgImageDescriptors.get(type); - if (id != null) { - image= id.createImage(); - dispose= true; - } - - if (image == null) { - if (fgComparePlugin != null) { - if (ITypedElement.FOLDER_TYPE.equals(type)) { - image= getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - //image= SharedImages.getImage(ISharedImages.IMG_OBJ_FOLDER); - } else { - image= createWorkbenchImage(type); - dispose= true; - } - } else { - id= (ImageDescriptor) fgImageDescriptors.get(normalizeCase("file")); //$NON-NLS-1$ - image= id.createImage(); - dispose= true; - } - } - if (image != null) - registerImage(type, image, dispose); - } - return image; - } - - /** - * Returns a shared image for the given adaptable. - * This convenience method queries the given adaptable - * for its IWorkbenchAdapter.getImageDescriptor, which it - * uses to create an image if it does not already have one. - *

- * Note: Images returned from this method will be automitically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param adaptable the adaptable for which to find an image - * @return an image - */ - public static Image getImage(IAdaptable adaptable) { - if (adaptable != null) { - Object o= adaptable.getAdapter(IWorkbenchAdapter.class); - if (o instanceof IWorkbenchAdapter) { - ImageDescriptor id= ((IWorkbenchAdapter) o).getImageDescriptor(adaptable); - if (id != null) { - Image image= (Image)fgImages2.get(id); - if (image == null) { - image= id.createImage(); - try { - fgImages2.put(id, image); - } catch (NullPointerException ex) { - // NeedWork - } - fgDisposeOnShutdownImages.add(image); - - } - return image; - } - } - } - return null; - } - - private static Image createWorkbenchImage(String type) { - IEditorRegistry er= getDefault().getWorkbench().getEditorRegistry(); - ImageDescriptor id= er.getImageDescriptor("foo." + type); //$NON-NLS-1$ - return id.createImage(); - } - - /** - * Returns an structure creator descriptor for the given type. - * - * @param type the type for which to find a descriptor - * @return a descriptor for the given type, or null if no - * descriptor has been registered - */ - public StructureCreatorDescriptor getStructureCreator(String type) { - initializeRegistries(); - return (StructureCreatorDescriptor) fStructureCreators.search(type); - } - - /** - * Returns a stream merger for the given type. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public IStreamMerger createStreamMerger(String type) { - initializeRegistries(); - StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fStreamMergers.search(type); - if (descriptor != null) - return descriptor.createStreamMerger(); - return null; - } - - /** - * Returns a stream merger for the given content type. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public IStreamMerger createStreamMerger(IContentType type) { - initializeRegistries(); - StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fStreamMergers.search(type); - if (descriptor != null) - return descriptor.createStreamMerger(); - return null; - } - - /** - * Returns a structure compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input, the old viewer - * is returned. Otherwise, the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a structure compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - - if (input.getLeft() == null || input.getRight() == null) // we don't show the structure of additions or deletions - return null; - - // content type search - IContentType ctype= getCommonType(getContentTypes(input)); - if (ctype != null) { - initializeRegistries(); - Viewer viewer= getViewer(fStructureMergeViewers.search(ctype), oldViewer, parent, configuration); - if (viewer != null) - return viewer; - } - - // old style search - String[] types= getTypes(input); - String type= null; - if (isHomogenous(types)) { - type= normalizeCase(types[0]); - initializeRegistries(); - IViewerDescriptor vd= (IViewerDescriptor) fStructureMergeViewers.search(type); - if (vd == null) { - String alias= getStructureViewerAlias(type); - if (alias != null) - vd= (IViewerDescriptor) fStructureMergeViewers.search(alias); - } - if (vd != null) - return vd.createViewer(oldViewer, parent, configuration); - } - - // we didn't found any viewer so far. - // now we try to find a structurecreator for the generic StructureDiffViewer - - StructureCreatorDescriptor scc= null; - initializeRegistries(); - Object desc= fStructureCreators.search(ctype); // search for content type - if (desc instanceof StructureCreatorDescriptor) - scc= (StructureCreatorDescriptor) desc; - if (scc == null && type != null) - scc= getStructureCreator(type); // search for old-style type scheme - if (scc != null) { - IStructureCreator sc= scc.createStructureCreator(); - if (sc != null) { - StructureDiffViewer sdv= new StructureDiffViewer(parent, configuration); - sdv.setStructureCreator(sc); - return sdv; - } - } - return null; - } - - /** - * Returns a content compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input the old viewer - * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a content compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param in the input object for which to find a content viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param cc a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) { - - if (in instanceof IStreamContentAccessor) { - String type= ITypedElement.TEXT_TYPE; - - if (in instanceof ITypedElement) { - ITypedElement tin= (ITypedElement) in; - - IContentType ct= getContentType(tin); - if (ct != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentViewers.search(ct), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - String ty= tin.getType(); - if (ty != null) - type= ty; - } - - initializeRegistries(); - Viewer viewer= getViewer(fContentViewers.search(type), oldViewer, parent, cc); - if (viewer != null) - return viewer; - // fallback - return new SimpleTextViewer(parent); - } - - if (!(in instanceof ICompareInput)) - return null; - - ICompareInput input= (ICompareInput) in; - - IContentType ctype= getCommonType(getContentTypes(input)); - if (ctype != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - String[] types= getTypes(input); - String type= null; - if (isHomogenous(types)) - type= types[0]; - - if (ITypedElement.FOLDER_TYPE.equals(type)) - return null; - - if (type == null) { - int n= 0; - for (int i= 0; i < types.length; i++) - if (!ITypedElement.UNKNOWN_TYPE.equals(types[i])) { - n++; - if (type == null) - type= types[i]; // remember the first known type - } - if (n > 1) // don't use the type if there were more than one - type= null; - } - - if (type != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentMergeViewers.search(type), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - // fallback - String leftType= guessType(input.getLeft()); - String rightType= guessType(input.getRight()); - - if (leftType != null || rightType != null) { - boolean right_text= rightType != null && ITypedElement.TEXT_TYPE.equals(rightType); - boolean left_text= leftType != null && ITypedElement.TEXT_TYPE.equals(leftType); - if ((leftType == null && right_text) || (left_text && rightType == null) || (left_text && right_text)) - type= ITypedElement.TEXT_TYPE; - else - type= BINARY_TYPE; - - initializeRegistries(); - IViewerDescriptor vd= (IViewerDescriptor) fContentMergeViewers.search(type); - if (vd != null) - return vd.createViewer(oldViewer, parent, cc); - } - return null; - } - - private static Viewer getViewer(Object descriptor, Viewer oldViewer, Composite parent, CompareConfiguration cc) { - if (descriptor instanceof IViewerDescriptor) - return ((IViewerDescriptor)descriptor).createViewer(oldViewer, parent, cc); - return null; - } - - private static String[] getTypes(ICompareInput input) { - ITypedElement ancestor= input.getAncestor(); - ITypedElement left= input.getLeft(); - ITypedElement right= input.getRight(); - - ArrayList tmp= new ArrayList(); - if (ancestor != null) { - String type= ancestor.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - if (left != null) { - String type= left.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - if (right != null) { - String type= right.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - return (String[]) tmp.toArray(new String[tmp.size()]); - } - - private static IContentType[] getContentTypes(ICompareInput input) { - ITypedElement ancestor= input.getAncestor(); - ITypedElement left= input.getLeft(); - ITypedElement right= input.getRight(); - - ArrayList tmp= new ArrayList(); - IContentType type= getContentType(ancestor); - if (type != null) - tmp.add(type); - type= getContentType(left); - if (type != null) - tmp.add(type); - type= getContentType(right); - if (type != null) - tmp.add(type); - - return (IContentType[]) tmp.toArray(new IContentType[tmp.size()]); - } - - private static IContentType getContentType(ITypedElement element) { - if (element == null) - return null; - String name= element.getName(); - IContentType[] associated= fgContentTypeManager.findContentTypesFor(name); - if (associated.length > 0) - return associated[0]; - IContentType ct= null; - if (element instanceof IStreamContentAccessor) { - IStreamContentAccessor isa= (IStreamContentAccessor) element; - try { - InputStream is= isa.getContents(); - if (is != null) { - InputStream bis= new BufferedInputStream(is); - try { - ct= fgContentTypeManager.findContentTypeFor(is, name); - } catch (IOException e) { - // silently ignored - } - try { - bis.close(); - } catch (IOException e2) { - // silently ignored - } - } - } catch (CoreException e1) { - // silently ignored - } - } - return ct; - } - - /* - * Returns true if the given types are homogenous. - */ - private static boolean isHomogenous(String[] types) { - switch (types.length) { - case 1: - return true; - case 2: - return types[0].equals(types[1]); - case 3: - return types[0].equals(types[1]) && types[1].equals(types[2]); - } - return false; - } - - /* - * Returns the most specific content type that is common to the given inputs or null. - */ - private static IContentType getCommonType(IContentType[] types) { - Set s= null; - ArrayList l= null; - switch (types.length) { - case 1: - return types[0]; - case 2: - l= new ArrayList(); - s= toSet(l, types[0]); - s.retainAll(toSet(l, types[1])); - break; - case 3: - l= new ArrayList(); - s= toSet(l, types[0]); - s.retainAll(toSet(l, types[1])); - s.retainAll(toSet(l, types[2])); - break; - } - if (s != null && !s.isEmpty()) { - Iterator iter= l.iterator(); - while (iter.hasNext()) { - IContentType ct= (IContentType) iter.next(); - if (s.contains(ct)) - return ct; - } - } - return null; - } - - private static Set toSet(ArrayList l, IContentType ct) { - Set set= new HashSet(); - for (; ct != null; ct= ct.getBaseType()) { - l.add(ct); - set.add(ct); - } - return set; - } - - /* - * Guesses the file type of the given input. - * Returns ITypedElement.TEXT_TYPE if none of the first 10 lines is longer than 1000 bytes. - * Returns ITypedElement.UNKNOWN_TYPE otherwise. - * Returns null if the input isn't an IStreamContentAccessor. - */ - private static String guessType(ITypedElement input) { - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - InputStream is= null; - try { - is= sca.getContents(); - if (is == null) - return null; - int lineLength= 0; - int lines= 0; - while (lines < 10) { - int c= is.read(); - if (c == -1) // EOF - break; - if (c == '\n' || c == '\r') { // reset line length - lineLength= 0; - lines++; - } else - lineLength++; - if (lineLength > 1000) - return ITypedElement.UNKNOWN_TYPE; - } - return ITypedElement.TEXT_TYPE; - } catch (CoreException ex) { - // be silent and return UNKNOWN_TYPE - } catch (IOException ex) { - // be silent and return UNKNOWN_TYPE - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - return ITypedElement.UNKNOWN_TYPE; - } - return null; - } - - private static String normalizeCase(String s) { - if (NORMALIZE_CASE && s != null) - return s.toUpperCase(); - return s; - } - - //---- alias mgmt - - private String getStructureViewerAlias(String type) { - return (String) getStructureViewerAliases().get(type); - } - - public void addStructureViewerAlias(String type, String alias) { - getStructureViewerAliases().put(normalizeCase(alias), normalizeCase(type)); - } - - private Map getStructureViewerAliases() { - if (fStructureViewerAliases == null) { - fStructureViewerAliases= new Hashtable(10); - String aliases= getPreferenceStore().getString(STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME); - if (aliases != null && aliases.length() > 0) { - StringTokenizer st= new StringTokenizer(aliases, " "); //$NON-NLS-1$ - while (st.hasMoreTokens()) { - String pair= st.nextToken(); - int pos= pair.indexOf('.'); - if (pos > 0) { - String key= pair.substring(0, pos); - String alias= pair.substring(pos+1); - fStructureViewerAliases.put(key, alias); - } - } - } - } - return fStructureViewerAliases; - } - - public void removeAllStructureViewerAliases(String type) { - if (fStructureViewerAliases == null) - return; - String t= normalizeCase(type); - Set entrySet= fStructureViewerAliases.entrySet(); - for (Iterator iter= entrySet.iterator(); iter.hasNext(); ) { - Map.Entry entry= (Map.Entry)iter.next(); - if (entry.getValue().equals(t)) - iter.remove(); - } - } - - /* - * Converts the aliases into a single string before they are stored - * in the preference store. - * The format is: - * '.' ' ' '.' ... - */ - private void rememberAliases(IPreferenceStore ps) { - if (fStructureViewerAliases == null) - return; - StringBuffer buffer= new StringBuffer(); - Iterator iter= fStructureViewerAliases.keySet().iterator(); - while (iter.hasNext()) { - String key= (String) iter.next(); - String alias= (String) fStructureViewerAliases.get(key); - buffer.append(key); - buffer.append('.'); - buffer.append(alias); - buffer.append(' '); - } - ps.setValue(STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME, buffer.toString()); - } - - //---- filters - - public boolean filter(String name, boolean isFolder, boolean isArchive) { - if (fFilter == null) { - fFilter= new CompareFilter(); - final IPreferenceStore ps= getPreferenceStore(); - fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER)); - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (ComparePreferencePage.PATH_FILTER.equals(event.getProperty())) - fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER)); - } - }; - ps.addPropertyChangeListener(fPropertyChangeListener); - } - return fFilter.filter(name, isFolder, isArchive); - } - - //---- more utilities - - /** - * Returns an array of all editors that have an unsaved content. If the identical content is - * presented in more than one editor, only one of those editor parts is part of the result. - * - * @return an array of all dirty editor parts. - */ - public static IEditorPart[] getDirtyEditors() { - Set inputs= new HashSet(); - List result= new ArrayList(0); - IWorkbench workbench= getDefault().getWorkbench(); - IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); - for (int i= 0; i < windows.length; i++) { - IWorkbenchPage[] pages= windows[i].getPages(); - for (int x= 0; x < pages.length; x++) { - IEditorPart[] editors= pages[x].getDirtyEditors(); - for (int z= 0; z < editors.length; z++) { - IEditorPart ep= editors[z]; - IEditorInput input= ep.getEditorInput(); - if (!inputs.contains(input)) { - inputs.add(input); - result.add(ep); - } - } - } - } - return (IEditorPart[])result.toArray(new IEditorPart[result.size()]); - } - - public static void logErrorMessage(String message) { - if (message == null) - message= ""; //$NON-NLS-1$ - log(new Status(IStatus.ERROR, getPluginId(), INTERNAL_ERROR, message, null)); - } - - public static void log(Throwable e) { - log(new Status(IStatus.ERROR, getPluginId(), INTERNAL_ERROR, CompareMessages.getString("ComparePlugin.internal_error"), e)); //$NON-NLS-1$ - } - - public static void log(IStatus status) { - getDefault().getLog().log(status); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java deleted file mode 100644 index f8cef54d1..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -public class CompareWithEditionAction extends EditionAction { - - public CompareWithEditionAction() { - super(false, "org.eclipse.compare.internal.CompareWithEditionAction"); //$NON-NLS-1$ - this.fHelpContextId= ICompareContextIds.COMPARE_WITH_EDITION_DIALOG; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties deleted file mode 100644 index 154531afa..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)CompareWithEditionAction.properties -# -# Resources for CompareWithEditionAction.java - -title= Compare with Local History - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= Editor Buffer -workspaceTargetLabel= Workspace File - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -closeButton.label=Close - -noLocalHistoryError= No local history available for selected resource. diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java deleted file mode 100644 index 1c17ded85..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.graphics.*; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Combines an image with an overlay. - */ -public class DiffImage extends CompositeImageDescriptor { - - static final int HEIGHT= 16; - - private Image fBaseImage; - private ImageDescriptor fOverlayImage; - private int fWidth; - private boolean fLeft= true; - - public DiffImage(Image base, ImageDescriptor overlay, int w) { - fBaseImage= base; - fOverlayImage= overlay; - fWidth= w; - } - - public DiffImage(Image base, ImageDescriptor overlay, int w, boolean onLeft) { - fBaseImage= base; - fOverlayImage= overlay; - fWidth= w; - fLeft= onLeft; - } - - protected Point getSize() { - return new Point(fWidth, HEIGHT); - } - - protected void drawCompositeImage(int width, int height) { - if (fLeft) { - if (fBaseImage != null) { - ImageData base= fBaseImage.getImageData(); - if (base == null) - base= DEFAULT_IMAGE_DATA; - drawImage(base, fWidth - base.width, 0); - } - - if (fOverlayImage != null) { - ImageData overlay= fOverlayImage.getImageData(); - if (overlay == null) - overlay= DEFAULT_IMAGE_DATA; - drawImage(overlay, 0, (HEIGHT - overlay.height) / 2); - } - } else { - if (fBaseImage != null) { - ImageData base= fBaseImage.getImageData(); - if (base == null) - base= DEFAULT_IMAGE_DATA; - drawImage(base, 0, 0); - } - - if (fOverlayImage != null) { - ImageData overlay= fOverlayImage.getImageData(); - if (overlay == null) - overlay= DEFAULT_IMAGE_DATA; - drawImage(overlay, fWidth - overlay.width, (HEIGHT - overlay.height) / 2); - } - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java deleted file mode 100644 index d1671df31..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.text.*; -import org.eclipse.compare.contentmergeviewer.ITokenComparator; -import org.eclipse.compare.rangedifferencer.IRangeComparator; - -/** - * Implements the IRangeComparator interface for lines in a document. - * A DocLineComparator is used as the input for the RangeDifferencer - * engine to perform a line oriented compare on documents. - *

- * A DocLineComparator doesn't know anything about line separators because - * its notion of lines is solely defined in the underlying IDocument. - */ -public class DocLineComparator implements ITokenComparator { - - private IDocument fDocument; - private int fLineOffset; - private int fLineCount; - private int fLength; - private boolean fIgnoreWhiteSpace; - - /** - * Creates a DocLineComparator for the given document range. - * ignoreWhiteSpace controls whether comparing lines (in method - * rangesEqual) should ignore whitespace. - * - * @param document the document from which the lines are taken - * @param region if non-null only lines within this range are taken - * @param ignoreWhiteSpace if true white space is ignored when comparing lines - */ - public DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) { - - fDocument= document; - fIgnoreWhiteSpace= ignoreWhiteSpace; - - fLineOffset= 0; - if (region != null) { - fLength= region.getLength(); - int start= region.getOffset(); - try { - fLineOffset= fDocument.getLineOfOffset(start); - } catch (BadLocationException ex) { - // silently ignored - } - - if (fLength == 0) - fLineCount= 0; - else { - int endLine= fDocument.getNumberOfLines(); - try { - endLine= fDocument.getLineOfOffset(start + fLength); - } catch (BadLocationException ex) { - // silently ignored - } - fLineCount= endLine - fLineOffset + 1; - } - - } else { - fLength= document.getLength(); - fLineCount= fDocument.getNumberOfLines(); - } - } - - /** - * Returns the number of lines in the document. - * - * @return number of lines - */ - public int getRangeCount() { - return fLineCount; - } - - /* (non Javadoc) - * see ITokenComparator.getTokenStart - */ - public int getTokenStart(int line) { - try { - IRegion r= fDocument.getLineInformation(fLineOffset + line); - return r.getOffset(); - } catch (BadLocationException ex) { - return fDocument.getLength(); - } - } - - /* (non Javadoc) - * Returns the length of the given line. - * see ITokenComparator.getTokenLength - */ - public int getTokenLength(int line) { - return getTokenStart(line+1) - getTokenStart(line); - } - - /** - * Returns true if a line given by the first index - * matches a line specified by the other IRangeComparator and index. - * - * @param thisIndex the number of the line within this range comparator - * @param otherComparator the range comparator to compare this with - * @param otherIndex the number of the line within the other comparator - * @return true if the lines are equal - */ - public boolean rangesEqual(int thisIndex, IRangeComparator otherComparator, int otherIndex) { - - if (otherComparator != null && otherComparator.getClass() == getClass()) { - DocLineComparator other= (DocLineComparator) otherComparator; - - if (fIgnoreWhiteSpace) { - String s1= extract(thisIndex); - String s2= other.extract(otherIndex); - //return s1.trim().equals(s2.trim()); - return compare(s1, s2); - } - - int tlen= getTokenLength(thisIndex); - int olen= other.getTokenLength(otherIndex); - if (tlen == olen) { - String s1= extract(thisIndex); - String s2= other.extract(otherIndex); - return s1.equals(s2); - } - } - return false; - } - - /** - * Aborts the comparison if the number of tokens is too large. - * - * @param length a number on which to base the decision whether to return - * true or false - * @param maxLength another number on which to base the decision whether to return - * true or false - * @param other the other IRangeComparator to compare with - * @return true to avoid a too lengthy range comparison - */ - public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { - return false; - } - - //---- private methods - - /** - * Extract a single line from the underlying document without the line separator. - * - * @param line the number of the line to extract - * @return the contents of the line as a String - */ - private String extract(int line) { - if (line < fLineCount) { - try { - IRegion r= fDocument.getLineInformation(fLineOffset + line); - return fDocument.get(r.getOffset(), r.getLength()); - } catch(BadLocationException e) { - // silently ignored - } - } - return ""; //$NON-NLS-1$ - } - - private boolean compare(String s1, String 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/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java deleted file mode 100644 index b2db19190..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.*; - -import org.eclipse.jface.text.IDocument; - -/** - * No API yet. - */ -public class DocumentManager { - - private static final boolean DEBUG= false; - - private static ArrayList fgKeys= new ArrayList(); - private static ArrayList fgValues= new ArrayList(); - - public static IDocument get(Object o) { - - for (int i= 0; i < fgKeys.size(); i++) { - if (fgKeys.get(i) == o) - return (IDocument) fgValues.get(i); - } - return null; - } - - public static void put(Object o, IDocument document) { - if (DEBUG) System.out.println("DocumentManager.put: " + document); //$NON-NLS-1$ - for (int i= 0; i < fgKeys.size(); i++) { - if (fgKeys.get(i) == o) { - fgValues.set(i, document); - return; - } - } - fgKeys.add(o); - fgValues.add(document); - } - - public static void remove(IDocument document) { - if (document != null) { - if (DEBUG) System.out.println("DocumentManager.remove: " + document); //$NON-NLS-1$ - for (int i= 0; i < fgValues.size(); i++) { - if (fgValues.get(i) == document) { - fgKeys.remove(i); - fgValues.remove(i); - return; - } - } - if (DEBUG) System.out.println("DocumentManager.remove: not found"); //$NON-NLS-1$ - } - } - - public static void dump() { - if (DEBUG) System.out.println("DocumentManager: managed docs:" + fgValues.size()); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java deleted file mode 100644 index 43c09b13d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.ResourceBundle; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.BadLocationException; - -import org.eclipse.ui.*; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.compare.*; -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.IStreamContentAccessor; - - -public class EditionAction extends BaseCompareAction { - - /** - * Implements the IStreamContentAccessor and ITypedElement protocols - * for a Document. - */ - class DocumentBufferNode implements ITypedElement, IEncodedStreamContentAccessor { - private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - private IDocument fDocument; - private IFile fFile; - - DocumentBufferNode(IDocument document, IFile file) { - fDocument= document; - fFile= file; - } - - public String getName() { - return fFile.getName(); - } - - public String getType() { - return fFile.getFileExtension(); - } - - public Image getImage() { - return null; - } - - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fDocument.get(), UTF_16)); - } - - public String getCharset() { - return UTF_16; - } - } - - private String fBundleName; - private boolean fReplaceMode; - protected boolean fPrevious= false; - protected String fHelpContextId; - - EditionAction(boolean replaceMode, String bundleName) { - fReplaceMode= replaceMode; - fBundleName= bundleName; - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getFiles(selection).length == 1; // we don't support multiple selection for now - } - - protected void run(ISelection selection) { - IFile[] files= Utilities.getFiles(selection); - for (int i= 0; i < files.length; i++) - doFromHistory(files[i]); - } - - private void doFromHistory(final IFile file) { - - ResourceBundle bundle= ResourceBundle.getBundle(fBundleName); - String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - - Shell parentShell= CompareUIPlugin.getShell(); - - IFileState states[]= null; - try { - states= file.getHistory(null); - } catch (CoreException ex) { - MessageDialog.openError(parentShell, title, ex.getMessage()); - return; - } - - if (states == null || states.length <= 0) { - String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ - MessageDialog.openInformation(parentShell, title, msg); - return; - } - - ITypedElement base= new ResourceNode(file); - - IDocument document= getDocument(file); - ITypedElement target= base; - if (document != null) - target= new DocumentBufferNode(document, file); - - ITypedElement[] editions= new ITypedElement[states.length+1]; - editions[0]= base; - for (int i= 0; i < states.length; i++) - editions[i+1]= new HistoryItem(base, states[i]); - - EditionSelectionDialog d= new EditionSelectionDialog(parentShell, bundle); - d.setEditionTitleArgument(file.getName()); - d.setEditionTitleImage(CompareUIPlugin.getImage(file)); - //d.setHideIdenticalEntries(false); - if (fHelpContextId != null) - d.setHelpContextId(fHelpContextId); - - if (fReplaceMode) { - - ITypedElement ti= null; - if (fPrevious) - ti= d.selectPreviousEdition(target, editions, null); - else - ti= d.selectEdition(target, editions, null); - - if (ti instanceof IStreamContentAccessor) { - IStreamContentAccessor sa= (IStreamContentAccessor)ti; - - if (Utilities.validateResource(file, parentShell, title)) { - try { - - if (document != null) - updateDocument(document, sa); - else - updateWorkspace(bundle, parentShell, sa, file); - - } catch (InterruptedException x) { - // Do nothing. Operation has been canceled by user. - - } catch (InvocationTargetException x) { - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$ - } - } - } - } else { - d.setCompareMode(true); - - d.selectEdition(target, editions, null); - } - } - - private void updateWorkspace(final ResourceBundle bundle, Shell shell, - final IStreamContentAccessor sa, final IFile file) - throws InvocationTargetException, InterruptedException { - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws InvocationTargetException { - try { - String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$ - pm.beginTask(taskName, IProgressMonitor.UNKNOWN); - file.setContents(sa.getContents(), false, true, pm); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - pm.done(); - } - } - }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); - } - - private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { - try { - String text= Utilities.readString(sa); - document.replace(0, document.getLength(), text); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } catch (BadLocationException e) { - throw new InvocationTargetException(e); - } - } - - private IDocument getDocument(IFile file) { - IWorkbench wb= PlatformUI.getWorkbench(); - if (wb == null) - return null; - IWorkbenchWindow[] ws= wb.getWorkbenchWindows(); - if (ws == null) - return null; - - FileEditorInput test= new FileEditorInput(file); - - for (int i= 0; i < ws.length; i++) { - IWorkbenchWindow w= ws[i]; - IWorkbenchPage[] wps= w.getPages(); - if (wps != null) { - for (int j= 0; j < wps.length; j++) { - IWorkbenchPage wp= wps[j]; - IEditorPart ep= wp.findEditor(test); - if (ep instanceof ITextEditor) { - ITextEditor te= (ITextEditor) ep; - IDocumentProvider dp= te.getDocumentProvider(); - if (dp != null) { - IDocument doc= dp.getDocument(ep); - if (doc != null) - return doc; - } - } - } - } - } - return null; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java deleted file mode 100644 index 58d12b4fb..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; - -/** - * The default exception handler shows an error dialog when one of its handle methods - * is called. If the passed exception is a CoreException an error dialog - * pops up showing the exception's status information. For a InvocationTargetException - * a normal message dialog pops up showing the exception's message. Additionally the exception - * is written to the platform log. - */ -public class ExceptionHandler { - - private static ExceptionHandler fgInstance= new ExceptionHandler(); - - /* - * Logs the given exception using the platform's logging mechanism. The exception is - * logged as an error with the error code JavaStatusConstants.INTERNAL_ERROR. - */ - public static void log(Throwable t, String message) { - CompareUIPlugin.log(new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), - CompareUIPlugin.INTERNAL_ERROR, message, t)); - } - - /** - * Handles the given CoreException. The workbench shell is used as a parent - * for the dialog window. - * - * @param e the CoreException to be handled - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(CoreException e, String title, String message) { - handle(e, CompareUIPlugin.getShell(), title, message); - } - - /** - * Handles the given CoreException. - * - * @param e the CoreException to be handled - * @param parent the dialog window's parent shell - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(CoreException e, Shell parent, String title, String message) { - fgInstance.perform(e, parent, title, message); - } - - /** - * Handles the given InvocationTargetException. The workbench shell is used - * as a parent for the dialog window. - * - * @param e the InvocationTargetException to be handled - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(InvocationTargetException e, String title, String message) { - handle(e, CompareUIPlugin.getShell(), title, message); - } - - /** - * Handles the given InvocationTargetException. - * - * @param e the InvocationTargetException to be handled - * @param parent the dialog window's parent shell - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(InvocationTargetException e, Shell parent, String title, String message) { - fgInstance.perform(e, parent, title, message); - } - - //---- Hooks for subclasses to control exception handling ------------------------------------ - - protected void perform(CoreException e, Shell shell, String title, String message) { - CompareUIPlugin.log(e); - IStatus status= e.getStatus(); - if (status != null) { - ErrorDialog.openError(shell, title, message, status); - } else { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } - } - - protected void perform(InvocationTargetException e, Shell shell, String title, String message) { - Throwable target= e.getTargetException(); - if (target instanceof CoreException) { - perform((CoreException)target, shell, title, message); - } else { - CompareUIPlugin.log(e); - if (e.getMessage() != null && e.getMessage().length() > 0) { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } else { - displayMessageDialog(e, target.getMessage(), shell, title, message); - } - } - } - - //---- Helper methods ----------------------------------------------------------------------- - - private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) { - StringWriter msg= new StringWriter(); - if (message != null) { - msg.write(message); - msg.write("\n\n"); //$NON-NLS-1$ - } - if (exceptionMessage == null || exceptionMessage.length() == 0) - msg.write(CompareMessages.getString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$ - else - msg.write(exceptionMessage); - MessageDialog.openError(shell, title, msg.toString()); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java deleted file mode 100644 index a6df241e4..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.compare.CompareUI; - -/** - * Help context ids for the Compare UI. - *

- * This interface contains constants only; it is not intended to be implemented - * or extended. - *

- * - */ -public interface ICompareContextIds { - - public static final String PREFIX= CompareUI.PLUGIN_ID + '.'; - - // Dialogs - public static final String EDITION_DIALOG= PREFIX + "edition_dialog_context"; //$NON-NLS-1$ - - public static final String COMPARE_EDITOR= PREFIX + "compare_editor_context"; //$NON-NLS-1$ - public static final String PATCH_INPUT_WIZARD_PAGE= PREFIX + "patch_input_wizard_page_context"; //$NON-NLS-1$ - public static final String PATCH_PREVIEW_WIZARD_PAGE= PREFIX + "patch_preview_wizard_page_context"; //$NON-NLS-1$ - public static final String ADD_FROM_HISTORY_DIALOG= PREFIX + "add_from_history_dialog_context"; //$NON-NLS-1$ - public static final String COMPARE_DIALOG= PREFIX + "compare_dialog_context"; //$NON-NLS-1$ - public static final String COMPARE_WITH_EDITION_DIALOG= PREFIX + "compare_with_edition_dialog_context"; //$NON-NLS-1$ - public static final String REPLACE_WITH_EDITION_DIALOG= PREFIX + "replace_with_edition_dialog_context"; //$NON-NLS-1$ - - // Viewer - public static final String TEXT_MERGE_VIEW= PREFIX + "text_merge_view_context"; //$NON-NLS-1$ - public static final String IMAGE_COMPARE_VIEW= PREFIX + "image_compare_view_context"; //$NON-NLS-1$ - public static final String BINARY_COMPARE_VIEW= PREFIX + "binary_compare_view_context"; //$NON-NLS-1$ - public static final String DIFF_VIEW= PREFIX + "diff_view_context"; //$NON-NLS-1$ - - // Actions - public static final String GLOBAL_NEXT_DIFF_ACTION= PREFIX + "global_next_diff_action_context"; //$NON-NLS-1$ - public static final String GLOBAL_PREVIOUS_DIFF_ACTION= PREFIX + "global_previous_diff_action_context"; //$NON-NLS-1$ - public static final String NEXT_DIFF_ACTION= PREFIX + "next_diff_action_context"; //$NON-NLS-1$ - public static final String PREVIOUS_DIFF_ACTION= PREFIX + "previous_diff_action_context"; //$NON-NLS-1$ - public static final String IGNORE_WHITESPACE_ACTION= PREFIX + "ignore_whitespace_action_context"; //$NON-NLS-1$ - - // Preference page - public static final String COMPARE_PREFERENCE_PAGE= PREFIX + "compare_preference_page_context"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java deleted file mode 100644 index eab7f523d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -public interface INavigatable { - - static final String NAVIGATOR_PROPERTY= "org.eclipse.compare.internal.Navigator"; //$NON-NLS-1$ - - /* - * Returns true if at end or beginning. - */ - boolean gotoDifference(boolean next); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java deleted file mode 100644 index 013885909..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -/* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ -public interface IOpenable { - - static final String OPENABLE_PROPERTY= "org.eclipse.compare.internal.Openable"; //$NON-NLS-1$ - - /** - * Opens the selected element - */ - void openSelected(); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java deleted file mode 100644 index 359d6a293..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.resources.IResource; - -public interface IResourceProvider { - - /** - * Returns the corresponding resource for this object or null. - * - * @return the corresponding resource or null - */ - IResource getResource(); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java deleted file mode 100644 index a15db7c68..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -public interface ISavable { - - void save(IProgressMonitor pm) throws CoreException; -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java deleted file mode 100644 index 2dda66e0d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.compare.CompareConfiguration; - -/** - * A factory object for creating a Viewers from a descriptor. - *

- * It is used when registering a viewer for a specific type - * in CompareUIPlugin.registerContentViewerDescriptor and - * in CompareUIPlugin.registerStructureViewerDescriptor. - * - * @see org.eclipse.compare.structuremergeviewer.IStructureCreator - * @see CompareUIPlugin - */ -public interface IViewerDescriptor { - - /** - * Creates a new viewer from this descriptor under the given STW parent control. - * If the current viewer has the same type as a new viewer - * the implementation of this method is free to return the current viewer instead. - * - * @param currentViewer the current viewer which is going to be replaced with a new viewer. - * @param parent the SWT parent control under which the new viewer has to be created. - * @param config a compare configuration the new viewer might be interested in. - * @return a new viewer or the current viewer. - */ - Viewer createViewer(Viewer currentViewer, Composite parent, CompareConfiguration config); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java deleted file mode 100644 index b6b0fa14d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.compare.*; - -/** - * Toggles the ICompareConfiguration.IGNORE_WS property of an - * ICompareConfiguration. - */ -public class IgnoreWhiteSpaceAction extends ChangePropertyAction { - - public IgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration cc) { - super(bundle, cc, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java deleted file mode 100644 index 7a9266b49..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; - -/** - * A Canvas showing a single centered SWT Image. - * If the Image is larger than the Canvas, - * Scrollbars will appear. - */ -class ImageCanvas extends Canvas { - - private Image fImage; - - /* - * Create a new ImageCanvas with the given SWT stylebits. - * (SWT.H_SCROLL and SWT.V_SCROLL are automtically added). - */ - public ImageCanvas(Composite parent, int style) { - super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL); - - ScrollBar sb= getHorizontalBar(); - sb.setIncrement(20); - sb.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - repaint(); - } - }); - - sb= getVerticalBar(); - sb.setIncrement(20); - sb.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - repaint(); - } - }); - - addListener(SWT.Resize, new Listener() { - public void handleEvent(Event e) { - updateScrollbars(); - } - }); - - addListener(SWT.Paint, new Listener() { - public void handleEvent(Event event) { - paint(event.gc); - } - }); - } - - /* - * Set the SWT Image to use as the ImageCanvas contents. - */ - public void setImage(Image img) { - fImage= img; - - if (!isDisposed()) { - getHorizontalBar().setSelection(0); - getVerticalBar().setSelection(0); - updateScrollbars(); - getParent().layout(); - redraw(); - } - } - - public void repaint() { - if (!isDisposed()) { - GC gc= new GC(this); - paint(gc); - gc.dispose(); - } - } - - void paint(GC gc) { - if (fImage != null) { - Rectangle bounds= fImage.getBounds(); - Rectangle clientArea= getClientArea(); - - int x; - if (bounds.width < clientArea.width) - x= (clientArea.width - bounds.width) / 2; - else - x= -getHorizontalBar().getSelection(); - - int y; - if (bounds.height < clientArea.height) - y= (clientArea.height - bounds.height) / 2; - else - y= -getVerticalBar().getSelection(); - - gc.drawImage(fImage, x, y); - } - } - - /** - * @private - */ - void updateScrollbars() { - Rectangle bounds= fImage != null ? fImage.getBounds() : new Rectangle(0, 0, 0, 0); - Point size= getSize(); - Rectangle clientArea= getClientArea(); - - ScrollBar horizontal= getHorizontalBar(); - if (bounds.width <= clientArea.width) { - horizontal.setVisible(false); - horizontal.setSelection(0); - } else { - horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement()); - int max= bounds.width + (size.x - clientArea.width); - horizontal.setMaximum(max); - horizontal.setThumb(size.x > max ? max : size.x); - horizontal.setVisible(true); - } - - ScrollBar vertical= getVerticalBar(); - if (bounds.height <= clientArea.height) { - vertical.setVisible(false); - vertical.setSelection(0); - } else { - vertical.setPageIncrement(clientArea.height - vertical.getIncrement()); - int max= bounds.height + (size.y - clientArea.height); - vertical.setMaximum(max); - vertical.setThumb(size.y > max ? max : size.y); - vertical.setVisible(true); - } - } - -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java deleted file mode 100644 index fd733547a..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.InputStream; -import java.io.IOException; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.compare.*; -import org.eclipse.compare.contentmergeviewer.ContentMergeViewer; - -/** - */ -public class ImageMergeViewer extends ContentMergeViewer { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.ImageMergeViewerResources"; //$NON-NLS-1$ - - private Object fLeftImage; - private Object fRightImage; - - private ImageCanvas fAncestor; - private ImageCanvas fLeft; - private ImageCanvas fRight; - - - public ImageMergeViewer(Composite parent, int styles, CompareConfiguration mp) { - super(styles, ResourceBundle.getBundle(BUNDLE_NAME), mp); - - WorkbenchHelp.setHelp(parent, ICompareContextIds.IMAGE_COMPARE_VIEW); - - buildControl(parent); - String title= Utilities.getString(getResourceBundle(), "title"); //$NON-NLS-1$ - getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, title); - } - - protected void updateContent(Object ancestor, Object left, Object right) { - - setInput(fAncestor, ancestor); - - fLeftImage= left; - setInput(fLeft, left); - - fRightImage= right; - setInput(fRight, right); - } - - /* - * We can't modify the contents of either side we just return null. - */ - protected byte[] getContents(boolean left) { - return null; - } - - public void createControls(Composite composite) { - fAncestor= new ImageCanvas(composite, SWT.NO_FOCUS); - fLeft= new ImageCanvas(composite, SWT.NO_FOCUS); - fRight= new ImageCanvas(composite, SWT.NO_FOCUS); - } - - private static void setInput(ImageCanvas canvas, Object input) { - if (canvas != null) { - - InputStream stream= null; - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - if (sca != null) { - try { - stream= sca.getContents(); - } catch (CoreException ex) { - // NeedWork - } - } - } - - Image image= null; - Display display= canvas.getDisplay(); - if (stream != null) { - try { - image= new Image(display, stream); - } catch (SWTException ex) { - // silently ignored - } - } - - canvas.setImage(image); - if (image != null) { - canvas.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - } else { - canvas.setBackground(null); - } - - if (stream != null) { - try { - stream.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - } - - protected void handleResizeAncestor(int x, int y, int width, int height) { - if (width > 0) { - fAncestor.setVisible(true); - fAncestor.setBounds(x, y, width, height); - } else { - fAncestor.setVisible(false); - } - } - - protected void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height) { - fLeft.setBounds(x, y, width1, height); - fRight.setBounds(x+width1+centerWidth, y, width2, height); - } - - protected void copy(boolean leftToRight) { - if (leftToRight) { - fRightImage= fLeftImage; - setInput(fRight, fRightImage); - setRightDirty(true); - } else { - fLeftImage= fRightImage; - setInput(fLeft, fLeftImage); - setLeftDirty(true); - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java deleted file mode 100644 index ae0ab7813..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.compare.*; -import org.eclipse.jface.viewers.Viewer; - -/** - * A factory object for the ImageMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class ImageMergeViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new ImageMergeViewer(parent, SWT.NULL, mp); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties deleted file mode 100644 index cb23466b0..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)ImageMergeViewerResources.properties -# -# Resource strings for ImageMergeViewer.java - -title= Image Compare - -##################################################### -# Actions -##################################################### - -action.CopyLeftToRight.label= Copy Left to Right -action.CopyLeftToRight.tooltip= Copy Image from Left to Right -action.CopyLeftToRight.image= elcl16/copy_r_co.gif - -action.CopyRightToLeft.label= Copy Right to Left -action.CopyRightToLeft.tooltip= Copy Image from Right to Left -action.CopyRightToLeft.image= elcl16/copy_l_co.gif - -action.EnableAncestor.label= Enable Ancestor Pane -action.EnableAncestor.tooltip= Control Visibility of Ancestor Pane -action.EnableAncestor.image= elcl16/ancestorpane_co.gif diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java deleted file mode 100644 index 8de56aa1d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * A specialized content provider to show a list of editor parts. - */ -public class ListContentProvider implements IStructuredContentProvider { - List fContents; - - public ListContentProvider() { - // nothing to do - } - - public Object[] getElements(Object input) { - if (fContents != null && fContents == input) - return fContents.toArray(); - return new Object[0]; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof List) - fContents= (List)newInput; - else - fContents= null; - // we use a fixed set. - } - - public void dispose() { - // empty default implementation - } - - public boolean isDeleted(Object o) { - return fContents != null && !fContents.contains(o); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java deleted file mode 100644 index 5df991bc3..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; - -import org.eclipse.ui.dialogs.SelectionDialog; - -public class ListDialog extends SelectionDialog { - - private IStructuredContentProvider fContentProvider; - private ILabelProvider fLabelProvider; - private Object fInput; - private TableViewer fTableViewer; - private boolean fAddCancelButton; - - public ListDialog(Shell parent) { - super(parent); - fAddCancelButton= false; - } - - public void setInput(Object input) { - fInput= input; - } - - public void setContentProvider(IStructuredContentProvider sp){ - fContentProvider= sp; - } - - public void setLabelProvider(ILabelProvider lp){ - fLabelProvider= lp; - } - - public void setAddCancelButton(boolean addCancelButton) { - fAddCancelButton= addCancelButton; - } - - public TableViewer getTableViewer(){ - return fTableViewer; - } - - public boolean hasFilters(){ - return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0; - } - - public void create() { - setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE); - super.create(); - } - - protected void createButtonsForButtonBar(Composite parent) { - if (! fAddCancelButton) - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - else - super.createButtonsForButtonBar(parent); - } - - protected Control createDialogArea(Composite container) { - Composite parent= (Composite) super.createDialogArea(container); - createMessageArea(parent); - fTableViewer= new TableViewer(parent, getTableStyle()); - fTableViewer.setContentProvider(fContentProvider); - Table table= fTableViewer.getTable(); - fTableViewer.setLabelProvider(fLabelProvider); - fTableViewer.setInput(fInput); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= convertHeightInCharsToPixels(15); - gd.widthHint= convertWidthInCharsToPixels(55); - table.setLayoutData(gd); - applyDialogFont(parent); - return parent; - } - - protected int getTableStyle() { - return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java deleted file mode 100644 index d162414d7..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.graphics.Font; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.text.*; -import org.eclipse.jface.text.source.*; - -import org.eclipse.jface.viewers.SelectionChangedEvent; -/** - * Extends the JFace SourceViewer with some convenience methods. - */ -public class MergeSourceViewer extends SourceViewer - implements ISelectionChangedListener, ITextListener, IMenuListener { - - public static final String UNDO_ID= "undo"; //$NON-NLS-1$ - public static final String REDO_ID= "redo"; //$NON-NLS-1$ - public static final String CUT_ID= "cut"; //$NON-NLS-1$ - public static final String COPY_ID= "copy"; //$NON-NLS-1$ - public static final String PASTE_ID= "paste"; //$NON-NLS-1$ - public static final String DELETE_ID= "delete"; //$NON-NLS-1$ - public static final String SELECT_ALL_ID= "selectAll"; //$NON-NLS-1$ - public static final String SAVE_ID= "save"; //$NON-NLS-1$ - - class TextOperationAction extends MergeViewerAction { - - private int fOperationCode; - - TextOperationAction(int operationCode, boolean mutable, boolean selection, boolean content) { - super(mutable, selection, content); - fOperationCode= operationCode; - update(); - } - - public void run() { - if (isEnabled()) - doOperation(fOperationCode); - } - - public boolean isEnabled() { - return fOperationCode != -1 && canDoOperation(fOperationCode); - } - - public void update() { - this.setEnabled(isEnabled()); - } - } - - private ResourceBundle fResourceBundle; - private Position fRegion; - private boolean fEnabled= true; - private HashMap fActions= new HashMap(); - private IDocument fRememberedDocument; - - private boolean fAddSaveAction= true; - - - public MergeSourceViewer(Composite parent, ResourceBundle bundle) { - super(parent, null, SWT.H_SCROLL + SWT.V_SCROLL); - - fResourceBundle= bundle; - - MenuManager menu= new MenuManager(); - menu.setRemoveAllWhenShown(true); - menu.addMenuListener(this); - StyledText te= getTextWidget(); - te.setMenu(menu.createContextMenu(te)); - } - - public void rememberDocument(IDocument doc) { -// if (doc != null && fRememberedDocument != null) { -// System.err.println("MergeSourceViewer.rememberDocument: fRememberedDocument != null: shouldn't happen"); //$NON-NLS-1$ -// } - fRememberedDocument= doc; - } - - public IDocument getRememberedDocument() { - return fRememberedDocument; - } - - public void hideSaveAction() { - fAddSaveAction= false; - } - - public void setFont(Font font) { - StyledText te= getTextWidget(); - if (te != null) - te.setFont(font); - } - - public void setBackgroundColor(Color color) { - StyledText te= getTextWidget(); - if (te != null) - te.setBackground(color); - } - - public void setEnabled(boolean enabled) { - if (enabled != fEnabled) { - fEnabled= enabled; - StyledText c= getTextWidget(); - if (c != null) { - c.setEnabled(enabled); - Display d= c.getDisplay(); - c.setBackground(enabled ? d.getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null); - } - } - } - - public boolean getEnabled() { - return fEnabled; - } - - public void setRegion(Position region) { - fRegion= region; - } - - public Position getRegion() { - return fRegion; - } - - public boolean isControlOkToUse() { - StyledText t= getTextWidget(); - return t != null && !t.isDisposed(); - } - - public void setSelection(Position position) { - if (position != null) - setSelectedRange(position.getOffset(), position.getLength()); - } - - public void setLineBackground(Position position, Color c) { - StyledText t= getTextWidget(); - if (t != null && !t.isDisposed()) { - Point region= new Point(0, 0); - getLineRange(position, region); - - region.x-= getDocumentRegionOffset(); - - try { - t.setLineBackground(region.x, region.y, c); - } catch (IllegalArgumentException ex) { - // silently ignored - } - } - } - - public void resetLineBackground() { - StyledText t= getTextWidget(); - if (t != null && !t.isDisposed()) { - int lines= getLineCount(); - t.setLineBackground(0, lines, null); - } - } - - /* - * Returns number of lines in document region. - */ - public int getLineCount() { - IRegion region= getVisibleRegion(); - - int length= region.getLength(); - if (length == 0) - return 0; - - IDocument doc= getDocument(); - int startLine= 0; - int endLine= 0; - - int start= region.getOffset(); - try { - startLine= doc.getLineOfOffset(start); - } catch(BadLocationException ex) { - // silently ignored - } - try { - endLine= doc.getLineOfOffset(start+length); - } catch(BadLocationException ex) { - // silently ignored - } - - return endLine-startLine+1; - } - - public int getViewportLines() { - StyledText te= getTextWidget(); - Rectangle clArea= te.getClientArea(); - if (!clArea.isEmpty()) - return clArea.height / te.getLineHeight(); - return 0; - } - - public int getViewportHeight() { - StyledText te= getTextWidget(); - Rectangle clArea= te.getClientArea(); - if (!clArea.isEmpty()) - return clArea.height; - return 0; - } - - /* - * Returns lines - */ - public int getDocumentRegionOffset() { - int start= getVisibleRegion().getOffset(); - IDocument doc= getDocument(); - if (doc != null) { - try { - return doc.getLineOfOffset(start); - } catch(BadLocationException ex) { - // silently ignored - } - } - return 0; - } - - public int getVerticalScrollOffset() { - StyledText st= getTextWidget(); - int lineHeight= st.getLineHeight(); - return getTopInset() - ((getDocumentRegionOffset()*lineHeight) + st.getTopPixel()); - } - - /* - * Returns the start line and the number of lines which correspond to the given position. - * Starting line number is 0 based. - */ - public Point getLineRange(Position p, Point region) { - - IDocument doc= getDocument(); - - if (p == null || doc == null) { - region.x= 0; - region.y= 0; - return region; - } - - int start= p.getOffset(); - int length= p.getLength(); - - int startLine= 0; - try { - startLine= doc.getLineOfOffset(start); - } catch (BadLocationException e) { - // silently ignored - } - - int lineCount= 0; - - if (length == 0) { -// // if range length is 0 and if range starts a new line -// try { -// if (start == doc.getLineStartOffset(startLine)) { -// lines--; -// } -// } catch (BadLocationException e) { -// lines--; -// } - - } else { - int endLine= 0; - try { - endLine= doc.getLineOfOffset(start + length - 1); // why -1? - } catch (BadLocationException e) { - // silently ignored - } - lineCount= endLine-startLine+1; - } - - region.x= startLine; - region.y= lineCount; - return region; - } - - /* - * Scroll TextPart to the given line. - */ - public void vscroll(int line) { - - int srcViewSize= getLineCount(); - int srcExtentSize= getViewportLines(); - - if (srcViewSize > srcExtentSize) { - - if (line < 0) - line= 0; - - int cp= getTopIndex(); - if (cp != line) - setTopIndex(line + getDocumentRegionOffset()); - } - } - - public void addAction(String actionId, MergeViewerAction action) { - fActions.put(actionId, action); - } - - public MergeViewerAction getAction(String actionId) { - MergeViewerAction action= (MergeViewerAction) fActions.get(actionId); - if (action == null) { - action= createAction(actionId); - if (action == null) - return null; - - if (action.isContentDependent()) - addTextListener(this); - if (action.isSelectionDependent()) - addSelectionChangedListener(this); - - Utilities.initAction(action, fResourceBundle, "action." + actionId + "."); //$NON-NLS-1$ //$NON-NLS-2$ - fActions.put(actionId, action); - } - if (action.isEditableDependent() && !isEditable()) - return null; - return action; - } - - protected MergeViewerAction createAction(String actionId) { - if (UNDO_ID.equals(actionId)) - return new TextOperationAction(UNDO, true, false, true); - if (REDO_ID.equals(actionId)) - return new TextOperationAction(REDO, true, false, true); - if (CUT_ID.equals(actionId)) - return new TextOperationAction(CUT, true, true, false); - if (COPY_ID.equals(actionId)) - return new TextOperationAction(COPY, false, true, false); - if (PASTE_ID.equals(actionId)) - return new TextOperationAction(PASTE, true, false, false); - if (DELETE_ID.equals(actionId)) - return new TextOperationAction(DELETE, true, false, false); - if (SELECT_ALL_ID.equals(actionId)) - return new TextOperationAction(SELECT_ALL, false, false, false); - return null; - } - - public void selectionChanged(SelectionChangedEvent event) { - Iterator e= fActions.values().iterator(); - while (e.hasNext()) { - MergeViewerAction action= (MergeViewerAction) e.next(); - if (action.isSelectionDependent()) - action.update(); - } - } - - public void textChanged(TextEvent event) { - Iterator e= fActions.values().iterator(); - while (e.hasNext()) { - MergeViewerAction action= (MergeViewerAction) e.next(); - if (action.isContentDependent()) - action.update(); - } - } - - /* - * Allows the viewer to add menus and/or tools to the context menu. - */ - public void menuAboutToShow(IMenuManager menu) { - - menu.add(new Separator("undo")); //$NON-NLS-1$ - addMenu(menu, UNDO_ID); - addMenu(menu, REDO_ID); - - menu.add(new Separator("ccp")); //$NON-NLS-1$ - addMenu(menu, CUT_ID); - addMenu(menu, COPY_ID); - addMenu(menu, PASTE_ID); - addMenu(menu, DELETE_ID); - addMenu(menu, SELECT_ALL_ID); - - menu.add(new Separator("edit")); //$NON-NLS-1$ - menu.add(new Separator("find")); //$NON-NLS-1$ - //addMenu(menu, FIND_ID); - - menu.add(new Separator("save")); //$NON-NLS-1$ - if (fAddSaveAction) - addMenu(menu, SAVE_ID); - - menu.add(new Separator("rest")); //$NON-NLS-1$ - } - - private void addMenu(IMenuManager menu, String actionId) { - IAction action= getAction(actionId); - if (action != null) - menu.add(action); - } - - protected void handleDispose() { - - removeTextListener(this); - removeSelectionChangedListener(this); - - super.handleDispose(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java deleted file mode 100644 index d0e53995e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.ui.texteditor.IUpdate; -import org.eclipse.jface.action.Action; - - -public abstract class MergeViewerAction extends Action implements IUpdate { - - private boolean fMutable; - private boolean fSelection; - private boolean fContent; - - public MergeViewerAction(boolean mutable, boolean selection, boolean content) { - fMutable= mutable; - fSelection= selection; - fContent= content; - } - - public boolean isSelectionDependent() { - return fSelection; - } - - public boolean isContentDependent() { - return fContent; - } - - public boolean isEditableDependent() { - return fMutable; - } - - public void update() { - // empty default implementation - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java deleted file mode 100644 index d36ec19d5..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider; - -/** - * Adapts any ContentMergeViewer to work on an ICompareInput - * e.g. a DiffNode. - */ -public class MergeViewerContentProvider implements IMergeViewerContentProvider { - - private CompareConfiguration fCompareConfiguration; - private String fAncestorError; - private String fLeftError; - private String fRightError; - - public MergeViewerContentProvider(CompareConfiguration cc) { - fCompareConfiguration= cc; - } - - private boolean hasError() { - return fAncestorError != null || fLeftError != null || fRightError != null; - } - - public void dispose() { - // empty default implementation - } - - public void inputChanged(Viewer v, Object o1, Object o2) { - // we are not interested since we have no state - } - - //---- ancestor - - public void setAncestorError(String errorMessage) { - fAncestorError= errorMessage; - } - - public String getAncestorLabel(Object element) { - if (fAncestorError != null) - return fAncestorError; - return fCompareConfiguration.getAncestorLabel(element); - } - - public Image getAncestorImage(Object element) { - if (fAncestorError != null) - return null; - return fCompareConfiguration.getAncestorImage(element); - } - - public Object getAncestorContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getAncestor(); - return null; - } - - public boolean showAncestor(Object element) { - if (element instanceof ICompareInput) - return true; // fix for #45239: Show ancestor for incoming and outgoing changes - //return (((ICompareInput)element).getKind() & Differencer.DIRECTION_MASK) == Differencer.CONFLICTING; - return false; - } - - //---- left - - public void setLeftError(String errorMessage) { - fLeftError= errorMessage; - } - - public String getLeftLabel(Object element) { - if (fLeftError != null) - return fLeftError; - return fCompareConfiguration.getLeftLabel(element); - } - - public Image getLeftImage(Object element) { - if (fLeftError != null) - return null; - return fCompareConfiguration.getLeftImage(element); - } - - public Object getLeftContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getLeft(); - return null; - } - - public boolean isLeftEditable(Object element) { - if (hasError()) - return false; - if (element instanceof ICompareInput) { - Object left= ((ICompareInput) element).getLeft(); - if (left == null) { - IDiffElement parent= ((IDiffElement)element).getParent(); - if (parent instanceof ICompareInput) - left= ((ICompareInput) parent).getLeft(); - } - if (left instanceof IEditableContent) - return ((IEditableContent)left).isEditable(); - } - return false; - } - - public void saveLeftContent(Object element, byte[] bytes) { - if (element instanceof ICompareInput) { - ICompareInput node= (ICompareInput) element; - if (bytes != null) { - ITypedElement left= node.getLeft(); - // #9869: problem if left is null (because no resource exists yet) nothing is done! - if (left == null) { - node.copy(false); - left= node.getLeft(); - } - if (left instanceof IEditableContent) - ((IEditableContent)left).setContent(bytes); - if (node instanceof ResourceCompareInput.MyDiffNode) - ((ResourceCompareInput.MyDiffNode)node).fireChange(); - } else { - node.copy(false); - } - } - } - - //---- right - - public void setRightError(String errorMessage) { - fRightError= errorMessage; - } - - public String getRightLabel(Object element) { - if (fRightError != null) - return fRightError; - return fCompareConfiguration.getRightLabel(element); - } - - public Image getRightImage(Object element) { - if (fRightError != null) - return null; - return fCompareConfiguration.getRightImage(element); - } - - public Object getRightContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getRight(); - return null; - } - - public boolean isRightEditable(Object element) { - if (hasError()) - return false; - if (element instanceof ICompareInput) { - Object right= ((ICompareInput) element).getRight(); - if (right == null) { - IDiffContainer parent= ((IDiffElement)element).getParent(); - if (parent instanceof ICompareInput) - right= ((ICompareInput) parent).getRight(); - } - if (right instanceof IEditableContent) - return ((IEditableContent)right).isEditable(); - } - return false; - } - - public void saveRightContent(Object element, byte[] bytes) { - if (element instanceof ICompareInput) { - ICompareInput node= (ICompareInput) element; - if (bytes != null) { - ITypedElement right= node.getRight(); - // #9869: problem if right is null (because no resource exists yet) nothing is done! - if (right == null) { - node.copy(true); - right= node.getRight(); - } - if (right instanceof IEditableContent) - ((IEditableContent)right).setContent(bytes); - if (node instanceof ResourceCompareInput.MyDiffNode) - ((ResourceCompareInput.MyDiffNode)node).fireChange(); - } else { - node.copy(true); - } - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java deleted file mode 100644 index 495a8cf28..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; - -import org.eclipse.compare.CompareViewerPane; - -/** - * Used whenever the input is null or no viewer can be found. - */ -public class NullViewer extends AbstractViewer { - - private Control fDummy; - - public NullViewer(Composite parent) { - - fDummy= new Tree(parent, SWT.NULL); - - CompareViewerPane.clearToolBar(parent); - } - - public Control getControl() { - return fDummy; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java deleted file mode 100644 index 9cc039d26..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java +++ /dev/null @@ -1,452 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * An overlaying preference store. - */ -public class OverlayPreferenceStore implements IPreferenceStore { - - - public static final class TypeDescriptor { - private TypeDescriptor() { - // nothing to do - } - } - - public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); - public static final TypeDescriptor DOUBLE= new TypeDescriptor(); - public static final TypeDescriptor FLOAT= new TypeDescriptor(); - public static final TypeDescriptor INT= new TypeDescriptor(); - public static final TypeDescriptor LONG= new TypeDescriptor(); - public static final TypeDescriptor STRING= new TypeDescriptor(); - - public static class OverlayKey { - - TypeDescriptor fDescriptor; - String fKey; - - public OverlayKey(TypeDescriptor descriptor, String key) { - fDescriptor= descriptor; - fKey= key; - } - } - - private class PropertyListener implements IPropertyChangeListener { - - /* - * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - OverlayKey key= findOverlayKey(event.getProperty()); - if (key != null) - propagateProperty(fParent, key, fStore); - } - } - - - private IPreferenceStore fParent; - private IPreferenceStore fStore; - private OverlayKey[] fOverlayKeys; - - private PropertyListener fPropertyListener; - - - public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { - fParent= parent; - fOverlayKeys= overlayKeys; - fStore= new PreferenceStore(); - } - - private OverlayKey findOverlayKey(String key) { - for (int i= 0; i < fOverlayKeys.length; i++) { - if (fOverlayKeys[i].fKey.equals(key)) - return fOverlayKeys[i]; - } - return null; - } - - private boolean covers(String key) { - return (findOverlayKey(key) != null); - } - - private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { - - if (orgin.isDefault(key.fKey)) { - if (!target.isDefault(key.fKey)) - target.setToDefault(key.fKey); - return; - } - - TypeDescriptor d= key.fDescriptor; - if (BOOLEAN == d) { - - boolean originValue= orgin.getBoolean(key.fKey); - boolean targetValue= target.getBoolean(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (DOUBLE == d) { - - double originValue= orgin.getDouble(key.fKey); - double targetValue= target.getDouble(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (FLOAT == d) { - - float originValue= orgin.getFloat(key.fKey); - float targetValue= target.getFloat(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (INT == d) { - - int originValue= orgin.getInt(key.fKey); - int targetValue= target.getInt(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (LONG == d) { - - long originValue= orgin.getLong(key.fKey); - long targetValue= target.getLong(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (STRING == d) { - - String originValue= orgin.getString(key.fKey); - String targetValue= target.getString(key.fKey); - if (targetValue != null && originValue != null && !targetValue.equals(originValue)) - target.setValue(key.fKey, originValue); - - } - } - - public void propagate() { - for (int i= 0; i < fOverlayKeys.length; i++) - propagateProperty(fStore, fOverlayKeys[i], fParent); - } - - private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { - TypeDescriptor d= key.fDescriptor; - if (BOOLEAN == d) { - - if (forceInitialization) - target.setValue(key.fKey, true); - target.setValue(key.fKey, orgin.getBoolean(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); - - } else if (DOUBLE == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1.0D); - target.setValue(key.fKey, orgin.getDouble(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); - - } else if (FLOAT == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1.0F); - target.setValue(key.fKey, orgin.getFloat(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); - - } else if (INT == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1); - target.setValue(key.fKey, orgin.getInt(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); - - } else if (LONG == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1L); - target.setValue(key.fKey, orgin.getLong(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); - - } else if (STRING == d) { - - if (forceInitialization) - target.setValue(key.fKey, "1"); //$NON-NLS-1$ - target.setValue(key.fKey, orgin.getString(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); - - } - } - - public void load() { - for (int i= 0; i < fOverlayKeys.length; i++) - loadProperty(fParent, fOverlayKeys[i], fStore, true); - } - - public void loadDefaults() { - for (int i= 0; i < fOverlayKeys.length; i++) - setToDefault(fOverlayKeys[i].fKey); - } - - public void start() { - if (fPropertyListener == null) { - fPropertyListener= new PropertyListener(); - fParent.addPropertyChangeListener(fPropertyListener); - } - } - - public void stop() { - if (fPropertyListener != null) { - fParent.removePropertyChangeListener(fPropertyListener); - fPropertyListener= null; - } - } - - /* - * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - fStore.addPropertyChangeListener(listener); - } - - /* - * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fStore.removePropertyChangeListener(listener); - } - - /* - * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - fStore.firePropertyChangeEvent(name, oldValue, newValue); - } - - /* - * @see IPreferenceStore#contains(String) - */ - public boolean contains(String name) { - return fStore.contains(name); - } - - /* - * @see IPreferenceStore#getBoolean(String) - */ - public boolean getBoolean(String name) { - return fStore.getBoolean(name); - } - - /* - * @see IPreferenceStore#getDefaultBoolean(String) - */ - public boolean getDefaultBoolean(String name) { - return fStore.getDefaultBoolean(name); - } - - /* - * @see IPreferenceStore#getDefaultDouble(String) - */ - public double getDefaultDouble(String name) { - return fStore.getDefaultDouble(name); - } - - /* - * @see IPreferenceStore#getDefaultFloat(String) - */ - public float getDefaultFloat(String name) { - return fStore.getDefaultFloat(name); - } - - /* - * @see IPreferenceStore#getDefaultInt(String) - */ - public int getDefaultInt(String name) { - return fStore.getDefaultInt(name); - } - - /* - * @see IPreferenceStore#getDefaultLong(String) - */ - public long getDefaultLong(String name) { - return fStore.getDefaultLong(name); - } - - /* - * @see IPreferenceStore#getDefaultString(String) - */ - public String getDefaultString(String name) { - return fStore.getDefaultString(name); - } - - /* - * @see IPreferenceStore#getDouble(String) - */ - public double getDouble(String name) { - return fStore.getDouble(name); - } - - /* - * @see IPreferenceStore#getFloat(String) - */ - public float getFloat(String name) { - return fStore.getFloat(name); - } - - /* - * @see IPreferenceStore#getInt(String) - */ - public int getInt(String name) { - return fStore.getInt(name); - } - - /* - * @see IPreferenceStore#getLong(String) - */ - public long getLong(String name) { - return fStore.getLong(name); - } - - /* - * @see IPreferenceStore#getString(String) - */ - public String getString(String name) { - return fStore.getString(name); - } - - /* - * @see IPreferenceStore#isDefault(String) - */ - public boolean isDefault(String name) { - return fStore.isDefault(name); - } - - /* - * @see IPreferenceStore#needsSaving() - */ - public boolean needsSaving() { - return fStore.needsSaving(); - } - - /* - * @see IPreferenceStore#putValue(String, String) - */ - public void putValue(String name, String value) { - if (covers(name)) - fStore.putValue(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, double) - */ - public void setDefault(String name, double value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, float) - */ - public void setDefault(String name, float value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, int) - */ - public void setDefault(String name, int value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, long) - */ - public void setDefault(String name, long value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, String) - */ - public void setDefault(String name, String value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, boolean) - */ - public void setDefault(String name, boolean value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setToDefault(String) - */ - public void setToDefault(String name) { - fStore.setToDefault(name); - } - - /* - * @see IPreferenceStore#setValue(String, double) - */ - public void setValue(String name, double value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, float) - */ - public void setValue(String name, float value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, int) - */ - public void setValue(String name, int value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, long) - */ - public void setValue(String name, long value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, String) - */ - public void setValue(String name, String value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, boolean) - */ - public void setValue(String name, boolean value) { - if (covers(name)) - fStore.setValue(name, value); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java deleted file mode 100644 index fdcc7bf68..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ReplaceWithEditionAction extends EditionAction { - - public ReplaceWithEditionAction() { - super(true, "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ - fHelpContextId= ICompareContextIds.REPLACE_WITH_EDITION_DIALOG; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties deleted file mode 100644 index 76e8d323b..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)ReplaceWithEditionAction.properties -# -# Resources for ReplaceWithEditionAction.java - -title= Replace from Local History - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= {0} - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -buttonLabel= Replace - -noLocalHistoryError= No local history available for selected resource. -replaceError=Cannot replace resource (reason: {0}). - -taskName=Replacing diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java deleted file mode 100644 index 3fa6b07aa..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ReplaceWithPreviousEditionAction extends EditionAction { - - public ReplaceWithPreviousEditionAction() { - super(true, - "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ - fPrevious= true; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java deleted file mode 100644 index 669aec61d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.DialogSettings; - - -/** - * Base class for resizable Dialogs with persistent window bounds. - */ -public abstract class ResizableDialog extends Dialog { - - // dialog store id constants - private final static String DIALOG_BOUNDS_KEY= "ResizableDialogBounds"; //$NON-NLS-1$ - private static final String X= "x"; //$NON-NLS-1$ - private static final String Y= "y"; //$NON-NLS-1$ - private static final String WIDTH= "width"; //$NON-NLS-1$ - private static final String HEIGHT= "height"; //$NON-NLS-1$ - - protected ResourceBundle fBundle; - private Rectangle fNewBounds; - private IDialogSettings fSettings; - private String fContextId; - - - public ResizableDialog(Shell parent, ResourceBundle bundle) { - super(parent); - setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); - - fBundle= bundle; - - fSettings= CompareUIPlugin.getDefault().getDialogSettings(); - } - - public void setHelpContextId(String contextId) { - fContextId= contextId; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (fContextId != null) - WorkbenchHelp.setHelp(newShell, fContextId); - } - - protected Point getInitialSize() { - - int width= 0; - int height= 0; - - final Shell s= getShell(); - if (s != null) { - s.addControlListener( - new ControlListener() { - public void controlMoved(ControlEvent arg0) { - fNewBounds= s.getBounds(); - } - public void controlResized(ControlEvent arg0) { - fNewBounds= s.getBounds(); - } - } - ); - } - - IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); //$NON-NLS-1$ - if (bounds == null) { - if (fBundle != null) { - width= Utilities.getInteger(fBundle, WIDTH, 0); - height= Utilities.getInteger(fBundle, HEIGHT, 0); - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - if (width <= 0) - width= parentSize.x-300; - if (height <= 0) - height= parentSize.y-200; - } - } else { - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - width= parentSize.x-100; - height= parentSize.y-100; - } - } - if (width < 700) - width= 700; - if (height < 500) - height= 500; - } else { - try { - width= bounds.getInt(WIDTH); - } catch (NumberFormatException e) { - width= 700; - } - try { - height= bounds.getInt(HEIGHT); - } catch (NumberFormatException e) { - height= 500; - } - } - - return new Point(width, height); - } - - protected Point getInitialLocation(Point initialSize) { - Point loc= super.getInitialLocation(initialSize); - - IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); - if (bounds != null) { - try { - loc.x= bounds.getInt(X); - } catch (NumberFormatException e) { - // silently ignored - } - try { - loc.y= bounds.getInt(Y); - } catch (NumberFormatException e) { - // silently ignored - } - } - return loc; - } - - public boolean close() { - boolean closed= super.close(); - if (closed && fNewBounds != null) - saveBounds(fNewBounds); - return closed; - } - - private void saveBounds(Rectangle bounds) { - IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY); - if (dialogBounds == null) { - dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY); - fSettings.addSection(dialogBounds); - } - dialogBounds.put(X, bounds.x); - dialogBounds.put(Y, bounds.y); - dialogBounds.put(WIDTH, bounds.width); - dialogBounds.put(HEIGHT, bounds.height); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java deleted file mode 100644 index d2de626b2..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A two-way or three-way compare for arbitrary IResources. - */ -class ResourceCompareInput extends CompareEditorInput { - - private static final boolean NORMALIZE_CASE= true; - - private boolean fThreeWay= false; - private Object fRoot; - private IStructureComparator fAncestor; - private IStructureComparator fLeft; - private IStructureComparator fRight; - private IResource fAncestorResource; - private IResource fLeftResource; - private IResource fRightResource; - private DiffTreeViewer fDiffViewer; - private IAction fOpenAction; - - class MyDiffNode extends DiffNode { - - private boolean fDirty= false; - private ITypedElement fLastId; - private String fLastName; - - - public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - super(parent, description, ancestor, left, right); - } - public void fireChange() { - super.fireChange(); - setDirty(true); - fDirty= true; - if (fDiffViewer != null) - fDiffViewer.refresh(this); - } - void clearDirty() { - fDirty= false; - } - public String getName() { - if (fLastName == null) - fLastName= super.getName(); - if (fDirty) - return '<' + fLastName + '>'; - return fLastName; - } - - public ITypedElement getId() { - ITypedElement id= super.getId(); - if (id == null) - return fLastId; - fLastId= id; - return id; - } - } - - static class FilteredBufferedResourceNode extends BufferedResourceNode { - FilteredBufferedResourceNode(IResource resource) { - super(resource); - } - protected IStructureComparator createChild(IResource child) { - String name= child.getName(); - if (CompareUIPlugin.getDefault().filter(name, child instanceof IContainer, false)) - return null; - return new FilteredBufferedResourceNode(child); - } - } - - /* - * Creates an compare editor input for the given selection. - */ - ResourceCompareInput(CompareConfiguration config) { - super(config); - } - - public Viewer createDiffViewer(Composite parent) { - fDiffViewer= new DiffTreeViewer(parent, getCompareConfiguration()) { - protected void fillContextMenu(IMenuManager manager) { - - if (fOpenAction == null) { - fOpenAction= new Action() { - public void run() { - handleOpen(null); - } - }; - Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents."); //$NON-NLS-1$ - } - - boolean enable= false; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection)selection; - if (ss.size() == 1) { - Object element= ss.getFirstElement(); - if (element instanceof MyDiffNode) { - ITypedElement te= ((MyDiffNode) element).getId(); - if (te != null) - enable= !ITypedElement.FOLDER_TYPE.equals(te.getType()); - } else - enable= true; - } - } - fOpenAction.setEnabled(enable); - - manager.add(fOpenAction); - - super.fillContextMenu(manager); - } - }; - return fDiffViewer; - } - - void setSelection(ISelection s) { - - IResource[] selection= Utilities.getResources(s); - - fThreeWay= selection.length == 3; - - fAncestorResource= null; - fLeftResource= selection[0]; - fRightResource= selection[1]; - if (fThreeWay) { - fLeftResource= selection[1]; - fRightResource= selection[2]; - } - - fAncestor= null; - fLeft= getStructure(fLeftResource); - fRight= getStructure(fRightResource); - - if (fThreeWay) { - fAncestorResource= selection[0]; - fAncestor= getStructure(fAncestorResource); - } - } - - /* - * Returns true if compare can be executed for the given selection. - */ - public boolean isEnabled(ISelection s) { - - IResource[] selection= Utilities.getResources(s); - if (selection.length < 2 || selection.length > 3) - return false; - - fThreeWay= selection.length == 3; - - fLeftResource= selection[0]; - fRightResource= selection[1]; - if (fThreeWay) { - fLeftResource= selection[1]; - fRightResource= selection[2]; - } - - if (!comparable(fLeftResource, fRightResource)) - return false; - - if (fThreeWay) { - fAncestorResource= selection[0]; - - if (!comparable(fLeftResource, fRightResource)) - return false; - } - - return true; - } - - /** - * Initializes the images in the compare configuration. - */ - void initializeCompareConfiguration() { - CompareConfiguration cc= getCompareConfiguration(); - if (fLeftResource != null) { - cc.setLeftLabel(buildLabel(fLeftResource)); - cc.setLeftImage(CompareUIPlugin.getImage(fLeftResource)); - } - if (fRightResource != null) { - cc.setRightLabel(buildLabel(fRightResource)); - cc.setRightImage(CompareUIPlugin.getImage(fRightResource)); - } - if (fThreeWay && fAncestorResource != null) { - cc.setAncestorLabel(buildLabel(fAncestorResource)); - cc.setAncestorImage(CompareUIPlugin.getImage(fAncestorResource)); - } - } - - /* - * Returns true if both resources are either structured or unstructured. - */ - private boolean comparable(IResource c1, IResource c2) { - return hasStructure(c1) == hasStructure(c2); - } - - /* - * Returns true if the given argument has a structure. - */ - private boolean hasStructure(IResource input) { - - if (input instanceof IContainer) - return true; - - if (input instanceof IFile) { - IFile file= (IFile) input; - String type= file.getFileExtension(); - if (type != null) { - type= normalizeCase(type); - return "JAR".equals(type) || "ZIP".equals(type); //$NON-NLS-2$ //$NON-NLS-1$ - } - } - - return false; - } - - /* - * Creates a IStructureComparator for the given input. - * Returns null if no IStructureComparator - * can be found for the IResource. - */ - private IStructureComparator getStructure(IResource input) { - - if (input instanceof IContainer) - return new FilteredBufferedResourceNode(input); - - if (input instanceof IFile) { - IStructureComparator rn= new FilteredBufferedResourceNode(input); - IFile file= (IFile) input; - String type= normalizeCase(file.getFileExtension()); - if ("JAR".equals(type) || "ZIP".equals(type)) //$NON-NLS-2$ //$NON-NLS-1$ - return new ZipFileStructureCreator().getStructure(rn); - return rn; - } - return null; - } - - /* - * Performs a two-way or three-way diff on the current selection. - */ - public Object prepareInput(IProgressMonitor pm) throws InvocationTargetException { - - try { - // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty - fLeftResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - fRightResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - if (fThreeWay && fAncestorResource != null) - fAncestorResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - // end fix - - pm.beginTask(Utilities.getString("ResourceCompare.taskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - - String leftLabel= fLeftResource.getName(); - String rightLabel= fRightResource.getName(); - - String title; - if (fThreeWay) { - String format= Utilities.getString("ResourceCompare.threeWay.title"); //$NON-NLS-1$ - String ancestorLabel= fAncestorResource.getName(); - title= MessageFormat.format(format, new String[] {ancestorLabel, leftLabel, rightLabel}); - } else { - String format= Utilities.getString("ResourceCompare.twoWay.title"); //$NON-NLS-1$ - title= MessageFormat.format(format, new String[] {leftLabel, rightLabel}); - } - setTitle(title); - - Differencer d= new Differencer() { - protected Object visit(Object parent, int description, Object ancestor, Object left, Object right) { - return new MyDiffNode((IDiffContainer) parent, description, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); - } - }; - - fRoot= d.findDifferences(fThreeWay, pm, null, fAncestor, fLeft, fRight); - return fRoot; - - } catch (CoreException ex) { - throw new InvocationTargetException(ex); - } finally { - pm.done(); - } - } - - public String getToolTipText() { - if (fLeftResource != null && fRightResource != null) { - String leftLabel= fLeftResource.getFullPath().makeRelative().toString(); - String rightLabel= fRightResource.getFullPath().makeRelative().toString(); - if (fThreeWay) { - String format= Utilities.getString("ResourceCompare.threeWay.tooltip"); //$NON-NLS-1$ - String ancestorLabel= fAncestorResource.getFullPath().makeRelative().toString(); - return MessageFormat.format(format, new String[] {ancestorLabel, leftLabel, rightLabel}); - } - String format= Utilities.getString("ResourceCompare.twoWay.tooltip"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] {leftLabel, rightLabel}); - } - // fall back - return super.getToolTipText(); - } - - private String buildLabel(IResource r) { - String n= r.getFullPath().toString(); - if (n.charAt(0) == IPath.SEPARATOR) - return n.substring(1); - return n; - } - - public void saveChanges(IProgressMonitor pm) throws CoreException { - super.saveChanges(pm); - if (fRoot instanceof DiffNode) { - try { - commit(pm, (DiffNode) fRoot); - } finally { - if (fDiffViewer != null) - fDiffViewer.refresh(); - setDirty(false); - } - } - } - - /* - * Recursively walks the diff tree and commits all changes. - */ - private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - - if (node instanceof MyDiffNode) - ((MyDiffNode)node).clearDirty(); - - ITypedElement left= node.getLeft(); - if (left instanceof BufferedResourceNode) - ((BufferedResourceNode) left).commit(pm); - - ITypedElement right= node.getRight(); - if (right instanceof BufferedResourceNode) - ((BufferedResourceNode) right).commit(pm); - - IDiffElement[] children= node.getChildren(); - if (children != null) { - for (int i= 0; i < children.length; i++) { - IDiffElement element= children[i]; - if (element instanceof DiffNode) - commit(pm, (DiffNode) element); - } - } - } - - /* (non Javadoc) - * see IAdaptable.getAdapter - */ - public Object getAdapter(Class adapter) { - if (IFile[].class.equals(adapter)) { - HashSet collector= new HashSet(); - collectDirtyResources(fRoot, collector); - return (IFile[]) collector.toArray(new IFile[collector.size()]); - } - return super.getAdapter(adapter); - } - - private void collectDirtyResources(Object o, Set collector) { - if (o instanceof DiffNode) { - DiffNode node= (DiffNode) o; - - ITypedElement left= node.getLeft(); - if (left instanceof BufferedResourceNode) { - BufferedResourceNode bn= (BufferedResourceNode) left; - if (bn.isDirty()) { - IResource resource= bn.getResource(); - if (resource instanceof IFile) - collector.add(resource); - } - } - - ITypedElement right= node.getRight(); - if (right instanceof BufferedResourceNode) { - BufferedResourceNode bn= (BufferedResourceNode) right; - if (bn.isDirty()) { - IResource resource= bn.getResource(); - if (resource instanceof IFile) - collector.add(resource); - } - } - - IDiffElement[] children= node.getChildren(); - if (children != null) { - for (int i= 0; i < children.length; i++) { - IDiffElement element= children[i]; - if (element instanceof DiffNode) - collectDirtyResources(element, collector); - } - } - } - } - - private static String normalizeCase(String s) { - if (NORMALIZE_CASE && s != null) - return s.toUpperCase(); - return s; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java deleted file mode 100644 index 581527039..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.compare.*; - -/** - * Toggles the ICompareConfiguration.SHOW_PSEUDO_CONFLICTS property of an - * ICompareConfiguration. - */ -public class ShowPseudoConflicts extends ChangePropertyAction { - - public ShowPseudoConflicts(ResourceBundle bundle, CompareConfiguration cc) { - super(bundle, cc, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java deleted file mode 100644 index a28339bfb..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.Document; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -public class SimpleTextViewer extends AbstractViewer { - - private SourceViewer fSourceViewer; - private ICompareInput fInput; - - - SimpleTextViewer(Composite parent) { - fSourceViewer= new SourceViewer(parent, null, SWT.H_SCROLL + SWT.V_SCROLL); - fSourceViewer.setEditable(false); - } - - public Control getControl() { - return fSourceViewer.getTextWidget(); - } - - public void setInput(Object input) { - if (input instanceof IStreamContentAccessor) { - fSourceViewer.setDocument(new Document(getString(input))); - } else if (input instanceof ICompareInput) { - fInput= (ICompareInput) input; - ITypedElement left= fInput.getLeft(); - fSourceViewer.setDocument(new Document(getString(left))); - } - } - - public Object getInput() { - return fInput; - } - - private String getString(Object input) { - - if (input instanceof IStreamContentAccessor) { - try { - return Utilities.readString((IStreamContentAccessor) input); - } catch (CoreException ex) { - // NeedWork - } - } - return ""; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java deleted file mode 100644 index 16225ecb4..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.compare.IStreamMerger; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -/** - * A factory proxy for creating a StructureCreator. - */ -class StreamMergerDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - - private IConfigurationElement fElement; - - /* - * Creates a new sorter node with the given configuration element. - */ - public StreamMergerDescriptor(IConfigurationElement element) { - fElement= element; - } - - /* - * Creates a new stream merger from this node. - */ - public IStreamMerger createStreamMerger() { - try { - return (IStreamMerger)fElement.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException ex) { - //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } catch (ClassCastException ex) { - //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java deleted file mode 100644 index be8a4d6b9..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -import org.eclipse.compare.structuremergeviewer.IStructureCreator; - -/** - * A factory proxy for creating a StructureCreator. - */ -public class StructureCreatorDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - - private IConfigurationElement fElement; - - /* - * Creates a new sorter node with the given configuration element. - */ - public StructureCreatorDescriptor(IConfigurationElement element) { - fElement= element; - } - - /* - * Creates a new sorter from this node. - */ - public IStructureCreator createStructureCreator() { - try { - return (IStructureCreator)fElement.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException ex) { - CompareUIPlugin.log(ex.getStatus()); - //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } catch (ClassCastException ex) { - //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } - } - - /* - * Returns the structure creator's extensions. - */ - public String getExtension() { - return fElement.getAttribute(EXTENSIONS_ATTRIBUTE); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java deleted file mode 100644 index 739b82f0e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; - -public class TabFolderLayout extends Layout { - - protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - - Control [] children = composite.getChildren (); - int count = children.length; - int maxWidth = 0, maxHeight = 0; - for (int i=0; iTextMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class TextMergeViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new TextMergeViewer(parent, mp); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java deleted file mode 100644 index 66eaba9f8..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.IViewerCreator; - - -/** - * A factory object for the TextMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class TextViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new SimpleTextViewer(parent); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java deleted file mode 100644 index e2ecaf7eb..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.compare.rangedifferencer.IRangeComparator; -import org.eclipse.compare.contentmergeviewer.ITokenComparator; - -/** - * Implements the ITokenComparator interface for words (or tokens) - * in a string. - * A TokenComparator is used as the input for the RangeDifferencer - * engine to perform a token oriented compare on strings. - */ -public class TokenComparator implements ITokenComparator { - - private boolean fShouldEscape= true; - private String fText; - private int fCount; - private int[] fStarts; - private int[] fLengths; - - /** - * Creates a TokenComparator for the given string. - * - * @param text the string that is split into token - */ - public TokenComparator(String text) { - - Assert.isNotNull(text); - - fText= text; - - int length= fText.length(); - fStarts= new int[length]; // pessimistic assumption! - fLengths= new int[length]; - fCount= 0; - - char lastCategory= 0; // 0: no category - for (int i= 0; i < length; i++) { - char c= fText.charAt(i); - - char category= '?'; // unspecified category - if (Character.isWhitespace(c)) - category= ' '; // white space category - else if (Character.isDigit(c)) - category= '0'; // digits - else if (Character.isLetter(c)) - category= 'a'; // letters - - if (category != lastCategory) { - // start a new token - fStarts[fCount++]= i; - lastCategory= category; - } - fLengths[fCount-1]++; - } - } - - /** - * Creates a TokenComparator for the given string. - * - * @param text the string that is split into token - * @param shouldEscape - */ - public TokenComparator(String text, boolean shouldEscape) { - this(text); - fShouldEscape= shouldEscape; - } - - /** - * Returns the number of token in the string. - * - * @return number of token in the string - */ - public int getRangeCount() { - return fCount; - } - - /* (non Javadoc) - * see ITokenComparator.getTokenStart - */ - public int getTokenStart(int index) { - if (index < fCount) - return fStarts[index]; - return fText.length(); - } - - /* (non Javadoc) - * see ITokenComparator.getTokenLength - */ - public int getTokenLength(int index) { - if (index < fCount) - return fLengths[index]; - return 0; - } - - /** - * Returns true if a token given by the first index - * matches a token specified by the other IRangeComparator and index. - * - * @param thisIndex the number of the token within this range comparator - * @param other the range comparator to compare this with - * @param otherIndex the number of the token within the other comparator - * @return true if the token are equal - */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) { - if (other != null && getClass() == other.getClass()) { - TokenComparator tc= (TokenComparator) other; - int thisLen= getTokenLength(thisIndex); - int otherLen= tc.getTokenLength(otherIndex); - if (thisLen == otherLen) - return fText.regionMatches(false, getTokenStart(thisIndex), tc.fText, tc.getTokenStart(otherIndex), thisLen); - } - return false; - } - - /* - * Aborts the comparison if the number of tokens is too large. - * @return true to abort a token comparison - */ - public boolean skipRangeComparison(int length, int max, IRangeComparator other) { - - if (!fShouldEscape) - return false; - - if (getRangeCount() < 50 || other.getRangeCount() < 50) - return false; - - if (max < 100) - return false; - - if (length < 100) - return false; - - if (max > 800) - return true; - - if (length < max / 4) - return false; - - return true; - } - -// public static void main(String args[]) { -// //String in= "private static boolean isWhitespace(char c) {"; -// //String in= "for (int j= 0; j < l-1; j++) {"; -// String in= "for do i= 123; i++"; -// TokenComparator tc= new TokenComparator(in, false); -// -// System.out.println("n: " + tc.getRangeCount()); -// System.out.println(in); -// -// int p= 0; -// for (int i= 0; i < tc.getRangeCount(); i++) { -// int l= tc.getTokenLength(i); -// System.out.print("<"); -// -// for (int j= 0; j < l-1; j++) -// System.out.print(" "); -// } -// System.out.println(); -// -// //System.out.println("extract: <" + tc.extract(16, 1) + ">"); -// } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java deleted file mode 100644 index ef697931f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java +++ /dev/null @@ -1,592 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import java.util.List; - -import org.eclipse.swt.widgets.*; - -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.dialogs.ErrorDialog; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.ui.*; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareUI; -import org.eclipse.compare.IEncodedStreamContentAccessor; -import org.eclipse.compare.IStreamContentAccessor; - -/** - * Convenience and utility methods. - */ -public class Utilities { - - public static void registerAction(IKeyBindingService kbs, IAction a, String id) { - if (kbs != null) { - a.setActionDefinitionId(id); - kbs.registerAction(a); - } - } - - public static IWorkbenchPartSite findSite(Control c) { - while (c != null && !c.isDisposed()) { - Object data= c.getData(); - if (data instanceof IWorkbenchPart) - return ((IWorkbenchPart)data).getSite(); - c= c.getParent(); - } - return null; - } - - public static IActionBars findActionBars(Control c) { - while (c != null && !c.isDisposed()) { - Object data= c.getData(); - if (data instanceof CompareEditor) - return ((CompareEditor)data).getActionBars(); - - // PR 1GDVZV7: ITPVCM:WIN98 - CTRL + C does not work in Java source compare - if (data instanceof IViewPart) - return ((IViewPart)data).getViewSite().getActionBars(); - // end PR 1GDVZV7 - - c= c.getParent(); - } - return null; - } - - public static void setEnableComposite(Composite composite, boolean enable) { - Control[] children= composite.getChildren(); - for (int i= 0; i < children.length; i++) - children[i].setEnabled(enable); - } - - public static boolean getBoolean(CompareConfiguration cc, String key, boolean dflt) { - if (cc != null) { - Object value= cc.getProperty(key); - if (value instanceof Boolean) - return ((Boolean) value).booleanValue(); - } - return dflt; - } - - public static void firePropertyChange(ListenerList ll, Object source, String property, Object old, Object newValue) { - if (ll != null) { - PropertyChangeEvent event= null; - Object[] listeners= ll.getListeners(); - for (int i= 0; i < listeners.length; i++) { - IPropertyChangeListener l= (IPropertyChangeListener) listeners[i]; - if (event == null) - event= new PropertyChangeEvent(source, property, old, newValue); - l.propertyChange(event); - } - } - } - - public static boolean okToUse(Widget widget) { - return widget != null && !widget.isDisposed(); - } - - private static ArrayList internalGetResources(ISelection selection, Class type) { - - ArrayList tmp= new ArrayList(); - - if (selection instanceof IStructuredSelection) { - - Object[] s= ((IStructuredSelection)selection).toArray(); - - for (int i= 0; i < s.length; i++) { - - IResource resource= null; - - Object o= s[i]; - if (type.isInstance(o)) { - resource= (IResource) o; - - } else if (o instanceof IAdaptable) { - IAdaptable a= (IAdaptable) o; - Object adapter= a.getAdapter(IResource.class); - if (type.isInstance(adapter)) - resource= (IResource) adapter; - } - - if (resource != null && resource.isAccessible()) - tmp.add(resource); - } - } - - return tmp; - } - - /* - * Convenience method: extract all accessible IResources from given selection. - * Never returns null. - */ - public static IResource[] getResources(ISelection selection) { - ArrayList tmp= internalGetResources(selection, IResource.class); - return (IResource[]) tmp.toArray(new IResource[tmp.size()]); - } - - /* - * Convenience method: extract all accessible IFiles from given selection. - * Never returns null. - */ - public static IFile[] getFiles(ISelection selection) { - ArrayList tmp= internalGetResources(selection, IFile.class); - return (IFile[]) tmp.toArray(new IFile[tmp.size()]); - } - - public static byte[] readBytes(InputStream in) { - ByteArrayOutputStream bos= new ByteArrayOutputStream(); - try { - while (true) { - int c= in.read(); - if (c == -1) - break; - bos.write(c); - } - - } catch (IOException ex) { - return null; - - } finally { - Utilities.close(in); - try { - bos.close(); - } catch (IOException x) { - // silently ignored - } - } - - return bos.toByteArray(); - } - - public static String getIconPath(Display display) { - return "icons/full/"; //$NON-NLS-1$ - } - - /* - * Initialize the given Action from a ResourceBundle. - */ - public static void initAction(IAction a, 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; - } - - a.setText(getString(bundle, labelKey, labelKey)); - a.setToolTipText(getString(bundle, tooltipKey, null)); - a.setDescription(getString(bundle, descriptionKey, null)); - - String relPath= getString(bundle, imageKey, null); - if (relPath != null && relPath.trim().length() > 0) { - - String dPath; - String ePath; - - if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$ - String path= relPath.substring(1); - dPath= 'd' + path; - ePath= 'e' + path; - } else { - dPath= "dlcl16/" + relPath; //$NON-NLS-1$ - ePath= "elcl16/" + relPath; //$NON-NLS-1$ - } - - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87) - if (id != null) - a.setDisabledImageDescriptor(id); - id= CompareUIPlugin.getImageDescriptor(ePath); - if (id != null) { - a.setImageDescriptor(id); - a.setHoverImageDescriptor(id); - } - } - } - - public static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) { - - String tooltip= null; - if (checked) - tooltip= getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$ - else - tooltip= getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$ - if (tooltip == null) - tooltip= getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$ - - if (tooltip != null) - a.setToolTipText(tooltip); - - String description= null; - if (checked) - description= getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$ - else - description= getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$ - if (description == null) - description= getString(bundle, prefix + "description", null); //$NON-NLS-1$ - - if (description != null) - a.setDescription(description); - - } - - public static String getString(ResourceBundle bundle, String key, String dfltValue) { - - if (bundle != null) { - try { - return bundle.getString(key); - } catch (MissingResourceException x) { - // NeedWork - } - } - return dfltValue; - } - - public static String getFormattedString(ResourceBundle bundle, String key, String arg) { - - if (bundle != null) { - try { - return MessageFormat.format(bundle.getString(key), new String[] { arg }); - } catch (MissingResourceException x) { - // NeedWork - } - } - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - - public static String getString(String key) { - try { - return CompareUI.getResourceBundle().getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getFormattedString(String key, String arg) { - try { - return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg }); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getFormattedString(String key, String arg0, String arg1) { - try { - return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg0, arg1 }); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getString(ResourceBundle bundle, String key) { - return getString(bundle, key, key); - } - - public static int getInteger(ResourceBundle bundle, String key, int dfltValue) { - - if (bundle != null) { - try { - String s= bundle.getString(key); - if (s != null) - return Integer.parseInt(s); - } catch (NumberFormatException x) { - // NeedWork - } catch (MissingResourceException x) { - // NeedWork - } - } - return dfltValue; - } - - /** - * Answers true if the given selection contains resources that don't - * have overlapping paths and false otherwise. - */ - /* - public static boolean isSelectionNonOverlapping() throws TeamException { - IResource[] resources = getSelectedResources(); - // allow operation for non-overlapping resource selections - if(resources.length>0) { - List validPaths = new ArrayList(2); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - - // only allow cvs resources to be selected - if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) { - return false; - } - - // check if this resource overlaps other selections - IPath resourceFullPath = resource.getFullPath(); - if(!validPaths.isEmpty()) { - for (Iterator it = validPaths.iterator(); it.hasNext();) { - IPath path = (IPath) it.next(); - if(path.isPrefixOf(resourceFullPath) || - resourceFullPath.isPrefixOf(path)) { - return false; - } - } - } - validPaths.add(resourceFullPath); - - // ensure that resources are managed - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if(cvsResource.isFolder()) { - if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false; - } else { - if( ! cvsResource.isManaged()) return false; - } - } - return true; - } - return false; - } - */ - - /* validate edit utilities */ - - /** - * Status constant indicating that an validateEdit call has changed the - * content of a file on disk. - */ - private static final int VALIDATE_EDIT_PROBLEM= 10004; - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResource(IResource resource, Shell shell, String title) { - return validateResources(new IResource[] { resource }, shell, title); - } - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResources(List resources, Shell shell, String title) { - IResource r[]= (IResource[]) resources.toArray(new IResource[resources.size()]); - return validateResources(r, shell, title); - } - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResources(IResource[] resources, Shell shell, String title) { - - // get all readonly files - List readOnlyFiles= getReadonlyFiles(resources); - if (readOnlyFiles.size() == 0) - return true; - - // get timestamps of readonly files before validateEdit - Map oldTimeStamps= createModificationStampMap(readOnlyFiles); - - IFile[] files= (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]); - IStatus status= ResourcesPlugin.getWorkspace().validateEdit(files, shell); - if (! status.isOK()) { - String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, message, status); //$NON-NLS-1$ - return false; - } - - IStatus modified= null; - Map newTimeStamps= createModificationStampMap(readOnlyFiles); - for (Iterator iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) { - IFile file= (IFile) iter.next(); - if (file.isReadOnly()) { - IStatus entry= new Status(IStatus.ERROR, - CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), //$NON-NLS-1$ - null); - modified= addStatus(modified, entry); - } else if (! oldTimeStamps.get(file).equals(newTimeStamps.get(file))) { - IStatus entry= new Status(IStatus.ERROR, - CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), //$NON-NLS-1$ - null); - modified= addStatus(modified, entry); - } - } - if (modified != null) { - String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, message, modified); - return false; - } - return true; - } - - private static List getReadonlyFiles(IResource[] resources) { - List readOnlyFiles= new ArrayList(); - for (int i= 0; i < resources.length; i++) { - IResource resource= resources[i]; - ResourceAttributes resourceAttributes= resource.getResourceAttributes(); - if (resource.getType() == IResource.FILE && resourceAttributes != null && resourceAttributes.isReadOnly()) - readOnlyFiles.add(resource); - } - return readOnlyFiles; - } - - private static Map createModificationStampMap(List files) { - Map map= new HashMap(); - for (Iterator iter= files.iterator(); iter.hasNext(); ) { - IFile file= (IFile)iter.next(); - map.put(file, new Long(file.getModificationStamp())); - } - return map; - } - - private static IStatus addStatus(IStatus status, IStatus entry) { - - if (status == null) - return entry; - - if (status.isMultiStatus()) { - ((MultiStatus)status).add(entry); - return status; - } - - MultiStatus result= new MultiStatus(CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getString("ValidateEdit.error.unable_to_perform"), null); //$NON-NLS-1$ - result.add(status); - result.add(entry); - return result; - } - - // encoding - - /* - * Returns null if an error occurred. - */ - public static String readString(InputStream is, String encoding) { - if (is == null) - return null; - BufferedReader reader= null; - try { - StringBuffer buffer= new StringBuffer(); - char[] part= new char[2048]; - int read= 0; - reader= new BufferedReader(new InputStreamReader(is, encoding)); - - while ((read= reader.read(part)) != -1) - buffer.append(part, 0, read); - - return buffer.toString(); - - } catch (IOException ex) { - // NeedWork - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - return null; - } - - public static String getCharset(IResource resource) { - if (resource instanceof IEncodedStorage) { - try { - return ((IEncodedStorage)resource).getCharset(); - } catch (CoreException ex) { - // fall through - } - } - return ResourcesPlugin.getEncoding(); - } - - public static byte[] getBytes(String s, String encoding) { - byte[] bytes= null; - if (s != null) { - try { - bytes= s.getBytes(encoding); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - bytes= s.getBytes(); - } - } - return bytes; - } - - public static String readString(IStreamContentAccessor sa) throws CoreException { - InputStream is= sa.getContents(); - String encoding= null; - if (sa instanceof IEncodedStreamContentAccessor) - encoding= ((IEncodedStreamContentAccessor)sa).getCharset(); - if (encoding == null) - encoding= ResourcesPlugin.getEncoding(); - return Utilities.readString(is, encoding); - } - - public static void close(InputStream is) { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - // silently ignored - } - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java deleted file mode 100644 index 3d5dbcc6f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.compare.*; - -import org.eclipse.jface.viewers.Viewer; - -/** - * Creates Viewers from an IConfigurationElement. - */ -public class ViewerDescriptor implements IViewerDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - - private IConfigurationElement fConfiguration; - private IViewerCreator fViewerCreator; - private Class fViewerClass; - - public ViewerDescriptor(IConfigurationElement config) { - fConfiguration= config; - } - - public Viewer createViewer(Viewer currentViewer, Composite parent, CompareConfiguration mp) { - - if (currentViewer != null && currentViewer.getClass() == fViewerClass) { - //System.out.println("reused viewer: " + currentViewer.getClass().getName()); - return currentViewer; - } - - if (fViewerCreator == null) { - try { - fViewerCreator= (IViewerCreator) fConfiguration.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException e) { - // NeedWork - } - } - - if (fViewerCreator != null) { - Viewer viewer= fViewerCreator.createViewer(parent, mp); - if (viewer != null) - fViewerClass= viewer.getClass(); - return viewer; - } - - return null; - } - - public String getExtension() { - return fConfiguration.getAttribute(EXTENSIONS_ATTRIBUTE); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java deleted file mode 100644 index 0be0b1396..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ViewerSwitchingCancelled extends RuntimeException { - - private static final long serialVersionUID = 1L; - -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java deleted file mode 100644 index ce923314a..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.io.*; -import java.util.ArrayList; -import org.eclipse.compare.rangedifferencer.IRangeComparator; - -/** - * This implementation of IRangeComparator breaks an input stream into lines. - */ -class LineComparator implements IRangeComparator { - - private String[] fLines; - - public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException { - - BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding)); - String line; - ArrayList ar = new ArrayList(); - try { - while ((line = br.readLine()) != null) - ar.add(line); - } catch (IOException e) { - // silently ignored - } -// try { -// is.close(); -// } catch (IOException e1) { -// } - fLines = (String[]) ar.toArray(new String[ar.size()]); - } - - String getLine(int ix) { - return fLines[ix]; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount() - */ - public int getRangeCount() { - return fLines.length; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int) - */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, - int otherIndex) { - String s1 = fLines[thisIndex]; - String s2 = ((LineComparator) other).fLines[otherIndex]; - return s1.equals(s2); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator) - */ - public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { - return false; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java deleted file mode 100644 index 21c7939cf..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -class MergeMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.merge.MergeMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private MergeMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties deleted file mode 100644 index 8b55acb6c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -TextAutoMerge.inputEncodingError= Unsupported encoding for input streams -TextAutoMerge.outputEncodingError= Unsupported encoding for output streams -TextAutoMerge.outputIOError= IO error on writing -TextAutoMerge.conflict= Conflict: cannot auto merge \ No newline at end of file diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java deleted file mode 100644 index c7bc3fe30..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import org.eclipse.compare.*; -import org.eclipse.compare.rangedifferencer.RangeDifference; -import org.eclipse.compare.rangedifferencer.RangeDifferencer; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * A simple merger for streams containing text lines. - */ -public class TextStreamMerger implements IStreamMerger { - - /* - * (non-Javadoc) - * - * @see org.eclipse.compare.internal.merge.IAutoMerger#automerge(java.io.OutputStream, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus merge(OutputStream output, String outputEncoding, - InputStream ancestor, String ancestorEncoding, - InputStream target, String targetEncoding, - InputStream other, String otherEncoding, - IProgressMonitor monitor) { - - LineComparator a, t, o; - - try { - a= new LineComparator(ancestor, ancestorEncoding); - t= new LineComparator(target, targetEncoding); - o= new LineComparator(other, otherEncoding); - } catch (UnsupportedEncodingException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.inputEncodingError"), e); //$NON-NLS-1$ - } - - try { - char lineSeparator= '\n'; - - RangeDifference[] diffs = RangeDifferencer.findRanges(monitor, a, t, o); - - for (int i = 0; i < diffs.length; i++) { - RangeDifference rd = diffs[i]; - switch (rd.kind()) { - case RangeDifference.ANCESTOR: // pseudo conflict - case RangeDifference.NOCHANGE: - case RangeDifference.RIGHT: - for (int j = rd.rightStart(); j < rd.rightEnd(); j++) { - String s= o.getLine(j); - output.write(s.getBytes(outputEncoding)); - output.write(lineSeparator); - } - break; - - case RangeDifference.LEFT: - for (int j = rd.leftStart(); j < rd.leftEnd(); j++) { - String s= t.getLine(j); - output.write(s.getBytes(outputEncoding)); - output.write(lineSeparator); - } - break; - - case RangeDifference.CONFLICT: - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, CONFLICT, MergeMessages.getString("TextAutoMerge.conflict"), null); //$NON-NLS-1$ - - default: - break; - } - } - - } catch (UnsupportedEncodingException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputEncodingError"), e); //$NON-NLS-1$ - } catch (IOException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputIOError"), e); //$NON-NLS-1$ - } - - return Status.OK_STATUS; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java deleted file mode 100644 index 08b7b9556..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -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.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.ui.IEditorPart; - -import org.eclipse.compare.internal.*; - - -public class CompareWithPatchAction extends BaseCompareAction { - - static class PatchWizardDialog extends WizardDialog { - - PatchWizardDialog(Shell parent, IWizard wizard) { - super(parent, wizard); - - setShellStyle(getShellStyle() | SWT.RESIZE); - setMinimumPageSize(700, 500); - } - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getResources(selection).length == 1; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.BaseCompareAction#run(org.eclipse.jface.viewers.ISelection) - */ - protected void run(ISelection selection) { - PatchWizard wizard= new PatchWizard(selection); - - if (areAllEditorsSaved()) { - PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard); - dialog.open(); - } - } - - private boolean areAllEditorsSaved(){ - if (CompareUIPlugin.getDirtyEditors().length == 0) - return true; - if (! saveAllDirtyEditors()) - return false; - Shell shell= CompareUIPlugin.getShell(); - try { - // Save isn't cancelable. - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceDescription description= workspace.getDescription(); - boolean autoBuild= description.isAutoBuilding(); - description.setAutoBuilding(false); - workspace.setDescription(description); - try { - new ProgressMonitorDialog(shell).run(false, false, createRunnable()); - } finally { - description.setAutoBuilding(autoBuild); - workspace.setDescription(description); - } - return true; - } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, shell, PatchMessages.getString("PatchAction.ExceptionTitle"), PatchMessages.getString("Exception")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } catch (CoreException e) { - ExceptionHandler.handle(e, shell, PatchMessages.getString("PatchAction.ExceptionTitle"), PatchMessages.getString("Exception")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } catch (InterruptedException e) { - Assert.isTrue(false); // Can't happen. Operation isn't cancelable. - return false; - } - } - - private IRunnableWithProgress createRunnable() { - return new IRunnableWithProgress() { - public void run(IProgressMonitor pm) { - IEditorPart[] editorsToSave= CompareUIPlugin.getDirtyEditors(); - pm.beginTask(PatchMessages.getString("PatchAction.SavingDirtyEditorsTask"), editorsToSave.length); //$NON-NLS-1$ - for (int i= 0; i < editorsToSave.length; i++) { - editorsToSave[i].doSave(new SubProgressMonitor(pm, 1)); - pm.worked(1); - } - pm.done(); - } - }; - } - - private boolean saveAllDirtyEditors() { - if (ComparePreferencePage.getSaveAllEditors()) //must save everything - return true; - ListDialog dialog= new ListDialog(CompareUIPlugin.getShell()) { - protected Control createDialogArea(Composite parent) { - Composite result= (Composite) super.createDialogArea(parent); - final Button check= new Button(result, SWT.CHECK); - check.setText(PatchMessages.getString("PatchAction.AlwaysSaveQuestion")); //$NON-NLS-1$ - check.setSelection(ComparePreferencePage.getSaveAllEditors()); - check.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - ComparePreferencePage.setSaveAllEditors(check.getSelection()); - } - } - ); - applyDialogFont(result); - return result; - } - }; - dialog.setTitle(PatchMessages.getString("PatchAction.SaveAllQuestion")); //$NON-NLS-1$ - dialog.setAddCancelButton(true); - dialog.setLabelProvider(createDialogLabelProvider()); - dialog.setMessage(PatchMessages.getString("PatchAction.SaveAllDescription")); //$NON-NLS-1$ - dialog.setContentProvider(new ListContentProvider()); - dialog.setInput(Arrays.asList(CompareUIPlugin.getDirtyEditors())); - return dialog.open() == Window.OK; - } - - private ILabelProvider createDialogLabelProvider() { - return new LabelProvider() { - public Image getImage(Object element) { - return ((IEditorPart) element).getTitleImage(); - } - public String getText(Object element) { - return ((IEditorPart) element).getTitle(); - } - }; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java deleted file mode 100644 index ad5899bbe..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.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.compare.internal.patch; - -import java.util.*; - -import org.eclipse.core.runtime.IPath; - -import org.eclipse.compare.structuremergeviewer.Differencer; - - -/* package */ class Diff { - - IPath fOldPath, fNewPath; - long fOldDate, fNewDate; // if 0: no file - List fHunks= new ArrayList(); - boolean fMatches= false; - private boolean fIsEnabled2= true; - String fRejected; - - - /* package */ Diff(IPath oldPath, long oldDate, IPath newPath, long newDate) { - fOldPath= oldPath; - fOldDate= oldPath == null ? 0 : oldDate; - fNewPath= newPath; - fNewDate= newPath == null ? 0 : newDate; - } - - boolean isEnabled() { - return fIsEnabled2; - } - - void setEnabled(boolean b) { - fIsEnabled2= b; - } - - void reverse() { - IPath tp= fOldPath; - fOldPath= fNewPath; - fNewPath= tp; - - long t= fOldDate; - fOldDate= fNewDate; - fNewDate= t; - - Iterator iter= fHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - hunk.reverse(); - } - } - - Hunk[] getHunks() { - return (Hunk[]) fHunks.toArray(new Hunk[fHunks.size()]); - } - - IPath getPath() { - if (fOldPath != null) - return fOldPath; - return fNewPath; - } - - void finish() { - if (fHunks.size() == 1) { - Hunk h= (Hunk) fHunks.get(0); - if (h.fNewLength == 0) { - fNewDate= 0; - fNewPath= fOldPath; - } - } - } - - /* package */ void add(Hunk hunk) { - fHunks.add(hunk); - } - - /* package */ int getType() { - if (fOldDate == 0) - return Differencer.ADDITION; - if (fNewDate == 0) - return Differencer.DELETION; - return Differencer.CHANGE; - } - - /* package */ String getDescription(int strip) { - IPath path= fOldPath; - if (fOldDate == 0) - path= fNewPath; - if (strip > 0 && strip < path.segmentCount()) - path= path.removeFirstSegments(strip); - return path.toOSString(); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java deleted file mode 100644 index 24a336532..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.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.compare.internal.patch; - -import java.util.List; - -/** - * A Hunk describes a range of changed lines and some context lines. - */ -/* package */ class Hunk { - - Diff fParent; - int fOldStart, fOldLength; - int fNewStart, fNewLength; - String[] fLines; - boolean fMatches= false; - private boolean fIsEnabled= true; - - - /* package */ Hunk(Diff parent, int[] oldRange, int[] newRange, List lines) { - - fParent= parent; - if (fParent != null) - fParent.add(this); - - if (oldRange[0] > 0) - fOldStart= oldRange[0]-1; // line number start at 0! - else - fOldStart= 0; - fOldLength= oldRange[1]; - if (newRange[0] > 0) - fNewStart= newRange[0]-1; // line number start at 0! - else - fNewStart= 0; - fNewLength= newRange[1]; - - fLines= (String[]) lines.toArray(new String[lines.size()]); - } - - boolean isEnabled() { - return fIsEnabled; - } - - void setEnabled(boolean enable) { - fIsEnabled= enable; - } - - void reverse() { - int t= fOldStart; - fOldStart= fNewStart; - fNewStart= t; - - t= fOldLength; - fOldLength= fNewLength; - fNewLength= t; - - for (int i= 0; i < fLines.length; i++) { - String line= fLines[i]; - char c= line.charAt(0); - switch (c) { - case '+': - fLines[i]= '-' + line.substring(1); - break; - case '-': - fLines[i]= '+' + line.substring(1); - break; - default: - break; - } - } - } - - /* - * Returns the contents of this hunk. - * Each line starts with a control character. Their meaning is as follows: - *

    - *
  • - * '+': add the line - *
  • - * '-': delete the line - *
  • - * ' ': no change, context line - *
- */ - String getContent() { - StringBuffer sb= new StringBuffer(); - for (int i= 0; i < fLines.length; i++) { - String line= fLines[i]; - sb.append(line.substring(0, Patcher.length(line))); - sb.append('\n'); - } - return sb.toString(); - } - - /* - * Returns a descriptive String for this hunk. - * It is in the form old_start,old_length -> new_start,new_length. - */ - String getDescription() { - StringBuffer sb= new StringBuffer(); - sb.append(Integer.toString(fOldStart)); - sb.append(','); - sb.append(Integer.toString(fOldLength)); - sb.append(" -> "); //$NON-NLS-1$ - sb.append(Integer.toString(fNewStart)); - sb.append(','); - sb.append(Integer.toString(fNewLength)); - return sb.toString(); - } - - String getRejectedDescription() { - StringBuffer sb= new StringBuffer(); - sb.append("@@ -"); //$NON-NLS-1$ - sb.append(Integer.toString(fOldStart)); - sb.append(','); - sb.append(Integer.toString(fOldLength)); - sb.append(" +"); //$NON-NLS-1$ - sb.append(Integer.toString(fNewStart)); - sb.append(','); - sb.append(Integer.toString(fNewLength)); - sb.append(" @@"); //$NON-NLS-1$ - return sb.toString(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java deleted file mode 100644 index 6ec5fd293..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java +++ /dev/null @@ -1,532 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.text.MessageFormat; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.*; - -import org.eclipse.ui.help.*; -import org.eclipse.ui.model.*; - -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - - -/* package */ class InputPatchPage extends WizardPage { - - // constants - protected static final int SIZING_TEXT_FIELD_WIDTH= 250; - protected static final int COMBO_HISTORY_LENGTH= 5; - - // dialog store id constants - private final static String PAGE_NAME= "PatchWizardPage1"; //$NON-NLS-1$ - private final static String STORE_PATCH_FILES_ID= PAGE_NAME + ".PATCH_FILES"; //$NON-NLS-1$ - private final static String STORE_USE_CLIPBOARD_ID= PAGE_NAME + ".USE_CLIPBOARD"; //$NON-NLS-1$ - - static final char SEPARATOR = System.getProperty ("file.separator").charAt (0); //$NON-NLS-1$ - - private boolean fShowError= false; - - // SWT widgets - private Button fUseClipboardButton; - private Combo fPatchFileNameField; - private Button fPatchFileBrowseButton; - private Button fUsePatchFileButton; - private Group fPatchFileGroup; - private CheckboxTreeViewer fPatchTargets; - private PatchWizard fPatchWizard; - - - InputPatchPage(PatchWizard pw) { - super("InputPatchPage", PatchMessages.getString("InputPatchPage.title"), null); //$NON-NLS-1$ //$NON-NLS-2$ - fPatchWizard= pw; - setMessage(PatchMessages.getString("InputPatchPage.message")); //$NON-NLS-1$ - } - - /* - * Get a path from the supplied text widget. - * @return org.eclipse.core.runtime.IPath - */ - protected IPath getPathFromText(Text textField) { - return (new Path(textField.getText())).makeAbsolute(); - } - - /* package */ String getPatchName() { - if (getUseClipboard()) - return PatchMessages.getString("InputPatchPage.Clipboard"); //$NON-NLS-1$ - return getPatchFilePath(); - } - - public void createControl(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - setControl(composite); - - Label l= new Label(composite, SWT.NONE); - l.setText(PatchMessages.getString("InputPatchPage.SelectInput")); //$NON-NLS-1$ - buildInputGroup(composite); - - new Label(composite, SWT.NONE); // a spacer - - buildPatchFileGroup(composite); - - restoreWidgetValues(); - - updateWidgetEnablements(); - - Dialog.applyDialogFont(composite); - WorkbenchHelp.setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE); - } - - /* (non-JavaDoc) - * Method declared in IWizardPage. - */ - public IWizardPage getNextPage() { - - Patcher patcher= ((PatchWizard) getWizard()).getPatcher(); - - String source; - // Create a reader for the input - Reader reader= null; - if (getUseClipboard()) { - Control c= getControl(); - if (c != null) { - Clipboard clipboard= new Clipboard(c.getDisplay()); - Object o= clipboard.getContents(TextTransfer.getInstance()); - clipboard.dispose(); - if (o instanceof String) - reader= new StringReader((String)o); - } - source= PatchMessages.getString("InputPatchPage.Clipboard.title"); //$NON-NLS-1$ - } else { - String patchFilePath= getPatchFilePath(); - if (patchFilePath != null) { - try { - reader= new FileReader(patchFilePath); - } catch (FileNotFoundException ex) { - MessageDialog.openError(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$ - PatchMessages.getString("InputPatchPage.PatchFileNotFound.message")); //$NON-NLS-1$ - } - } - source= PatchMessages.getString("InputPatchPage.PatchFile.title"); //$NON-NLS-1$ - } - - // parse the input - if (reader != null) { - try { - patcher.parse(new BufferedReader(reader)); - } catch (IOException ex) { - MessageDialog.openError(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$ - PatchMessages.getString("InputPatchPage.ParseError.message")); //$NON-NLS-1$ - } - - try { - reader.close(); - } catch (IOException x) { - // silently ignored - } - } - - Diff[] diffs= patcher.getDiffs(); - if (diffs == null || diffs.length == 0) { - String format= PatchMessages.getString("InputPatchPage.NoDiffsFound.format"); //$NON-NLS-1$ - String message= MessageFormat.format(format, new String[] { source }); - MessageDialog.openInformation(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), message); //$NON-NLS-1$ - return this; - } - - // if selected target is file ensure that patch file - // contains only a patch for a single file - IResource target= fPatchWizard.getTarget(); - if (target instanceof IFile && diffs.length > 1) { - String format= PatchMessages.getString("InputPatchPage.SingleFileError.format"); //$NON-NLS-1$ - String message= MessageFormat.format(format, new String[] { source }); - MessageDialog.openInformation(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), message); //$NON-NLS-1$ - return this; - } - - // guess prefix count - int guess= 0; // guessPrefix(diffs); - patcher.setStripPrefixSegments(guess); - - return super.getNextPage(); - } - - /* (non-JavaDoc) - * Method declared in IWizardPage. - */ - public boolean canFlipToNextPage() { - // we can't call getNextPage to determine if flipping is allowed since computing - // the next page is quite expensive. So we say yes if the page is complete. - return isPageComplete(); - } - - private void setEnablePatchFile(boolean enable) { - fPatchFileNameField.setEnabled(enable); - fPatchFileBrowseButton.setEnabled(enable); - } - - /* - * Create the group for selecting the patch file - */ - private void buildPatchFileGroup(Composite parent) { - - fPatchFileGroup= new Group(parent, SWT.NONE); - fPatchFileGroup.setText(PatchMessages.getString("InputPatchPage.SelectPatch.title")); //$NON-NLS-1$ - GridLayout layout= new GridLayout(); - layout.numColumns= 3; - fPatchFileGroup.setLayout(layout); - fPatchFileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // 1st row - fUsePatchFileButton= new Button(fPatchFileGroup, SWT.RADIO); - fUsePatchFileButton.setText(PatchMessages.getString("InputPatchPage.FileButton.text")); //$NON-NLS-1$ - - fPatchFileNameField= new Combo(fPatchFileGroup, SWT.BORDER); - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - //gd.horizontalIndent= 8; - gd.widthHint= SIZING_TEXT_FIELD_WIDTH; - fPatchFileNameField.setLayoutData(gd); - - fPatchFileBrowseButton= new Button(fPatchFileGroup, SWT.PUSH); - fPatchFileBrowseButton.setText(PatchMessages.getString("InputPatchPage.ChooseFileButton.text")); //$NON-NLS-1$ - fPatchFileBrowseButton.setLayoutData(new GridData()); - - // 2nd row - fUseClipboardButton= new Button(fPatchFileGroup, SWT.RADIO); - fUseClipboardButton.setText(PatchMessages.getString("InputPatchPage.UseClipboardButton.text")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalSpan= 2; - fUseClipboardButton.setLayoutData(gd); - - - // Add listeners - fUsePatchFileButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fShowError= true; - setEnablePatchFile(!getUseClipboard()); - updateWidgetEnablements(); - } - } - ); - fPatchFileNameField.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setSourceName(fPatchFileNameField.getText()); - updateWidgetEnablements(); - } - } - ); - fPatchFileNameField.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - fShowError= true; - updateWidgetEnablements(); - } - } - ); - fPatchFileBrowseButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handlePatchFileBrowseButtonPressed(); - updateWidgetEnablements(); - } - } - ); - - //fPatchFileNameField.setFocus(); - } - - private void buildInputGroup(Composite parent) { - - PatchWizard pw= (PatchWizard) getWizard(); - IResource target= pw.getTarget(); - IWorkspace workspace= target.getWorkspace(); - IWorkspaceRoot root= workspace.getRoot(); - - Tree tree= new Tree(parent, SWT.BORDER); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= 200; - tree.setLayoutData(gd); - - fPatchTargets= new CheckboxTreeViewer(tree); - fPatchTargets.setLabelProvider(new WorkbenchLabelProvider()); - fPatchTargets.setContentProvider(new WorkbenchContentProvider()); - fPatchTargets.setSorter(new WorkbenchViewerSorter()); - fPatchTargets.setInput(root); - if (target != null) { - fPatchTargets.expandToLevel(target, 0); - fPatchTargets.setSelection(new StructuredSelection(target)); - } - - // register listeners - fPatchTargets.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - fPatchWizard.setTargets(Utilities.getResources(event.getSelection())); - updateWidgetEnablements(); - } - } - ); - } - - /** - * Updates the enable state of this page's controls. - */ - private void updateWidgetEnablements() { - - String error= null; - - ISelection selection= fPatchTargets.getSelection(); - boolean anySelected= selection != null && !selection.isEmpty(); - if (!anySelected) - error= PatchMessages.getString("InputPatchPage.NothingSelected.message"); //$NON-NLS-1$ - - boolean gotPatch= false; - if (getUseClipboard()) { - Control c= getControl(); - if (c != null) { - Clipboard clipboard= new Clipboard(c.getDisplay()); - Object o= clipboard.getContents(TextTransfer.getInstance()); - clipboard.dispose(); - if (o instanceof String) { - String s= ((String) o).trim(); - if (s.length() > 0) - gotPatch= true; - else - error= PatchMessages.getString("InputPatchPage.ClipboardIsEmpty.message"); //$NON-NLS-1$ - } else - error= PatchMessages.getString("InputPatchPage.NoTextInClipboard.message"); //$NON-NLS-1$ - } else - error= PatchMessages.getString("InputPatchPage.CouldNotReadClipboard.message"); //$NON-NLS-1$ - } else { - String path= fPatchFileNameField.getText(); - if (path != null && path.length() > 0) { - File file= new File(path); - gotPatch= file.exists() && file.isFile() && file.length() > 0; - if (!gotPatch) - error= PatchMessages.getString("InputPatchPage.CannotLocatePatch.message") + path; //$NON-NLS-1$ - } else { - error= PatchMessages.getString("InputPatchPage.NoFileName.message"); //$NON-NLS-1$ - } - } - - setPageComplete(anySelected && gotPatch); - if (fShowError) - setErrorMessage(error); - } - - protected void handlePatchFileBrowseButtonPressed() { - FileDialog dialog= new FileDialog(getShell(), SWT.NONE); - dialog.setText(PatchMessages.getString("InputPatchPage.SelectPatchFileDialog.title")); //$NON-NLS-1$ - String patchFilePath= getPatchFilePath(); - if (patchFilePath != null) { - int lastSegment= patchFilePath.lastIndexOf(SEPARATOR); - if (lastSegment > 0) { - patchFilePath= patchFilePath.substring(0, lastSegment); - } - } - dialog.setFilterPath(patchFilePath); - String res= dialog.open(); - if (res == null) - return; - - patchFilePath= dialog.getFileName(); - IPath filterPath= new Path(dialog.getFilterPath()); - IPath path= filterPath.append(patchFilePath).makeAbsolute(); - patchFilePath= path.toOSString(); - //fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString()); - - fPatchFileNameField.setText(patchFilePath); - //setSourceName(patchFilePath); - } - - /** - * Sets the source name of the import to be the supplied path. - * Adds the name of the path to the list of items in the - * source combo and selects it. - * - * @param path the path to be added - */ - protected void setSourceName(String path) { - - if (path.length() > 0) { - - String[] currentItems= fPatchFileNameField.getItems(); - int selectionIndex= -1; - for (int i= 0; i < currentItems.length; i++) - if (currentItems[i].equals(path)) - selectionIndex= i; - - if (selectionIndex < 0) { // not found in history - int oldLength= currentItems.length; - String[] newItems= new String[oldLength + 1]; - System.arraycopy(currentItems, 0, newItems, 0, oldLength); - newItems[oldLength]= path; - fPatchFileNameField.setItems(newItems); - selectionIndex= oldLength; - } - fPatchFileNameField.select(selectionIndex); - - //resetSelection(); - } - } - - /** - * The Finish button was pressed. Try to do the required work now and answer - * a boolean indicating success. If false is returned then the wizard will - * not close. - * - * @return boolean - */ - public boolean finish() { -// if (!ensureSourceIsValid()) -// return false; - - saveWidgetValues(); - -// Iterator resourcesEnum = getSelectedResources().iterator(); -// List fileSystemObjects = new ArrayList(); -// while (resourcesEnum.hasNext()) { -// fileSystemObjects.add( -// ((FileSystemElement) resourcesEnum.next()).getFileSystemObject()); -// } -// -// if (fileSystemObjects.size() > 0) -// return importResources(fileSystemObjects); -// -// MessageDialog -// .openInformation( -// getContainer().getShell(), -// DataTransferMessages.getString("DataTransfer.information"), //$NON-NLS-1$ -// DataTransferMessages.getString("FileImport.noneSelected")); //$NON-NLS-1$ -// -// return false; - - return true; - } - - /** - * Use the dialog store to restore widget values to the values that they held - * last time this wizard was used to completion - */ - private void restoreWidgetValues() { - - boolean useClipboard= false; - - IDialogSettings settings= getDialogSettings(); - if (settings != null) { - - useClipboard= settings.getBoolean(STORE_USE_CLIPBOARD_ID); - - // set filenames history - String[] sourceNames= settings.getArray(STORE_PATCH_FILES_ID); - if (sourceNames != null) - for (int i= 0; i < sourceNames.length; i++) - if (sourceNames[i] != null && sourceNames[i].length() > 0) - fPatchFileNameField.add(sourceNames[i]); - - // set patch file path - String patchFilePath= settings.get(STORE_PATCH_FILES_ID); - if (patchFilePath != null) - setSourceName(patchFilePath); - } - - // set 'Use Clipboard' radio buttons - setUseClipboard(useClipboard); - } - - /** - * Since Finish was pressed, write widget values to the dialog store so that they - * will persist into the next invocation of this wizard page - */ - void saveWidgetValues() { - IDialogSettings settings= getDialogSettings(); - if (settings != null) { - - settings.put(STORE_USE_CLIPBOARD_ID, getUseClipboard()); - settings.put(STORE_PATCH_FILES_ID, getPatchFilePath()); - - // update source names history - String[] sourceNames= settings.getArray(STORE_PATCH_FILES_ID); - if (sourceNames == null) - sourceNames= new String[0]; - - sourceNames= addToHistory(sourceNames, getPatchFilePath()); - settings.put(STORE_PATCH_FILES_ID, sourceNames); - } - } - - // static helpers - - private void setUseClipboard(boolean useClipboard) { - if (useClipboard) - fUseClipboardButton.setSelection(true); - else - fUsePatchFileButton.setSelection(true); - setEnablePatchFile(!useClipboard); - } - - private boolean getUseClipboard() { - if (fUseClipboardButton != null) - return fUseClipboardButton.getSelection(); - return false; - } - - private String getPatchFilePath() { - if (fPatchFileNameField != null) - return fPatchFileNameField.getText(); - return ""; //$NON-NLS-1$ - } - - /* - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length COMBO_HISTORY_LENGTH. - * - * @param history the current history - * @param newEntry the entry to add to the history - */ - protected static String[] addToHistory(String[] history, String newEntry) { - java.util.ArrayList l= new java.util.ArrayList(java.util.Arrays.asList(history)); - - l.remove(newEntry); - l.add(0,newEntry); - - // since only one new item was added, we can be over the limit - // by at most one item - if (l.size() > COMBO_HISTORY_LENGTH) - l.remove(COMBO_HISTORY_LENGTH); - - return (String[]) l.toArray(new String[l.size()]); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java deleted file mode 100644 index f4ceeeb01..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.util.*; - -import org.eclipse.jface.util.Assert; - -/* package */ class LineReader { - - private boolean fHaveChar= false; - private int fLastChar; - private boolean fSawEOF= false; - private BufferedReader fReader; - private boolean fIgnoreSingleCR= false; - - - /* package */ LineReader(BufferedReader reader) { - fReader= reader; - Assert.isNotNull(reader); - } - - void ignoreSingleCR() { - fIgnoreSingleCR= true; - } - - /** - * Reads a line of text. A line is considered to be terminated by any one - * of a line feed ('\n'), a carriage return ('\r'), or a carriage return - * followed immediately by a linefeed. - * @return A string containing the contents of the line including - * the line-termination characters, or null if the end of the - * stream has been reached - * @exception IOException If an I/O error occurs - */ - /* package */ String readLine() throws IOException { - StringBuffer sb= null; - - while (!fSawEOF) { - int c= readChar(); - if (c == -1) { - fSawEOF= true; - break; - } - if (sb == null) - sb= new StringBuffer(); - sb.append((char)c); - if (c == '\n') - break; - if (c == '\r') { - c= readChar(); - if (c == -1) { - fSawEOF= true; - break; // EOF - } - if (c != '\n') { - if (fIgnoreSingleCR) { - sb.append((char)c); - continue; - } - fHaveChar= true; - fLastChar= c; - } else - sb.append((char)c); - break; - } - } - - if (sb != null) - return sb.toString(); - return null; - } - - /* package */ void close() { - try { - fReader.close(); - } catch (IOException ex) { - // silently ignored - } - } - - /* package */ List readLines() { - try { - List lines= new ArrayList(); - String line; - while ((line= readLine()) != null) - lines.add(line); - return lines; - } catch (IOException ex) { - // NeedWork - //System.out.println("error while reading file: " + fileName + "(" + ex + ")"); - } finally { - close(); - } - return null; - } - - /* - * Returns the number of characters in the given string without - * counting a trailing line separator. - */ - /* package */ int lineContentLength(String line) { - if (line == null) - return 0; - int length= line.length(); - for (int i= length-1; i >= 0; i--) { - char c= line.charAt(i); - if (c =='\n' || c == '\r') - length--; - else - break; - } - return length; - } - - //---- private - - private int readChar() throws IOException { - if (fHaveChar) { - fHaveChar= false; - return fLastChar; - } - return fReader.read(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java deleted file mode 100644 index 7b1b0a702..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -public class PatchErrorDialog { - - private PatchErrorDialog() { - // no instance. - } - -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java deleted file mode 100644 index eac554ccf..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class PatchMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.patch.PatchMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private PatchMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties deleted file mode 100644 index e0e37821e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties +++ /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 -############################################################################### - -# -# 'Compare with Patch' Action -# -PatchAction.ExceptionTitle=Saving Resources -PatchAction.Exception=Unexpected exception. See log for details -PatchAction.SavingDirtyEditorsTask=Saving dirty editors -PatchAction.AlwaysSaveQuestion=&Always save all modified resources automatically prior to patching -PatchAction.SaveAllQuestion=Save all modified resources -PatchAction.SaveAllDescription=All modified resources have to be saved before this operation.\nClick 'OK' to confirm or click 'Cancel'. - -# -# PatchWizard -# -PatchWizard.title=Apply Patch -PatchWizard.unexpectedException.message= Unexpected exception while applying the patch. See log for a detailed error description. - -# -# InputPatchPage -# -InputPatchPage.title= Patch Input Specification -InputPatchPage.message= Define the resource to patch and the patch to apply -InputPatchPage.Clipboard=Clipboard -InputPatchPage.SelectInput=Select a single file or folder to patch: -InputPatchPage.PatchErrorDialog.title=Patch Error -InputPatchPage.PatchErrorDialog=Patch Error -InputPatchPage.SelectPatch.title=Select Patch -InputPatchPage.FileButton.text=Fil&e -InputPatchPage.ChooseFileButton.text=&Browse... -InputPatchPage.UseClipboardButton.text=&Clipboard -InputPatchPage.NothingSelected.message=Select a file or folder to be patched -InputPatchPage.ClipboardIsEmpty.message=Clipboard is empty -InputPatchPage.NoTextInClipboard.message=Clipboard does not contain text -InputPatchPage.CouldNotReadClipboard.message=Cannot retrieve clipboard contents -InputPatchPage.CannotLocatePatch.message=Cannot locate patch file: -InputPatchPage.NoFileName.message=No file name -#SI - Select file name ? -InputPatchPage.SelectPatchFileDialog.title=Select Patch File -InputPatchPage.PatchFileNotFound.message=Patch file not found. -InputPatchPage.ParseError.message=Error while parsing patch -InputPatchPage.Clipboard.title=Clipboard -InputPatchPage.PatchFile.title=Patch file -InputPatchPage.NoDiffsFound.format={0} does not contain valid patch. -InputPatchPage.SingleFileError.format={0} contains multiple patches. You cannot apply them to a single file. - -# -# PreviewPatchPage -# -PreviewPatchPage.title= Verify Patch -PreviewPatchPage.message= The tree shows the contents of the patch.\nA checked item indicates that a patch can be applied successfully. To remove an item, clear its checkbox. -PreviewPatchPage.Left.title= Original -PreviewPatchPage.Right.title= Result -PreviewPatchPage.PatchOptions.title=Patch Options -PreviewPatchPage.IgnoreSegments.text=&Ignore leading path name segments: -PreviewPatchPage.ReversePatch.text=&Reverse patch -PreviewPatchPage.FuzzFactor.text=&Maximum fuzz factor: -PreviewPatchPage.FuzzFactor.tooltip=Allow Context to Shift This Number of Lines from the Original Location -PreviewPatchPage.IgnoreWhitespace.text=Ignore &white space -PreviewPatchPage.NoName.text=no name -PreviewPatchPage.FileExists.error=(file already exists) -PreviewPatchPage.FileDoesNotExist.error=(file does not exist) -PreviewPatchPage.NoMatch.error=(no match) -PreviewPatchPage.FileIsReadOnly.error=(file is read-only) -PreviewPatchPage.GuessFuzz.text= &Guess -PreviewPatchPage.GuessFuzzProgress.text= Guessing Fuzz Factor... -PreviewPatchPage.GuessFuzzProgress.format= {0} (hunk #{1}) - -# -# Patcher -# -Patcher.ErrorDialog.title=title -Patcher.DeleteError.message=Error while deleting resource -Patcher.UpdateError.message=Error while updating resource -Patcher.RefreshError.message=Error while refreshing from local -Patcher.Marker.message=Rejected patch -Patcher.Task.message=Patching - -# -# PatchCompareInput -# -PatchCompareInput.RightTitle.format= Patch: {0} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java deleted file mode 100644 index 6f7b1f5e5..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.Wizard; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.compare.internal.*; - - -/* package */ class PatchWizard extends Wizard { - - // dialog store id constants - private final static String DIALOG_SETTINGS_KEY= "PatchWizard"; //$NON-NLS-1$ - - private boolean fHasNewDialogSettings; - - private InputPatchPage fPatchWizardPage; - - private Patcher fPatcher; - private IResource fTarget; - - - /* - * Creates a wizard for applying a patch file to the workspace. - */ - /* package */ PatchWizard(ISelection selection) { - - setDefaultPageImageDescriptor(CompareUIPlugin.getImageDescriptor("wizban/applypatch_wizban.gif")); //$NON-NLS-1$ - setWindowTitle(PatchMessages.getString("PatchWizard.title")); //$NON-NLS-1$ - - setTargets(Utilities.getResources(selection)); - - fPatcher= new Patcher(); - - IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); //$NON-NLS-1$ - if (section == null) - fHasNewDialogSettings= true; - else { - fHasNewDialogSettings= false; - setDialogSettings(section); - } - } - - Patcher getPatcher() { - return fPatcher; - } - - IResource getTarget() { - return fTarget; - } - - void setTargets(IResource[] targets) { - if (targets != null && targets.length > 0) - fTarget= targets[0]; // right now we can only deal with a single selection - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public void addPages() { - super.addPages(); - - addPage(fPatchWizardPage= new InputPatchPage(this)); - addPage(new PreviewPatchPage(this)); - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public boolean needsProgressMonitor() { - return true; - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public boolean performFinish() { - - fPatcher.setName(fPatchWizardPage.getPatchName()); - - try { - WorkspaceModifyOperation op= new WorkspaceModifyOperation(fTarget.getProject()) { - protected void execute(IProgressMonitor monitor) throws InvocationTargetException { - try { - fPatcher.applyAll(getTarget(), monitor, getShell(), PatchMessages.getString("PatchWizard.title")); //$NON-NLS-1$ - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }; - getContainer().run(true, false, op); - - } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, - PatchMessages.getString("PatchWizard.title"), //$NON-NLS-1$ - PatchMessages.getString("PatchWizard.unexpectedException.message")); //$NON-NLS-1$ - } catch (InterruptedException e) { - // cannot happen - // NeedWork: use assert! - } - - // Save the dialog settings - if (fHasNewDialogSettings) { - IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); - section= workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY); - setDialogSettings(section); - } - - fPatchWizardPage.saveWidgetValues(); - //fPreviewPatchPage.saveWidgetValues(); - - return true; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java deleted file mode 100644 index 29e3827d1..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java +++ /dev/null @@ -1,1081 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.text.*; -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.resources.*; - -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.Differencer; - -/** - * A Patcher - * - knows how to parse various patch file formats into some in-memory structure, - * - holds onto the parsed data and the options to use when applying the patches, - * - knows how to apply the patches to files and folders. - */ -public class Patcher { - - private static final boolean DEBUG= false; - - private static final String DEV_NULL= "/dev/null"; //$NON-NLS-1$ - - private static final String REJECT_FILE_EXTENSION= ".rej"; //$NON-NLS-1$ - - private static final String MARKER_TYPE= "org.eclipse.compare.rejectedPatchMarker"; //$NON-NLS-1$ - - // diff formats -// private static final int CONTEXT= 0; -// private static final int ED= 1; -// private static final int NORMAL= 2; -// private static final int UNIFIED= 3; - - // we recognize the following date/time formats - private static DateFormat[] DATE_FORMATS= new DateFormat[] { - new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy"), //$NON-NLS-1$ - new SimpleDateFormat("yyyy/MM/dd kk:mm:ss"), //$NON-NLS-1$ - new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy", Locale.US) //$NON-NLS-1$ - }; - - private String fName; - private Diff[] fDiffs; - // patch options - private int fStripPrefixSegments; - private int fFuzz; - private boolean fIgnoreWhitespace= false; - private boolean fIgnoreLineDelimiter= true; - private boolean fPreserveLineDelimiters= false; - private boolean fReverse= false; - private boolean fAdjustShift= true; - - - Patcher() { - // nothing to do - } - - //---- options - - void setName(String name) { - fName= name; - } - - String getName() { - return fName; - } - - /* - * Returns an array of Diffs after a sucessfull call to parse. - * If parse hasn't been called returns null. - */ - Diff[] getDiffs() { - return fDiffs; - } - - IPath getPath(Diff diff) { - IPath path= diff.getPath(); - if (fStripPrefixSegments > 0 && fStripPrefixSegments < path.segmentCount()) - path= path.removeFirstSegments(fStripPrefixSegments); - return path; - } - - /* - * Returns true if new value differs from old. - */ - boolean setStripPrefixSegments(int strip) { - if (strip != fStripPrefixSegments) { - fStripPrefixSegments= strip; - return true; - } - return false; - } - - int getStripPrefixSegments() { - return fStripPrefixSegments; - } - - /* - * Returns true if new value differs from old. - */ - boolean setFuzz(int fuzz) { - if (fuzz != fFuzz) { - fFuzz= fuzz; - return true; - } - return false; - } - - /* - * Returns true if new value differs from old. - */ - boolean setReversed(boolean reverse) { - if (fReverse != reverse) { - fReverse= reverse; - - for (int i= 0; i < fDiffs.length; i++) - fDiffs[i].reverse(); - - return true; - } - return false; - } - - /* - * Returns true if new value differs from old. - */ - boolean setIgnoreWhitespace(boolean ignoreWhitespace) { - if (ignoreWhitespace != fIgnoreWhitespace) { - fIgnoreWhitespace= ignoreWhitespace; - return true; - } - return false; - } - - //---- parsing patch files - - /* package */ void parse(BufferedReader reader) throws IOException { - List diffs= new ArrayList(); - String line= null; - boolean reread= false; - String diffArgs= null; - String fileName= null; - - LineReader lr= new LineReader(reader); - if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ - lr.ignoreSingleCR(); - - // read leading garbage - while (true) { - if (!reread) - line= lr.readLine(); - reread= false; - if (line == null) - break; - if (line.length() < 4) - continue; // too short - - // remember some infos - if (line.startsWith("Index: ")) { //$NON-NLS-1$ - fileName= line.substring(7).trim(); - continue; - } - if (line.startsWith("diff")) { //$NON-NLS-1$ - diffArgs= line.substring(4).trim(); - continue; - } - - if (line.startsWith("--- ")) { //$NON-NLS-1$ - line= readUnifiedDiff(diffs, lr, line, diffArgs, fileName); - diffArgs= fileName= null; - reread= true; - } else if (line.startsWith("*** ")) { //$NON-NLS-1$ - line= readContextDiff(diffs, lr, line, diffArgs, fileName); - diffArgs= fileName= null; - reread= true; - } - } - - lr.close(); - - fDiffs= (Diff[]) diffs.toArray(new Diff[diffs.size()]); - } - - /* - * Returns the next line that does not belong to this diff - */ - private String readUnifiedDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException { - - String[] oldArgs= split(line.substring(4)); - - // read info about new file - line= reader.readLine(); - if (line == null || !line.startsWith("+++ ")) //$NON-NLS-1$ - return line; - - String[] newArgs= split(line.substring(4)); - - Diff diff= new Diff(extractPath(oldArgs, 0, fileName), extractDate(oldArgs, 1), - extractPath(newArgs, 0, fileName), extractDate(newArgs, 1)); - diffs.add(diff); - - int[] oldRange= new int[2]; - int[] newRange= new int[2]; - List lines= new ArrayList(); - - try { - // read lines of hunk - while (true) { - - line= reader.readLine(); - if (line == null) - return null; - - if (reader.lineContentLength(line) == 0) { - //System.out.println("Warning: found empty line in hunk; ignored"); - //lines.add(' ' + line); - continue; - } - - char c= line.charAt(0); - switch (c) { - case '@': - if (line.startsWith("@@ ")) { //$NON-NLS-1$ - // flush old hunk - if (lines.size() > 0) { - new Hunk(diff, oldRange, newRange, lines); - lines.clear(); - } - - // format: @@ -oldStart,oldLength +newStart,newLength @@ - extractPair(line, '-', oldRange); - extractPair(line, '+', newRange); - continue; - } - break; - case ' ': - case '+': - case '-': - lines.add(line); - continue; - case '\\': - if (line.startsWith("No newline at end of file", 2)) { //$NON-NLS-1$ - int lastIndex= lines.size(); - if (lastIndex > 0) { - line= (String) lines.get(lastIndex-1); - int end= line.length()-1; - char lc= line.charAt(end); - if (lc == '\n') { - end--; - if (end > 0 && line.charAt(end-1) == '\r') - end--; - } else if (lc == '\r') { - end--; - } - line= line.substring(0, end); - lines.set(lastIndex-1, line); - } - continue; - } - break; - default: - if (DEBUG) { - int a1= c, a2= 0; - if (line.length() > 1) - a2= line.charAt(1); - System.out.println("char: " + a1 + " " + a2); //$NON-NLS-1$ //$NON-NLS-2$ - } - break; - } - return line; - } - } finally { - if (lines.size() > 0) - new Hunk(diff, oldRange, newRange, lines); - diff.finish(); - } - } - - /* - * Returns the next line that does not belong to this diff - */ - private String readContextDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException { - - String[] oldArgs= split(line.substring(4)); - - // read info about new file - line= reader.readLine(); - if (line == null || !line.startsWith("--- ")) //$NON-NLS-1$ - return line; - - String[] newArgs= split(line.substring(4)); - - Diff diff= new Diff(extractPath(oldArgs, 0, fileName), extractDate(oldArgs, 1), - extractPath(newArgs, 0, fileName), extractDate(newArgs, 1)); - diffs.add(diff); - - int[] oldRange= new int[2]; - int[] newRange= new int[2]; - List oldLines= new ArrayList(); - List newLines= new ArrayList(); - List lines= oldLines; - - try { - // read lines of hunk - while (true) { - - line= reader.readLine(); - if (line == null) - return line; - - int l= line.length(); - if (l == 0) - continue; - if (l > 1) { - switch (line.charAt(0)) { - case '*': - if (line.startsWith("***************")) { // new hunk //$NON-NLS-1$ - // flush old hunk - if (oldLines.size() > 0 || newLines.size() > 0) { - new Hunk(diff, oldRange, newRange, unifyLines(oldLines, newLines)); - oldLines.clear(); - newLines.clear(); - } - continue; - } - if (line.startsWith("*** ")) { // old range //$NON-NLS-1$ - // format: *** oldStart,oldEnd *** - extractPair(line, ' ', oldRange); - oldRange[1]= oldRange[1]-oldRange[0]+1; - lines= oldLines; - continue; - } - break; - case ' ': // context line - case '+': // addition - case '!': // change - if (line.charAt(1) == ' ') { - lines.add(line); - continue; - } - break; - case '-': - if (line.charAt(1) == ' ') { // deletion - lines.add(line); - continue; - } - if (line.startsWith("--- ")) { // new range //$NON-NLS-1$ - // format: *** newStart,newEnd *** - extractPair(line, ' ', newRange); - newRange[1]= newRange[1]-newRange[0]+1; - lines= newLines; - continue; - } - break; - default: - break; - } - } - return line; - } - } finally { - // flush last hunk - if (oldLines.size() > 0 || newLines.size() > 0) - new Hunk(diff, oldRange, newRange, unifyLines(oldLines, newLines)); - diff.finish(); - } - } - - /* - * Creates a List of lines in the unified format from - * two Lists of lines in the 'classic' format. - */ - private List unifyLines(List oldLines, List newLines) { - List result= new ArrayList(); - - String[] ol= (String[]) oldLines.toArray(new String[oldLines.size()]); - String[] nl= (String[]) newLines.toArray(new String[newLines.size()]); - - int oi= 0, ni= 0; - - while (true) { - - char oc= 0; - String o= null; - if (oi < ol.length) { - o= ol[oi]; - oc= o.charAt(0); - } - - char nc= 0; - String n= null; - if (ni < nl.length) { - n= nl[ni]; - nc= n.charAt(0); - } - - // EOF - if (oc == 0 && nc == 0) - break; - - // deletion in old - if (oc == '-') { - do { - result.add('-' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == '-'); - continue; - } - - // addition in new - if (nc == '+') { - do { - result.add('+' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == '+'); - continue; - } - - // differing lines on both sides - if (oc == '!' && nc == '!') { - // remove old - do { - result.add('-' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == '!'); - - // add new - do { - result.add('+' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == '!'); - - continue; - } - - // context lines - if (oc == ' ' && nc == ' ') { - do { - Assert.isTrue(o.equals(n), "non matching context lines"); //$NON-NLS-1$ - result.add(' ' + o.substring(2)); - oi++; - ni++; - if (oi >= ol.length || ni >= nl.length) - break; - o= ol[oi]; - n= nl[ni]; - } while (o.charAt(0) == ' ' && n.charAt(0) == ' '); - continue; - } - - if (oc == ' ') { - do { - result.add(' ' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == ' '); - continue; - } - - if (nc == ' ') { - do { - result.add(' ' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == ' '); - continue; - } - - Assert.isTrue(false, "unexpected char <" + oc + "> <" + nc + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - return result; - } - - /* - * Breaks the given string into tab separated substrings. - * Leading and trailing whitespace is removed from each token. - */ - private String[] split(String line) { - List l= new ArrayList(); - StringTokenizer st= new StringTokenizer(line, "\t"); //$NON-NLS-1$ - while (st.hasMoreElements()) { - String token= st.nextToken().trim(); - if (token.length() > 0) - l.add(token); - } - return (String[]) l.toArray(new String[l.size()]); - } - - /* - * @return the parsed time/date in milliseconds or -1 on error - */ - private long extractDate(String[] args, int n) { - if (n < args.length) { - String line= args[n]; - for (int i= 0; i < DATE_FORMATS.length; i++) { - DATE_FORMATS[i].setLenient(true); - try { - Date date= DATE_FORMATS[i].parse(line); - return date.getTime(); - } catch (ParseException ex) { - // silently ignored - } - } - // System.err.println("can't parse date: <" + line + ">"); - } - return -1; - } - - /* - * Returns null if file name is "/dev/null". - */ - private IPath extractPath(String[] args, int n, String path2) { - if (n < args.length) { - String path= args[n]; - if (DEV_NULL.equals(path)) - return null; - int pos= path.lastIndexOf(':'); - if (pos >= 0) - path= path.substring(0, pos); - if (path2 != null && !path2.equals(path)) { - if (DEBUG) System.out.println("path mismatch: " + path2); //$NON-NLS-1$ - path= path2; - } - return new Path(path); - } - return null; - } - - /* - * Tries to extract two integers separated by a comma. - * The parsing of the line starts at the position after - * the first occurrence of the given character start an ends - * at the first blank (or the end of the line). - * If only a single number is found this is assumed to be the length of the range. - * In this case the start of the range is set to 1. - * If an error occurs the range -1,-1 is returned. - */ - private void extractPair(String line, char start, int[] pair) { - pair[0]= pair[1]= -1; - int startPos= line.indexOf(start); - if (startPos < 0) { - if (DEBUG) System.out.println("parsing error in extractPair: couldn't find \'" + start + "\'"); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - line= line.substring(startPos+1); - int endPos= line.indexOf(' '); - if (endPos < 0) { - if (DEBUG) System.out.println("parsing error in extractPair: couldn't find end blank"); //$NON-NLS-1$ - return; - } - line= line.substring(0, endPos); - int comma= line.indexOf(','); - if (comma >= 0) { - pair[0]= Integer.parseInt(line.substring(0, comma)); - pair[1]= Integer.parseInt(line.substring(comma+1)); - } else { - pair[0]= 1; - pair[1]= Integer.parseInt(line.substring(comma+1)); - } - } - - //---- applying a patch file - - /* - * Tries to patch the given lines with the specified Diff. - * Any hunk that couldn't be applied is returned in the list failedHunks. - */ - /* package */ void patch(Diff diff, List lines, List failedHunks) { - - int shift= 0; - Iterator iter= diff.fHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - hunk.fMatches= false; - shift= patch(hunk, lines, shift, failedHunks); - } - } - - /* - * Tries to apply the specified hunk to the given lines. - * If the hunk cannot be applied at the original position - * the methods tries Fuzz lines before and after. - * If this fails the Hunk is added to the given list of failed hunks. - */ - private int patch(Hunk hunk, List lines, int shift, List failedHunks) { - if (tryPatch(hunk, lines, shift)) { - if (hunk.isEnabled()) - shift+= doPatch(hunk, lines, shift); - } else { - boolean found= false; - int oldShift= shift; - - for (int i= 1; i <= fFuzz; i++) { - if (tryPatch(hunk, lines, shift-i)) { - if (fAdjustShift) - shift-= i; - found= true; - break; - } - } - - if (! found) { - for (int i= 1; i <= fFuzz; i++) { - if (tryPatch(hunk, lines, shift+i)) { - if (fAdjustShift) - shift+= i; - found= true; - break; - } - } - } - - if (found) { - if (DEBUG) System.out.println("patched hunk at offset: " + (shift-oldShift)); //$NON-NLS-1$ - shift+= doPatch(hunk, lines, shift); - } else { - if (failedHunks != null) { - if (DEBUG) System.out.println("failed hunk"); //$NON-NLS-1$ - failedHunks.add(hunk); - } - } - } - return shift; - } - - /* - * Tries to apply the given hunk on the specified lines. - * The parameter shift is added to the line numbers given - * in the hunk. - */ - private boolean tryPatch(Hunk hunk, List lines, int shift) { - int pos= hunk.fOldStart + shift; - int deleteMatches= 0; - for (int i= 0; i < hunk.fLines.length; i++) { - String s= hunk.fLines[i]; - Assert.isTrue(s.length() > 0); - String line= s.substring(1); - char controlChar= s.charAt(0); - if (controlChar == ' ') { // context lines - while (true) { - if (pos < 0 || pos >= lines.size()) - return false; - if (linesMatch(line, (String) lines.get(pos))) { - pos++; - break; - } - return false; - } - } else if (controlChar == '-') { - // deleted lines - while (true) { - if (pos < 0 || pos >= lines.size()) - return false; - if (linesMatch(line, (String) lines.get(pos))) { - deleteMatches++; - pos++; - break; - } - if (deleteMatches <= 0) - return false; - pos++; - } - } else if (controlChar == '+') { - // added lines - // we don't have to do anything for a 'try' - } else - Assert.isTrue(false, "tryPatch: unknown control character: " + controlChar); //$NON-NLS-1$ - } - return true; - } - - private int doPatch(Hunk hunk, List lines, int shift) { - int pos= hunk.fOldStart + shift; - for (int i= 0; i < hunk.fLines.length; i++) { - String s= hunk.fLines[i]; - Assert.isTrue(s.length() > 0); - String line= s.substring(1); - char controlChar= s.charAt(0); - if (controlChar == ' ') { // context lines - while (true) { - Assert.isTrue(pos < lines.size(), "doPatch: inconsistency in context"); //$NON-NLS-1$ - if (linesMatch(line, (String) lines.get(pos))) { - pos++; - break; - } - pos++; - } - } else if (controlChar == '-') { - // deleted lines - while (true) { - Assert.isTrue(pos < lines.size(), "doPatch: inconsistency in deleted lines"); //$NON-NLS-1$ - if (linesMatch(line, (String) lines.get(pos))) { - break; - } - pos++; - } - lines.remove(pos); - } else if (controlChar == '+') { - // added lines - lines.add(pos, line); - pos++; - } else - Assert.isTrue(false, "doPatch: unknown control character: " + controlChar); //$NON-NLS-1$ - } - hunk.fMatches= true; - return hunk.fNewLength - hunk.fOldLength; - } - - public void applyAll(IResource target, IProgressMonitor pm, Shell shell, String title) throws CoreException { - - final int WORK_UNIT= 10; - - int i; - - IFile singleFile= null; // file to be patched - IContainer container= null; - if (target instanceof IContainer) - container= (IContainer) target; - else if (target instanceof IFile) { - singleFile= (IFile) target; - container= singleFile.getParent(); - } else { - Assert.isTrue(false); - } - - // get all files to be modified in order to call validateEdit - List list= new ArrayList(); - if (singleFile != null) - list.add(singleFile); - else { - for (i= 0; i < fDiffs.length; i++) { - Diff diff= fDiffs[i]; - if (diff.isEnabled()) { - switch (diff.getType()) { - case Differencer.CHANGE: - list.add(createPath(container, getPath(diff))); - break; - } - } - } - } - if (! Utilities.validateResources(list, shell, title)) - return; - - if (pm != null) { - String message= PatchMessages.getString("Patcher.Task.message"); //$NON-NLS-1$ - pm.beginTask(message, fDiffs.length*WORK_UNIT); - } - - for (i= 0; i < fDiffs.length; i++) { - - int workTicks= WORK_UNIT; - - Diff diff= fDiffs[i]; - if (diff.isEnabled()) { - - IPath path= getPath(diff); - if (pm != null) - pm.subTask(path.toString()); - - IFile file= singleFile != null - ? singleFile - : createPath(container, path); - - List failed= new ArrayList(); - List result= null; - - int type= diff.getType(); - switch (type) { - case Differencer.ADDITION: - // patch it and collect rejected hunks - result= apply(diff, file, true, failed); - store(createString(result), file, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - case Differencer.DELETION: - file.delete(true, true, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - case Differencer.CHANGE: - // patch it and collect rejected hunks - result= apply(diff, file, false, failed); - store(createString(result), file, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - } - - if (failed.size() > 0) { - IPath pp= null; - if (path.segmentCount() > 1) { - pp= path.removeLastSegments(1); - pp= pp.append(path.lastSegment() + REJECT_FILE_EXTENSION); - } else - pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); - file= createPath(container, pp); - if (file != null) { - store(getRejected(failed), file, pm); - try { - IMarker marker= file.createMarker(MARKER_TYPE); - marker.setAttribute(IMarker.MESSAGE, PatchMessages.getString("Patcher.Marker.message")); //$NON-NLS-1$ - marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH); - } catch (CoreException ex) { - // NeedWork - } - } - } - } - - if (pm != null) { - if (pm.isCanceled()) - break; - if (workTicks > 0) - pm.worked(workTicks); - } - } - } - - /* - * Reads the contents from the given file and returns them as - * a List of lines. - */ - List load(IFile file, boolean create) { - List lines= null; - if (!create && file != null) { - // read current contents - InputStream is= null; - try { - is= file.getContents(); - - Reader streamReader= null; - try { - streamReader= new InputStreamReader(is, Utilities.getCharset(file)); - } catch (UnsupportedEncodingException x) { - // use default encoding - streamReader= new InputStreamReader(is); - } - - BufferedReader reader= new BufferedReader(streamReader); - LineReader lr= new LineReader(reader); - if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ - lr.ignoreSingleCR(); - lines= lr.readLines(); - } catch(CoreException ex) { - // NeedWork - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - - if (lines == null) - lines= new ArrayList(); - return lines; - } - - List apply(Diff diff, IFile file, boolean create, List failedHunks) { - List lines= load(file, create); - patch(diff, lines, failedHunks); - return lines; - } - - /* - * Converts the string into bytes and stores them in the given file. - */ - private void store(String contents, IFile file, IProgressMonitor pm) throws CoreException { - - byte[] bytes; - try { - bytes= contents.getBytes(Utilities.getCharset(file)); - } catch (UnsupportedEncodingException x) { - // uses default encoding - bytes= contents.getBytes(); - } - - InputStream is= new ByteArrayInputStream(bytes); - try { - if (file.exists()) { - file.setContents(is, false, true, pm); - } else { - file.create(is, false, pm); - } - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - - /* - * Concatenates all strings found in the given List. - */ - private String createString(List lines) { - StringBuffer sb= new StringBuffer(); - Iterator iter= lines.iterator(); - if (fPreserveLineDelimiters) { - while (iter.hasNext()) - sb.append((String)iter.next()); - } else { - String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ - while (iter.hasNext()) { - String line= (String)iter.next(); - int l= length(line); - if (l < line.length()) { // line has delimiter - sb.append(line.substring(0, l)); - sb.append(lineSeparator); - } else { - sb.append(line); - } - } - } - return sb.toString(); - } - - String getRejected(List failedHunks) { - if (failedHunks.size() <= 0) - return null; - - String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ - StringBuffer sb= new StringBuffer(); - Iterator iter= failedHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - sb.append(hunk.getRejectedDescription()); - sb.append(lineSeparator); - sb.append(hunk.getContent()); - } - return sb.toString(); - } - - /* - * Ensures that a file with the given path exists in - * the given container. Folder are created as necessary. - */ - private IFile createPath(IContainer container, IPath path) throws CoreException { - if (path.segmentCount() > 1) { - IFolder f= container.getFolder(path.uptoSegment(1)); - if (!f.exists()) - f.create(false, true, null); - return createPath(f, path.removeFirstSegments(1)); - } - // a leaf - return container.getFile(path); - } - - /* - * Returns the given string with all whitespace characters removed. - * Whitespace is defined by Character.isWhitespace(...). - */ - private static String stripWhiteSpace(String s) { - StringBuffer sb= new StringBuffer(); - int l= s.length(); - for (int i= 0; i < l; i++) { - char c= s.charAt(i); - if (!Character.isWhitespace(c)) - sb.append(c); - } - return sb.toString(); - } - - /* - * Compares two strings. - * If fIgnoreWhitespace is true whitespace is ignored. - */ - private boolean linesMatch(String line1, String line2) { - if (fIgnoreWhitespace) - return stripWhiteSpace(line1).equals(stripWhiteSpace(line2)); - if (fIgnoreLineDelimiter) { - int l1= length(line1); - int l2= length(line2); - if (l1 != l2) - return false; - return line1.regionMatches(0, line2, 0, l1); - } - return line1.equals(line2); - } - - /* - * Returns the length (exluding a line delimiter CR, LF, CR/LF) - * of the given string. - */ - /* package */ static int length(String s) { - int l= s.length(); - if (l > 0) { - char c= s.charAt(l-1); - if (c == '\r') - return l-1; - if (c == '\n') { - if (l > 1 && s.charAt(l-2) == '\r') - return l-2; - return l-1; - } - } - return l; - } - - int calculateFuzz(Hunk hunk, List lines, int shift, IProgressMonitor pm, int[] fuzz) { - - hunk.fMatches= false; - if (tryPatch(hunk, lines, shift)) { - shift+= doPatch(hunk, lines, shift); - fuzz[0]= 0; - } else { - boolean found= false; - int hugeFuzz= lines.size(); // the maximum we need for this file - fuzz[0]= -2; // not found - - for (int i= 1; i <= hugeFuzz; i++) { - if (pm.isCanceled()) { - fuzz[0]= -1; - return 0; - } - if (tryPatch(hunk, lines, shift-i)) { - fuzz[0]= i; - if (fAdjustShift) - shift-= i; - found= true; - break; - } - } - - if (! found) { - for (int i= 1; i <= hugeFuzz; i++) { - if (pm.isCanceled()) { - fuzz[0]= -1; - return 0; - } - if (tryPatch(hunk, lines, shift+i)) { - fuzz[0]= i; - if (fAdjustShift) - shift+= i; - found= true; - break; - } - } - } - - if (found) - shift+= doPatch(hunk, lines, shift); - } - return shift; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java deleted file mode 100644 index b4046f039..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java +++ /dev/null @@ -1,740 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.internal.DiffImage; -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * Shows the parsed patch file and any mismatches - * between files, hunks and the currently selected - * resources. - */ -/* package */ class PreviewPatchPage extends WizardPage { - - /** - * Used with CompareInput - */ - static class HunkInput implements ITypedElement, IEncodedStreamContentAccessor { - static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - String fContent; - String fType; - - HunkInput(String type, String s) { - fType= type; - fContent= s; - } - public Image getImage() { - return null; - } - public String getName() { - return PatchMessages.getString("PreviewPatchPage.NoName.text"); //$NON-NLS-1$ - } - public String getType() { - return fType; - } - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); - } - public String getCharset() { - return UTF_16; - } - } - - private PatchWizard fPatchWizard; - - private Tree fTree; - private Combo fStripPrefixSegments; - private CompareViewerSwitchingPane fHunkViewer; - private Button fIgnoreWhitespaceButton; - private Button fReversePatchButton; - private Text fFuzzField; - - private Image[] fImages= new Image[6]; - private CompareConfiguration fCompareConfiguration; - - - /* package */ PreviewPatchPage(PatchWizard pw) { - super("PreviewPatchPage", //$NON-NLS-1$ - PatchMessages.getString("PreviewPatchPage.title"), null); //$NON-NLS-1$ - - setMessage(PatchMessages.getString("PreviewPatchPage.message")); //$NON-NLS-1$ - - fPatchWizard= pw; - //setPageComplete(false); - - int w= 16; - - ImageDescriptor addId= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - ImageDescriptor delId= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - - ImageDescriptor errId= CompareUIPlugin.getImageDescriptor("ovr16/error_ov.gif"); //$NON-NLS-1$ - Image errIm= errId.createImage(); - - fImages[0]= new DiffImage(null, null, w).createImage(); - fImages[1]= new DiffImage(null, addId, w).createImage(); - fImages[2]= new DiffImage(null, delId, w).createImage(); - - fImages[3]= new DiffImage(errIm, null, w).createImage(); - fImages[4]= new DiffImage(errIm, addId, w).createImage(); - fImages[5]= new DiffImage(errIm, delId, w).createImage(); - - fCompareConfiguration= new CompareConfiguration(); - - fCompareConfiguration.setLeftEditable(false); - fCompareConfiguration.setLeftLabel(PatchMessages.getString("PreviewPatchPage.Left.title")); //$NON-NLS-1$ - - fCompareConfiguration.setRightEditable(false); - fCompareConfiguration.setRightLabel(PatchMessages.getString("PreviewPatchPage.Right.title")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * Method declared in WizardPage - */ - public void setVisible(boolean visible) { - if (visible) - buildTree(); - super.setVisible(visible); - } - - Image getImage(Diff diff) { - if (diff.fMatches) { - switch (diff.getType()) { - case Differencer.ADDITION: - return fImages[1]; - case Differencer.DELETION: - return fImages[2]; - } - return fImages[0]; - } - switch (diff.getType()) { - case Differencer.ADDITION: - return fImages[4]; - case Differencer.DELETION: - return fImages[5]; - } - return fImages[3]; - } - - Image getImage(Hunk hunk) { - if (hunk.fMatches) - return fImages[0]; - return fImages[3]; - } - - public void createControl(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - - WorkbenchHelp.setHelp(composite, ICompareContextIds.PATCH_PREVIEW_WIZARD_PAGE); - - setControl(composite); - - buildPatchOptionsGroup(composite); - - Splitter splitter= new Splitter(composite, SWT.VERTICAL); - splitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - - // top pane showing diffs and hunks in a check box tree - fTree= new Tree(splitter, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridData gd= new GridData(); - gd.verticalAlignment= GridData.FILL; - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.grabExcessVerticalSpace= true; - fTree.setLayoutData(gd); - - // bottom pane showing hunks in compare viewer - fHunkViewer= new CompareViewerSwitchingPane(splitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration); - } - }; - gd= new GridData(); - gd.verticalAlignment= GridData.FILL; - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.grabExcessVerticalSpace= true; - fHunkViewer.setLayoutData(gd); - - // register listeners - - fTree.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TreeItem ti= (TreeItem) e.item; - Object data= e.item.getData(); - if (e.detail == SWT.CHECK) { - boolean checked= ti.getChecked(); - if (data instanceof Hunk) { - Hunk hunk= (Hunk) data; - checked= checked && hunk.fMatches; - //hunk.setEnabled(checked); - ti.setChecked(checked); - updateGrayedState(ti); - } else if (data instanceof Diff) { - updateCheckedState(ti); - } - } else { - if (data instanceof Hunk) - PreviewPatchPage.this.fHunkViewer.setInput(createInput((Hunk)data)); - else - PreviewPatchPage.this.fHunkViewer.setInput(null); - } - } - } - ); - fTree.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fImages != null) { - for (int i= 0; i < fImages.length; i++) { - if (fImages[i] == null) - fImages[i].dispose(); - } - fImages= null; - } - } - }); - // creating tree's content - buildTree(); - Dialog.applyDialogFont(composite); - } - - /* - * Create the group for setting various patch options - */ - private void buildPatchOptionsGroup(Composite parent) { - - GridLayout gl; - GridData gd; - Label l; - - final Patcher patcher= fPatchWizard.getPatcher(); - - Group group= new Group(parent, SWT.NONE); - group.setText(PatchMessages.getString("PreviewPatchPage.PatchOptions.title")); //$NON-NLS-1$ - gl= new GridLayout(); gl.numColumns= 4; gl.marginHeight= 0; - group.setLayout(gl); - group.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - - // 1st row - - Composite pair= new Composite(group, SWT.NONE); - gl= new GridLayout(); gl.numColumns= 2; gl.marginHeight= gl.marginWidth= 0; - pair.setLayout(gl); - gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - pair.setLayoutData(gd); - - l= new Label(pair, SWT.NONE); - l.setText(PatchMessages.getString("PreviewPatchPage.IgnoreSegments.text")); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL); - l.setLayoutData(gd); - - fStripPrefixSegments= new Combo(pair, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SIMPLE); - int prefixCnt= patcher.getStripPrefixSegments(); - String prefix= Integer.toString(prefixCnt); - fStripPrefixSegments.add(prefix); - fStripPrefixSegments.setText(prefix); - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END); - fStripPrefixSegments.setLayoutData(gd); - - addSpacer(group); - - fReversePatchButton= new Button(group, SWT.CHECK); - fReversePatchButton.setText(PatchMessages.getString("PreviewPatchPage.ReversePatch.text")); //$NON-NLS-1$ - - addSpacer(group); - - // 2nd row - pair= new Composite(group, SWT.NONE); - gl= new GridLayout(); gl.numColumns= 3; gl.marginHeight= gl.marginWidth= 0; - pair.setLayout(gl); - gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - pair.setLayoutData(gd); - - l= new Label(pair, SWT.NONE); - l.setText(PatchMessages.getString("PreviewPatchPage.FuzzFactor.text")); //$NON-NLS-1$ - l.setToolTipText(PatchMessages.getString("PreviewPatchPage.FuzzFactor.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL); - l.setLayoutData(gd); - - fFuzzField= new Text(pair, SWT.BORDER); - fFuzzField.setText("2"); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END); gd.widthHint= 30; - fFuzzField.setLayoutData(gd); - - Button b= new Button(pair, SWT.PUSH); - b.setText(PatchMessages.getString("PreviewPatchPage.GuessFuzz.text")); //$NON-NLS-1$ - b.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int fuzz= guessFuzzFactor(patcher); - if (fuzz >= 0) - fFuzzField.setText(Integer.toString(fuzz)); - } - } - ); - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER); - b.setLayoutData(gd); - - addSpacer(group); - - fIgnoreWhitespaceButton= new Button(group, SWT.CHECK); - fIgnoreWhitespaceButton.setText(PatchMessages.getString("PreviewPatchPage.IgnoreWhitespace.text")); //$NON-NLS-1$ - - addSpacer(group); - - // register listeners - - if (fStripPrefixSegments != null) - fStripPrefixSegments.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setStripPrefixSegments(getStripPrefixSegments())) - updateTree(); - } - } - ); - fReversePatchButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setReversed(fReversePatchButton.getSelection())) - updateTree(); - } - } - ); - fIgnoreWhitespaceButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setIgnoreWhitespace(fIgnoreWhitespaceButton.getSelection())) - updateTree(); - } - } - ); - - fFuzzField.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (patcher.setFuzz(getFuzzFactor())) - updateTree(); - } - } - ); - } - - private int guessFuzzFactor(final Patcher patcher) { - final int strip= getStripPrefixSegments(); - final int[] result= new int[1]; - try { - PlatformUI.getWorkbench().getProgressService().run(true, true, - //TimeoutContext.run(true, GUESS_TIMEOUT, getControl().getShell(), - new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - result[0]= guess(patcher, monitor, strip); - } - } - ); - return result[0]; - } catch (InvocationTargetException ex) { - // NeedWork - } catch (InterruptedException ex) { - // NeedWork - } - return -1; - } - - private int guess(Patcher patcher, IProgressMonitor pm, int strip) { - - Diff[] diffs= patcher.getDiffs(); - if (diffs == null || diffs.length <= 0) - return -1; - - // now collect files and determine "work" - IFile[] files= new IFile[diffs.length]; - int work= 0; - for (int i= 0; i < diffs.length; i++) { - Diff diff= diffs[i]; - if (diff == null) - continue; - if (diff.getType() != Differencer.ADDITION) { - IPath p= diff.fOldPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - IFile file= existsInSelection(p); - if (file != null) { - files[i]= file; - work+= diff.fHunks.size(); - } - } - } - - // do the "work" - int[] fuzzRef= new int[1]; - String format= PatchMessages.getString("PreviewPatchPage.GuessFuzzProgress.format"); //$NON-NLS-1$ - pm.beginTask(PatchMessages.getString("PreviewPatchPage.GuessFuzzProgress.text"), work); //$NON-NLS-1$ - try { - int fuzz= 0; - for (int i= 0; i < diffs.length; i++) { - Diff d= diffs[i]; - IFile file= files[i]; - if (d != null && file != null) { - List lines= patcher.load(file, false); - String name= d.getPath().lastSegment(); - Iterator iter= d.fHunks.iterator(); - int shift= 0; - for (int hcnt= 1; iter.hasNext(); hcnt++) { - pm.subTask(MessageFormat.format(format, new String[] { name, Integer.toString(hcnt) } )); - Hunk h= (Hunk) iter.next(); - shift= patcher.calculateFuzz(h, lines, shift, pm, fuzzRef); - int f= fuzzRef[0]; - if (f == -1) // cancel - return -1; - if (f > fuzz) - fuzz= f; - pm.worked(1); - } - } - } - return fuzz; - } finally { - pm.done(); - } - } - - ICompareInput createInput(Hunk hunk) { - - String[] lines= hunk.fLines; - StringBuffer left= new StringBuffer(); - StringBuffer right= new StringBuffer(); - - for (int i= 0; i < lines.length; i++) { - String line= lines[i]; - String rest= line.substring(1); - switch (line.charAt(0)) { - case ' ': - left.append(rest); - right.append(rest); - break; - case '-': - left.append(rest); - break; - case '+': - right.append(rest); - break; - } - } - - Diff diff= hunk.fParent; - IPath path= diff.getPath(); - String type= path.getFileExtension(); - - return new DiffNode(new HunkInput(type, left.toString()), new HunkInput(type, right.toString())); - } - - /** - * Builds a tree from list of Diffs. - * As a side effect it calculates the maximum number of segments - * in all paths. - */ - private void buildTree() { - setPageComplete(true); - if (fTree != null && !fTree.isDisposed()) { - fTree.removeAll(); - fHunkViewer.setInput(null); - - int length= 99; - - Diff[] diffs= fPatchWizard.getPatcher().getDiffs(); - if (diffs != null) { - for (int i= 0; i < diffs.length; i++) { - Diff diff= diffs[i]; - TreeItem d= new TreeItem(fTree, SWT.NULL); - d.setData(diff); - d.setImage(getImage(diff)); - - if (diff.fOldPath != null) - length= Math.min(length, diff.fOldPath.segmentCount()); - if (diff.fNewPath != null) - length= Math.min(length, diff.fNewPath.segmentCount()); - - java.util.List hunks= diff.fHunks; - java.util.Iterator iter= hunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - TreeItem h= new TreeItem(d, SWT.NULL); - h.setData(hunk); - h.setText(hunk.getDescription()); - } - } - } - if (fStripPrefixSegments != null && length != 99) - for (int i= 1; i < length; i++) - fStripPrefixSegments.add(Integer.toString(i)); - } - - updateTree(); - } - - private IFile existsInSelection(IPath path) { - IResource target= fPatchWizard.getTarget(); - if (target instanceof IFile) { // special case - IFile file= (IFile) target; - if (matches(file.getFullPath(), path)) - return file; - } else if (target instanceof IContainer) { - IContainer c= (IContainer) target; - if (c.exists(path)) - return c.getFile(path); - } - return null; - } - - /* - * Returns true if path completely matches the end of fullpath - */ - private boolean matches(IPath fullpath, IPath path) { - - for (IPath p= fullpath; path.segmentCount() <= p.segmentCount(); p= p.removeFirstSegments(1)) { - if (p.equals(path)) - return true; - } - return false; - } - - /** - * Updates label and checked state of tree items. - */ - private void updateTree() { - if (fTree == null || fTree.isDisposed()) - return; - int strip= getStripPrefixSegments(); - TreeItem[] children= fTree.getItems(); - for (int i= 0; i < children.length; i++) { - TreeItem item= children[i]; - Diff diff= (Diff) item.getData(); - diff.fMatches= false; - String error= null; - - boolean create= false; - IFile file= null; - if (diff.getType() == Differencer.ADDITION) { - IPath p= diff.fNewPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - file= existsInSelection(p); - if (file == null) { - diff.fMatches= true; - } else { - // file already exists - error= PatchMessages.getString("PreviewPatchPage.FileExists.error"); //$NON-NLS-1$ - } - create= true; - } else { - IPath p= diff.fOldPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - file= existsInSelection(p); - diff.fMatches= false; - if (file != null) { - if (file.isReadOnly()) { - // file is readonly - error= PatchMessages.getString("PreviewPatchPage.FileIsReadOnly.error"); //$NON-NLS-1$ - file= null; - } else { - diff.fMatches= true; - } - } else { - // file doesn't exist - error= PatchMessages.getString("PreviewPatchPage.FileDoesNotExist.error"); //$NON-NLS-1$ - } - } - - ArrayList failedHunks= new ArrayList(); - Patcher patcher= fPatchWizard.getPatcher(); - patcher.setFuzz(getFuzzFactor()); - patcher.apply(diff, file, create, failedHunks); - - if (failedHunks.size() > 0) - diff.fRejected= fPatchWizard.getPatcher().getRejected(failedHunks); - - int checkedSubs= 0; // counts checked hunk items - TreeItem[] hunkItems= item.getItems(); - for (int h= 0; h < hunkItems.length; h++) { - Hunk hunk= (Hunk) hunkItems[h].getData(); - boolean failed= failedHunks.contains(hunk); - String hunkError= null; - if (failed) - hunkError= PatchMessages.getString("PreviewPatchPage.NoMatch.error"); //$NON-NLS-1$ - - boolean check= !failed; - hunkItems[h].setChecked(check); - if (check) - checkedSubs++; - - String hunkLabel= hunk.getDescription(); - if (hunkError != null) - hunkLabel+= " " + hunkError; //$NON-NLS-1$ - hunkItems[h].setText(hunkLabel); - hunkItems[h].setImage(getImage(hunk)); - } - - String label= diff.getDescription(strip); - if (error != null) - label+= " " + error; //$NON-NLS-1$ - item.setText(label); - item.setImage(getImage(diff)); - item.setChecked(checkedSubs > 0); - boolean gray= (checkedSubs > 0 && checkedSubs < hunkItems.length); - item.setGrayed(gray); - item.setExpanded(gray); - } - setPageComplete(updateModel()); - } - - /* - * Updates the gray state of the given diff and the checked state of its children. - */ - private void updateCheckedState(TreeItem diffItem) { - boolean checked= diffItem.getChecked(); - // check whether we can enable all hunks - TreeItem[] hunks= diffItem.getItems(); - int checkedCount= 0; - for (int i= 0; i < hunks.length; i++) { - Hunk hunk= (Hunk) hunks[i].getData(); - if (checked) { - if (hunk.fMatches) { - hunks[i].setChecked(true); - checkedCount++; - } - } else { - hunks[i].setChecked(false); - } - } - diffItem.setGrayed(checkedCount > 0 && checkedCount < hunks.length); - diffItem.setChecked(checkedCount > 0); - - setPageComplete(updateModel()); - } - - /* - * Updates the gray state of the given items parent. - */ - private void updateGrayedState(TreeItem hunk) { - TreeItem diff= hunk.getParentItem(); - TreeItem[] hunks= diff.getItems(); - int checked= 0; - for (int i= 0; i < hunks.length; i++) - if (hunks[i].getChecked()) - checked++; - diff.setChecked(checked > 0); - diff.setGrayed(checked > 0 && checked < hunks.length); - - setPageComplete(updateModel()); - } - - private void addSpacer(Composite parent) { - Label label= new Label(parent, SWT.NONE); - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint= 20; - label.setLayoutData(gd); - } - - private int getStripPrefixSegments() { - int stripPrefixSegments= 0; - if (fStripPrefixSegments != null) { - String s= fStripPrefixSegments.getText(); - try { - stripPrefixSegments= Integer.parseInt(s); - } catch(NumberFormatException ex) { - // silently ignored - } - } - return stripPrefixSegments; - } - - private int getFuzzFactor() { - int fuzzFactor= 0; - if (fFuzzField != null) { - String s= fFuzzField.getText(); - try { - fuzzFactor= Integer.parseInt(s); - } catch(NumberFormatException ex) { - // silently ignored - } - } - return fuzzFactor; - } - - public boolean updateModel() { - boolean atLeastOneIsEnabled= false; - if (fTree != null && !fTree.isDisposed()) { - TreeItem [] diffItems= fTree.getItems(); - for (int i= 0; i < diffItems.length; i++) { - TreeItem diffItem= diffItems[i]; - Object data= diffItem.getData(); - if (data instanceof Diff) { - Diff diff= (Diff) data; - boolean b= diffItem.getChecked(); - diff.setEnabled(b); - if (b) { - TreeItem [] hunkItems= diffItem.getItems(); - for (int j= 0; j < hunkItems.length; j++) { - TreeItem hunkItem= hunkItems[j]; - data= hunkItem.getData(); - if (data instanceof Hunk) { - Hunk hunk= (Hunk) data; - b= hunkItem.getChecked(); - hunk.setEnabled(b); - if (b) { - atLeastOneIsEnabled= true; - } - } - } - } - } - } - } - return atLeastOneIsEnabled; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/package.html b/bundles/org.eclipse.compare/compare/org/eclipse/compare/package.html deleted file mode 100644 index 96ffb6342..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/package.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for performing structural and textual -compare operations on arbitrary data and displaying the results. -

-Package Specification

- -The class CompareUI defines the entry point to initiate a configurable -compare operation on arbitrary resources. The result of the compare is -opened into a compare editor where the details can be browsed and edited -in dynamically selected structure and content viewers. -

- -A compare operation must be implemented as a subclass of CompareEditorInput. -A CompareEditorInput runs a (potentially lengthy) compare operation -under progress monitor control, creates a UI for drilling-down into the -compare results, tracks the dirty state of the result in case of merge, -and saves any changes that occured during a merge. -

- -The NavigationAction is used to navigate (step) through the individual -differences of a CompareEditorInput. -

- -An instance of CompareConfiguration configures various UI aspects -of compare/merge viewers like title labels and images, or whether a side -of a merge viewer is editable. It is passed to the CompareEditorInput -on creation. -

- -When implementing a hierarchical compare operation as a subclass of -CompareEditorInput clients have to provide a tree of objects where each -node implements the interface -org.eclipse.compare.structuremergeviewer.IStructureComparator. -This interface is used by the hierarchical differencing engine -(org.eclipse.compare.structuremergeviewer.Differencer) to walk the tree. -
-In addition every leaf of the tree must implement the IStreamContentAccessor -or IEncodedStreamContentAccessor -interfaces in order to give the differencing engine access to its stream content -and to its encoding (with IEncodedStreamContentAccessor). -

- -The abstract class BufferedContent provides a default implementation -for the IStreamContentAccessor and IContentChangeNotifier interfaces. -Its subclass ResourceNode adds an implementation for the -IStructureComparator and ITypedElement interfaces -based on Eclipse workbench resources (org.eclipse.core.resources.IResource). -It can be used without modification as the input to the differencing engine. -

- -The ZipFileStructureCreator is an implementation of the -org.eclipse.compare.structuremergeviewer.IStructureCreator interface -and makes the contents of a zip archive available as a -hierarchical structure of IStructureComparators which can be easily compared -by the differencing engine (org.eclipse.compare.structuremergeviewer.Differencer). -It is a good example for how to make structured files available to the hierarchical -compare functionality of the Compare plugin. -

- -The EditionSelectionDialog is a simple selection dialog where -one input element can be compared against a list of historic variants (editions) -of the same input element. The dialog can be used to implement functions -like "Replace with Version" or "Replace with Edition" on workbench resources. -

- -In addition it is possible to specify a subsection of the input element -(e.g. a method in a Java source file) by means of a path. In this -case the dialog compares only the subsection (as specified by the path) -with the corresponding subsection in the list of editions. This functionality -can be used to implement "Replace with Method Edition" for the Java -language. -

- -The EditionSelectionDialog requires that the editions implement -the IStreamContentAccessor and IModificationDate interfaces. -The HistoryItem is a convenience class that implements these interfaces -for IFileState objects. -

- - -The CompareViewerPane is a convenience class which provides -a label and local toolbar for a compare viewer (or any other subclass of a -JFace Viewer). -
-Its abstract subclass CompareViewerSwitchingPane supports dynamic -viewer switching, that is the viewer installed in the pane is dynamically -determined by the pane's input object. -Both classes are useful if you want to use compare viewers outside the context of -a compare editor, for example in a dialog or wizard. -

- -A Splitter is an extension of a SashForm that supports nesting, maximizing of panes, -and propagating the visibility state of panes. -

- -The interface IStreamMerger defines a single operation for performing a three-way merge on three -input streams. The merged result is written to an output stream. -
-Clients must implement this interface when contributing new mergers to the -org.eclipse.compare.streamMergers extension point. -New IStreamMergers can be created for registered types with the createStreamMerger methods of CompareUI. - - - - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java deleted file mode 100644 index 0ad70b4f4..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.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.compare.rangedifferencer; - -import java.util.ArrayList; -import java.util.List; - -/** - * A custom iterator to iterate over a List of RangeDifferences. - * It is used internally by the RangeDifferencer. - */ -/* package */ class DifferencesIterator { - - List fRange; - int fIndex; - RangeDifference[] fArray; - RangeDifference fDifference; - - /* - * Creates a differences iterator on an array of RangeDifferences. - */ - 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 RangeDifference. - */ - 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 RangeDifferences - */ - void removeAll() { - fRange.clear(); - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java deleted file mode 100644 index 70bd1d5e0..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.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.compare.rangedifferencer; - -/** - * For breaking an object to compare into a sequence of comparable entities. - *

- * It is used by RangeDifferencer to find longest sequences of - * matching and non-matching ranges. - *

- * 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. getRangeCount would return the number of lines in the - * document, and rangesEqual would compare a specified line given - * with one in another IRangeComparator. - *

- *

- * Clients should implement this interface; there is no standard implementation. - *

- */ -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 IRangeComparator and index. - * - * @param thisIndex the index of the comparable entity within this IRangeComparator - * @param other the IRangeComparator to compare this with - * @param otherIndex the index of the comparable entity within the other IRangeComparator - * @return true 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 - * true or false - * @param maxLength another number on which to base the decision whether to return - * true or false - * @param other the other IRangeComparator to compare with - * @return true to avoid a too lengthy range comparison - */ - boolean skipRangeComparison(int length, int maxLength, IRangeComparator other); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java deleted file mode 100644 index 0d06930bf..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.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.compare.rangedifferencer; - -/* 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/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java deleted file mode 100644 index 8d75eae7e..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.rangedifferencer; - -/** - * Description of a change between two or three ranges of comparable entities. - *

- * RangeDifference objects are the elements of a compare result returned from - * the RangeDifferencer find* methods. - * Clients use these objects as they are returned from the differencer. - * This class is not intended to be instantiated or subclassed. - *

- * Note: A range in the RangeDifference 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. - *

- * - * @see RangeDifferencer - */ -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 RIGHT) */ - 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; - - /** - * Creates a new range difference with the given change kind. - * - * @param changeKind the kind of change - */ - /* package */ RangeDifference(int changeKind) { - fKind= changeKind; - } - - /** - * Creates a new RangeDifference 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 - */ - /* package */ RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength) { - fKind= kind; - fRightStart= rightStart; - fRightLength= rightLength; - fLeftStart= leftStart; - fLeftLength= leftLength; - } - - /** - * Creates a new RangeDifference 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 - */ - /* package */ 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 - * NOCHANGE, CHANGE, LEFT, RIGHT, - * ANCESTOR, CONFLICT, ERROR - */ - 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)); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java deleted file mode 100644 index 31cbc8214..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java +++ /dev/null @@ -1,536 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.rangedifferencer; - -import java.util.*; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A RangeDifferencer finds the differences between two or three IRangeComparators. - *

- * To use the differencer, clients provide an IRangeComparator - * that breaks their input data into a sequence of comparable entities. The differencer - * returns the differences among these sequences as an array of RangeDifference objects - * (findDifferences methods). - * Every RangeDifference represents a single kind of difference - * and the corresponding ranges of the underlying comparable entities in the - * left, right, and optionally ancestor sides. - *

- * Alternatively, the findRanges methods not only return objects for - * the differing ranges but for non-differing ranges too. - *

- * The algorithm used is an objectified version of one described in: - * A File Comparison Program, by Webb Miller and Eugene W. Myers, - * Software Practice and Experience, Vol. 15, Nov. 1985. - * - * @see IRangeComparator - * @see RangeDifference - */ -public final class RangeDifferencer { - - private static final RangeDifference[] EMPTY_RESULT= new RangeDifference[0]; - - /* (non Javadoc) - * Non instantiatiable! - */ - private RangeDifferencer() { - // nothing to do - } - - /** - * Finds the differences between two IRangeComparators. - * The differences are returned as an array of RangeDifferences. - * 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 - */ - public static RangeDifference[] findDifferences(IRangeComparator left, IRangeComparator right) { - return findDifferences((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences between two IRangeComparators. - * The differences are returned as an array of RangeDifferences. - * If no differences are detected an empty array is returned. - * - * @param pm if not null 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 - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) { - - // 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++; - - 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); - - // 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= new LinkedRangeDifference(script[k + 1], LinkedRangeDifference.DELETE); - } else { - // - // move right - // - row= lastDiagonal[k - 1]; - edit= new LinkedRangeDifference(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 IRangeComparators. - * The differences are returned as a list of RangeDifferences. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param ancestor the ancestor range comparator or null - * @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 - */ - public static RangeDifference[] findDifferences(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - return findDifferences(null, ancestor, left, right); - } - - /** - * Finds the differences among three IRangeComparators. - * The differences are returned as a list of RangeDifferences. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param pm if not null used to report progress - * @param ancestor the ancestor range comparator or null - * @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 - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - - 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 IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - */ - public static RangeDifference[] findRanges(IRangeComparator left, IRangeComparator right) { - return findRanges((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences among two IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * - * @param pm if not null used to report progress - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @since 2.0 - */ - public static RangeDifference[] findRanges(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) { - 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 (RangeDifference[]) out.toArray(EMPTY_RESULT); - } - - /** - * Finds the differences among three IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param ancestor the ancestor range comparator or null - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - */ - public static RangeDifference[] findRanges(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - return findRanges(null, ancestor, left, right); - } - - /** - * Finds the differences among three IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param pm if not null used to report progress - * @param ancestor the ancestor range comparator or null - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @since 2.0 - */ - public static RangeDifference[] findRanges(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - - 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 (RangeDifference[]) out.toArray(EMPTY_RESULT); - } - - //---- 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 RangeDifference3 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 right and 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/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html b/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html deleted file mode 100644 index 368068b3b..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for finding the differences between -two or three sequences of comparable entities. -

-Package Specification

- -The class RangeDifferencer finds longest sequences of matching and -non-matching comparable entities. Its implementation is based on -an objectified version of the algorithm described in: -A File Comparison Program, by Webb Miller and Eugene W. Myers, -Software Practice and Experience, Vol. 15, Nov. 1985. -

- -Clients must supply the input to the differencer as an implementation -of the IRangeComparator interface. -An IRangeComparator breaks the input data into a sequence -of entities and provides a method for comparing -one entity with the entity in another IRangeComparator. -

- -For example, to compare two text documents and find longest common -sequences of matching and non-matching lines, -the implementation of IRangeComparator -must break the document into lines and provide a method for testing -whether two lines are considered equal. -See org.eclipse.compare.internal.DocLineComparator for how this can be done. -

- -The differencer returns the differences among these sequences as an -array of RangeDifference objects. -Every single RangeDifference describes the kind of difference -(no change, change, addition, deletion) and the corresponding ranges -of the underlying comparable entities in the two or three inputs. - - - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java deleted file mode 100644 index b74d36e1b..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.util.ArrayList; - -/** - * The standard implementation of a diff container element. - *

- * This class may be instantiated, or further subclassed. - *

- */ -public abstract class DiffContainer extends DiffElement implements IDiffContainer { - - private static IDiffElement[] fgEmptyArray= new IDiffElement[0]; - private ArrayList fChildren; - - /** - * Creates a new container with the specified kind under the given parent. - * - * @param parent under which the new container is added as a child or null. - * @param kind of difference (defined in Differencer). - */ - public DiffContainer(IDiffContainer parent, int kind) { - super(parent, kind); - } - - /** - * Tries to find the child with the given name. - * Returns null if no such child exists. - * - * @param name of the child to find - * @return the first element with a matching name - */ - public IDiffElement findChild(String name) { - Object[] children= getChildren(); - for (int i= 0; i < children.length; i++) { - IDiffElement child= (IDiffElement) children[i]; - if (name.equals(child.getName())) - return child; - } - return null; - } - - /* (non Javadoc) - * see IDiffContainer.add - */ - public void add(IDiffElement diff) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(diff); - diff.setParent(this); - } - - /* - * Removes the given child from this container. - * If the container becomes empty it is removed from its container. - */ - public void removeToRoot(IDiffElement child) { - if (fChildren != null) { - fChildren.remove(child); - child.setParent(null); - if (fChildren.size() == 0) { - IDiffContainer p= getParent(); - if (p != null) - p.removeToRoot(this); - } - } - } - - /** - * Removes the given child (non-recursively) from this container. - * - * @param child to remove - */ - public void remove(IDiffElement child) { - if (fChildren != null) { - fChildren.remove(child); - child.setParent(null); - } - } - - /* (non Javadoc) - * see IDiffContainer.hasChildren - */ - public boolean hasChildren() { - return fChildren != null && fChildren.size() > 0; - } - - /* (non Javadoc) - * see IDiffContainer.getChildren - */ - public IDiffElement[] getChildren() { - if (fChildren != null) - return (IDiffElement[]) fChildren.toArray(fgEmptyArray); - return fgEmptyArray; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java deleted file mode 100644 index ef1cf5f59..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.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.compare.structuremergeviewer; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.compare.ITypedElement; - -/** - * An abstract base implementation of the IDiffElement interface. - *

- * Subclasses may add behavior and state, and may override getImage - * and getType to suit. - *

- */ -public abstract class DiffElement implements IDiffElement { - - private int fKind; - private IDiffContainer fParent; - - /** - * Creates a new DiffElement as a child of the given parent. - * If parent is not null the new element is added to the parent. - * - * @param parent the parent of this child; if not null this element is automatically added as a child - * @param kind the kind of change - */ - public DiffElement(IDiffContainer parent, int kind) { - fParent= parent; - fKind= kind; - if (parent != null) - parent.add(this); - } - - /** - * The DiffElement implementation of this ITypedInput - * method returns null. Subclasses may re-implement to provide - * an image for this element. - * @return null. - */ - public Image getImage() { - return null; - } - - /** - * The DiffElement implementation of this ITypedElement - * method returns ITypedElement.UNKNOWN_TYPE. Subclasses may - * re-implement to provide a type for this element. - * @return ITypedElement.UNKNOWN_TYPE. - */ - public String getType() { - return ITypedElement.UNKNOWN_TYPE; - } - - /** - * Sets the kind of difference for this element. - * - * @param kind set the kind of difference this element represents - * @see Differencer - */ - public void setKind(int kind) { - fKind= kind; - } - - /* (non Javadoc) - * see IDiffElement.getKind - */ - public int getKind() { - return fKind; - } - - /* (non Javadoc) - * see IDiffElement.getParent - */ - public IDiffContainer getParent() { - return fParent; - } - - /* (non Javadoc) - * see IDiffElement.setParent - */ - public void setParent(IDiffContainer parent) { - fParent= parent; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java deleted file mode 100644 index 8e062d273..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.text.MessageFormat; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.ListenerList; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; - -/** - * Diff node are used as the compare result of the differencing engine. - * Since it implements the ITypedElement and ICompareInput - * interfaces it can be used directly to display the - * compare result in a DiffTreeViewer and as the input to any other - * compare/merge viewer. - *

- * DiffNodes are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients typically use this class as is, but may subclass if required. - * - * @see DiffTreeViewer - * @see Differencer - */ -public class DiffNode extends DiffContainer implements ITypedElement, ICompareInput { - - private ITypedElement fAncestor; - private ITypedElement fLeft; - private ITypedElement fRight; - private boolean fDontExpand; - private ListenerList fListener; - private boolean fSwapSides; - - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param parent under which the new container is added as a child or null - * @param kind of difference (defined in Differencer) - * @param ancestor the common ancestor input to a compare - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - this(parent, kind); - fAncestor= ancestor; - fLeft= left; - fRight= right; - } - - /** - * Creates a new DiffNode with diff kind Differencer.CHANGE - * and initializes with the given values. - * - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(ITypedElement left, ITypedElement right) { - this(null, Differencer.CHANGE, null, left, right); - } - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param kind of difference (defined in Differencer) - * @param ancestor the common ancestor input to a compare - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - this(null, kind, ancestor, left, right); - } - - /** - * Creates a new DiffNode with the given diff kind. - * - * @param kind of difference (defined in Differencer) - */ - public DiffNode(int kind) { - super(null, kind); - } - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param parent under which the new container is added as a child or null - * @param kind of difference (defined in Differencer) - */ - public DiffNode(IDiffContainer parent, int kind) { - super(parent, kind); - } - - /** - * Registers a listener for changes of this ICompareInput. - * Has no effect if an identical listener is already registered. - * - * @param listener the listener to add - */ - public void addCompareInputChangeListener(ICompareInputChangeListener listener) { - if (fListener == null) - fListener= new ListenerList(); - fListener.add(listener); - } - - /** - * Unregisters a ICompareInput listener. - * Has no effect if listener is not registered. - * - * @param listener the listener to remove - */ - public void removeCompareInputChangeListener(ICompareInputChangeListener listener) { - if (fListener != null) { - fListener.remove(listener); - if (fListener.isEmpty()) - fListener= null; - } - } - - /** - * Sends out notification that a change has occured on the ICompareInput. - */ - protected void fireChange() { - if (fListener != null) { - Object[] listeners= fListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((ICompareInputChangeListener) listeners[i]).compareInputChanged(this); - } - } - - //---- getters & setters - - /** - * Returns true if this node shouldn't automatically be expanded in - * a DiffTreeViewer. - * - * @return true if node shouldn't automatically be expanded - */ - public boolean dontExpand() { - return fDontExpand; - } - - /** - * Controls whether this node is not automatically expanded when displayed in - * a DiffTreeViewer. - * - * @param dontExpand if true this node is not automatically expanded in DiffTreeViewer - */ - public void setDontExpand(boolean dontExpand) { - fDontExpand= dontExpand; - } - - /** - * Returns the first not-null input of this node. - * Method checks the three inputs in the order: ancestor, right, left. - * - * @return the first not-null input of this node - */ - public ITypedElement getId() { - if (fAncestor != null) - return fAncestor; - if (fRight != null) - return fRight; - return fLeft; - } - - /** - * Returns the (non-null) name of the left or right side if they are identical. - * Otherwise both names are concatenated (separated with a slash ('/')). - *

- * Subclasses may re-implement to provide a different name for this node. - * @return the name of this node. - */ - public String getName() { - String right= null; - if (fRight != null) - right= fRight.getName(); - - String left= null; - if (fLeft != null) - left= fLeft.getName(); - - if (right == null && left == null) { - if (fAncestor != null) - return fAncestor.getName(); - return Utilities.getString("DiffNode.noName"); //$NON-NLS-1$ - } - - if (right == null) - return left; - if (left == null) - return right; - - if (right.equals(left)) - return right; - - String s1; - String s2; - - if (fSwapSides) { - s1= left; - s2= right; - } else { - s1= right; - s2= left; - } - - String fmt= Utilities.getString("DiffNode.nameFormat"); //$NON-NLS-1$ - return MessageFormat.format(fmt, new String[] { s1, s2 }); - } - - void swapSides(boolean swap) { - fSwapSides= swap; - } - - /* (non Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - ITypedElement id= getId(); - if (id != null) - return id.getImage(); - return null; - } - - /* (non Javadoc) - * see ITypedElement.getType - */ - public String getType() { - ITypedElement id= getId(); - if (id != null) - return id.getType(); - return ITypedElement.UNKNOWN_TYPE; - } - - /** - * Sets the ancestor input to the given value. - * - * @param ancestor the new value for the ancestor input - * @since 3.0 - */ - public void setAncestor(ITypedElement ancestor) { - fAncestor= ancestor; - } - - /* (non Javadoc) - * see ICompareInput.getAncestor - */ - public ITypedElement getAncestor() { - return fAncestor; - } - - /** - * Sets the left input to the given value. - * - * @param left the new value for the left input - */ - public void setLeft(ITypedElement left) { - fLeft= left; - } - - /* (non Javadoc) - * see ICompareInput.getLeft - */ - public ITypedElement getLeft() { - return fLeft; - } - - /** - * Sets the right input to the given value. - * - * @param right the new value for the right input - */ - public void setRight(ITypedElement right) { - fRight= right; - } - - /* (non Javadoc) - * see ICompareInput.getRight - */ - public ITypedElement getRight() { - return fRight; - } - - /* (non Javadoc) - * see ICompareInput.copy - */ - public void copy(boolean leftToRight) { - //System.out.println("DiffNode.copy: " + leftToRight); - - IDiffContainer pa= getParent(); - if (pa instanceof ICompareInput) { - ICompareInput parent= (ICompareInput) pa; - Object dstParent= leftToRight ? parent.getRight() : parent.getLeft(); - - if (dstParent instanceof IEditableContent) { - ITypedElement dst= leftToRight ? getRight() : getLeft(); - ITypedElement src= leftToRight ? getLeft() : getRight(); - dst= ((IEditableContent)dstParent).replace(dst, src); - if (leftToRight) - setRight(dst); - else - setLeft(dst); - - //setKind(Differencer.NO_CHANGE); - - fireChange(); - } - } - } - - /* (non Javadoc) - * see Object.hashCode - */ - public int hashCode() { - String[] path= getPath(this, 0); - int hashCode= 1; - for (int i= 0; i < path.length; i++) { - String s= path[i]; - hashCode= (31*hashCode) + (s != null ? s.hashCode() : 0); - } - return hashCode; - } - - /* (non Javadoc) - * see Object.equals - */ - public boolean equals(Object other) { - if (other != null && getClass() == other.getClass()) { - String[] path1= getPath(this, 0); - String[] path2= getPath((DiffNode) other, 0); - if (path1.length != path2.length) - return false; - for (int i= 0; i < path1.length; i++) - if (! path1[i].equals(path2[i])) - return false; - return true; - } - return super.equals(other); - } - - private static String[] getPath(ITypedElement el, int level) { - String[] path= null; - if (el instanceof IDiffContainer) { - IDiffContainer parent= ((IDiffContainer)el).getParent(); - if (parent != null) - path= getPath(parent, level+1); - } - if (path == null) - path= new String[level+1]; - path[(path.length-1)-level]= el.getName(); - return path; - } -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java deleted file mode 100644 index 5b6b849f3..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java +++ /dev/null @@ -1,727 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.util.Iterator; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.*; - -/** - * A tree viewer that works on objects implementing - * the IDiffContainer and IDiffElement interfaces. - *

- * This class may be instantiated; it is not intended to be subclassed outside - * this package. - *

- * - * @see IDiffContainer - * @see IDiffElement - */ -public class DiffTreeViewer extends TreeViewer { - - static class DiffViewerSorter extends ViewerSorter { - - public boolean isSorterProperty(Object element, Object property) { - return false; - } - - public int category(Object node) { - if (node instanceof DiffNode) { - Object o= ((DiffNode) node).getId(); - if (o instanceof DocumentRangeNode) - return ((DocumentRangeNode) o).getTypeCode(); - } - return 0; - } - } - - class DiffViewerContentProvider implements ITreeContentProvider { - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // empty implementation - } - - public boolean isDeleted(Object element) { - return false; - } - - public void dispose() { - inputChanged(DiffTreeViewer.this, getInput(), null); - } - - public Object getParent(Object element) { - if (element instanceof IDiffElement) - return ((IDiffElement)element).getParent(); - return null; - } - - public final boolean hasChildren(Object element) { - if (element instanceof IDiffContainer) - return ((IDiffContainer)element).hasChildren(); - return false; - } - - public final Object[] getChildren(Object element) { - if (element instanceof IDiffContainer) - return ((IDiffContainer)element).getChildren(); - return new Object[0]; - } - - public Object[] getElements(Object element) { - return getChildren(element); - } - } - - /* - * Takes care of swapping left and right if fLeftIsLocal - * is true. - */ - class DiffViewerLabelProvider extends LabelProvider { - - public String getText(Object element) { - - if (element instanceof IDiffElement) - return ((IDiffElement)element).getName(); - - return Utilities.getString(fBundle, "defaultLabel"); //$NON-NLS-1$ - } - - public Image getImage(Object element) { - if (element instanceof IDiffElement) { - IDiffElement input= (IDiffElement) element; - - int kind= input.getKind(); - if (fLeftIsLocal) { - switch (kind & Differencer.DIRECTION_MASK) { - case Differencer.LEFT: - kind= (kind &~ Differencer.LEFT) | Differencer.RIGHT; - break; - case Differencer.RIGHT: - kind= (kind &~ Differencer.RIGHT) | Differencer.LEFT; - break; - } - } - - return fCompareConfiguration.getImage(input.getImage(), kind); - } - return null; - } - } - - static class FilterSame extends ViewerFilter { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof IDiffElement) - return (((IDiffElement)element).getKind() & Differencer.PSEUDO_CONFLICT) == 0; - return true; - } - public boolean isFilterProperty(Object element, Object property) { - return false; - } - } - - private ResourceBundle fBundle; - private CompareConfiguration fCompareConfiguration; - /* package */ boolean fLeftIsLocal; - private IPropertyChangeListener fPropertyChangeListener; - - private Action fCopyLeftToRightAction; - private Action fCopyRightToLeftAction; - private Action fEmptyMenuAction; - private Action fExpandAllAction; - - /** - * Creates a new viewer for the given SWT tree control with the specified configuration. - * - * @param tree the tree control - * @param configuration the configuration for this viewer - */ - public DiffTreeViewer(Tree tree, CompareConfiguration configuration) { - super(tree); - initialize(configuration); - } - - /** - * Creates a new viewer under the given SWT parent and with the specified configuration. - * - * @param parent the SWT control under which to create the viewer - * @param configuration the configuration for this viewer - */ - public DiffTreeViewer(Composite parent, CompareConfiguration configuration) { - super(new Tree(parent, SWT.MULTI)); - initialize(configuration); - } - - private void initialize(CompareConfiguration configuration) { - - Control tree= getControl(); - - INavigatable nav= new INavigatable() { - public boolean gotoDifference(boolean next) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return internalNavigate(next, true); - } - }; - tree.setData(INavigatable.NAVIGATOR_PROPERTY, nav); - - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - IOpenable openable= new IOpenable() { - public void openSelected() { - internalOpen(); - } - }; - tree.setData(IOpenable.OPENABLE_PROPERTY, openable); - - fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - - tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - - Composite parent= tree.getParent(); - - fBundle= ResourceBundle.getBundle("org.eclipse.compare.structuremergeviewer.DiffTreeViewerResources"); //$NON-NLS-1$ - - // register for notification with the CompareConfiguration - fCompareConfiguration= configuration; - if (fCompareConfiguration != null) { - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - DiffTreeViewer.this.propertyChange(event); - } - }; - fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); - } - - setContentProvider(new DiffViewerContentProvider()); - setLabelProvider(new DiffViewerLabelProvider()); - - addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent se) { - updateActions(); - } - } - ); - - setSorter(new DiffViewerSorter()); - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - - tbm.add(new Separator("merge")); //$NON-NLS-1$ - tbm.add(new Separator("modes")); //$NON-NLS-1$ - tbm.add(new Separator("navigation")); //$NON-NLS-1$ - - createToolItems(tbm); - updateActions(); - - tbm.update(true); - } - - MenuManager mm= new MenuManager(); - mm.setRemoveAllWhenShown(true); - mm.addMenuListener( - new IMenuListener() { - public void menuAboutToShow(IMenuManager mm2) { - fillContextMenu(mm2); - if (mm2.isEmpty()) { - if (fEmptyMenuAction == null) { - fEmptyMenuAction= new Action(Utilities.getString(fBundle, "emptyMenuItem")) { //$NON-NLS-1$ - // left empty - }; - fEmptyMenuAction.setEnabled(false); - } - mm2.add(fEmptyMenuAction); - } - } - } - ); - tree.setMenu(mm.createContextMenu(tree)); - } - - /** - * Returns the viewer's name. - * - * @return the viewer's name - */ - public String getTitle() { - String title= Utilities.getString(fBundle, "title", null); //$NON-NLS-1$ - if (title == null) - title= Utilities.getString("DiffTreeViewer.title"); //$NON-NLS-1$ - return title; - } - - /** - * Returns the resource bundle. - * - * @return the viewer's resource bundle - */ - protected ResourceBundle getBundle() { - return fBundle; - } - - /** - * Returns the compare configuration of this viewer. - * - * @return the compare configuration of this viewer - */ - public CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - * @param event dispose event that triggered call to this method - */ - protected void handleDispose(DisposeEvent event) { - - if (fCompareConfiguration != null) { - if (fPropertyChangeListener != null) - fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener); - fCompareConfiguration= null; - } - fPropertyChangeListener= null; - - super.handleDispose(event); - } - - /** - * Tracks property changes of the configuration object. - * Clients may extend to track their own property changes. - * @param event property change event that triggered call to this method - */ - protected void propertyChange(PropertyChangeEvent event) { - // empty default implementation - } - - protected void inputChanged(Object in, Object oldInput) { - super.inputChanged(in, oldInput); - - if (in != oldInput) { - initialSelection(); - updateActions(); - } - } - - /** - * This hook method is called from within inputChanged - * after a new input has been set but before any controls are updated. - * This default implementation calls navigate(true) - * to select and expand the first leaf node. - * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * - * @since 2.0 - */ - protected void initialSelection() { - navigate(true); - } - - /** - * Overridden to avoid expanding DiffNodes that shouldn't expand. - * @param node the node to expand - * @param level non-negative level, or ALL_LEVELS to collapse all levels of the tree - */ - protected void internalExpandToLevel(Widget node, int level) { - - Object data= node.getData(); - - if (dontExpand(data)) - return; - - super.internalExpandToLevel(node, level); - } - - /** - * This hook method is called from within internalExpandToLevel - * to control whether a given model node should be expanded or not. - * This default implementation checks whether the object is a DiffNode and - * calls dontExpand() on it. - * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * - * @param o the model object to be expanded - * @return false if a node should be expanded, true to prevent expanding - * @since 2.0 - */ - protected boolean dontExpand(Object o) { - return o instanceof DiffNode && ((DiffNode)o).dontExpand(); - } - - //---- merge action support - - /** - * This factory method is called after the viewer's controls have been created. - * It installs four actions in the given ToolBarManager. Two actions - * allow for copying one side of a DiffNode to the other side. - * Two other actions are for navigating from one node to the next (previous). - *

- * Clients can override this method and are free to decide whether they want to call - * the inherited method. - * - * @param toolbarManager the toolbar manager for which to add the actions - */ - protected void createToolItems(ToolBarManager toolbarManager) { - -// fCopyLeftToRightAction= new Action() { -// public void run() { -// copySelected(true); -// } -// }; -// Utilities.initAction(fCopyLeftToRightAction, fBundle, "action.TakeLeft."); -// toolbarManager.appendToGroup("merge", fCopyLeftToRightAction); - -// fCopyRightToLeftAction= new Action() { -// public void run() { -// copySelected(false); -// } -// }; -// Utilities.initAction(fCopyRightToLeftAction, fBundle, "action.TakeRight."); -// toolbarManager.appendToGroup("merge", fCopyRightToLeftAction); - -// fNextAction= new Action() { -// public void run() { -// navigate(true); -// } -// }; -// Utilities.initAction(fNextAction, fBundle, "action.NextDiff."); //$NON-NLS-1$ -// toolbarManager.appendToGroup("navigation", fNextAction); //$NON-NLS-1$ - -// fPreviousAction= new Action() { -// public void run() { -// navigate(false); -// } -// }; -// Utilities.initAction(fPreviousAction, fBundle, "action.PrevDiff."); //$NON-NLS-1$ -// toolbarManager.appendToGroup("navigation", fPreviousAction); //$NON-NLS-1$ - } - - /** - * This method is called to add actions to the viewer's context menu. - * It installs actions for expanding tree nodes, copying one side of a DiffNode to the other side. - * Clients can override this method and are free to decide whether they want to call - * the inherited method. - * - * @param manager the menu manager for which to add the actions - */ - protected void fillContextMenu(IMenuManager manager) { - if (fExpandAllAction == null) { - fExpandAllAction= new Action() { - public void run() { - expandSelection(); - } - }; - Utilities.initAction(fExpandAllAction, fBundle, "action.ExpandAll."); //$NON-NLS-1$ - } - - boolean enable= false; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator elements= ((IStructuredSelection)selection).iterator(); - while (elements.hasNext()) { - Object element= elements.next(); - if (element instanceof IDiffContainer) { - if (((IDiffContainer)element).hasChildren()) { - enable= true; - break; - } - } - } - } - fExpandAllAction.setEnabled(enable); - - manager.add(fExpandAllAction); - - if (fCopyLeftToRightAction != null) - manager.add(fCopyLeftToRightAction); - if (fCopyRightToLeftAction != null) - manager.add(fCopyRightToLeftAction); - } - - /** - * Expands to infinity all items in the selection. - * - * @since 2.0 - */ - protected void expandSelection() { - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator elements= ((IStructuredSelection)selection).iterator(); - while (elements.hasNext()) { - Object next= elements.next(); - expandToLevel(next, ALL_LEVELS); - } - } - } - - /** - * Copies one side of all DiffNodes in the current selection to the other side. - * Called from the (internal) actions for copying the sides of a DiffNode. - * Clients may override. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copySelected(boolean leftToRight) { - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator e= ((IStructuredSelection) selection).iterator(); - while (e.hasNext()) { - Object element= e.next(); - if (element instanceof ICompareInput) - copyOne((ICompareInput) element, leftToRight); - } - } - } - - /** - * Called to copy one side of the given node to the other. - * This default implementation delegates the call to ICompareInput.copy(...). - * Clients may override. - * @param node the node to copy - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copyOne(ICompareInput node, boolean leftToRight) { - - node.copy(leftToRight); - - // update node's image - update(new Object[] { node }, null); - } - - /** - * Selects the next (or previous) node of the current selection. - * If there is no current selection the first (last) node in the tree is selected. - * Wraps around at end or beginning. - * Clients may override. - * - * @param next if true the next node is selected, otherwise the previous node - */ - protected void navigate(boolean next) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - internalNavigate(next, false); - } - - //---- private - - /** - * Selects the next (or previous) node of the current selection. - * If there is no current selection the first (last) node in the tree is selected. - * Wraps around at end or beginning. - * Clients may override. - * - * @param next if true the next node is selected, otherwise the previous node - * @param fireOpen if true an open event is fired. - * @return true if at end (or beginning) - */ - private boolean internalNavigate(boolean next, boolean fireOpen) { - - Control c= getControl(); - if (!(c instanceof Tree)) - return false; - - Tree tree= (Tree) c; - TreeItem item= null; - TreeItem children[]= tree.getSelection(); - if (children != null && children.length > 0) - item= children[0]; - if (item == null) { - children= tree.getItems(); - if (children != null && children.length > 0) { - item= children[0]; - if (item != null && item.getItemCount() <= 0) { - internalSetSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - } - } - - while (true) { - item= findNextPrev(item, next); - if (item == null) - break; - if (item.getItemCount() <= 0) - break; - } - - if (item != null) { - internalSetSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - return true; - } - - private TreeItem findNextPrev(TreeItem item, boolean next) { - - if (item == null) - return null; - - TreeItem children[]= null; - - if (!next) { - - TreeItem parent= item.getParentItem(); - if (parent != null) - children= parent.getItems(); - else - children= item.getParent().getItems(); - - if (children != null && children.length > 0) { - // goto previous child - int index= 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - - if (index > 0) { - - item= children[index-1]; - - while (true) { - createChildren(item); - int n= item.getItemCount(); - if (n <= 0) - break; - - item.setExpanded(true); - item= item.getItems()[n-1]; - } - - // previous - return item; - } - } - - // go up - item= parent; - - } else { - item.setExpanded(true); - createChildren(item); - - if (item.getItemCount() > 0) { - // has children: go down - children= item.getItems(); - return children[0]; - } - - while (item != null) { - children= null; - TreeItem parent= item.getParentItem(); - if (parent != null) - children= parent.getItems(); - else - children= item.getParent().getItems(); - - if (children != null && children.length > 0) { - // goto next child - int index= 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - - if (index < children.length-1) { - // next - return children[index+1]; - } - } - - // go up - item= parent; - } - } - - return item; - } - - private void internalSetSelection(TreeItem ti, boolean fireOpen) { - if (ti != null) { - Object data= ti.getData(); - if (data != null) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - ISelection selection= new StructuredSelection(data); - setSelection(selection, true); - ISelection currentSelection= getSelection(); - if (fireOpen && currentSelection != null && selection.equals(currentSelection)) { - fireOpen(new OpenEvent(this, selection)); - } - } - } - } - - private final boolean isEditable(Object element, boolean left) { - if (element instanceof ICompareInput) { - ICompareInput diff= (ICompareInput) element; - Object side= left ? diff.getLeft() : diff.getRight(); - if (side == null && diff instanceof IDiffElement) { - IDiffContainer container= ((IDiffElement)diff).getParent(); - if (container instanceof ICompareInput) { - ICompareInput parent= (ICompareInput) container; - side= left ? parent.getLeft() : parent.getRight(); - } - } - if (side instanceof IEditableContent) - return ((IEditableContent) side).isEditable(); - } - return false; - } - - private void updateActions() { - int leftToRight= 0; - int rightToLeft= 0; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - Iterator e= ss.iterator(); - while (e.hasNext()) { - Object element= e.next(); - if (element instanceof ICompareInput) { - if (isEditable(element, false)) - leftToRight++; - if (isEditable(element, true)) - rightToLeft++; - if (leftToRight > 0 && rightToLeft > 0) - break; - } - } - if (fExpandAllAction != null) - fExpandAllAction.setEnabled(selection.isEmpty()); - } - if (fCopyLeftToRightAction != null) - fCopyLeftToRightAction.setEnabled(leftToRight > 0); - if (fCopyRightToLeftAction != null) - fCopyRightToLeftAction.setEnabled(rightToLeft > 0); - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private void internalOpen() { - ISelection selection= getSelection(); - if (selection != null && !selection.isEmpty()) { - fireOpen(new OpenEvent(this, selection)); - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties deleted file mode 100644 index f737039be..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties +++ /dev/null @@ -1,53 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)DiffTreeViewerResources.properties -# -# Resource strings for DiffTreeViewer.java - -title= Structure Compare -defaultLabel= - -##################################################### -# Dummy menu item for empty context menu -##################################################### - -emptyMenuItem= - -##################################################### -# Actions -##################################################### - -action.Smart.label=Smart -action.Smart.tooltip=Guess Similar Elements -action.Smart.image=smartmode_co.gif - -action.ExpandAll.label=Expand All -action.ExpandAll.tooltip=Expand All Nodes - -action.CompareContents.label= Show Content Comparison -action.CompareContents.tooltip= Show Content Comparison - -action.NextDiff.label=Next -action.NextDiff.tooltip=Select Next Change -action.NextDiff.image=next_nav.gif - -action.PrevDiff.label=Previous -action.PrevDiff.tooltip=Select Previous Change -action.PrevDiff.image=prev_nav.gif - -action.TakeLeft.label=Copy Left to Right -action.TakeLeft.tooltip=Copy Selected Nodes from Left to Right -action.TakeLeft.image=copycont_r_co.gif - -action.TakeRight.label=Copy Right to Left -action.TakeRight.tooltip=Copy Selected Nodes from Right to Left -action.TakeRight.image=copycont_l_co.gif diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java deleted file mode 100644 index b90c3c0ef..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java +++ /dev/null @@ -1,529 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.io.*; -import java.util.*; -import java.text.MessageFormat; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; - - -/** - * A generic two-way or three-way differencing engine. - *

- * The engine is used by calling one of the findDifferences methods and passing - * in the objects to compare. - * The engine calls the following methods on the input objects to perform the compare: - *

    - *
  • getChildren: for enumerating the children of an object (if any), - *
  • contentsEqual: for comparing the content of leaf objects, that is, objects without children, - *
  • visit: for every pair of compared object the compare result is passed in. - *
- * Clients may use as is, or subclass to provide a custom implementation for the three hooks. - * However the default implementation already deals with the typical case: - *
    - *
  • getChildren: tries to apply the IStructureComparator - * interface to enumerate the children, - *
  • contentsEqual: tries to apply the IStreamContentAccessor interface - * to perform a byte-wise content comparison, - *
  • visit: creates a DiffNode for any detected difference between the compared objects and - * links it under a parent node effectively creating a tree of differences. - *
- * The different kind of changes detected by the engine are decoded as follows: - * In the two-way case only NO_CHANGE, ADDITION, DELETION, and CHANGE are used. - * In the three-way case these constants are bitwise ORed with one of directional constants - * LEFT, RIGHT, and CONFLICTING. - */ -public class Differencer { - - // The kind of differences. - /** - * Difference constant (value 0) indicating no difference. - */ - public static final int NO_CHANGE= 0; - /** - * Difference constant (value 1) indicating one side was added. - */ - public static final int ADDITION= 1; - /** - * Difference constant (value 2) indicating one side was removed. - */ - public static final int DELETION= 2; - /** - * Difference constant (value 3) indicating side changed. - */ - public static final int CHANGE= 3; - - /** - * Bit mask (value 3) for extracting the kind of difference. - */ - public static final int CHANGE_TYPE_MASK= 3; - - // The direction of a three-way change. - /** - * Three-way change constant (value 4) indicating a change on left side. - */ - public static final int LEFT= 4; - - /** - * Three-way change constant (value 8) indicating a change on right side. - */ - public static final int RIGHT= 8; - - /** - * Three-way change constant (value 12) indicating a change on left and - * right sides. - */ - public static final int CONFLICTING= 12; - - /** - * Bit mask (value 12) for extracting the direction of a three-way change. - */ - public static final int DIRECTION_MASK= 12; - - /** - * Constant (value 16) indicating a change on left and - * right side (with respect to ancestor) but left and right are identical. - */ - public static final int PSEUDO_CONFLICT= 16; - - - static class Node { - List fChildren; - int fCode; - Object fAncestor; - Object fLeft; - Object fRight; - - Node() { - // nothing to do - } - Node(Node parent, Object ancestor, Object left, Object right) { - parent.add(this); - fAncestor= ancestor; - fLeft= left; - fRight= right; - } - void add(Node child) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(child); - } - Object visit(Differencer d, Object parent, int level) { - if (fCode == NO_CHANGE) - return null; - //dump(level); - Object data= d.visit(parent, fCode, fAncestor, fLeft, fRight); - if (fChildren != null) { - Iterator i= fChildren.iterator(); - while (i.hasNext()) { - Node n= (Node) i.next(); - n.visit(d, data, level+1); - } - } - return data; - } -// private void dump(int level) { -// String name= null; -// if (fAncestor instanceof ITypedElement) -// name= ((ITypedElement)fAncestor).getName(); -// if (name == null && fLeft instanceof ITypedElement) -// name= ((ITypedElement)fLeft).getName(); -// if (name == null && fRight instanceof ITypedElement) -// name= ((ITypedElement)fRight).getName(); -// if (name == null) -// name= "???"; //$NON-NLS-1$ -// -// for (int i= 0; i < level; i++) -// System.out.print(" "); //$NON-NLS-1$ -// -// System.out.println(getDiffType(fCode) + name); -// } - -// private String getDiffType(int code) { -// String dir= " "; //$NON-NLS-1$ -// switch (code & DIRECTION_MASK) { -// case LEFT: -// dir= ">"; //$NON-NLS-1$ -// break; -// case RIGHT: -// dir= "<"; //$NON-NLS-1$ -// break; -// case CONFLICTING: -// dir= "!"; //$NON-NLS-1$ -// break; -// } -// String change= "="; //$NON-NLS-1$ -// switch (code & CHANGE_TYPE_MASK) { -// case ADDITION: -// change= "+"; //$NON-NLS-1$ -// break; -// case DELETION: -// change= "-"; //$NON-NLS-1$ -// break; -// case CHANGE: -// change= "#"; //$NON-NLS-1$ -// break; -// } -// return dir + change + " "; //$NON-NLS-1$ -// } - } - - /** - * Creates a new differencing engine. - */ - public Differencer() { - // nothing to do - } - - /** - * Starts the differencing engine on the three input objects. If threeWay is true a - * three-way comparison is performed, otherwise a two-way compare (in the latter case the ancestor argument is ignored). - * The progress monitor is passed to the method updateProgress which is called for every node or - * leaf compare. The method returns the object that was returned from the top-most call to method visit. - * At most two of the ancestor, left, and right parameters are allowed to be null. - * - * @param threeWay if true a three-way comparison is performed, otherwise a two-way compare - * @param pm a progress monitor which is passed to method updateProgress - * @param data a client data that is passed to the top-level call to visit - * @param ancestor the ancestor object of the compare (may be null) - * @param left the left object of the compare - * @param right the right object of the compare - * @return the object returned from the top most call to method visit, - * possibly null - */ - public Object findDifferences(boolean threeWay, IProgressMonitor pm, Object data, Object ancestor, Object left, Object right) { - - Node root= new Node(); - - int code= traverse(threeWay, root, pm, threeWay ? ancestor : null, left, right); - - if (code != NO_CHANGE) { - List l= root.fChildren; - if (l.size() > 0) { - Node first= (Node)l.get(0); - return first.visit(this, data, 0); - } - } - return null; - } - - /* - * Traverse tree in postorder. - */ - private int traverse(boolean threeWay, Node parent, IProgressMonitor pm, Object ancestor, Object left, Object right) { - - Object[] ancestorChildren= getChildren(ancestor); - Object[] rightChildren= getChildren(right); - Object[] leftChildren= getChildren(left); - - int code= NO_CHANGE; - - Node node= new Node(parent, ancestor, left, right); - - boolean content= true; // we reset this if we have at least one child - - if (((threeWay && ancestorChildren != null) || !threeWay) - && rightChildren != null && leftChildren != null) { - // we only recurse down if no leg is null - // a node - - Set allSet= new HashSet(20); - Map ancestorSet= null; - Map rightSet= null; - Map leftSet= null; - - if (ancestorChildren != null) { - ancestorSet= new HashMap(10); - for (int i= 0; i < ancestorChildren.length; i++) { - Object ancestorChild= ancestorChildren[i]; - ancestorSet.put(ancestorChild, ancestorChild); - allSet.add(ancestorChild); - } - } - - if (rightChildren != null) { - rightSet= new HashMap(10); - for (int i= 0; i < rightChildren.length; i++) { - Object rightChild= rightChildren[i]; - rightSet.put(rightChild, rightChild); - allSet.add(rightChild); - } - } - - if (leftChildren != null) { - leftSet= new HashMap(10); - for (int i= 0; i < leftChildren.length; i++) { - Object leftChild= leftChildren[i]; - leftSet.put(leftChild, leftChild); - allSet.add(leftChild); - } - } - - Iterator e= allSet.iterator(); - while (e.hasNext()) { - Object keyChild= e.next(); - - content= false; - - if (pm != null) { - - if (pm.isCanceled()) - throw new OperationCanceledException(); - - updateProgress(pm, keyChild); - } - - Object ancestorChild= ancestorSet != null ? ancestorSet.get(keyChild) : null; - Object leftChild= leftSet != null ? leftSet.get(keyChild) : null; - Object rightChild= rightSet != null ? rightSet.get(keyChild) : null; - - int c= traverse(threeWay, node, pm, ancestorChild, leftChild, rightChild); - - if ((c & CHANGE_TYPE_MASK) != NO_CHANGE) { - code|= CHANGE; // deletions and additions of child result in a change of the container - code|= (c & DIRECTION_MASK); // incoming & outgoing are just ored - } - } - } - - if (content) // a leaf - code= compare(threeWay, ancestor, left, right); - - node.fCode= code; - - return code; - } - - /** - * Called for every node or leaf comparison. - * The differencing engine passes in the input objects of the compare and the result of the compare. - * The data object is the value returned from a call to the visit method on the parent input. - * It can be considered the "parent" reference and is useful when building a tree. - *

- * The Differencer implementation returns a new - * DiffNode which is initialized with the corresponding values. - * Subclasses may override. - * - * @param data object returned from parent call to visit, - * possibly null - * @param result the result of the compare operation performed on the three inputs - * @param ancestor the compare ancestor of the left and right inputs - * @param left the left input to the compare - * @param right the right input to the compare - * @return the result, possibly null - */ - protected Object visit(Object data, int result, Object ancestor, Object left, Object right) { - return new DiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); - } - - /* - * Performs a 2-way or 3-way compare of the given leaf elements and returns an integer - * describing the kind of difference. - */ - private int compare(boolean threeway, Object ancestor, Object left, Object right) { - - int description= NO_CHANGE; - - if (threeway) { - if (ancestor == null) { - if (left == null) { - if (right == null) { - Assert.isTrue(false); - // shouldn't happen - } else { - description= RIGHT | ADDITION; - } - } else { - if (right == null) { - description= LEFT | ADDITION; - } else { - description= CONFLICTING | ADDITION; - if (contentsEqual(left, right)) - description|= PSEUDO_CONFLICT; - } - } - } else { - if (left == null) { - if (right == null) { - description= CONFLICTING | DELETION | PSEUDO_CONFLICT; - } else { - if (contentsEqual(ancestor, right)) - description= LEFT | DELETION; - else - description= CONFLICTING | CHANGE; - } - } else { - if (right == null) { - if (contentsEqual(ancestor, left)) - description= RIGHT | DELETION; - else - description= CONFLICTING | CHANGE; - } else { - boolean ay= contentsEqual(ancestor, left); - boolean am= contentsEqual(ancestor, right); - - if (ay && am) { - // empty - } else if (ay && !am) { - description= RIGHT | CHANGE; - } else if (!ay && am) { - description= LEFT | CHANGE; - } else { - description= CONFLICTING | CHANGE; - if (contentsEqual(left, right)) - description|= PSEUDO_CONFLICT; - } - } - } - } - } else { // two way compare ignores ancestor - if (left == null) { - if (right == null) { - Assert.isTrue(false); - // shouldn't happen - } else { - description= ADDITION; - } - } else { - if (right == null) { - description= DELETION; - } else { - if (! contentsEqual(left, right)) - description= CHANGE; - } - } - } - - return description; - } - - /** - * Performs a content compare on the two given inputs. - *

- * The Differencer implementation - * returns true if both inputs implement IStreamContentAccessor - * and their byte contents is identical. Subclasses may override to implement - * a different content compare on the given inputs. - *

- * - * @param input1 first input to contents compare - * @param input2 second input to contents compare - * @return true if content is equal - */ - protected boolean contentsEqual(Object input1, Object input2) { - - if (input1 == input2) - return true; - - InputStream is1= getStream(input1); - InputStream is2= getStream(input2); - - if (is1 == null && is2 == null) // no byte contents - return true; - - try { - if (is1 == null || is2 == null) // only one has contents - return false; - - while (true) { - int c1= is1.read(); - int c2= is2.read(); - if (c1 == -1 && c2 == -1) - return true; - if (c1 != c2) - break; - - } - } catch (IOException ex) { - // NeedWork - } finally { - if (is1 != null) { - try { - is1.close(); - } catch(IOException ex) { - // silently ignored - } - } - if (is2 != null) { - try { - is2.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - return false; - } - - /* - * Tries to return an InputStream for the given object. - * Returns null if the object not an IStreamContentAccessor - * or an error occured. - */ - private InputStream getStream(Object o) { - if (o instanceof IStreamContentAccessor) { - try { - return ((IStreamContentAccessor)o).getContents(); - } catch(CoreException ex) { - // NeedWork - } - } - return null; - } - - /** - * Returns the children of the given input or null if there are no children. - *

- * The Differencer implementation checks whether the input - * implements the IStructureComparator interface. If yes it is used - * to return an array containing all children. Otherwise null is returned. - * Subclasses may override to implement a different strategy to enumerate children. - *

- * - * @param input the object for which to return children - * @return the children of the given input or null if there are no children. - */ - protected Object[] getChildren(Object input) { - if (input instanceof IStructureComparator) - return ((IStructureComparator)input).getChildren(); - return null; - } - - /** - * Called for every leaf or node compare to update progress information. - *

- * The Differencer implementation shows the name of the input object - * as a subtask. Subclasses may override. - *

- * - * @param progressMonitor the progress monitor for reporting progress - * @param node the currently processed non-null node - */ - protected void updateProgress(IProgressMonitor progressMonitor, Object node) { - if (node instanceof ITypedElement) { - String name= ((ITypedElement)node).getName(); - String fmt= Utilities.getString("Differencer.progressFormat"); //$NON-NLS-1$ - String msg= MessageFormat.format(fmt, new String[] { name }); - progressMonitor.subTask(msg); - //progressMonitor.worked(1); - } - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java deleted file mode 100644 index d35bc457c..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.ArrayList; - -import org.eclipse.jface.text.*; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.contentmergeviewer.IDocumentRange; - - -/** - * A document range node represents a structural element - * when performing a structure compare of documents. - * DocumentRangeNodes are created while parsing the document and represent - * a semantic entity (e.g. a Java class or method). - * As a consequence of the parsing a DocumentRangeNode maps to a range - * of characters in the document. - *

- * Since a DocumentRangeNode implements the IStructureComparator - * and IStreamContentAccessor interfaces it can be used as input to the - * differencing engine. This makes it possible to perform - * a structural diff on a document and have the nodes and leaves of the compare easily map - * to character ranges within the document. - *

- * Subclasses may add additional state collected while parsing the document. - *

- * @see Differencer - */ -public class DocumentRangeNode - implements IDocumentRange, IStructureComparator, IEditableContent, IEncodedStreamContentAccessor { - - private static final boolean POS_UPDATE= true; - private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - - private IDocument fBaseDocument; - private Position fRange; // the range in the base document - private int fTypeCode; - private String fID; - private Position fAppendPosition; // a position where to insert a child textually - private ArrayList fChildren; - - /** - * Creates a new DocumentRangeNode for the given range within the specified - * document. The typeCode is uninterpreted client data. The ID is used when comparing - * two nodes with each other: i.e. the differencing engine performs a content compare - * on two nodes if their IDs are equal. - * - * @param typeCode a type code for this node - * @param id an identifier for this node - * @param document document on which this node is based on - * @param start start position of range within document - * @param length length of range - */ - public DocumentRangeNode(int typeCode, String id, IDocument document, int start, int length) { - - fTypeCode= typeCode; - fID= id; - - fBaseDocument= document; - fBaseDocument.addPositionCategory(RANGE_CATEGORY); - fRange= new Position(start, length); - - if (POS_UPDATE) { - try { - document.addPosition(RANGE_CATEGORY, fRange); - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } - } - - /* (non Javadoc) - * see IDocumentRange.getDocument - */ - public IDocument getDocument() { - return fBaseDocument; - } - - /* (non Javadoc) - * see IDocumentRange.getRange - */ - public Position getRange() { - return fRange; - } - - /** - * Returns the type code of this node. - * The type code is uninterpreted client data which can be set in the constructor. - * - * @return the type code of this node - */ - public int getTypeCode() { - return fTypeCode; - } - - /** - * Returns this node's id. - * It is used in equals and hashcode. - * - * @return the node's id - */ - public String getId() { - return fID; - } - - /** - * Sets this node's id. - * It is used in equals and hashcode. - * - * @param id the new id for this node - */ - public void setId(String id) { - fID= id; - } - - /** - * Adds the given node as a child. - * - * @param node the node to add as a child - */ - public void addChild(DocumentRangeNode node) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(node); - } - - /* (non Javadoc) - * see IStructureComparator.getChildren - */ - public Object[] getChildren() { - if (fChildren != null) - return fChildren.toArray(); - return new Object[0]; - } - - /** - * Sets the length of the range of this node. - * - * @param length the length of the range - */ - public void setLength(int length) { - getRange().setLength(length); - } - - /** - * Sets a position within the document range that can be used to (legally) insert - * text without breaking the syntax of the document. - *

- * E.g. when parsing a Java document the "append position" of a DocumentRangeNode - * representating a Java class could be the character position just before the closing bracket. - * Inserting the text of a new method there would not disturb the syntax of the class. - * - * @param pos the character position within the underlying document where text can be legally inserted - */ - public void setAppendPosition(int pos) { - if (POS_UPDATE) { - fBaseDocument.removePosition(fAppendPosition); - try { - Position p= new Position(pos); - fBaseDocument.addPosition(RANGE_CATEGORY, p); - fAppendPosition= p; - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } else { - fAppendPosition= new Position(pos); - } - } - - /** - * Returns the position that has been set with setAppendPosition. - * If setAppendPosition hasn't been called, the position after the last character - * of this range is returned. - * - * @return a position where text can be legally inserted - */ - public Position getAppendPosition() { - if (fAppendPosition == null) { - if (POS_UPDATE) { - try { - Position p= new Position(fBaseDocument.getLength()); - fBaseDocument.addPosition(RANGE_CATEGORY, p); - fAppendPosition= p; - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } else { - fAppendPosition= new Position(fBaseDocument.getLength()); - } - } - return fAppendPosition; - } - - /** - * Implementation based on getID. - * @param other the object to compare this DocumentRangeNode against. - * @return true if the DocumentRangeNodesare equal; false otherwise. - */ - public boolean equals(Object other) { - if (other != null && other.getClass() == getClass()) { - DocumentRangeNode tn= (DocumentRangeNode) other; - return fTypeCode == tn.fTypeCode && fID.equals(tn.fID); - } - return super.equals(other); - } - - /** - * Implementation based on getID. - * @return a hashcode for this object. - */ - public int hashCode() { - return fID.hashCode(); - } - - /* - * Find corresponding position - */ - private Position findCorrespondingPosition(DocumentRangeNode otherParent, DocumentRangeNode child) { - - // we try to find a predecessor of left Node which exists on the right side - - if (child != null && fChildren != null) { - int ix= otherParent.fChildren.indexOf(child); - if (ix >= 0) { - - for (int i= ix - 1; i >= 0; i--) { - DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i); - int i2= fChildren.indexOf(c1); - if (i2 >= 0) { - DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2); - //System.out.println(" found corresponding: " + i2 + " " + c); - Position p= c.fRange; - - //try { - Position po= new Position(p.getOffset() + p.getLength() + 1, 0); - //c.fBaseDocument.addPosition(RANGE_CATEGORY, po); - return po; - //} catch (BadLocationException ex) { - //} - //break; - } - } - - for (int i= ix; i < otherParent.fChildren.size(); i++) { - DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i); - int i2= fChildren.indexOf(c1); - if (i2 >= 0) { - DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2); - //System.out.println(" found corresponding: " + i2 + " " + c); - Position p= c.fRange; - //try { - Position po= new Position(p.getOffset(), 0); - //c.fBaseDocument.addPosition(RANGE_CATEGORY, po); - return po; - //} catch (BadLocationException ex) { - //} - //break; - } - } - - } - } - return getAppendPosition(); - } - - private void add(String s, DocumentRangeNode parent, DocumentRangeNode child) { - - Position p= findCorrespondingPosition(parent, child); - if (p != null) { - try { - fBaseDocument.replace(p.getOffset(), p.getLength(), s); - } catch (BadLocationException ex) { - // silently ignored - } - } - } - - /* (non Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() { - String s; - try { - s= fBaseDocument.get(fRange.getOffset(), fRange.getLength()); - } catch (BadLocationException ex) { - s= ""; //$NON-NLS-1$ - } - return new ByteArrayInputStream(Utilities.getBytes(s, UTF_16)); - } - - /* (non Javadoc) - * see IEditableContent.isEditable - */ - public boolean isEditable() { - return true; - } - - /* (non Javadoc) - * see IEditableContent.replace - */ - public ITypedElement replace(ITypedElement child, ITypedElement other) { - - DocumentRangeNode src= null; - String srcContents= ""; //$NON-NLS-1$ - - if (other != null) { - src= (DocumentRangeNode) child; - - if (other instanceof IStreamContentAccessor) { - try { - srcContents= Utilities.readString((IStreamContentAccessor)other); - } catch(CoreException ex) { - // NeedWork - } - } - } - - if (child == null) // no destination: we have to add the contents into the parent - add(srcContents, null, src); - - return child; - } - - /* (non Javadoc) - * see IEditableContent.setContent - */ - public void setContent(byte[] content) { - // empty default implementation - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IStreamContentAccessor#getEncoding() - */ - public String getCharset() { - return UTF_16; - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java deleted file mode 100644 index 4d937937f..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import org.eclipse.compare.ITypedElement; -import org.eclipse.swt.graphics.Image; - -/** - * Interface for objects used as input to a two-way or three-way compare viewer. - * It defines API for accessing the three sides for the compare, - * and a name and image which is used when displaying the three way input - * in the UI, for example, in a title bar. - *

- * Note: at most two sides of an ICompareInput can be null, - * (as it is normal for additions or deletions) but not all three. - *

- * ICompareInput provides methods for registering - * ICompareInputChangeListeners - * that get informed if one (or more) - * of the three sides of an ICompareInput object changes its value. - *

- * For example when accepting an incoming addition - * the (non-null) left side of an ICompareInput - * is copied to the right side by means of method copy. - * This should trigger a call to compareInputChanged of registered - * ICompareInputChangeListeners. - *

- * Clients can implement this interface, or use the convenience implementation - * DiffNode. - *

- * - * @see StructureDiffViewer - * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer - * @see DiffNode - */ -public interface ICompareInput { - - /** - * Returns name of input. - * This name is displayed when this input is shown in a viewer. - * In many cases this name is the name of one of the non-null sides or a combination - * thereof. - * - * @return name of input - */ - String getName(); - - /** - * Returns an image representing this input. - * This image is typically displayed when this input is shown in a viewer. - * In many cases this image is the image of one of the non-null sides. - * - * @return image representing this input, or null if no icon should be shown - */ - Image getImage(); - - /** - * Returns the kind of difference between the - * three sides ancestor, left and right. - * This field is only meaningful if the ICompareInput - * is the result of another compare. In this case it is used - * together with getImage to compose a icon - * which reflects the kind of difference between the two or three elements. - * - * @return kind of difference (see Differencer) - */ - int getKind(); - - /** - * Returns the ancestor side of this input. - * Returns null if this input has no ancestor - * or in the two-way compare case. - * - * @return the ancestor of this input, or null - */ - ITypedElement getAncestor(); - - /** - * Returns the left side of this input. - * Returns null if there is no left side (deletion or addition). - * - * @return the left side of this input, or null - */ - ITypedElement getLeft(); - - /** - * Returns the right side of this input. - * Returns null if there is no right side (deletion or addition). - * - * @return the right side of this input, or null - */ - ITypedElement getRight(); - - /** - * Registers the given listener for notification. - * If the identical listener is already registered the method has no effect. - * - * @param listener the listener to register for changes of this input - */ - void addCompareInputChangeListener(ICompareInputChangeListener listener); - - /** - * Unregisters the given listener. - * If the identical listener is not registered the method has no effect. - * - * @param listener the listener to unregister - */ - void removeCompareInputChangeListener(ICompareInputChangeListener listener); - - /** - * Copy one side (source) to the other side (destination) depending on the - * value of leftToRight. This method is called from - * a merge viewer if a corresponding action ("take left" or "take right") - * has been pressed. - *

- * The implementation should handle the following cases: - *

    - *
  • - * if the source side is null the destination must be deleted, - *
  • - * if the destination is null the destination must be created - * and filled with the contents from the source, - *
  • - * if both sides are non-null the contents of source must be copied to destination. - *
- * In addition the implementation should send out notification to the registered - * ICompareInputChangeListener. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - void copy(boolean leftToRight); -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java deleted file mode 100644 index 461a94ab4..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.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.compare.structuremergeviewer; - -/** - * Listener that gets informed if one (or more) - * of the three sides of an ICompareInput object changes its value. - *

- * For example when accepting an incoming addition - * the (non-null) left side of an ICompareInput - * is copied to the right side (which was null). - * This triggers a call to compareInputChanged of registered - * ICompareInputChangeListener. - *

- * Note however, that listener are not informed if the content of one of the sides changes. - *

- * Clients may implement this interface. It is also implemented by viewers that take - * an ICompareInput as input. - *

- */ -public interface ICompareInputChangeListener { - - /** - * Called whenever the value (not the content) of one or more of the three sides - * of a ICompareInput has changed. - * - * @param source the ICompareInput that has changed - */ - void compareInputChanged(ICompareInput source); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java deleted file mode 100644 index 598996bef..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.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.compare.structuremergeviewer; - -/** - * IDiffContainer is a IDiffElement with children. - *

- * IDiffContainer are the inner nodes displayed - * by the DiffTreeViewer. - * IDiffContainer are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients may implement this interface, or use one of the standard implementations, - * DiffContainer or DiffNode. - * - * @see Differencer - * @see DiffTreeViewer - */ -public interface IDiffContainer extends IDiffElement { - - /** - * Returns whether this container has at least one child. - * In some cases this methods avoids having to call the - * potential more costly getChildren method. - * - * @return true if this container has at least one child - */ - boolean hasChildren(); - - /** - * Returns the children of this container. - * If this container has no children an empty array is returned (not null). - * - * @return the children of this container as an array - */ - IDiffElement[] getChildren(); - - /** - * Adds the given child to this container. - * If the child is already contained in this container, this method has no effect. - * - * @param child the child to be added to this container - */ - void add(IDiffElement child); - - /** - * Removes the given child from this container. - * If the container becomes empty it is removed from its container. - * If the child is not contained in this container, this method has no effect. - * - * @param child the child to be removed from this container - */ - void removeToRoot(IDiffElement child); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java deleted file mode 100644 index f09742a1d..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.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.compare.structuremergeviewer; - -import org.eclipse.compare.ITypedElement; - -/** - * An IDiffElement is used in the DiffTreeViewer - * to display the kind of change detected as the result of a two-way or three-way compare. - *

- * The base interface ITypedElement provides a name, a type, and an image. - * IDiffElement adds API for maintaining a parent relationship. - *

- * DiffTreeViewer works on a tree of IDiffElements. - * Leaf elements must implement the - * IDiffElement interface, inner nodes the IDiffContainer interface. - *

- * IDiffElements are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients may implement this interface, or use one of the standard implementations, - * DiffElement, DiffContainer, or DiffNode. - * - * @see DiffTreeViewer - * @see DiffElement - * @see DiffContainer - * @see DiffNode - */ -public interface IDiffElement extends ITypedElement { - - /** - * Returns the kind of difference as defined in Differencer. - * - * @return the kind of difference as defined in Differencer - */ - int getKind(); - - /** - * Returns the parent of this element. - * If the object is the root of a hierarchy null is returned. - * - * @return the parent of this element, or null if the element has no parent - */ - IDiffContainer getParent(); - - /** - * Sets the parent of this element. - * - * @param parent the new parent of this element, or null if this - * element is to have no parent - */ - void setParent(IDiffContainer parent); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java deleted file mode 100644 index b4bb8e0d0..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -/** - * Interface used to compare hierarchical structures. - * It is used by the differencing engine. - *

- * Clients typically implement this interface in an adaptor class which - * wrappers the objects to be compared. - * - * @see org.eclipse.compare.ResourceNode - * @see Differencer - */ -public interface IStructureComparator { - - /** - * Returns an iterator for all children of this object or null - * if there are no children. - * - * @return an array with all children of this object, or an empty array if there are no children - */ - Object[] getChildren(); - - /** - * Returns whether some other object is "equal to" this one - * with respect to a structural comparison. For example, when comparing - * Java class methods, equals would return true - * if two methods have the same signature (the argument names and the - * method body might differ). - * - * @param other the reference object with which to compare - * @return true if this object is the same as the other argument; false otherwise - * @see java.lang.Object#equals - */ - boolean equals(Object other); -} diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java deleted file mode 100644 index 2f2c3916a..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.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.compare.structuremergeviewer; - -/** - * Interface used to create a hierarchical structure of - * IStructureComparators for a given input object. - * In addition, it provides methods for locating a path in the hierarchical structure - * and to map a node of this structure back to the corresponding input object. - *

- * Structure creators are used in the following contexts: - *

    - *
  • - * the StructureDiffViewer uses an IStructureCreator to - * build two (or three) tree structures of its input elements (method getStructure). - * These trees are then compared with each other by means of the differencing engine and displayed - * with the DiffTreeViewer, - *
  • - *
  • - * the ReplaceWithEditionDialog uses an IStructureCreator - * to map a path back to a range of characters in the textual representation. - *
  • - *
- * A IStructureCreator provides methods for rewriting the tree produced by the differencing - * engine to support "smart" structural differencing. E.g. certain patterns of pairs of "addition" - * and "deletion" nodes can be detected as renames and merged into a single node. - *

- *

- * Clients may implement this interface; there is no standard implementation. - *

- * - * @see StructureDiffViewer - * @see org.eclipse.compare.EditionSelectionDialog - * @see Differencer - */ -public interface IStructureCreator { - - /** - * Returns a descriptive name which can be used in the UI of the StructureDiffViewer. - * - * @return a descriptive name for this IStructureCreator - */ - String getName(); - - /** - * Creates a tree structure consisting of IStructureComparators - * from the given object and returns its root object. - * Implementing this method typically involves parsing the input object. - * In case of an error (e.g. a parsing error) the value null is returned. - * - * @param input the object from which to create the tree of IStructureComparator - * @return the root node of the structure or null in case of error - */ - IStructureComparator getStructure(Object input); - - /** - * Creates the single node specified by path from the given input object. - * In case of an error (e.g. a parsing error) the value null is returned. - * This method is similar to getStructure but in - * contrast to getStructure only a single node without any children must be returned. - * This method is used in the ReplaceWithEditionDialog to locate a sub element - * (e.g. a method) within an input object (e.g. a file containing source code). - *

- * One (not optimized) approach to implement this method is calling getStructure(input) - * to build the full tree, and then finding that node within the tree that is specified - * by path. - *

- * The syntax of path is not specified, because it is treated by the compare subsystem - * as an opaque entity and is not further interpreted. Clients using this functionality - * will pass a value of path to the selectEdition - * method of ReplaceWithEditionDialog and will receive this value unchanged - * as an argument to locate. - * - * @param path specifies a sub object within the input object - * @param input the object from which to create the IStructureComparator - * @return the single node specified by path or null - * - * @see org.eclipse.compare.EditionSelectionDialog#selectEdition - */ - IStructureComparator locate(Object path, Object input); - - /** - * Returns the contents of the given node as a string for the purpose - * of performing a content comparison only (that is the string will not be visible in the UI). - * If ignoreWhitespace is true all character sequences considered - * whitespace should be removed from the returned string. - * - * @param node the node for which to return a string representation - * @param ignoreWhitespace if true the returned string should not contain whitespace - * @return the string contents of the given node - */ - String getContents(Object node, boolean ignoreWhitespace); - - /** - * Called whenever a copy operation has been performed on a tree node. - * - * @param node the node for which to save the new content - * @param input the object from which the structure tree was created in getStructure - */ - void save(IStructureComparator node, Object input); -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java deleted file mode 100644 index 9dd4f68f8..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.widgets.*; -import org.eclipse.jface.util.PropertyChangeEvent; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.*; - - -/** - * A diff tree viewer that can be configured with a IStructureCreator - * to retrieve a hierarchical structure from the input object (an ICompareInput) - * and perform a two-way or three-way compare on it. - *

- * This class may be instantiated; it is not intended to be subclassed outside - * this package. - *

- * - * @see IStructureCreator - * @see ICompareInput - */ -public class StructureDiffViewer extends DiffTreeViewer { - - private Differencer fDifferencer; - private boolean fThreeWay= false; - - private ITypedElement fAncestorInput; - private ITypedElement fLeftInput; - private ITypedElement fRightInput; - - private IStructureComparator fAncestorStructure; - private IStructureComparator fLeftStructure; - private IStructureComparator fRightStructure; - - private IStructureCreator fStructureCreator; - private IDiffContainer fRoot; - private IContentChangeListener fContentChangedListener; - private CompareViewerSwitchingPane fParent; - - /** - * Creates a new viewer for the given SWT tree control with the specified configuration. - * - * @param tree the tree control - * @param configuration the configuration for this viewer - */ - public StructureDiffViewer(Tree tree, CompareConfiguration configuration) { - super(tree, configuration); - Composite c= tree.getParent(); - if (c instanceof CompareViewerSwitchingPane) - fParent= (CompareViewerSwitchingPane) c; - initialize(); - } - - /** - * Creates a new viewer under the given SWT parent with the specified configuration. - * - * @param parent the SWT control under which to create the viewer - * @param configuration the configuration for this viewer - */ - public StructureDiffViewer(Composite parent, CompareConfiguration configuration) { - super(parent, configuration); - if (parent instanceof CompareViewerSwitchingPane) - fParent= (CompareViewerSwitchingPane) parent; - initialize(); - } - - private void initialize() { - - setAutoExpandLevel(3); - - fContentChangedListener= new IContentChangeListener() { - public void contentChanged(IContentChangeNotifier changed) { - StructureDiffViewer.this.contentChanged(changed); - } - }; - new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput input) { - StructureDiffViewer.this.compareInputChanged(input); - } - }; - } - - /** - * Configures the StructureDiffViewer with a structure creator. - * The structure creator is used to create a hierarchical structure - * for each side of the viewer's input element of type ICompareInput. - * - * @param structureCreator the new structure creator - */ - public void setStructureCreator(IStructureCreator structureCreator) { - if (fStructureCreator != structureCreator) { - fStructureCreator= structureCreator; - Control tree= getControl(); - if (tree != null && !tree.isDisposed()) - tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - } - } - - /** - * Returns the structure creator or null if no - * structure creator has been set with setStructureCreator. - * - * @return the structure creator or null - */ - public IStructureCreator getStructureCreator() { - return fStructureCreator; - } - - /** - * Reimplemented to get the descriptive title for this viewer from the IStructureCreator. - * @return the viewer's name - */ - public String getTitle() { - if (fStructureCreator != null) - return fStructureCreator.getName(); - return super.getTitle(); - } - - /** - * Overridden because the input of this viewer is not identical to the root of the tree. - * The tree's root is a IDiffContainer that was returned from the method diff. - * - * @return the root of the diff tree produced by method diff - */ - protected Object getRoot() { - return fRoot; - } - - /* - * (non-Javadoc) Method declared on StructuredViewer. - * Overridden to create the comparable structures from the input object - * and to feed them through the differencing engine. Note: for this viewer - * the value from getInput is not identical to getRoot. - */ - protected void inputChanged(Object input, Object oldInput) { - if (input instanceof ICompareInput) { - compareInputChanged((ICompareInput) input); - if (input != oldInput) - initialSelection(); - } - } - - protected void initialSelection() { - expandToLevel(2); - } - - /* (non Javadoc) - * Overridden to unregister all listeners. - */ - protected void handleDispose(DisposeEvent event) { - - compareInputChanged(null); - - fContentChangedListener= null; - - super.handleDispose(event); - } - - /** - * Recreates the comparable structures for the input sides. - * @param input this viewer's new input - */ - protected void compareInputChanged(ICompareInput input) { - ITypedElement t= null; - boolean changed= false; - - if (input != null) - t= input.getAncestor(); - - fThreeWay= (t != null); - - if (t != fAncestorInput) { - if (fAncestorInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fAncestorInput).removeContentChangeListener(fContentChangedListener); - fAncestorInput= t; - if (fAncestorInput != null) { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - changed= true; - } else - fAncestorStructure= null; - if (fAncestorInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fAncestorInput).addContentChangeListener(fContentChangedListener); - } - - if (input != null) - t= input.getLeft(); - if (t != fLeftInput) { - if (fLeftInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fLeftInput).removeContentChangeListener(fContentChangedListener); - fLeftInput= t; - if (fLeftInput != null) { - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - changed= true; - } else - fLeftStructure= null; - if (fLeftInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fLeftInput).addContentChangeListener(fContentChangedListener); - } - - if (input != null) - t= input.getRight(); - if (t != fRightInput) { - if (fRightInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fRightInput).removeContentChangeListener(fContentChangedListener); - fRightInput= t; - if (fRightInput != null) { - fRightStructure= fStructureCreator.getStructure(fRightInput); - changed= true; - } else - fRightStructure= null; - if (fRightInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fRightInput).addContentChangeListener(fContentChangedListener); - } - - if (changed) - diff(); - } - - /** - * Calls diff whenever the byte contents changes. - * @param changed the object that sent out the notification - */ - protected void contentChanged(IContentChangeNotifier changed) { - - if (fStructureCreator == null) - return; - - if (changed != null) { - if (changed == fAncestorInput) { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - } else if (changed == fLeftInput) { - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - } else if (changed == fRightInput) { - fRightStructure= fStructureCreator.getStructure(fRightInput); - } else - return; - } else { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - fRightStructure= fStructureCreator.getStructure(fRightInput); - } - - diff(); - } - - /** - * This method is called from within diff() before the difference - * tree is being built. - * Clients may override this method to perform their own pre-processing. - * This default implementation does nothing. - * @param ancestor the ancestor input to the differencing operation - * @param left the left input to the differencing operation - * @param right the right input to the differencing operation - * @since 2.0 - */ - protected void preDiffHook(IStructureComparator ancestor, IStructureComparator left, IStructureComparator right) { - // we do nothing here - } - - /** - * Runs the difference engine and refreshes the tree. - */ - protected void diff() { - - preDiffHook(fAncestorStructure, fLeftStructure, fRightStructure); - - String message= null; - - if ((fThreeWay && fAncestorStructure == null) || fLeftStructure == null || fRightStructure == null) { - // could not get structure of one (or more) of the legs - fRoot= null; - message= CompareMessages.getString("StructureDiffViewer.StructureError"); //$NON-NLS-1$ - - } else { // calculate difference of the two (or three) structures - - if (fDifferencer == null) - fDifferencer= new Differencer() { - protected boolean contentsEqual(Object o1, Object o2) { - return StructureDiffViewer.this.contentsEqual(o1, o2); - } - protected Object visit(Object data, int result, Object ancestor, Object left, Object right) { - Object o= super.visit(data, result, ancestor, left, right); - if (fLeftIsLocal && o instanceof DiffNode) - ((DiffNode)o).swapSides(fLeftIsLocal); - return o; - } - }; - - fRoot= (IDiffContainer) fDifferencer.findDifferences(fThreeWay, null, null, - fAncestorStructure, fLeftStructure, fRightStructure); - - if (fRoot == null || fRoot.getChildren().length == 0) { - message= CompareMessages.getString("StructureDiffViewer.NoStructuralDifferences"); //$NON-NLS-1$ - } else { - postDiffHook(fDifferencer, fRoot); - } - } - if (fParent != null) - fParent.setTitleArgument(message); - - refresh(getRoot()); - } - - /** - * This method is called from within diff() after the difference - * tree has been built. - * Clients may override this method to perform their own post-processing. - * This default implementation does nothing. - * @param differencer the differencer used to perform the differencing - * @param root the non-null root node of the difference tree - * @since 2.0 - */ - protected void postDiffHook(Differencer differencer, IDiffContainer root) { - // we do nothing here - } - - /* - * Performs a byte compare on the given objects. - * Called from the difference engine. - * Returns null if no structure creator has been set. - */ - private boolean contentsEqual(Object o1, Object o2) { - if (fStructureCreator != null) { - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - String s1= fStructureCreator.getContents(o1, ignoreWhiteSpace); - String s2= fStructureCreator.getContents(o2, ignoreWhiteSpace); - if (s1 == null || s2 == null) - return false; - return s1.equals(s2); - } - return false; - } - - /** - * Tracks property changes of the configuration object. - * Clients may override to track their own property changes. - * In this case they must call the inherited method. - * @param event the property changed event that triggered the call to this method - */ - protected void propertyChange(PropertyChangeEvent event) { - String key= event.getProperty(); - if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) - diff(); - else - super.propertyChange(event); - } - - /** - * Overridden to call the save method on the structure creator after - * nodes have been copied from one side to the other side of an input object. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copySelected(boolean leftToRight) { - super.copySelected(leftToRight); - - if (fStructureCreator != null) - fStructureCreator.save( - leftToRight ? fRightStructure : fLeftStructure, - leftToRight ? fRightInput : fLeftInput); - } -} - diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html deleted file mode 100644 index 60257a4d8..000000000 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for finding and displaying the differences -between hierarchically structured data. -

-Package Specification

- -The class Differencer is a differencing engine for hierarchically -structured data. It takes two or three inputs and performs a two-way or -three-way compare on them. -

- -If the input elements to the differencing engine implement the IStructureComparator -interface the engine recursively applies itself to the children of -the input element. Leaf elements must implement the org.eclipse.compare.IStreamContentAccessor -interface so that the differencer can perform a bytewise comparison on their contents. -

- -One good example for this is org.eclipse.compare.ResourceNode which implements both interfaces -(and more) for Eclipse workspace resources (org.eclipse.core.resources.IResource). -

- -Another example is the DocumentRangeNode which can be used to compare hierarchical structures -that are superimposed on a document, that is where nodes and leafs correspond to ranges in a document -(org.eclipse.compare.contentmergeviewer.IDocumentRange). -
-Typically DocumentRangeNodes are created while parsing a document and they represent -the semantic entities of the document (e.g. a Java class, method or field). -The two subclasses JavaNode (in org.eclipse.jdt.internal.ui.compare) -and PropertyNode (in org.eclipse.jdt.internal.ui.compare) are good examples for this. -

- -By default the differencing engine returns the result of the compare operation -as a tree of DiffNode objects. However, this can be changed by overriding -a single method of the engine. -

- -Every DiffNode describes the changes among the two or three inputs. -

- -A tree of DiffNodes can be displayed in a DiffTreeViewer. -The DiffTreeViewer requires that inner nodes of the tree implement -the IDiffContainer interface and leafs the IDiffElement interface. -

- -The typical steps to compare hierarchically structured data and to display -the differences would be to: -

    -
  • -map the input data into a tree of IStructureComparator and IStreamContentAccessors,
  • - -
  • -perform the compare operation by means of the Differencer, and
  • - -
  • -feed the differencing result into the DiffTreeViewer.
  • - -
- -The StructureDiffViewer is a specialized DiffTreeViewer -that automates the three steps from above. It takes a single input object -of type ICompareInput from which it retrieves the two or three -input elements to compare. Then it uses a IStructureCreator to -extract a tree of IStructureComparator and IStreamContentAccessor -from them. These trees are then compared with the differencing engine and -the result is displayed in the tree viewer. -

- - - - - diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif deleted file mode 100644 index a021812e0..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif deleted file mode 100644 index 172e2a4ea..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif deleted file mode 100644 index 4cb42a1db..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif deleted file mode 100644 index 16539cd9f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif deleted file mode 100644 index 036abe05f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/next_nav.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/next_nav.gif deleted file mode 100644 index 8aacf959d..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/next_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif deleted file mode 100644 index 38841abe9..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif deleted file mode 100644 index 0ddac91a1..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif deleted file mode 100644 index 7da48249e..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif b/bundles/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif deleted file mode 100644 index 8cdef204b..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif b/bundles/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif deleted file mode 100644 index 398c71927..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif b/bundles/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif deleted file mode 100644 index 702f0a83b..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif deleted file mode 100644 index ff06855e7..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif deleted file mode 100644 index e029948cf..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif deleted file mode 100644 index 0659813a1..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif deleted file mode 100644 index db2b1e3d5..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif deleted file mode 100644 index 9ebd50a9f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/next_nav.gif b/bundles/org.eclipse.compare/icons/full/elcl16/next_nav.gif deleted file mode 100644 index 072b18445..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/next_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/prev_nav.gif b/bundles/org.eclipse.compare/icons/full/elcl16/prev_nav.gif deleted file mode 100644 index 091e88400..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/prev_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif deleted file mode 100644 index 542dddca3..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif deleted file mode 100644 index 2644c2ad6..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif b/bundles/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif deleted file mode 100644 index 12788bafa..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/etool16/conflict_edit.gif b/bundles/org.eclipse.compare/icons/full/etool16/conflict_edit.gif deleted file mode 100644 index 48a7d1d58..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/etool16/conflict_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif b/bundles/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif deleted file mode 100644 index 0b22e4a1a..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/eview16/compare_view.gif b/bundles/org.eclipse.compare/icons/full/eview16/compare_view.gif deleted file mode 100644 index dc549bce8..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/eview16/compare_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/obj16/day_obj.gif b/bundles/org.eclipse.compare/icons/full/obj16/day_obj.gif deleted file mode 100644 index 4fc84e4c3..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/obj16/day_obj.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/obj16/resource_obj.gif b/bundles/org.eclipse.compare/icons/full/obj16/resource_obj.gif deleted file mode 100644 index 3bd4e3605..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/obj16/resource_obj.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/add_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/add_ov.gif deleted file mode 100644 index c123a2b13..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/add_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/chg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/chg_ov.gif deleted file mode 100644 index 2b1b8d677..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/chg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif deleted file mode 100644 index 65101e939..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif deleted file mode 100644 index ee805f9ed..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif deleted file mode 100644 index 980c0f84f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/del_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/del_ov.gif deleted file mode 100644 index ef0207c62..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/del_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/error_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/error_ov.gif deleted file mode 100644 index 3f43a29d9..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/error_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif deleted file mode 100644 index 05a9f5a68..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif deleted file mode 100644 index 12d4a9732..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/indel_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/indel_ov.gif deleted file mode 100644 index 373a68f14..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/indel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif deleted file mode 100644 index 63fb2967c..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif deleted file mode 100644 index 78321d74d..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif deleted file mode 100644 index 7182e5596..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif deleted file mode 100644 index 0ac0cea9e..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif deleted file mode 100644 index c330c0c9f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif deleted file mode 100644 index 5acab6778..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif deleted file mode 100644 index 69607651f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif deleted file mode 100644 index 17ba1af4f..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif b/bundles/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif deleted file mode 100644 index ef6b8b745..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif b/bundles/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif deleted file mode 100644 index e7f0c5cdd..000000000 Binary files a/bundles/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/old_buildnotes_compare_3_0.html b/bundles/org.eclipse.compare/old_buildnotes_compare_3_0.html deleted file mode 100644 index 5bc43ccaa..000000000 --- a/bundles/org.eclipse.compare/old_buildnotes_compare_3_0.html +++ /dev/null @@ -1,1557 +0,0 @@ - - - - - - - Eclipse Platform Release Notes - Desktop - - - -

-Eclipse Platform Build Notes
-Compare

-Eclipse Build Input June 17th 2004 (RC3) - -

-Problem reports fixed

-37648: Exceptions after one of the compare viewer inputs got deleted
- -

-

-Eclipse Build Input June 11th 2004 (RC2) - -

-Problem reports fixed

-65460: Improve encoding fall back behavior for HistoryItems
-61998: bad idea to subclass Error for ordinary exceptions
-59232: DBCS: compare improperly in EUC-JP encoding project on workbench encoding MS932
-65515: Local History always says "Parsing Error; no structured Replace Available"
-55333: NPE in TextMergeViewer.interpolate
-55876: Viewer: Text not repainted when moving sash and then clicking on scroll bars
-65205: Compare editor doesn't update correctly while scrolling
-62545: binary compare text insertion cursor is very large
-56875: Resizing Apply Patch dialog doesn't resize tree
-47640: Move right to left misplaced the moved text
-66272: remove packages prefixes tag from plugin.xml
-64617: Not prompted to save dirty compare editor
- - -

-

-Eclipse Build Input May 28th 2004 (RC1) - -

-Problem reports fixed

-#62356: Use progress service when running compare input
-#64505: Remove unused class ColorEditor
-#63610: Colors and Fonts: Text Compare Appearance -> Text Compare
-#61996: bad idea to subclass Error for ordinary exceptions
-#63608: Migrate to improved modal progress support
- - -

-

-Eclipse Build Input May 11th 2004 - -

-Problem reports fixed

-added 3.0 tag to streamMergers schema file
-updated artwork
- -

-

-Eclipse Build Input May 4th 2004 - -

-Problem reports fixed

-#60383: Copy All non-conflicting changes from right-to-left erase left-to-right changes!!!
-#59273: target TextMergeViewerCreator not found
- -

-

-Eclipse Build Input April 27th 2004 - -

-Problem reports fixed

-#50914: Apply Patch dialog doesn't initialize file browse dialog
- -

-

-Eclipse Build Input April 20th 2004 - -

-Problem reports fixed

-#54091: Allow headless diff and merge
-#51791: Allow binding filenames to compare extensions
-#52261: DiffNode is missing setAncestor()
-#59204: NPE in CompareUIPlugin$CompareRegistry.search(...)
- -

-

-Eclipse Build Input April 13th 2004 - -

-Problem reports fixed

-new artwork - -

-

-Eclipse Build Input March 23rd 2004 (M8) - -

-Problem reports fixed

-#20914: Colorized Diff/compare output
-#55348: NPE in TextMergeViewer.interpolate
- -

-

-Eclipse Build Input March 9th 2004 - -

-Problem reports fixed

-#53754: Provide a resize affordance in the side by side compare part
- -

-

-Eclipse Build Input March 2th 2004 - -

-Problem reports fixed

-#42731: Synchronize horizontal scrolling in compare editor
-#2278: DCR: Would like coupled horizontal scrolling in compare browser (1GEJNHO)
-#53368: Layout problem with focus ring
- -

-

-Eclipse Build Input February 17th 2004 - -

-Problem reports fixed

-#51593: ArrayIndexOutOfBoundsException at org.eclipse.compare.internal.patch.PatchWizard.setTargets
-#52055: Method compare is broken
- -

-

-Eclipse Build Input February 10th 2004 (M7) - -

-API Additions

-Added new interface IEncodedStreamContentAccessor; deprecated IStreamContentAccessorExtension2
-Added first cut of outline view support. - -

-

-Eclipse Build Input January 27th 2004 - -

-Problem reports fixed

-#50565: [Preferences] Pref page Workbench/Compare/Patch; no mnemonic for "Filtered Members"
- -

-

-Eclipse Build Input January 13th 2004 - -

-Problem reports fixed

-#49695: Apply Patch wizard is leaking 7 Images
-#49803: Replace with local history leaks 2 images
- -

-

-Eclipse Build Input January 6th 2004 - -

-Problem reports fixed

-#32329: Support filters for compare
- -

-

-Eclipse Build Input December 18th (M6) 2003 - -

-Problem reports fixed

-#47866: Internal error in synchronize perspective
-#45239: Show ancestor for incoming and outgoing changes
-#41815: Internal error comparing with repository
-#46709: PatchWizard should use scheduling rule on project
- -

-

-Eclipse Build Input November 25th 2003 - -

-Problem reports fixed

-removed use of deprecated symbols - -

-

-Eclipse Build Input November 19th 2003 - -

-Problem reports fixed

-#46805: prepare Compare for encoding support
-#46877: Remove dependancies on Xerces
-#46977: Comparing/merging two local files screws up the content
- -

-

-Eclipse Build Input August 26th 2003 - -

-Problem reports fixed

-#40727: Allow navigation workflow control from other view
-#38770: CompareEditor should implement IReusableEditor
-#39757: Some compare operations fail on resources that do not exist
-#35380: Replace with Local History and read-only resources
- -

-

-Eclipse Build Input July 15th 2003 - -

-Problem reports fixed

-#38836: CompareEditorInput clears dirty state too quickly
-#38770: CompareEditor should implement IReusableEditor
- -

-

-Eclipse Build Input July 1st 2003 - -

-Problem reports fixed

-#38808: NPE in log file when restoring files from history.
-fixed minor error in schema files - -

-

-Eclipse Build Input June 24th 2003 - -

-Problem reports fixed

-#38770: CompareEditor should implement IReusableEditor
- -

-

-Eclipse Build Input June 10th 2003 - -

-Problem reports fixed

-#38713: Compare with -> Each other is not enabled
- -

-

-Eclipse Build Input June 3rd 2003 - -

-Problem reports fixed

-#37531: the javadoc of CompareViewerPane.setImage(Image)
-#38262: Apply patch applies unchecked changes
-#36399: Compare did retrieve entire remote ZIP contents on selection change
-#38198: TVT21: Strings are not externalized
- -

-

-Eclipse Build Input Mai 27th 2003 - -

-Problem reports fixed

-#37849: "Ignore whitespace" ignores also closing brackets?!?
- -Problem reports closed -#37582: Ignore whitespace option should be a button in the compare editor
- -

-

-Eclipse Build Input March 27th 2003 - -

-Problem reports fixed

-Fixed 5 Javadoc warnings - -

-

-Eclipse Build Input March 24th 2003 - -

-Problem reports fixed

-Updated schema copyright notices
-updated javadoc - -

-

-Eclipse Build Input March 19th 2003 - -

-Problem reports fixed

-Fixed wording in properties files
-#35130: Dialogs do not set the dialog font
- -

-

-Eclipse Build Input March 14th 2003 - -

-Problem reports fixed

-#34732: Compare/Patch preference page mnemonic
-#34696: Title casing issues
- - -

-

-Eclipse Build Input March 6th 2003 - -

-Problem reports fixed

-#27405: Should consider using the new font propogation support
-#24255: Internal error when invoking "Restore from Local History" in Outline view
-#32737: NegativeArraySizeException: Compare/patch preference page
- - -

-

-Eclipse Build Input March 4th 2003 - -

-Problem reports fixed

-#32769: Missing mneumonic in compare preference page
-#32798: No mnemonic for ComparePreferencePage.useSingleLine.label
-#32207: Wording: "Open with Compare Editor" action in sync view
-#28190: Middle area should act like sash
-added required IDs for compare viewers in plugin.xml
- - -

-

-Eclipse Build Input February 20th 2003 - -

-Problem reports fixed

-#20248: [Compare] Have to perform two actions to see diff
-#24165: Should have menu action for showing compare contents
-#13332: autosave before patching: can i undo?
-#24077: Comparing file named 'platformOption' does not use text editor
-#23958: NPE in compare with patch
-#28402: CompareConfiguration leaks Images
-#13844: TextMergeViewer should keep track of its posted runnables
-#14353: Cannot perform merge with keyboard accelerators/mnemonics
- -

-

-Eclipse Build Input February 18th 2003 - -

-Problem reports fixed

-#5323: Compare does not handle correctly conflicts at same location
-#26035: Local history uses wrong character encoding
-#15654: Can't maximize Compare with Local History window
- - -

-

-Eclipse Build Input February 13th 2003 - -

-Problem reports fixed

-#31136: Red icon too intrusive
-#31357: Compare View -- Compare-style option required.
-#31633: Cannot apply patch successfully
-#10754: Compare actions should target source window
- -

-

-Eclipse Build Input February 11th 2003 - -

-Problem reports fixed

-#25507: Compare view prevents Ctrl + F6 working
-#18571: patch: scary error dialog when no patch in clipboard
-#28840: Strange behavious applying patch
- -

-

-Eclipse Build Input February 6th 2003 (M5 aka RC0) - -

-API Additions

-Added new method EditionSelectionDialog.getSelection() - -

-Problem reports fixed

-#30525: "Team" menu item missing accelerator
-#28202: contentmergeviewers do not work with mixed-case extensions
-#19114: Restore Java Element from Local History should also provide check boxes [compare]
-#28436: Overview rule green only after focus change
-#29793: Automatically suggest a fuzz factor when applying a patch
- -

-

-Eclipse Build Input January 28th 2003 - -

-API Additions

-Added new method CompareUI.findContentViewer(..., Object input, ...) - -

-Problem reports fixed

-Remoced doc folder.
-#24597: Compare UI API issues
-#23883: CompareDialog.commitAction.label string resource name is wrong
-#29791: Rename 'Compare to Patch' to 'Apply Patch'
- -

-

-Eclipse Build Input January 14th 2003 - -

-Problem reports fixed

-Extension point schema files added.
-Resolve status indicator is only shown if there are incoming changes. - -

-

-Eclipse Build Input January 7th 2003 - -

-Problem reports fixed

-#28278: TextMergeViewer leaks Color objects
-#27864: Load of CompareUI fails when not triggered in UI thread
-#28388: Illegal Argument Exceptions in compare viewer
- -

-

-Eclipse Build Input December 17th 2002 - -

-Problem reports fixed

-#28388: Illegal Argument Exceptions in compare viewer
- -

-

-Eclipse Build Input December 16th 2002 - -

-Problem reports fixed

-Fixed a problem with trim in compare viewer on Mac OS X.
-#28278: TextMergeViewer leaks Color objects
- -
-Eclipse Build Input December 13th 2002 - -

-Problem reports fixed

-#28012: Double-click behaving strangely in Synchronize View
- -

-

-Eclipse Build Input December 10th 2002 - -

-What's new in this drop

-The Textmergeviewer sports a first cut of a new UI for left/right copying, -showing the 'resolved' status of a change, and uses smooth lines to -connect the differing ranges in the left and right panes. -The new UI options are off by default. You can turn them on -with the three 'experimental' options on the Compare preference page. - -

-Problem reports fixed

-#27993: Incorrect structure comparison
- -

-

-Eclipse Build Input December 3rd 2002 - -

-What's new in this drop

- -

-API Additions

-Made internal class Splitter public API. - -

-Problem reports fixed

-#24597: Compare UI API issues
- -

-

-Eclipse Build Input November 26th 2002 - -

-Problem reports fixed

-#20975: Compare preference page has no F1 help
- -

-

-Eclipse Build Input June 27th 2002 - -

-What's new in this drop

-Updated JavaDoc package.html files - -

-

-Eclipse Build Input June 25th 2002 - -

-What's new in this drop

-Updated JavaDoc - -

-

-Eclipse Build Input June 12th 2002 - -

-What's new in this drop

- -There were several complains that clicking on a zip file in the left pane (structure input pane) feeds all other -compare panes (see bug 13730). There are cases where this is expensive (for example a large zip file that has -to be read from a repository). To avoid those situations the left pane now honors single or double click mode as -set in Preferences->Workbench. So if this preference is set to double click the user has to double click on a file -in the left pane to actually feed all other compare panes. - -

-

-Eclipse Build Input June 8th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#18807: Compare with patch fails due to missing LF
-#13730: Entire zipfiles content sent prior when computing synchronization view content
- -

-Problem reports closed

- -

-

-Eclipse Build Input June 7th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13730: Entire zipfiles content sent prior when computing synchronization view content
-#14952: Diff Browser Opens Too Small / Not Easily Resizable
- - -

-Problem reports closed

- -

-

-Eclipse Build Input June 6th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-New constant CompareUI.PLUGIN_ID - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13949: DBCS: bogus at text compare
-#19013: backgronud color: is it honored?
-#19216: Accessibility in Workbench > Compare > Text Compare
-#19371: Java & Compare editor's Next/Previous toolbar buttons shouldn't be retargetable
- - -

-Problem reports closed

- -

-

-Eclipse Build Input June 1st 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-Made class NavigationAction public. - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8004: Ctrl+E beeps every time
-#14800: Compare View eats tabs
-#18200: Both sets of arrows say "Select Next Change"
-#18206: Casing, wording issue on "Last Resource reached" prompt
-#16285: Add from Local History needs a description label
-#17431: Accessibility issues
-#18148: Using combinations of No and Next file button break wrapping
-#18151: Next File button does not ding when on last file
-#16570: Compare refuses to show further differences if not ignoring whitespaces
-#10790: Patch does not apply if file not found locally
-#12643: Expand all does not disable when there is no selection
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 31st 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#18116: Compare view does not inherit Java editor background color
-#13190: Compare with Patch does not apply Patch, if single file selected
- - -

-Problem reports closed

- -

-

-Eclipse Build Input May 30th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#17699: Java Editor: Local Histroy menu entries are enabled for read-only files
-#16283: Add from Local History items are unsorted
-#16288: Add from Local History: list of available editions flashes
-#17664: Applying a patch with deleted package fails
- - -

-Problem reports closed

- -

-

-Eclipse Build Input May 29th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14040: Platform interoperability issue w.r.t. Compare With Patch
-#17790: Missing mnemonics in patch selection dialog
-#10917: Patch support does not use mnemonics
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 28th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#17889: Should not assume type of PropertyChangeEvent values
-#17678: Applying a patch does many compiles
-#17536: NPE in compare
-#17121: Casing of message when end of changes needs to be sentence style
-#17648: Can't apply patch w/o ignoring whitespace
-#16936: Compare with patch requires "Ignore Whitespace" to be turned off
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 18th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14371: TextMergeViewer.sameDoc() is broken
-#14378: CompareEditorInput never resets dirtyness flag (detailed)
-#14680: Compare unreadable in high contrast black
-#14952: Diff Browser Opens Too Small / Not Easily Resizable
-#14742: Ignore whitespace preference
-#14624: No visual cue when compared file wraps
-#13606: Support multiple selection in Add from local history
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 16th 2002 - -

-What's new in this drop

-Bumped plugin version number to 2.0.0
-Adapted to new findEditor methods
- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8373: Compare With->Patch... missing mnemonic
-#12719: "Show Pseudo-Conflicts" setting is problematic
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 30th 2002 - -

-What's new in this drop

-All strings NLSed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14515: java compare uses internal jcore scanner
-#14782: Add from Local History missing mnemonic
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 18th 2002 - -

-What's new in this drop

-All strings NLSed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13152: Internal error in "Add from Local History..." on packages
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 9th 2002 - -

-What's new in this drop

-New context menu action 'Add From Local History'. Just select any resource container and -'Add From Local History' presents all files that were deleted from the workspace but are -still in the local history. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

-The new 'Add From Local History' suffers from #12915. It works if the files were deleted -within the same session. However if you shut down and restart a workspace some deleted -files are nor listed. - -

-Problem reports fixed

-#11578: Patch: Missing resource on dialog
-#11579: Compare with Patch should be disabled on closed projects
-#11907: clicking in bird's eye view spots does nothing if panes not synched
-#11536: Option to turn off structured comparison
-#10682: Need better UI for recovering deletions from local history
-#11446: provide "add from local history" for compilation units
-#8615: Styled Text widget does not respond to system color change
-#9673: editor background color - no effect on other viewers
-#11642: Compare editors not using default background colors
-#10434: Compare browser fails silently and does not give result
- -

-Problem reports closed

- -

-

-Eclipse Build Input March 18th 2002 - -

-What's new in this drop

-First cut of a birdseyeview for the text compare viewer.
-'Compare which Each other' for Java elements. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#3641: DCR: Can't compare from outliner (1GDHJKK)
- -

-Problem reports closed

- -

-

-Eclipse Build Input March 14th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#11305: Can't compare a "C" file
- - -

-Problem reports closed

- -

-

-Eclipse Build Input March 12th 2002 - -

-What's new in this drop

-Structure Compare viewers are enabled by default.
- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#10379: Compare with Local History Dialog: lower pane is missing a bordeer
-#9768: (empty-menu) in compare view
-#9842: Expand All action needed in structure compare view
- - -

-Problem reports closed

- -

-

-Eclipse Build Input March 5th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9869: Need more support for creating/deleting resources
- - -

-Problem reports closed

- -

-

-Eclipse Build Input February 26th 2002 - -

-What's new in this drop

-Patch: for every rejected file a task marker is added
-Compare preference page shows options in a preview
-New preference option for additional compare status line information - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9540: Compare with patch: it should not be possible to check items that could not be applied
-#9532: Compare with patch: next disabled although clipboard specified
-#7681: Structured results expands import statements
-#9572: Debugging trace left in status bar
- - -

-Problem reports closed

- -

-

-Eclipse Build Input February 12th 2002 - -

-What's new in this drop

-The patch wizard no longer opens a Compare Editor but applies the -patch directly to the workspace. This will be the default. -In the future the old behavior of opening the Compare Editor will be -an additional option when finishing the wizard. -
-Patch wizard has a 'Reverse' option for applying a "reversed" patch. -This option can be used to 'undo' a patch. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9153: NPE when closing synchronize view
-#9331: NPE during compare with stream version
-#6346: Problems with Patch
-#6727: Patch: *.rej file must be saved in workspace
-#7358: Internal Error in Compare with Patch with new files
- -

-Problem reports closed

- -

-

-Eclipse Build Input February 5th 2002 - -

-What's new in this drop

-The structure compare pane opens when a resource is selected. -In previous version a double click was required. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#5063: Should not have to double-click to open Structure Compare
-#2602: Compare FW accessibility issues (1GK79UB)
-#2707: Merge viewer should ask for save before releasing (1GI9JXS)
-#2772: DCR: Automatic structure compare (1GJ6EUY)
-#3829: Smart rename button enabled when no smartness is available (1GEUVHN)
-#9089: Local history - Selecting item in structured compare has no effect
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 29th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6271: Can't tell which file is which in Compare browser
-#2519: next/prev arrows active when only one difference in compare (1GFIQX3)
-#8363: NPE comparing two resources in the navigator.
-#2501: Empty menu in compare browser (1GFBQKE)
-#2854: Compare: Save code path problematic (1GJYGAX)
-#8574: Not structure compare in compare with local history
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 23th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8089: Replace from local history: parse error
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 22th 2002 - -

-What's new in this drop

-Fixed an inconsistency in the binary compare viewer: -info message didn't match +/-icon in the resource compare pane. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#3859: replace from history does not work for elements with error (1GEYIZ6)
-#6177: Double click action dangerous in 'Restore from Local History'
-#7821: Team 2.0 CVS synchronze bug 'no-name' dirs..
-#2773: Java structure compare should give better indication when no changes (1GJ6ENE)
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 15th 2002 - -

-What's new in this drop

-Fixed a problem in DiffNode.getName()and the DiffTreeViewer's label provider -where the left and right half of a DiffNode label would be reversed because -the "leftIsLocal" property of a CompareConfiguration wasn't obeyed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#1893: Compare Viewer doesn't scroll to last line (1GBB34N)
-#5839: Usability: Initial diff is sometimes not horizontally aligned
-#5325: Compare always scroll the text pane to the extreme limit
-#7048: First element not selected
-#2548: Project compare should open viewing selected file (1GFMRP6)
-#2938: Replace from local history should show busy cursor (1GKU0P3)
-#7594: Menu entry "Replace with Previous" shouldn't have a "..."
-Workaround added for:
-#7320: Next diff scrolls when going into current diff
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 8th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-Added methods to CompareUI plugin for adding and removing aliases -for the file extension to StructureCompareViewer mapping -(addStructureViewerAlias, removeStructureViewerAlias). - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6828: Support with replace with previous
-#2396: Save in compare editors needs progress bar (1GEYF58)
-#5271: JARs compared as source in release browser
-#5121: Replace with Previous (from local history)
- -

-Problem reports closed

- -

-

-Eclipse Build Input December 11th 2001 - -

-What's new in this drop

-Keyboard shortcuts for 'Goto next Difference' and 'Goto previous Difference' -changed to Control-E and Control-Shift-E.
-Better NLS support.
-Updated file "about.html". - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

- -

-Problem reports closed

- -

-

-Eclipse Build Input December 4th 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#4381: Replace from local histroy - workspace element included
- -

-Problem reports closed

- -

-

-Eclipse Build Input November 27th 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6298: Replace with Local History: Workbench -> Workspace
-#5238: Compare fails if takes more than 20 seconds
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 210, November 12th, 2001 - -

-What's new in this drop

-First cut for 'rejected hunk' support. - -

-API changes

- -

-API Additions

-new classes CompareViewerPane and CompareViewerSwitchingPane
- -

-Other highlights

-Improved Patch wizard.
- -

-Known deficiencies

- -

-Problem reports fixed

-#5723: Apply Patch dialog has no radio selection
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 207, November 1st, 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#5334: Internal errors using patch tool
-#5150: Compare with patch cannot read VCM's CVS patch file
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 204, October 12th, 2001 - -

-What's new in this drop

-First cut of patch support. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

- -

-Problem reports closed

- -

-

-Eclipse SDK Build 202, September 27th, 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GKKUA5: ITPUI:WINNT - Severe: memory leak in sync view
-1GKKGGS: ITPJUI:WIN2000 - (136) compares zips as source
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 201, September 21st, 2001 - -

-What's new in this drop

-removed direction icon in TextMergeViewer for two-way compare - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GJURWJ: ITPUI:WIN2000 - Hebrew + Japanese: compare view defaults to binary
-1GK0388: ITPJCORE:WIN2000 - replace with local history: selecting (workspace) deletes source
-1GITG2V: ITPUI:WIN2000 - Comparing html files uses binary compare
-1GJW2TP: ITPJUI:WIN2000 - java compare: why beep every time?
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 200, September 13th, 2001 - -

-What's new in this drop

-If not specified otherwise Compare viewer font is taken from workbench text font
-The shortcut for "Goto Next/Previous Difference" is Ctrl-D/Ctrl-Shift-D -to avoid a clash with Ctrl-P of the Print command. - -

-API changes

- -

-API Additions

-new method EditionSelectionDialog.setHideIdenticalEntries(boolean)
-new method EditionSelectionDialog.setTargetIsRight(boolean)
-new method EditionSelectionDialog.setAddMode(boolean)
-new method CompareEditorInput.saveChanges(...)
-new method TextMergeViewer.createLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace)
- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty
-1GG0ELM: ITPVCM:ALL - Local history displayed some of Today's items as Yesterday
-1GGNKHN: ITPJUI:ALL - No progress during replace with local history
-1GF2JNI: ITPUI:ALL - (minor)Compare failed title should be title case
-1GHBPA1: ITPVCM:WINNT - Compare - next change arrow switches to wrong file
-1GGQQH3: ITPJUI:WINNT - Compare hightlights a non-change instead of the change
-1GI5DN9: ITPUI:WIN2000 - Conflicting token deletions don't show up in text compare viewer
-1GI3KUR: ITPJUI:WIN2000 - Compare: double-click in versions list closes view
-1GFFR4B: ITPUI:WIN98 - local history is misleading
-1GBM0IL: ITPUI:WINNT - CompareEditorInput#save should throw CoreException
-1GI99LE: ITPUI:ALL - Compare viewer does not show last line when horizontal scroll bar is present
-1GBB34N: ITPJUI:WIN2000 - Compare Viewer doesn't scroll to last line
-1GGZ8DO: ITPJUI:WIN - MergeViewer invalid selection range
-1GIIBHM: ITPUI:WIN2000 - Problems when comparing zip files
-1GIKKOZ: ITPUI:ALL - alt copyright text in html doc needs update
-1GIURNB: ITPUI:ALL - property file of EditionSelectionDialog contains configuration options
-1GIUS6L: ITPUI:ALL - TextMergeViewer uses deprecated Thread.stop()
-1GI3HDZ: ITPJUI:ALL - Compare: conflicts with no ancestor does not show differences
-1GEUX0D: ITPJUI:ALL - not state aware toolbar button in compare
- -

-Problem reports closed

-1GF9Y9C: ITPUI:WIN2000 - DCR: only get ancestor pane contents if pane is visible
- - - diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties deleted file mode 100644 index 264d30af9..000000000 --- a/bundles/org.eclipse.compare/plugin.properties +++ /dev/null @@ -1,216 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# -# Resource strings for Compare Plug-in -# -pluginName= Compare Support -providerName=Eclipse.org - -# -# Extension point names -# -streamMergers= Stream Merger -structureCreators= Structure Creator -structureMergeViewers= Structure Merge Viewer -contentMergeViewers= Content Merge Viewer -contentViewers= Content Viewer - -# -# CompareUIPlugin -# -CompareUIPlugin.dialogTitle=Compare -CompareUIPlugin.noActiveWorkbenchPage=Cannot find active workbench page -CompareUIPlugin.compareFailed=Compare Failed -CompareUIPlugin.openEditorError=Problems Opening Editor -CompareUIPlugin.noDifferences=There are no differences between the selected inputs. - -CompareUIPlugin.targetIdAttributeMissing=target id attribute ''{0}'' missing -CompareUIPlugin.contentTypeNotFound=content type ''{0}'' not found -CompareUIPlugin.targetNotFound=target ''{0}'' not found -CompareUIPlugin.unexpectedTag=expected tag ''{1}'', got ''{0}'' - -# -# Compare Editor -# -defaultCompareEditor.name= Default Compare Editor -CompareEditor.saveError.title= Save Error -CompareEditor.cantSaveError= Cannot save contents ({0}) -CompareEditor.invalidInput=Invalid input: not a CompareEditorInput -CompareEditor.error.setinput.title=Problem opening input -CompareEditor.error.setinput.message=Cannot open input: - -# -# Commands -# -compareCategory.name= Compare -compareCategory.description= Compare command category - -Command.copyRightToLeft.name= Copy from Right to Left -Command.copyRightToLeft.description= Copy Current Change from Right to Left - -Command.copyLeftToRight.name= Copy from Left to Right -Command.copyLeftToRight.description= Copy Current Change from Left to Right - -Command.copyAllRightToLeft.name= Copy All from Right to Left -Command.copyAllRightToLeft.description= Copy All Changes from Right to Left - -Command.copyAllLeftToRight.name= Copy All from Left to Right -Command.copyAllLeftToRight.description= Copy All Changes from Left to Right - -Command.selectNextChange.name= Select Next Change -Command.selectNextChange.description= Select Next Change - -Command.selectPreviousChange.name= Select Previous Change -Command.selectPreviousChange.description= Select Previous Change - - -# -# Context menu & actions -# -CompareWithMenu.label= Comp&are With - -CompareWithEachOtherAction.label= &Each Other -CompareWithEachOtherAction.tooltip= Compare the Selected Resources - -TeamMenu.label= T&eam - -CompareWithPatchAction.label= &Apply Patch... -CompareWithPatchAction.tooltip= Apply a Patch to the Selected Resources - -CompareWithHistoryAction.label= &Local History... -CompareWithHistoryAction.tooltip= Compare the Selected Resource with Local History - -ReplaceWithMenu.label= Rep&lace With - -ReplaceFromHistoryAction.label= &Local History... -ReplaceFromHistoryAction.tooltip= Replace the Selected Resource with Local History - -ReplaceWithPreviousFromHistoryAction.label= &Previous from Local History -ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with the Previous from Local History - -addFromHistoryAction.label= Restore from Local Histor&y... -addFromHistoryAction.tooltip= Restore Deleted Files from Local History - -# -# Preference Page -# -ComparePreferencePage.name= Compare/Patch - -ComparePreferencePage.generalTab.label= &General - -ComparePreferencePage.structureCompare.label= &Open structure compare automatically -ComparePreferencePage.showMoreInfo.label= &Show additional compare information in the status line -ComparePreferencePage.ignoreWhitespace.label= Ignore &white space -ComparePreferencePage.saveBeforePatching.label= A&utomatically save dirty editors before patching - -ComparePreferencePage.filter.description= Enter member names that should be excluded from 'Compare With Each Other'.\nList is comma separated (e.g. '*.class, .project, bin/') -ComparePreferencePage.filter.label= &Filtered Members: -ComparePreferencePage.filter.invalidsegment.error= Filter is invalid: {0} - -ComparePreferencePage.textCompareTab.label= &Text Compare - -ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor pane -ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts -ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers -ComparePreferencePage.useSingleLine.label= Connect &ranges with single line - -ComparePreferencePage.preview.label= Preview: -ComparePreferencePage.ancestor.label= Common Ancestor -ComparePreferencePage.left.label= Local -ComparePreferencePage.right.label= Remote -ComparePreferencePage.backgroundColor1.label= Bac&kground Color: -ComparePreferencePage.backgroundColor2.label= S&ystem Default -ComparePreferencePage.backgroundColor3.label= C&ustom - -# Compare editor contents for Compare preview page -ComparePreferencePage.previewAncestor= 1\n2\n3\nconflict\n4\n5 -ComparePreferencePage.previewLeft= 1\n2\noutgoing addition\n3\noutgoing change\n4\npseudo conflict\n5 -ComparePreferencePage.previewRight= 1\nincoming addition\nincoming addition\n2\n3\nincoming change\n4\npseudo conflict\n5 - -textCompareAppearance.label=Text Compare - -compareIncomingColor.label= Incoming change color -compareIncomingColor.description= The color used to indicate an incoming change in compare and merge tools. -compareOutgoingColor.label= Outgoing change color -compareOutgoingColor.description= The color used to indicate an outgoing change in compare and merge tools. -compareConflictColor.label= Conflicting change color -compareConflictColor.description= The color used to indicate a conflicting change in compare and merge tools. -compareResolvedColor.label= Resolved change color -compareResolvedColor.description= The color used to indicate a resolved change in merge tools. - -compareFontDefiniton.label= Compare text font -compareFontDefiniton.description= The compare text font is used by textual compare/merge tools. - -# New UI -#ComparePreferencePage.useSplines.label= Use splines in center panel -#ComparePreferencePage.useResolveUI.label= Use new resolve UI - -CompareEditorInput.defaultTitle= Compare - -# -# Toolbar actions -# -action.IgnoreWhiteSpace.label=Ignore White Space -action.IgnoreWhiteSpace.tooltip=Ignore White Space Where Applicable -action.IgnoreWhiteSpace.image=etool16/ignorews_edit.gif - -action.Next.label=Next Difference -action.Next.tooltip=Go to Next Difference -action.Next.image=elcl16/next_nav.gif - -action.Previous.label=Previous Difference -action.Previous.tooltip=Go to Previous Difference -action.Previous.image=elcl16/prev_nav.gif - -# -# Built in Structure Creators -# -ZipStructureCreator.name=Zip Archive Compare - -# -# Compare Dialog -# -CompareDialog.commitAction.label=Commit -CompareDialog.saveErrorTitle=Save Error -CompareDialog.saveErrorMessage=Cannot save - -# -# Compare With Each Other -# -ResourceCompare.taskName=Operation in Progress... -ResourceCompare.twoWay.title=Compare ({0}-{1}) -ResourceCompare.twoWay.tooltip=Two-way compare of {0} with {1} -ResourceCompare.threeWay.title=Compare ({0}-{1}-{2}) -ResourceCompare.threeWay.tooltip=Three-way compare of {1} and {2} relative to common ancestor {0} - -# -# DiffTreeViewer & DiffNodes -# -DiffTreeViewer.title= Structure Compare -DiffNode.noName= -DiffNode.nameFormat= {0} / {1} - -# -# Differencing engine -# -Differencer.progressFormat= Comparing {0} - -# -# Patch: rejected patch markers -# -rejectedPatchMarker.name= Rejected Patch - -# -# ValidateEdit -# -ValidateEdit.error.unable_to_perform= Operation cannot be performed. -ValidateEdit.error.fileModified= File ''{0}'' has been modified since the beginning of the operation. -ValidateEdit.error.stillReadonly= File ''{0}'' is read-only. diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml deleted file mode 100644 index ec7fac491..000000000 --- a/bundles/org.eclipse.compare/plugin.xml +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %compareIncomingColor.description - - - - - %compareOutgoingColor.description - - - - - %compareConflictColor.description - - - - - %compareResolvedColor.description - - - - - %compareFontDefiniton.description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.classpath b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.classpath deleted file mode 100644 index 3e86ace7d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.cvsignore b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.project b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.project deleted file mode 100644 index f0d1e74ed..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - org.eclipse.compare - - - org.eclipse.core.boot - org.eclipse.core.resources - org.eclipse.core.runtime - org.eclipse.core.runtime.compatibility - org.eclipse.jface.text - org.eclipse.ui - org.eclipse.ui.ide - org.eclipse.ui.views - org.eclipse.ui.workbench.texteditor - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7d97357dd..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,70 +0,0 @@ -#Tue Nov 30 15:51:47 CET 2004 -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error -org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=error -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.source=1.3 -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -eclipse.preferences.version=1 -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/about.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/about.html +++ /dev/null @@ -1,30 +0,0 @@ - - - -About - - - -

About This Content

- -

20th June, 2002

-

License

-

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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

- -

Contributions

- -

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.

- -

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.

- - - \ No newline at end of file diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/build.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/build.properties deleted file mode 100644 index 22bed075e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/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 -############################################################################### -source.compare.jar = compare/ -bin.includes = icons/,\ - plugin.xml,\ - *.jar,\ - plugin.properties,\ - about.html -src.includes = about.html,\ - schema/ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html deleted file mode 100644 index 93116b578..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - Eclipse Platform Release Notes - Desktop - - - -

-Eclipse Platform Build Notes
-Compare

- -Eclipse Build Input December 7th 2004 - -

Problem reports fixed

-Eliminated all compiler warnings
-Removed dependency on core.runtime.compatibility - - -


- -Eclipse Build Input November 30th 2004 - -

Problem reports fixed

-79414: states with same time stamps may appear in the wrong order
-79566: NPE when closing JUnit compare view
- - -


- -Eclipse Build Input November 23rd 2004 - -

Problem reports fixed

-47786: Possible leak in TextMergeViewer
-Added translatable attribute to extension point schemas. - - -


- -Eclipse Build Input November 16th 2004 - -

Problem reports fixed

- 78679: Prefs Filtered Members field does not restore defaults
- -


- -Eclipse Build Input November 9th 2004 - -

Problem reports fixed

- (partial fix; awaits fix in jdt.ui): - 77599: [5.0] Structure comparing of enums does not work
- - -


- -Eclipse Build Input November 1st 2004 - -

Problem reports fixed

-65981: empty compare viewer has no focus
- - -


- -Eclipse Build Input September 21th 2004 - -

Problem reports fixed

-74450: AbstractUIPlugin.initializeDefaultPreferences no longer called?
- - -


-Eclipse Build Input August 24th 2004 - -

Problem reports fixed

-Eliminated compiler warnings - - -


-Eclipse Build Input July 27th 2004 - -

Problem reports fixed

-Updated version number in plugin.xml and export script to 3.1 - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java deleted file mode 100644 index 5e352752a..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/BufferedContent.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.internal.Utilities; - -/** - * Abstract implementation for a buffered IStreamContentAccessor. - *

- * Subclasses must implement the createStream method - * to connect the buffered content with a streamable source (e.g., a file). - *

- * As long as the contents of BufferedContent is only retrieved as an input stream - * (by means of getContents) and the BufferedContent is not modified (with - * setContent) no buffering takes place. - * Buffering starts when either method getContent or setContent is called. - * - * @see IContentChangeNotifier - * @see IStreamContentAccessor - */ -public abstract class BufferedContent implements IContentChangeNotifier, IStreamContentAccessor { - - byte[] fContent; - private ListenerList fListenerList; - - /** - * Creates a buffered stream content accessor. - */ - protected BufferedContent() { - // empty implementation - } - - /* (non-Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - if (fContent != null) - return new ByteArrayInputStream(fContent); - return createStream(); - } - - /** - * Creates and returns a stream for reading the contents. - *

- * Subclasses must implement this method. - *

- * - * @return the stream from which the content is read - * @exception CoreException if the contents could not be accessed - */ - protected abstract InputStream createStream() throws CoreException; - - /** - * Sets the contents. Registered content change listeners are notified. - * - * @param contents the new contents - */ - public void setContent(byte[] contents) { - fContent= contents; - fireContentChanged(); - } - - /** - * Returns the contents as an array of bytes. - * - * @return the contents as an array of bytes, or null if - * the contents could not be accessed - */ - public byte[] getContent() { - if (fContent == null) { - try { - InputStream is= createStream(); - fContent= Utilities.readBytes(is); - } catch(CoreException ex) { - // NeedWork - } - } - return fContent; - } - - /** - * Discards the buffered content. - */ - public void discardBuffer() { - fContent= null; - } - - /* (non-Javadoc) - * see IContentChangeNotifier.addChangeListener - */ - public void addContentChangeListener(IContentChangeListener listener) { - if (fListenerList == null) - fListenerList= new ListenerList(); - fListenerList.add(listener); - } - - /* (non-Javadoc) - * see IContentChangeNotifier.removeChangeListener - */ - public void removeContentChangeListener(IContentChangeListener listener) { - if (fListenerList != null) { - fListenerList.remove(listener); - if (fListenerList.isEmpty()) - fListenerList= null; - } - } - - /** - * Notifies all registered IContentChangeListeners of a content change. - */ - protected void fireContentChanged() { - if (fListenerList != null) { - Object[] listeners= fListenerList.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IContentChangeListener)listeners[i]).contentChanged(this); - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java deleted file mode 100644 index 8a5e89b1f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.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 - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.HashMap; - -import org.eclipse.swt.graphics.*; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.preference.IPreferenceStore; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.Differencer; - -/** - * A CompareConfiguration object - * controls various UI aspects of compare/merge viewers like - * title labels and images, or whether a side of a merge viewer is editable. - * In addition to these fixed properties ICompareConfiguration provides - * API for an open ended set of properties. Different viewers which share the same - * configuration can communicate via this mechanism. E.g. if a compare editor - * has a button for controlling whether compare viewers ignore white space, - * the button would trigger a change of the boolean IGNORE_WHITESPACE property - * and all interested viewers would receive notification. - *

- * Suitable default labels are provided (without images); both the left and right sides - * are editable. - *

- *

- * Clients may use this class as is, or subclass to add new state and behavior. - *

- */ -public class CompareConfiguration { - - /** - * Name of the ignore whitespace property (value "IGNORE_WHITESPACE"). - */ - public static final String IGNORE_WHITESPACE= "IGNORE_WHITESPACE"; //$NON-NLS-1$ - /** - * Name of the show pseudo conflicts property (value "SHOW_PSEUDO_CONFLICTS"). - */ - public static final String SHOW_PSEUDO_CONFLICTS= "SHOW_PSEUDO_CONFLICTS"; //$NON-NLS-1$ - /** - * Name of the use outline view property (value "USE_OUTLINE_VIEW"). - * @since 3.0 - */ - public static final String USE_OUTLINE_VIEW= "USE_OUTLINE_VIEW"; //$NON-NLS-1$ - - - private static final int WIDTH= 22; - - private static ImageDescriptor[] fgImages= new ImageDescriptor[16]; - private static Object fgDummy= new Object(); - private static HashMap fgMap= new HashMap(20); - private static boolean fLeftIsLocal= true; - - static { - if (fLeftIsLocal) { - fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_inadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outadd_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_indel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outdel_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_inchg_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_outchg_ov.gif"); //$NON-NLS-1$ - } else { - fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/inadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/outadd_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/indel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/outdel_ov.gif"); //$NON-NLS-1$ - - fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/inchg_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/outchg_ov.gif"); //$NON-NLS-1$ - } - - fgImages[Differencer.CONFLICTING + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/confadd_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.CONFLICTING + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/confdel_ov.gif"); //$NON-NLS-1$ - fgImages[Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.gif"); //$NON-NLS-1$ - } - - private IPreferenceStore fPreferenceStore; - private ListenerList fListeners= new ListenerList(); - private HashMap fProperties= new HashMap(); - private boolean fLeftEditable= true; - private boolean fRightEditable= true; - private String fAncestorLabel; - private String fLeftLabel; - private String fRightLabel; - private Image fAncestorImage; - private Image fRightImage; - private Image fLeftImage; - private Image[] fImages= new Image[16]; - - /** - * Creates a new configuration with editable left and right sides, - * suitable default labels, and no images. - * The given preference store is used to connect this configuration - * with the Compare preference page properties ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, - * and CompareConfiguration.IGNORE_WHITESPACE. - * - * @param prefStore the preference store which this configuration holds onto. - * @since 2.0 - */ - public CompareConfiguration(IPreferenceStore prefStore) { - - setProperty("LEFT_IS_LOCAL", new Boolean(fLeftIsLocal)); //$NON-NLS-1$ - - fPreferenceStore= prefStore; - if (fPreferenceStore != null) { - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE); - setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b)); - - b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE); - setProperty(CompareConfiguration.IGNORE_WHITESPACE, new Boolean(b)); - } - } - - /** - * Creates a new configuration with editable left and right sides, - * suitable default labels, and no images. - * This configuration uses the preference store of the Compare plugin - * (CompareUIPlugin.getDefault().getPreferenceStore()). - */ - public CompareConfiguration() { - this(CompareUIPlugin.getDefault().getPreferenceStore()); - } - - /** - * Returns the preference store of this configuration. - * @return the preference store of this configuration. - * @since 2.0 - */ - public IPreferenceStore getPreferenceStore() { - return fPreferenceStore; - } - - /** - * Returns an image showing the specified change kind. - * The different kind of changes are defined in the Differencer. - * Newly created images are remembered by this class and - * disposed when the dispose method is called. - * - * @param kind the kind of change as defined in Differencer. - * @return an modification of the base image reflecting the kind of change. - * @see org.eclipse.compare.structuremergeviewer.Differencer - * @since 2.0 - */ - public Image getImage(int kind) { - Image image= fImages[kind & 15]; - if (image == null) { - ImageDescriptor id= fgImages[kind & 15]; - if (id != null) - image= id.createImage(); - fImages[kind & 15]= image; - } - return image; - } - - /** - * Returns an image showing the specified change kind applied to a - * given base image. The different kind of changes are defined in the Differencer. - * Typically an implementation would build a composite image - * from the given base image and an image representing the change kind. - * Newly created images are remembered by this class and - * disposed when the dispose method is called. - * - * @param base the image which is modified to reflect the kind of change - * @param kind the kind of change as defined in Differencer. - * @return an modification of the base image reflecting the kind of change. - * @see org.eclipse.compare.structuremergeviewer.Differencer - */ - public Image getImage(Image base, int kind) { - - Object key= base; - if (key == null) - key= fgDummy; - - kind &= 15; - - Image[] a= (Image[]) fgMap.get(key); - if (a == null) { - a= new Image[16]; - fgMap.put(key, a); - } - Image b= a[kind]; - if (b == null) { - b= new DiffImage(base, fgImages[kind], WIDTH, !fLeftIsLocal).createImage(); - CompareUI.disposeOnShutdown(b); - a[kind]= b; - } - return b; - } - - /** - * Dispose of this compare configuration. - * This method is called if the compare configuration is no longer used. - * An implementation must dispose of all resources. - */ - public void dispose() { - if (fImages != null) { - for (int i= 0; i < fImages.length; i++){ - Image image= fImages[i]; - if (image != null && !image.isDisposed()) - image.dispose(); - } - } - fImages= null; - } - - /** - * Fires a PropertyChangeEvent to registered listeners. - * - * @param propertyName the name of the property that has changed - * @param oldValue the property's old value - * @param newValue the property's new value - */ - private void fireChange(String propertyName, Object oldValue, Object newValue) { - PropertyChangeEvent event= null; - Object[] listeners= fListeners.getListeners(); - if (listeners != null) { - for (int i= 0; i < listeners.length; i++) { - IPropertyChangeListener l= (IPropertyChangeListener) listeners[i]; - if (event == null) - event= new PropertyChangeEvent(this, propertyName, oldValue, newValue); - l.propertyChange(event); - } - } - } - - /* (non javadoc) - * see IPropertyChangeNotifier.addListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - fListeners.add(listener); - } - - /* (non javadoc) - * see IPropertyChangeNotifier.removeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - } - - /** - * Sets the property with the given name. - * If the new value differs from the old a PropertyChangeEvent - * is sent to registered listeners. - * - * @param key the name of the property to set - * @param newValue the new value of the property - */ - public void setProperty(String key, Object newValue) { - Object oldValue= fProperties.get(key); - fProperties.put(key, newValue); - if (oldValue == null || !oldValue.equals(newValue)) - fireChange(key, oldValue, newValue); - } - - /** - * Returns the property with the given name, or null - * if no such property exists. - * - * @param key the name of the property to retrieve - * @return the property with the given name, or null if not found - */ - public Object getProperty(String key) { - return fProperties.get(key); - } - - //---- ancestor - - /** - * Sets the label to use for the ancestor of compare/merge viewers. - * - * @param label the new label for the ancestor of compare/merge viewers - */ - public void setAncestorLabel(String label) { - fAncestorLabel= label; - } - - /** - * Returns the label for the ancestor side of compare/merge viewers. - * This label is typically shown in the title of the ancestor area in a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the ancestor side or null - */ - public String getAncestorLabel(Object element) { - return fAncestorLabel; - } - - /** - * Sets the image to use for the ancestor of compare/merge viewers. - * The CompareConfiguration does not automatically dispose the old image. - * - * @param image the new image for the ancestor of compare/merge viewers - */ - public void setAncestorImage(Image image) { - fAncestorImage= image; - } - - /** - * Returns the image for the ancestor side of compare/merge viewers. - * This image is typically shown in the title of the ancestor area in a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the ancestor side or null - */ - public Image getAncestorImage(Object element) { - return fAncestorImage; - } - - //---- left side - - /** - * Controls whether the left side of a merge viewer is editable. - * - * @param editable if the value is true left side is editable - */ - public void setLeftEditable(boolean editable) { - fLeftEditable= editable; - } - - /** - * Returns whether the left hand side of a merge viewer is editable. - * - * @return true if the left hand side is editable - */ - public boolean isLeftEditable() { - return fLeftEditable; - } - - /** - * Sets the label to use for the left side of compare/merge viewers. - * - * @param label the new label for the left side of compare/merge viewers - */ - public void setLeftLabel(String label) { - fLeftLabel= label; - } - - /** - * Returns the label for the left hand side of compare/merge viewers. - * This label is typically shown in the title of the left side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the left hand side or null - */ - public String getLeftLabel(Object element) { - return fLeftLabel; - } - - /** - * Sets the image to use for the left side of compare/merge viewers. - * The compare configuration does not automatically dispose the old image. - * - * @param image the new image for the left side of compare/merge viewers - */ - public void setLeftImage(Image image) { - fLeftImage= image; - } - - /** - * Returns the image for the left hand side of compare/merge viewers. - * This image is typically shown in the title of the left side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the left hand side or null - */ - public Image getLeftImage(Object element) { - return fLeftImage; - } - - //---- right side - - /** - * Controls whether the right side of a merge viewer is editable. - * - * @param editable if the value is true right side is editable - */ - public void setRightEditable(boolean editable) { - fRightEditable= editable; - } - - /** - * Returns whether the right hand side of a merge viewer is editable. - * - * @return true if the right hand side is editable - */ - public boolean isRightEditable() { - return fRightEditable; - } - - /** - * Sets the label to use for the right side of compare/merge viewers. - * - * @param label the new label for the right side of compare/merge viewers - */ - public void setRightLabel(String label) { - fRightLabel= label; - } - - /** - * Returns the label for the right hand side of compare/merge viewers. - * This label is typically shown in the title of the right side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the label for the right hand side or null - */ - public String getRightLabel(Object element) { - return fRightLabel; - } - - /** - * Sets the image to use for the right side of compare/merge viewers. - * The compare configuration does not automatically dispose the old image. - * - * @param image the new image for the right side of compare/merge viewers - */ - public void setRightImage(Image image) { - fRightImage= image; - } - - /** - * Returns the image for the right hand side of compare/merge viewers. - * This image is typically shown in the title of the right side of a compare viewer. - * - * @param element the input object of a compare/merge viewer or null - * @return the image for the right hand side or null - */ - public Image getRightImage(Object element) { - return fRightImage; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java deleted file mode 100644 index 9cfb91b88..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java +++ /dev/null @@ -1,815 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.lang.reflect.InvocationTargetException; - -import java.util.ArrayList; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.custom.BusyIndicator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.*; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.IEditorInput; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A compare operation which can present its results in a special editor. - * Running the compare operation and presentating the results in a compare editor - * are combined in one class because it allows a client to keep the implementation - * all in one place while separating it from the innards of a specific UI implementation of compare/merge. - *

- * A CompareEditorInput defines methods for the following sequence steps: - *

    - *
  • running a lengthy compare operation under progress monitor control, - *
  • creating a UI for displaying the model and initializing the some widgets with the compare result, - *
  • tracking the dirty state of the model in case of merge, - *
  • saving the model. - *
- * The Compare plug-in's openCompareEditor method takes an ICompareEditorInput - * and starts sequencing through the above steps. If the compare result is not empty a new compare editor - * is opened and takes over the sequence until eventually closed. - *

- * The prepareInput method should contain the - * code of the compare operation. It is executed under control of a progress monitor - * and can be canceled. If the result of the compare is not empty, that is if there are differences - * that needs to be presented, the ICompareEditorInput should hold onto them and return them with - * the getCompareResult method. - * If the value returned from getCompareResult is not null - * a compare editor is opened on the ICompareEditorInput with title and title image initialized by the - * corresponding methods of the ICompareEditorInput. - *

- * Creation of the editor's SWT controls is delegated to the createContents method. - * Here the SWT controls must be created and initialized with the result of the compare operation. - *

- * If merging is allowed, the modification state of the compared constituents must be tracked and the dirty - * state returned from method isSaveNeeded. The value true triggers a subsequent call - * to save where the modified resources can be saved. - *

- * The most important part of this implementation is the setup of the compare/merge UI. - * The UI uses a simple browser metaphor to present compare results. - * The top half of the layout shows the structural compare results (e.g. added, deleted, and changed files), - * the bottom half the content compare results (e.g. textual differences between two files). - * A selection in the top pane is fed to the bottom pane. If a content viewer is registered - * for the type of the selected object, this viewer is installed in the pane. - * In addition if a structure viewer is registered for the selection type the top pane - * is split horizontally to make room for another pane and the structure viewer is installed - * in it. When comparing Java files this second structure viewer would show the structural - * differences within a Java file, e.g. added, deleted or changed methods and fields. - *

- * Subclasses provide custom setups, e.g. for a Catchup/Release operation - * by passing a subclass of CompareConfiguration and by implementing the prepareInput method. - * If a subclass cannot use the DiffTreeViewer which is installed by default in the - * top left pane, method createDiffViewer can be overridden. - * - * @see CompareUI - * @see CompareEditorInput - */ -public abstract class CompareEditorInput implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress { - - private static final boolean DEBUG= false; - - /** - * The name of the "dirty" property (value "DIRTY_STATE"). - */ - public static final String DIRTY_STATE= "DIRTY_STATE"; //$NON-NLS-1$ - - private static final String COMPARE_EDITOR_IMAGE_NAME= "eview16/compare_view.gif"; //$NON-NLS-1$ - private static Image fgTitleImage; - - private Splitter fComposite; - private CompareConfiguration fCompareConfiguration; - private CompareViewerSwitchingPane fStructureInputPane; - private CompareViewerSwitchingPane fStructurePane1; - private CompareViewerSwitchingPane fStructurePane2; - private CompareViewerSwitchingPane fContentInputPane; - private CompareViewerSwitchingPane fFocusPane; - private String fMessage; - private Object fInput; - private String fTitle; - private ListenerList fListenerList= new ListenerList(); - private CompareNavigator fNavigator; - private boolean fDirty= false; - private ArrayList fDirtyViewers= new ArrayList(); - private IPropertyChangeListener fDirtyStateListener; - - private IgnoreWhiteSpaceAction fIgnoreWhitespace; - private ShowPseudoConflicts fShowPseudoConflicts; - - boolean fStructureCompareOnSingleClick= true; - boolean fUseOutlineView= false; - - /** - * Creates a CompareEditorInput which is initialized with the given - * compare configuration. - * The compare configuration is passed to subsequently created viewers. - * - * @param configuration the compare configuration - */ - public CompareEditorInput(CompareConfiguration configuration) { - fCompareConfiguration= configuration; - Assert.isNotNull(configuration); - - Object object= fCompareConfiguration.getProperty(CompareConfiguration.USE_OUTLINE_VIEW); - if (object instanceof Boolean) - fUseOutlineView= ((Boolean) object).booleanValue(); - - ResourceBundle bundle= CompareUI.getResourceBundle(); - fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, configuration); - fShowPseudoConflicts= new ShowPseudoConflicts(bundle, configuration); - - fDirtyStateListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - String propertyName= e.getProperty(); - if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) { - boolean changed= false; - Object newValue= e.getNewValue(); - if (newValue instanceof Boolean) - changed= ((Boolean)newValue).booleanValue(); - setDirty(e.getSource(), changed); - } - } - }; - - IPreferenceStore ps= configuration.getPreferenceStore(); - if (ps != null) - fStructureCompareOnSingleClick= ps.getBoolean(ComparePreferencePage.OPEN_STRUCTURE_COMPARE); - } - - private boolean structureCompareOnSingleClick() { - return fStructureCompareOnSingleClick; - } - - /* (non Javadoc) - * see IAdaptable.getAdapter - */ - public Object getAdapter(Class adapter) { - if (ICompareNavigator.class.equals(adapter) || CompareNavigator.class.equals(adapter)) { - if (fNavigator == null) - fNavigator= new CompareNavigator( - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - return fNavigator; - } - if (IFile.class.equals(adapter)) { - IProgressMonitor pm= new NullProgressMonitor(); - // flush changes in any dirty viewer - try { - flushViewer(fStructureInputPane, pm); - flushViewer(fStructurePane1, pm); - flushViewer(fStructurePane2, pm); - flushViewer(fContentInputPane, pm); - } catch (CoreException e) { - CompareUIPlugin.log(e); - } - IFile[] files= (IFile[]) getAdapter(IFile[].class); - if (files.length > 0) - return files[0]; // can only return one: limitation on IDE.saveAllEditors; see #64617 - return null; - } - return null; - } - - /* (non Javadoc) - * see IEditorInput.getImageDescriptor - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* (non Javadoc) - * see IEditorInput.getToolTipText - */ - public String getToolTipText() { - return getTitle(); - } - - /* (non Javadoc) - * see IEditorInput.getName - */ - public String getName() { - return getTitle(); - } - - /** - * Returns null since this editor cannot be persisted. - * - * @return null because this editor cannot be persisted - */ - public IPersistableElement getPersistable() { - return null; - } - - /** - * Returns false to indicate that this input - * should not appear in the "File Most Recently Used" menu. - * - * @return false - */ - public boolean exists() { - return false; - } - - /* - * FIXME! - */ - protected void setMessage(String message) { - fMessage= message; - } - - /* - * FIXME! - */ - public String getMessage() { - return fMessage; - } - - /** - * Returns the title which will be used in the compare editor's title bar. - * It can be set with setTitle. - * - * @return the title - */ - public String getTitle() { - if (fTitle == null) - return Utilities.getString("CompareEditorInput.defaultTitle"); //$NON-NLS-1$ - return fTitle; - } - - /** - * Sets the title which will be used when presenting the compare result. - * This method must be called before the editor is opened. - * - * @param title the title to use for the CompareEditor - */ - public void setTitle(String title) { - fTitle= title; - } - - /** - * Returns the title image which will be used in the compare editor's title bar. - * Returns the title image which will be used when presenting the compare result. - * This implementation returns a generic compare icon. - * Subclasses can override. - * - * @return the title image, or null if none - */ - public Image getTitleImage() { - if (fgTitleImage == null) { - fgTitleImage= CompareUIPlugin.getImageDescriptor(COMPARE_EDITOR_IMAGE_NAME).createImage(); - CompareUI.disposeOnShutdown(fgTitleImage); - } - return fgTitleImage; - } - - /** - * Returns the configuration object for the viewers within the compare editor. - * Returns the configuration which was passed to the constructor. - * - * @return the compare configuration - */ - public CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * Adds standard actions to the given ToolBarManager. - *

- * Subclasses may override to add their own actions. - *

- * - * @param toolBarManager the ToolBarManager to which to contribute - */ - public void contributeToToolBar(ToolBarManager toolBarManager) { - - toolBarManager.add(new Separator()); - toolBarManager.add(fIgnoreWhitespace); - toolBarManager.add(fShowPseudoConflicts); - } - - /** - * Runs the compare operation and stores the compare result. - * - * @param monitor the progress monitor to use to display progress and receive - * requests for cancelation - * @exception InvocationTargetException if the prepareInput method must propagate a checked exception, - * it should wrap it inside an InvocationTargetException; runtime exceptions are automatically - * wrapped in an InvocationTargetException by the calling context - * @exception InterruptedException if the operation detects a request to cancel, - * using IProgressMonitor.isCanceled(), it should exit by throwing - * InterruptedException - */ - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - fInput= prepareInput(monitor); - } - - /** - * Runs the compare operation and returns the compare result. - * If null is returned no differences were found and no compare editor needs to be opened. - * Progress should be reported to the given progress monitor. - * A request to cancel the operation should be honored and acknowledged - * by throwing InterruptedException. - *

- * Note: this method is typically called in a modal context thread which doesn't have a Display assigned. - * Implementors of this method shouldn't therefore allocated any SWT resources in this method. - *

- * - * @param monitor the progress monitor to use to display progress and receive - * requests for cancelation - * @return the result of the compare operation, or null if there are no differences - * @exception InvocationTargetException if the prepareInput method must propagate a checked exception, - * it should wrap it inside an InvocationTargetException; runtime exceptions are automatically - * wrapped in an InvocationTargetException by the calling context - * @exception InterruptedException if the operation detects a request to cancel, - * using IProgressMonitor.isCanceled(), it should exit by throwing - * InterruptedException - */ - protected abstract Object prepareInput(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException; - - /** - * Returns the compare result computed by the most recent call to the - * run method. Returns null if no - * differences were found. - * - * @return the compare result prepared in method prepareInput - * or null if there were no differences - */ - public Object getCompareResult() { - return fInput; - } - - /** - * Create the SWT controls that are used to display the result of the compare operation. - * Creates the SWT Controls and sets up the wiring between the individual panes. - * This implementation creates all four panes but makes only the necessary ones visible. - * Finally it feeds the compare result into the top left structure viewer - * and the content viewer. - *

- * Subclasses may override if they need to change the layout or wiring between panes. - * - * @param parent the parent control under which the control must be created - * @return the SWT control hierarchy for the compare editor - */ - public Control createContents(Composite parent) { - - fComposite= new Splitter(parent, SWT.VERTICAL); - fComposite.setData(this); - - Control outline= null; - if (!fUseOutlineView) - outline= createOutlineContents(fComposite, SWT.HORIZONTAL); - - fContentInputPane= new CompareViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findContentViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - if (fFocusPane == null) - fFocusPane= fContentInputPane; - if (outline != null) - fComposite.setVisible(outline, false); - fComposite.setVisible(fContentInputPane, true); - - if (fStructureInputPane != null) - fComposite.setWeights(new int[] { 30, 70 }); - - fComposite.layout(); - - if (fStructureInputPane != null && fInput instanceof ICompareInput) { - fStructureInputPane.setInput(fInput); - ISelection sel= fStructureInputPane.getSelection(); - if (sel == null || sel.isEmpty()) - feed1(sel); // we only feed downstream viewers if the top left pane is empty - } - - fComposite.setData("Nav", //$NON-NLS-1$ - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - - return fComposite; - } - - /** - * @param parent the parent control under which the control must be created - * @param direction the layout direction of the contents, either SWT.HORIZONTAL or SWT.VERTICAL - * @return the SWT control hierarchy for the outline part of the compare editor - * @since 3.0 - */ - public Control createOutlineContents(Composite parent, int direction) { - final Splitter h= new Splitter(parent, direction); - - fStructureInputPane= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof DiffNode) { - DiffNode dn= (DiffNode) input; - if (dn.hasChildren()) - return createDiffViewer(this); - } - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - fFocusPane= fStructureInputPane; - - fStructurePane1= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - h.setVisible(fStructurePane1, false); - - fStructurePane2= new CompareViewerSwitchingPane(h, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return findStructureViewer(oldViewer, (ICompareInput)input, this); - return null; - } - }; - h.setVisible(fStructurePane2, false); - - // setup the wiring for top left pane - fStructureInputPane.addOpenListener( - new IOpenListener() { - public void open(OpenEvent oe) { - feed1(oe.getSelection()); - } - } - ); - fStructureInputPane.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - ISelection s= e.getSelection(); - if (s == null || s.isEmpty()) - feed1(s); - } - } - ); - fStructureInputPane.addDoubleClickListener( - new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - feedDefault1(event.getSelection()); - } - } - ); - - fStructurePane1.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feed2(e.getSelection()); - } - } - ); - - fStructurePane2.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feed3(e.getSelection()); - } - } - ); - - if (fUseOutlineView) { - if (fInput instanceof ICompareInput) { - fStructureInputPane.setInput(fInput); - ISelection sel= fStructureInputPane.getSelection(); - if (sel == null || sel.isEmpty()) - feed1(sel); // we only feed downstream viewers if the top left pane is empty - } - - fComposite.setData("Nav", //$NON-NLS-1$ - new CompareViewerSwitchingPane[] { - fStructureInputPane, - fStructurePane1, - fStructurePane2, - fContentInputPane - } - ); - } - - return h; - } - - private void feed1(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection == null || selection.isEmpty()) { - Object input= fStructureInputPane.getInput(); - fContentInputPane.setInput(input); - fStructurePane2.setInput(null); // clear downstream pane - fStructurePane1.setInput(null); - } else { - Object input= getElement(selection); - fContentInputPane.setInput(input); - if (structureCompareOnSingleClick()) - fStructurePane1.setInput(input); - fStructurePane2.setInput(null); // clear downstream pane - if (fStructurePane1.getInput() != input) - fStructurePane1.setInput(null); - } - } - } - ); - } - - private void feedDefault1(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (!selection.isEmpty()) - fStructurePane1.setInput(getElement(selection)); - } - } - ); - } - - private void feed2(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection.isEmpty()) { - Object input= fStructurePane1.getInput(); - fContentInputPane.setInput(input); - fStructurePane2.setInput(null); - } else { - Object input= getElement(selection); - fContentInputPane.setInput(input); - fStructurePane2.setInput(input); - } - } - } - ); - } - - private void feed3(final ISelection selection) { - BusyIndicator.showWhile(fComposite.getDisplay(), - new Runnable() { - public void run() { - if (selection.isEmpty()) - fContentInputPane.setInput(fStructurePane2.getInput()); - else - fContentInputPane.setInput(getElement(selection)); - } - } - ); - - } - - /** - * Returns the first element of the given selection if the selection - * is a IStructuredSelection with exactly one element. Returns - * null otherwise. - * - * @param selection the selection - * @return the first element of the selection, or null - */ - private static Object getElement(ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - if (ss.size() == 1) - return ss.getFirstElement(); - } - return null; - } - - /** - * Asks this input to take focus within its container (editor). - *

- * Clients should not call this method but they may - * override if they implement a different layout with different visual - * components. Clients are free to call the inherited method. - *

- */ - public void setFocus() { - if (fFocusPane != null) { - Viewer v= fFocusPane.getViewer(); - if (v != null) { - Control c= v.getControl(); - if (c != null) - c.setFocus(); - } - } else if (fComposite != null) - fComposite.setFocus(); - } - - /** - * Factory method for creating a differences viewer for the top left pane. - * It is called from createContents and returns a DiffTreeViewer. - *

- * Subclasses may override if they need a different viewer. - *

- * - * @param parent the SWT parent control under which to create the viewer's SWT controls - * @return a compare viewer for the top left pane - */ - public Viewer createDiffViewer(Composite parent) { - return new DiffTreeViewer(parent, fCompareConfiguration); - } - - /** - * Implements the dynamic viewer switching for structure viewers. - * The method must return a compare viewer based on the old (or current) viewer - * and a new input object. If the old viewer is suitable for showing the new input the old viewer - * can be returned. Otherwise a new viewer must be created under the given parent composite or - * null can be returned to indicate that no viewer could be found. - *

- * This implementation forwards the request to CompareUI.findStructureViewer. - *

- * Subclasses may override to implement a different strategy. - *

- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @return a compare viewer which is suitable for the given input object or null - */ - public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - return CompareUI.findStructureViewer(oldViewer, input, parent, fCompareConfiguration); - } - - /** - * Implements the dynamic viewer switching for content viewers. - * The method must return a compare viewer based on the old (or current) viewer - * and a new input object. If the old viewer is suitable for showing the new input the old viewer - * can be returned. Otherwise a new viewer must be created under the given parent composite or - * null can be returned to indicate that no viewer could be found. - *

- * This implementation forwards the request to CompareUI.findContentViewer. - *

- * Subclasses may override to implement a different strategy. - *

- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @return a compare viewer which is suitable for the given input object or null - */ - public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent) { - - Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, parent, fCompareConfiguration); - - boolean isNewViewer= newViewer != oldViewer; - if (DEBUG) System.out.println("CompareEditorInput.findContentViewer: " + isNewViewer); //$NON-NLS-1$ - - if (isNewViewer && newViewer instanceof IPropertyChangeNotifier) { - final IPropertyChangeNotifier dsp= (IPropertyChangeNotifier) newViewer; - dsp.addPropertyChangeListener(fDirtyStateListener); - - Control c= newViewer.getControl(); - c.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - dsp.removePropertyChangeListener(fDirtyStateListener); - } - } - ); - } - - return newViewer; - } - - /** - * Returns true if there are unsaved changes. - * The value returned is the value of the DIRTY_STATE property of this input object. - - * Returns true if this input has unsaved changes, - * that is if setDirty(true) has been called. - * Subclasses don't have to override if the functionality provided by setDirty
- * is sufficient. - * - * @return true if there are changes that need to be saved - */ - public boolean isSaveNeeded() { - return fDirty || fDirtyViewers.size() > 0; - } - - /** - * Sets the dirty state of this input to the given - * value and sends out a PropertyChangeEvent if the new value differs from the old value. - * - * @param dirty the dirty state for this compare input - */ - public void setDirty(boolean dirty) { - - boolean confirmSave= true; - Object o= fCompareConfiguration.getProperty(CompareEditor.CONFIRM_SAVE_PROPERTY); - if (o instanceof Boolean) - confirmSave= ((Boolean)o).booleanValue(); - - if (!confirmSave) { - fDirty= dirty; - if (!fDirty) - fDirtyViewers.clear(); - } - } - - private void setDirty(Object source, boolean dirty) { - Assert.isNotNull(source); - boolean oldDirty= fDirtyViewers.size() > 0; - if (dirty) - fDirtyViewers.add(source); - else - fDirtyViewers.remove(source); - boolean newDirty= fDirty || fDirtyViewers.size() > 0; - if (DEBUG) System.out.println("setDirty("+source+", "+dirty+"): " + newDirty); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (oldDirty != newDirty) - Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, new Boolean(oldDirty), new Boolean(newDirty)); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.addListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (listener != null) - fListenerList.add(listener); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.removeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - if (listener != null) - fListenerList.remove(listener); - } - - /** - * Save any unsaved changes. - * Empty implementation. - * Subclasses must override to save any changes. - * - * @param pm an IProgressMonitor that the implementation of save may use to show progress - * @deprecated Override method saveChanges instead. - */ - public void save(IProgressMonitor pm) { - // empty default implementation - } - - /** - * Save any unsaved changes. - * Subclasses must override to save any changes. - * This implementation tries to flush changes in all viewers by - * calling ISavable.save on them. - * - * @param pm an IProgressMonitor that the implementation of save may use to show progress - * @throws CoreException - * @since 2.0 - */ - public void saveChanges(IProgressMonitor pm) throws CoreException { - - // flush changes in any dirty viewer - flushViewer(fStructureInputPane, pm); - flushViewer(fStructurePane1, pm); - flushViewer(fStructurePane2, pm); - flushViewer(fContentInputPane, pm); - - save(pm); - } - - private static void flushViewer(CompareViewerSwitchingPane pane, IProgressMonitor pm) throws CoreException { - if (pane != null) { - Viewer v= pane.getViewer(); - if (v instanceof ISavable) - ((ISavable)v).save(pm); - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java deleted file mode 100644 index 222de63ac..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.ResourceBundle; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.content.IContentType; - -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -/** - * The class CompareUI defines the entry point to initiate a configurable - * compare operation on arbitrary resources. The result of the compare - * is opened into a compare editor where the details can be browsed and - * edited in dynamically selected structure and content viewers. - *

- * The Compare UI provides a registry for content and structure compare viewers, - * which is initialized from extensions contributed to extension points - * declared by this plug-in. - */ -public final class CompareUI { - - /** - * Compare Plug-in ID (value "org.eclipse.compare"). - * @since 2.0 - */ - public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$ - - /** - * Image descriptor for the disabled icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_DTOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.DTOOL_NEXT); - /** - * Image descriptor for the normal icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_CTOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.CTOOL_NEXT); - /** - * Image descriptor for the roll-over icon of the 'Next' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_ETOOL_NEXT= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.ETOOL_NEXT); - - /** - * Image descriptor for the disabled icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_DTOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.DTOOL_PREV); - /** - * Image descriptor for the normal icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_CTOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.CTOOL_PREV); - /** - * Image descriptor for the roll-over icon of the 'Previous' tool bar button. - * @since 2.0 - */ - public static final ImageDescriptor DESC_ETOOL_PREV= CompareUIPlugin.getImageDescriptor(CompareUIPlugin.ETOOL_PREV); - - /** - * Name of the title property of a compare viewer. - * If a property with this name is set - * on the top level SWT control of a viewer, it is used as a title in the pane's - * title bar. - */ - public static final String COMPARE_VIEWER_TITLE= "org.eclipse.compare.CompareUI.CompareViewerTitle"; //$NON-NLS-1$ - - private CompareUI() { - // empty implementation - } - - public static AbstractUIPlugin getPlugin() { - return CompareUIPlugin.getDefault(); - } - - /** - * Returns this plug-in's resource bundle. - * - * @return the plugin's resource bundle - */ - public static ResourceBundle getResourceBundle() { - return CompareUIPlugin.getDefault().getResourceBundle(); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result in the currently active workbench page. - * - * @param input the input on which to open the compare editor - */ - public static void openCompareEditor(CompareEditorInput input) { - openCompareEditorOnPage(input, null); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result in the given workbench page. - * - * @param input the input on which to open the compare editor - * @param page the workbench page in which to open the compare editor - * @since 2.1 - */ - public static void openCompareEditorOnPage(CompareEditorInput input, IWorkbenchPage page) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareEditor(input, page, null); - } - - /** - * Performs the comparison described by the given input and - * shows the result in the given editor. - * - * @param input the input on which to open the compare editor - * @param editor the compare editor to reuse or null to create a new one - * @since 3.0 - */ - public static void reuseCompareEditor(CompareEditorInput input, IReusableEditor editor) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareEditor(input, null, editor); - } - - /** - * Performs the comparison described by the given input and opens a - * modal compare dialog on the result. - * - * @param input the input on which to open the compare dialog - */ - public static void openCompareDialog(CompareEditorInput input) { - CompareUIPlugin plugin= CompareUIPlugin.getDefault(); - if (plugin != null) - plugin.openCompareDialog(input); - } - - /** - * Registers an image descriptor for the given type. - * - * @param type the type - * @param descriptor the image descriptor - */ - public static void registerImageDescriptor(String type, ImageDescriptor descriptor) { - CompareUIPlugin.registerImageDescriptor(type, descriptor); - } - - /** - * Returns a shared image for the given type, or a generic image if none - * has been registered for the given type. - *

- * Note: Images returned from this method will be automatically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param type the type - * @return the image - */ - public static Image getImage(String type) { - return CompareUIPlugin.getImage(type); - } - - /** - * Registers the given image for being disposed when this plug-in is shutdown. - * - * @param image the image to register for disposal - */ - public static void disposeOnShutdown(Image image) { - CompareUIPlugin.disposeOnShutdown(image); - } - - /** - * Returns a shared image for the given adaptable. - * This convenience method queries the given adaptable - * for its IWorkbenchAdapter.getImageDescriptor, which it - * uses to create an image if it does not already have one. - *

- * Note: Images returned from this method will be automatically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param adaptable the adaptable for which to find an image - * @return an image - */ - public static Image getImage(IAdaptable adaptable) { - return CompareUIPlugin.getImage(adaptable); - } - - - /** - * Creates a stream merger for the given content type. - * If no stream merger is registered for the given content type null is returned. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public static IStreamMerger createStreamMerger(IContentType type) { - return CompareUIPlugin.getDefault().createStreamMerger(type); - } - - /** - * Creates a stream merger for the given file extension. - * If no stream merger is registered for the file extension null is returned. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public static IStreamMerger createStreamMerger(String type) { - return CompareUIPlugin.getDefault().createStreamMerger(type); - } - - /** - * Returns a structure compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input, the old viewer - * is returned. Otherwise, the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a structure compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - - return CompareUIPlugin.getDefault().findStructureViewer(oldViewer, input, parent, configuration); - } - - /** - * Returns a content compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input the old viewer - * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a content compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a content viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - return CompareUIPlugin.getDefault().findContentViewer(oldViewer, input, parent, configuration); - } - - /** - * Returns a content compare viewer based on an old viewer and an input - * object. If the old viewer is suitable for showing the input the old - * viewer is returned. Otherwise the input's type is used to find a viewer - * descriptor in the registry which in turn is used to create a content - * compare viewer under the given parent composite. In order to determine - * the input's type, the input must either implement IStreamContentAccessor - * and ITypedElement or ICompareInput. If no viewer descriptor can be found - * null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a content viewer. Must - * implement either IStreamContentAccessor and - * ITypedElement or ICompareInput. - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public static Viewer findContentViewer(Viewer oldViewer, Object input, Composite parent, - CompareConfiguration configuration) { - - return CompareUIPlugin.getDefault().findContentViewer(oldViewer, input, parent, configuration); - } - - /** - * Adds an alias for the given type. - * Subsequent calls to findStructureViewer - * treat alias as a synonym for type and return the same viewer. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param type a type name for which a viewer has been registered - * @param alias a type name which should be treated as a synonym of type - * @since 2.0 - */ - public static void addStructureViewerAlias(String type, String alias) { - CompareUIPlugin.getDefault().addStructureViewerAlias(type, alias); - } - - /** - * Remove all aliases for the given type. This method does not affect - * the initial binding between type and viewer. If no aliases exist for the - * given type this method does nothing. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param type the type name for which all synonymes are removed. - * @since 2.0 - */ - public static void removeAllStructureViewerAliases(String type) { - CompareUIPlugin.getDefault().removeAllStructureViewerAliases(type); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java deleted file mode 100644 index 646f99092..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.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.compare; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.action.ToolBarManager; - -/** - * A CompareViewerPane is a convenience class which installs a - * CLabel and a Toolbar in a ViewForm. - *

- * Double clicking onto the CompareViewerPane's title bar maximizes - * the CompareViewerPane to the size of an enclosing Splitter - * (if there is one). - * If more Splitters are nested maximizing walks up and - * maximizes to the outermost Splitter. - * - * @since 2.0 - */ -public class CompareViewerPane extends ViewForm { - - private ToolBarManager fToolBarManager; - - /** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * - * @param container a widget which will be the container of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException

    - *
  • ERROR_NULL_ARGUMENT - if the parent is null
  • - *
- * @exception org.eclipse.swt.SWTException
    - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • - *
- */ - public CompareViewerPane(Composite container, int style) { - super(container, style); - - marginWidth= 0; - marginHeight= 0; - - CLabel label= new CLabel(this, SWT.NONE) { - public Point computeSize(int wHint, int hHint, boolean changed) { - return super.computeSize(wHint, Math.max(24, hHint), changed); - } - }; - setTopLeft(label); - - MouseAdapter ml= new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - Control content= getContent(); - if (content != null && content.getBounds().contains(e.x, e.y)) - return; - Control parent= getParent(); - if (parent instanceof Splitter) - ((Splitter)parent).setMaximizedControl(CompareViewerPane.this); - } - }; - - addMouseListener(ml); - label.addMouseListener(ml); - - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fToolBarManager != null) { - fToolBarManager.removeAll(); - fToolBarManager= null; - } - } - }); - } - - /** - * Set the pane's title text. - * The value null clears it. - * - * @param label the text to be displayed in the pane or null - */ - public void setText(String label) { - CLabel cl= (CLabel) getTopLeft(); - if (cl != null) - cl.setText(label); - } - - /** - * Set the pane's title Image. - * The value null clears it. - * - * @param image the image to be displayed in the pane or null - */ - public void setImage(Image image) { - CLabel cl= (CLabel) getTopLeft(); - if (cl != null) - cl.setImage(image); - } - - /** - * Returns a ToolBarManager if the given parent is a - * CompareViewerPane or null otherwise. - * - * @param parent a Composite or null - * @return a ToolBarManager if the given parent is a CompareViewerPane otherwise null - */ - public static ToolBarManager getToolBarManager(Composite parent) { - if (parent instanceof CompareViewerPane) { - CompareViewerPane pane= (CompareViewerPane) parent; - return pane.getToolBarManager(); - } - return null; - } - - /** - * Clears tool items in the CompareViewerPane's control bar. - * - * @param parent a Composite or null - */ - public static void clearToolBar(Composite parent) { - ToolBarManager tbm= getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - tbm.update(true); - } - } - - //---- private stuff - - private ToolBarManager getToolBarManager() { - if (fToolBarManager == null) { - ToolBar tb= new ToolBar(this, SWT.FLAT); - setTopCenter(tb); - fToolBarManager= new ToolBarManager(tb); - } - return fToolBarManager; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java deleted file mode 100644 index 1b5c92d8f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java +++ /dev/null @@ -1,369 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.text.MessageFormat; - -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -/** - * A custom CompareViewerPane that supports dynamic viewer switching. - * - *

- * Clients must implement the viewer switching strategy by implementing - * the getViewer(Viewer, Object) method. - *

- * If a property with the name CompareUI.COMPARE_VIEWER_TITLE is set - * on the top level SWT control of a viewer, it is used as a title in the CompareViewerPane's - * title bar. - * - * @since 2.0 - */ -public abstract class CompareViewerSwitchingPane extends CompareViewerPane - implements ISelectionChangedListener, ISelectionProvider, IDoubleClickListener { - - private Viewer fViewer; - private Object fInput; - private ListenerList fSelectionListeners= new ListenerList(); - private ListenerList fDoubleClickListener= new ListenerList(); - private ListenerList fOpenListener= new ListenerList(); - private boolean fControlVisibility= false; - private String fTitle; - private String fTitleArgument; - - private IOpenListener fOpenHandler= new IOpenListener() { - public void open(OpenEvent event) { - Object[] listeners= fOpenListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IOpenListener) listeners[i]).open(event); - } - }; - - /** - * Creates a CompareViewerSwitchingPane as a child of the given parent and with the - * specified SWT style bits. - * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException

    - *
  • ERROR_NULL_ARGUMENT - if the parent is null
  • - *
- * @exception org.eclipse.swt.SWTException
    - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • - *
- */ - public CompareViewerSwitchingPane(Composite parent, int style) { - this(parent, style, false); - } - - /** - * Creates a CompareViewerSwitchingPane as a child of the given parent and with the - * specified SWT style bits. - * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * @param visibility the initial visibility of the CompareViewerSwitchingPane - * - * @exception IllegalArgumentException
    - *
  • ERROR_NULL_ARGUMENT - if the parent is null
  • - *
- * @exception org.eclipse.swt.SWTException
    - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • - *
- */ - public CompareViewerSwitchingPane(Composite parent, int style, boolean visibility) { - super(parent, style); - - fControlVisibility= visibility; - - setViewer(new NullViewer(this)); - - addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fViewer != null) - fViewer.removeSelectionChangedListener(CompareViewerSwitchingPane.this); - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.removeDoubleClickListener(CompareViewerSwitchingPane.this); - sv.removeOpenListener(fOpenHandler); - } - fViewer= null; - fInput= null; - fSelectionListeners= null; - } - } - ); - } - - /** - * Returns the current viewer. - * - * @return the current viewer - */ - public Viewer getViewer() { - return fViewer; - } - - private void setViewer(Viewer newViewer) { - - if (newViewer == fViewer) - return; - - boolean oldEmpty= isEmpty(); - - if (fViewer != null) { - - fViewer.removeSelectionChangedListener(this); - - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.removeDoubleClickListener(this); - sv.removeOpenListener(fOpenHandler); - } - - Control content= getContent(); - setContent(null); - - fViewer.setInput(null); - - if (content != null && !content.isDisposed()) - content.dispose(); - - } else - oldEmpty= false; - setContent(null); - - fViewer= newViewer; - - if (fViewer != null) { - // we have to remember and restore the old visibility of the CustomPane - // since setContent changes the visibility - boolean old= getVisible(); - setContent(fViewer.getControl()); - setVisible(old); // restore old visibility - - boolean newEmpty= isEmpty(); - - fViewer.addSelectionChangedListener(this); - - if (fViewer instanceof StructuredViewer) { - StructuredViewer sv= (StructuredViewer) fViewer; - sv.addDoubleClickListener(this); - sv.addOpenListener(fOpenHandler); - } - - if (oldEmpty != newEmpty) { // relayout my container - Composite parent= getParent(); - if (parent instanceof Splitter) - ((Splitter)parent).setVisible(this, fControlVisibility ? !newEmpty : true); - } - - layout(true); - } - } - - /** - * Returns the optional title argument that has been set with setTitelArgument - * or null if no optional title argument has been set. - *

- * Note: this method is for internal use only. Clients should not call this method. - * - * @return the optional title argument or null - */ - public String getTitleArgument() { - return fTitleArgument; - } - - /** - * Returns true if no viewer is installed or if the current viewer - * is a NullViewer. - * - * @return true if no viewer is installed or if the current viewer is a NullViewer - */ - public boolean isEmpty() { - return fViewer == null || fViewer instanceof NullViewer; - } - - public void addSelectionChangedListener(ISelectionChangedListener l) { - fSelectionListeners.add(l); - } - - public void removeSelectionChangedListener(ISelectionChangedListener l) { - fSelectionListeners.remove(l); - } - - public void addDoubleClickListener(IDoubleClickListener l) { - fDoubleClickListener.add(l); - } - - public void removeDoubleClickListener(IDoubleClickListener l) { - fDoubleClickListener.remove(l); - } - - public void addOpenListener(IOpenListener l) { - fOpenListener.add(l); - } - - public void removeOpenListener(IOpenListener l) { - fOpenListener.remove(l); - } - - public void doubleClick(DoubleClickEvent event) { - Object[] listeners= fDoubleClickListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IDoubleClickListener) listeners[i]).doubleClick(event); - } - - public ISelection getSelection() { - if (fViewer != null) - return fViewer.getSelection(); - return null; - } - - public void setSelection(ISelection s) { - if (fViewer != null) - fViewer.setSelection(s); - } - - public void selectionChanged(SelectionChangedEvent ev) { - Object[] listeners= fSelectionListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((ISelectionChangedListener) listeners[i]).selectionChanged(ev); - } - - private boolean hasFocus2() { - // do we have focus? - Display display= getDisplay(); - if (display != null) - for (Control focus= display.getFocusControl(); focus != null; focus= focus.getParent()) - if (focus == this) - return true; - return false; - } - - /** - * Sets the input object of this pane. - * For this input object a suitable viewer is determined by calling the abstract - * method getViewer(Viewer, Object). - * If the returned viewer differs from the current one, the old viewer - * is disposed and the new one installed. Then the input object is fed - * into the newly installed viewer by calling its setInput(Object) method. - * If new and old viewer don't differ no new viewer is installed but just - * setInput(Object) is called. - * If the input is null the pane is cleared, - * that is the current viewer is disposed. - * - * @param input the new input object or null - */ - public void setInput(Object input) { - - if (fInput == input) - return; - - boolean hadFocus= hasFocus2(); - - fInput= input; - - // viewer switching - Viewer newViewer= null; - if (input != null) - newViewer= getViewer(fViewer, input); - - if (newViewer == null) { - if (fViewer instanceof NullViewer) - return; - newViewer= new NullViewer(this); - } - - setViewer(newViewer); - - // set input - fViewer.setInput(input); - - Image image= null; - if (!(fViewer instanceof NullViewer) && input instanceof ICompareInput) - image= ((ICompareInput)input).getImage(); - setImage(image); - - String title= null; - if (fViewer != null) { - Control c= fViewer.getControl(); - if (c != null) { - Object data= c.getData(CompareUI.COMPARE_VIEWER_TITLE); - if (data instanceof String) - title= (String) data; - if (hadFocus) - c.setFocus(); - } - } - - fTitle= title; - updateTitle(); - } - - /** - * Sets an additional and optional argument for the pane's title. - * Note: this method is for internal use only. Clients should not call this method. - * - * @param argument an optional argument for the pane's title - */ - public void setTitleArgument(String argument) { - fTitleArgument= argument; - updateTitle(); - } - - private void updateTitle() { - if (fTitle != null) { - if (fTitleArgument != null) { - String format= CompareMessages.getString("CompareViewerSwitchingPane.Titleformat"); //$NON-NLS-1$ - String t= MessageFormat.format(format, new String[] { fTitle, fTitleArgument } ); - setText(t); - } else - setText(fTitle); - } else { - setText(""); //$NON-NLS-1$ - } - } - - /** - * Returns the current input of this pane or null if the pane has no input. - * - * @return an Object that is the input to this pane or null if the pane has no input. - */ - public Object getInput() { - return fInput; - } - - /** - * Returns a viewer which is able to display the given input. - * If no viewer can be found, null is returned. - * The additional argument oldViewer represents the viewer currently installed - * in the pane (or null if no viewer is installed). - * It can be returned from this method if the current viewer can deal with the - * input (and no new viewer must be created). - * - * @param oldViewer the currently installed viewer or null - * @param input the input object for which a viewer must be determined or null - * @return a viewer for the given input, or null if no viewer can be determined - */ - abstract protected Viewer getViewer(Viewer oldViewer, Object input); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java deleted file mode 100644 index 229101703..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java +++ /dev/null @@ -1,1128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.ResourceBundle; -import java.util.Date; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.HashSet; -import java.util.Calendar; -import java.util.Comparator; -import java.text.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Button; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.dialogs.*; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A dialog where one input element can be compared against - * a list of historic variants (editions) of the same input element. - * The dialog can be used to implement functions like "Compare/Replace with Version" or - * "Compare/Replace from Local History" on workspace resources. - *

- * In addition it is possible to specify a subsection of the input element - * (e.g. a method in a Java source file) by means of a "path". - * In this case the dialog compares only the subsection (as specified by the path) - * with the corresponding subsection in the list of editions. - * Only those editions are shown where the subsection differs from the same subsection in - * another edition thereby minimizing the number of presented variants. - * This functionality can be used to implement "Replace from Local History" - * for the Java language. - *

- * Subsections of an input element are determined by first finding an - * IStructureCreator for the input's type. - * Then the method locate is used to extract the subsection. - *

- * Each edition (variant in the list of variants) must implement the IModificationDate interface - * so that the dialog can sort the editions and present them in a tree structure where every - * node corresponds one day. - *

- * The functionality is surfaced in a single function selectEdition. - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * - * @see IModificationDate - * @see ITypedElement - */ -public class EditionSelectionDialog extends ResizableDialog { - - /** - * An item in an underlying edition. - */ - private static class Pair { - - private ITypedElement fEdition; - private ITypedElement fItem; - private String fContent; - private IStructureCreator fStructureCreator; - private boolean fHasError= false; - - Pair(IStructureCreator structureCreator, ITypedElement edition, ITypedElement item) { - fStructureCreator= structureCreator; - fEdition= edition; - fItem= item; - } - - Pair(IStructureCreator structureCreator, ITypedElement edition) { - this(structureCreator, edition, edition); - } - - ITypedElement getEdition() { - return fEdition; - } - - ITypedElement getItem() { - return fItem; - } - - /* - * The content is lazily loaded - */ - private String getContent() { - if (fContent == null) { - if (fStructureCreator != null) - fContent= fStructureCreator.getContents(fItem, false); - else { - if (fItem instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) fItem; - try { - fContent= Utilities.readString(sca); - } catch (CoreException ex) { - // NeedWork - } - } - } - if (fContent == null) - fContent= ""; //$NON-NLS-1$ - } - return fContent; - } - - public boolean equals(Object other) { - if (other != null && other.getClass() == getClass()) { - if (getContent().equals(((Pair)other).getContent())) - return true; - } - return super.equals(other); - } - } - - // Configuration options - private CompareConfiguration fCompareConfiguration; - private ArrayList fArrayList= new ArrayList(); - /** use a side-by-side compare viewer */ - private boolean fCompare= true; - /** show target on right hand side */ - private boolean fTargetIsRight= false; - /** hide entries which have identical content */ - private boolean fHideIdentical= true; - /** add mode if true, otherwise replace mode */ - private boolean fAddMode= false; - /** compare mode if true, otherwise replace/add mode */ - private boolean fCompareMode= false; - /** perform structure compare on editions */ - private boolean fStructureCompare= false; - /** allow for multiple selection */ - private boolean fMultiSelect= false; - - /** - * Maps from members to their corresponding editions. - * Has only a single entry if dialog is used in "Replace" (and not "Add") mode. - */ - private HashMap fMemberEditions; - /** - * Maps from members to their corresponding selected edition. - */ - private HashMap fMemberSelection; - /** The editions of the current selected member */ - private List fCurrentEditions; - private Thread fThread; - private Pair fTargetPair; - /** The selected edition in the edition viewer */ - private ITypedElement fSelectedItem; - private String fTitleArg; - private Image fTitleImage; - - // SWT controls - private CompareViewerSwitchingPane fContentPane; - private Button fCommitButton; - private Table fMemberTable; - private CompareViewerPane fMemberPane; - private Tree fEditionTree; - private CompareViewerPane fEditionPane; - private Image fDateImage; - private Image fTimeImage; - private CompareViewerSwitchingPane fStructuredComparePane; - - /** - * Creates a new modal, resizable dialog. - * Various titles, icons, and labels are configured from the given resource bundle. - * The following resource keys are used: - *
-	 *	key         type          description
-	 *	title       String        dialog title
-	 *	width       Integer       initial width of dialog
-	 *	height      Integer       initial height of dialog
-	 *	treeTitleFormat   MessageFormat pane title for edition tree; arg 0 is the target
-	 *	dateIcon    String        icon for node in edition tree; path relative to plugin
-	 *	timeIcon    String        icon for leaf in edition tree; path relative to plugin
-	 *	todayFormat MessageFormat format string if date is todays date; arg 0 is date
-	 *	yesterdayFormat MessageFormat format string if date is yesterdays date; arg 0 is date
-	 *	dayFormat   MessageFormat format string if date is any other date; arg 0 is date
-	 *	editionLabel String       label for editions side of compare viewer; arg 0 is the date
-	 *	targetLabel  String       label for target side of compare viewer 
-	 *  buttonLabel  String       label for OK button; default is IDialogConstants.OK_LABEL
-	 * 
- * - * @param parent if not null the new dialog stays on top of this parent shell - * @param bundle ResourceBundle to configure the dialog - */ - public EditionSelectionDialog(Shell parent, ResourceBundle bundle) { - super(parent, bundle); - } - - private CompareConfiguration getCompareConfiguration() { - if (fCompareConfiguration == null) { - fCompareConfiguration= new CompareConfiguration(); - fCompareConfiguration.setLeftEditable(false); - fCompareConfiguration.setRightEditable(false); - } - return fCompareConfiguration; - } - - /** - * Sets an additional and optional argument for the edition pane's title. - * - * @param titleArgument an optional argument for the edition pane's title - * @since 2.0 - */ - public void setEditionTitleArgument(String titleArgument) { - fTitleArg= titleArgument; - } - - /** - * Sets an optional image for the edition pane's title. - * - * @param titleImage an optional image for the edition pane's title - * @since 2.0 - */ - public void setEditionTitleImage(Image titleImage) { - fTitleImage= titleImage; - } - - /** - * Select the previous edition (presenting a UI). - * - * @param target the input object against which the editions are compared; must not be null - * @param inputEditions the list of editions (element type: ITypedElements) - * @param ppath If null dialog shows full input; if non null it extracts a subsection - * @return returns the selected edition or null if error occurred. - * The returned ITypedElement is one of the original editions - * if path was null; otherwise - * it is an ITypedElement returned from IStructureCreator.locate(path, item) - * @since 2.0 - */ - public ITypedElement selectPreviousEdition(final ITypedElement target, ITypedElement[] inputEditions, Object ppath) { - Assert.isNotNull(target); - fTargetPair= new Pair(null, target); - - // sort input editions - final int count= inputEditions.length; - final IModificationDate[] editions= new IModificationDate[count]; - for (int i= 0; i < count; i++) - editions[i]= (IModificationDate) inputEditions[i]; - if (count > 1) - internalSort(editions); - - // find StructureCreator if ppath is not null - IStructureCreator structureCreator= null; - if (ppath != null) { - String type= target.getType(); - StructureCreatorDescriptor scd= CompareUIPlugin.getDefault().getStructureCreator(type); - if (scd != null) - structureCreator= scd.createStructureCreator(); - } - - if (fAddMode) { - // does not work in add mode - return null; - } - - if (structureCreator != null) { - Pair pair= createPair(structureCreator, ppath, target); - if (pair != null) - fTargetPair= pair; - else - ppath= null; // couldn't extract item because of error - } - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - ITypedElement edition= (ITypedElement) editions[i]; - Pair pair= null; - - if (structureCreator != null && ppath != null) { - // extract sub element from edition - pair= createPair(structureCreator, ppath, edition); - } else { - pair= new Pair(null, edition); - } - - if (pair != null && pair.fHasError) - return null; - - if (pair != null && !fTargetPair.equals(pair)) { - return pair.fItem; - } - } - - // nothing found - return null; - } - - /** - * Presents this modal dialog with the functionality described in the class comment above. - * - * @param target the input object against which the editions are compared; must not be null - * @param inputEditions the list of editions (element type: ITypedElements) - * @param ppath If null dialog shows full input; if non null it extracts a subsection - * @return returns the selected edition or null if dialog was cancelled. - * The returned ITypedElement is one of the original editions - * if path was null; otherwise - * it is an ITypedElement returned from IStructureCreator.locate(path, item) - */ - public ITypedElement selectEdition(final ITypedElement target, ITypedElement[] inputEditions, Object ppath) { - - Assert.isNotNull(target); - fTargetPair= new Pair(null, target); - - // sort input editions - final int count= inputEditions.length; - final IModificationDate[] editions= new IModificationDate[count]; - for (int i= 0; i < count; i++) - editions[i]= (IModificationDate) inputEditions[i]; - if (count > 1) - internalSort(editions); - - // find StructureCreator if ppath is not null - IStructureCreator structureCreator= null; - if (ppath != null) { - String type= target.getType(); - StructureCreatorDescriptor scd= CompareUIPlugin.getDefault().getStructureCreator(type); - if (scd != null) - structureCreator= scd.createStructureCreator(); - } - - if (!fAddMode) { - // replace mode - - if (structureCreator != null) { - Pair pair= createPair(structureCreator, ppath, target); - if (pair != null) - fTargetPair= pair; - else - ppath= null; // couldn't extract item because of error - } - - // set the left and right labels for the compare viewer - String targetLabel= getTargetLabel(target, fTargetPair.getItem()); - if (fTargetIsRight) - getCompareConfiguration().setRightLabel(targetLabel); - else - getCompareConfiguration().setLeftLabel(targetLabel); - - if (structureCreator != null && ppath != null) { // extract sub element - - final IStructureCreator sc= structureCreator; - final Object path= ppath; - - // construct the comparer thread - // and perform the background extract - fThread= new Thread() { - public void run() { - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - if (fEditionTree == null || fEditionTree.isDisposed()) - break; - ITypedElement edition= (ITypedElement) editions[i]; - - // extract sub element from edition - Pair pair= createPair(sc, path, edition); - if (pair != null) - sendPair(pair); - } - sendPair(null); - } - }; - } else { - // create tree widget - create(); - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) - addMemberEdition(new Pair(null, (ITypedElement) editions[i])); - } - - } else { - // add mode - final Object container= ppath; - Assert.isNotNull(container); - - if (structureCreator == null) - return null; // error - - // extract all elements of container - final HashSet current= new HashSet(); - IStructureComparator sco= structureCreator.locate(container, target); - if (sco != null) { - Object[] children= sco.getChildren(); - if (children != null) - for (int i= 0; i < children.length; i++) - current.add(children[i]); - } - - final IStructureCreator sc= structureCreator; - - // construct the comparer thread - // and perform the background extract - fThread= new Thread() { - public void run() { - - // from front (newest) to back (oldest) - for (int i= 0; i < count; i++) { - - if (fEditionTree == null || fEditionTree.isDisposed()) - break; - ITypedElement edition= (ITypedElement) editions[i]; - - IStructureComparator sco2= sc.locate(container, edition); - if (sco2 != null) { - Object[] children= sco2.getChildren(); - if (children != null) { - for (int i2= 0; i2 < children.length; i2++) { - ITypedElement child= (ITypedElement) children[i2]; - if (!current.contains(child)) - sendPair(new Pair(sc, edition, child)); - } - } - } - } - sendPair(null); - } - }; - } - - open(); - - if (getReturnCode() == OK) - return fSelectedItem; - return null; - } - - private Pair createPair(IStructureCreator sc, Object path, ITypedElement input) { - IStructureComparator scmp= sc.locate(path, input); - if (scmp == null && sc.getStructure(input) == null) { // parse error - Pair p= new Pair(sc, input); - p.fHasError= true; - return p; - } - if (scmp instanceof ITypedElement) - return new Pair(sc, input, (ITypedElement) scmp); - return null; - } - - /** - * Controls whether identical entries are shown or not (default). - * This method must be called before selectEdition. - * - * @param hide if true identical entries are hidden; otherwise they are shown. - * @since 2.0 - */ - public void setHideIdenticalEntries(boolean hide) { - fHideIdentical= hide; - } - - /** - * Controls whether workspace target is on the left (the default) or right hand side. - * - * @param isRight if true target is shown on right hand side. - * @since 2.0 - */ - public void setTargetIsRight(boolean isRight) { - fTargetIsRight= isRight; - } - - /** - * Controls whether the EditionSelectionDialog is in 'add' mode - * or 'replace' mode (the default). - * - * @param addMode if true dialog is in 'add' mode. - * @since 2.0 - */ - public void setAddMode(boolean addMode) { - fAddMode= addMode; - fMultiSelect= addMode; - } - - /** - * Controls whether the EditionSelectionDialog is in 'compare' mode - * or 'add/replace' (the default) mode. - * - * @param compareMode if true dialog is in 'add' mode. - * @since 2.0 - */ - public void setCompareMode(boolean compareMode) { - fCompareMode= compareMode; - fStructureCompare= fCompareMode && !fAddMode; - } - - /** - * Returns the input target that has been specified with the most recent call - * to selectEdition. If a not null path was specified this method - * returns a subsection of this target (IStructureCreator.locate(path, target)) - * instead of the input target. - *

- * For example if the target is a Java compilation unit and path specifies - * a method, the value returned from getTarget will be the method not the compilation unit. - * - * @return the last specified target or a subsection thereof. - */ - public ITypedElement getTarget() { - return fTargetPair.getItem(); - } - - /** - * Returns the editions that have been selected with the most - * recent call to selectEdition. - * - * @return the selected editions as an array. - * @since 2.1 - */ - public ITypedElement[] getSelection() { - ArrayList result= new ArrayList(); - if (fMemberSelection != null) { - Iterator iter= fArrayList.iterator(); - for (int i= 0; iter.hasNext(); i++) { - Object edition= iter.next(); - Object item= fMemberSelection.get(edition); - if (item != null) - result.add(item); - } - } else if (fSelectedItem != null) - result.add(fSelectedItem); - return (ITypedElement[]) result.toArray(new ITypedElement[result.size()]); - } - - /** - * Returns a label for identifying the target side of a compare viewer. - * This implementation extracts the value for the key "targetLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the name of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param target the target element for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given target; otherwise the same as target - * @return a label the target side of a compare viewer - */ - protected String getTargetLabel(ITypedElement target, ITypedElement item) { - String format= null; - if (target instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceTargetLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "targetLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - return MessageFormat.format(format, new Object[] { target.getName() }); - } - - /** - * Returns a label for identifying the edition side of a compare viewer. - * This implementation extracts the value for the key "editionLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param selectedEdition the selected edition for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given selectedEdition; otherwise the same as selectedEdition - * @return a label for the edition side of a compare viewer - */ - protected String getEditionLabel(ITypedElement selectedEdition, ITypedElement item) { - String format= null; - if (selectedEdition instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceEditionLabel", null); //$NON-NLS-1$ - else if (selectedEdition instanceof HistoryItem) - format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - - String date= ""; //$NON-NLS-1$ - if (selectedEdition instanceof IModificationDate) { - long modDate= ((IModificationDate)selectedEdition).getModificationDate(); - date= DateFormat.getDateTimeInstance().format(new Date(modDate)); - } - - return MessageFormat.format(format, new Object[] { date }); - } - - /** - * Returns a label for identifying a node in the edition tree viewer. - * This implementation extracts the value for the key "workspaceTreeFormat" or - * "treeFormat" (in that order) from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param edition the edition for which a label must be returned - * @param item if a path has been specified in edition a sub element of the given edition; otherwise the same as edition - * @param date this date will be returned as part of the formatted string - * @return a label of a node in the edition tree viewer - * @since 2.0 - */ - protected String getShortEditionLabel(ITypedElement edition, ITypedElement item, Date date) { - String format= null; - if (edition instanceof ResourceNode) - format= Utilities.getString(fBundle, "workspaceTreeFormat", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "treeFormat", null); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - String ds= DateFormat.getTimeInstance().format(date); - return MessageFormat.format(format, new Object[] { ds }); - } - - /** - * Returns an image for identifying the edition side of a compare viewer. - * This implementation extracts the value for the key "editionLabel" from the resource bundle - * and passes it as the format argument to MessageFormat.format. - * The single format argument for MessageFormat.format ("{0}" in the format string) - * is the formatted modification date of the given input element. - *

- * Subclasses may override to create their own label. - *

- * - * @param selectedEdition the selected edition for which a label must be returned - * @param item if a path has been specified in selectEdition a sub element of the given selectedEdition; otherwise the same as selectedEdition - * @return a label the edition side of a compare viewer - * @since 2.0 - */ - protected Image getEditionImage(ITypedElement selectedEdition, ITypedElement item) { - if (selectedEdition instanceof ResourceNode) - return selectedEdition.getImage(); - if (selectedEdition instanceof HistoryItem) { - if (fTimeImage == null) { - String iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fTimeImage= id.createImage(); - } - return fTimeImage; - } - return null; - } - - /* (non Javadoc) - * Creates SWT control tree. - */ - protected synchronized Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - Splitter vsplitter= new Splitter(parent, SWT.VERTICAL); - vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - vsplitter.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fCompareConfiguration != null) { - fCompareConfiguration.dispose(); - fCompareConfiguration= null; - } - if (fDateImage != null) { - fDateImage.dispose(); - fDateImage= null; - } - if (fTimeImage != null) { - fTimeImage.dispose(); - fTimeImage= null; - } - } - } - ); - - if (fAddMode) { - // we need two panes: the left for the elements, the right one for the editions - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - fMemberPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - fMemberPane.setText(Utilities.getString(fBundle, "memberPaneTitle")); //$NON-NLS-1$ - - int flags= SWT.H_SCROLL + SWT.V_SCROLL; - if (fMultiSelect) - flags|= SWT.CHECK; - fMemberTable= new Table(fMemberPane, flags); - fMemberTable.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (e.detail == SWT.CHECK) { - if (e.item instanceof TableItem) { - TableItem ti= (TableItem) e.item; - Object data= ti.getData(); - if (ti.getChecked()) - fArrayList.add(data); - else - fArrayList.remove(data); - - if (fCommitButton != null) - fCommitButton.setEnabled(fArrayList.size() > 0); - - fMemberTable.setSelection(new TableItem[] { ti }); - } - } - handleMemberSelect(e.item); - } - } - ); - fMemberPane.setContent(fMemberTable); - fMemberTable.setFocus(); - - fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - } else { - if (fStructureCompare) { - // we need two panes: the left for the elements, the right one for the structured diff - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - fStructuredComparePane= new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, true) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return CompareUI.findStructureViewer(oldViewer, (ICompareInput)input, this, getCompareConfiguration()); - return null; - } - }; - fStructuredComparePane.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feedInput2(e.getSelection()); - } - } - ); - } else { - // only a single pane showing the editions - fEditionPane= new CompareViewerPane(vsplitter, SWT.BORDER | SWT.FLAT); - } - if (fTitleArg == null) - fTitleArg= fTargetPair.getItem().getName(); - String titleFormat= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(titleFormat, new String[] { fTitleArg }); - fEditionPane.setText(title); - if (fTitleImage != null) - fEditionPane.setImage(fTitleImage); - } - - fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL + SWT.V_SCROLL); - fEditionTree.addSelectionListener( - new SelectionAdapter() { -// public void widgetDefaultSelected(SelectionEvent e) { -// handleDefaultSelected(); -// } - public void widgetSelected(SelectionEvent e) { - feedInput(e.item); - } - } - ); - fEditionPane.setContent(fEditionTree); - - // now start the thread (and forget about it) - if (fThread != null) { - fThread.start(); - fThread= null; - } - - fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, input, this, getCompareConfiguration()); - } - }; - vsplitter.setWeights(new int[] { 30, 70 }); - - applyDialogFont(parent); - return parent; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$ - if (fCompareMode) { - // only a 'Done' button - createButton(parent, IDialogConstants.CANCEL_ID, buttonLabel, false); - } else { - // a 'Cancel' and a 'Add/Replace' button - fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true); - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - } - - /** - * Overidden to disable dismiss on double click in compare mode. - * @since 2.0 - */ - protected void okPressed() { - if (fCompareMode) { - // don't dismiss dialog - } else - super.okPressed(); - } - - //---- private stuff ---------------------------------------------------------------------------------------- - - /* - * Asynchroneously sends a Pair (or null) to the UI thread. - */ - private void sendPair(final Pair pair) { - if (fEditionTree != null && !fEditionTree.isDisposed()) { - Display display= fEditionTree.getDisplay(); - display.asyncExec( - new Runnable() { - public void run() { - addMemberEdition(pair); - } - } - ); - } - } - - private static void internalSort(IModificationDate[] keys) { - Arrays.sort(keys, new Comparator() { - public int compare(Object o1, Object o2) { - IModificationDate d1= (IModificationDate) o1; - IModificationDate d2= (IModificationDate) o2; - long d= d2.getModificationDate() - d1.getModificationDate(); - if (d < 0) - return -1; - if (d > 0) - return 1; - return 0; - } - }); - } - - /* - * Adds the given Pair to the member editions. - * If HIDE_IDENTICAL is true the new Pair is only added if its contents - * is different from the preceeding Pair. - * If the argument is null the message "No Editions found" is shown - * in the member or edition viewer. - */ - private void addMemberEdition(Pair pair) { - - if (pair == null) { // end of list of pairs - if (fMemberTable != null) { - if (!fMemberTable.isDisposed() && fMemberTable.getItemCount() == 0) { - if (fMultiSelect) { - fMemberTable.dispose(); - fMemberTable= new Table(fMemberPane, SWT.NONE); - fMemberPane.setContent(fMemberTable); - } - TableItem ti= new TableItem(fMemberTable, SWT.NONE); - ti.setText(Utilities.getString(fBundle, "noAdditionalMembersMessage")); //$NON-NLS-1$ - } - return; - } - if (fEditionTree != null && !fEditionTree.isDisposed() && fEditionTree.getItemCount() == 0) { - TreeItem ti= new TreeItem(fEditionTree, SWT.NONE); - ti.setText(Utilities.getString(fBundle, "notFoundInLocalHistoryMessage")); //$NON-NLS-1$ - } - return; - } - - if (fMemberEditions == null) - fMemberEditions= new HashMap(); - if (fMultiSelect && fMemberSelection == null) - fMemberSelection= new HashMap(); - - ITypedElement item= pair.getItem(); - List editions= (List) fMemberEditions.get(item); - if (editions == null) { - editions= new ArrayList(); - fMemberEditions.put(item, editions); - if (fMemberTable != null && !fMemberTable.isDisposed()) { - ITypedElement te= item; - String name= te.getName(); - - // find position - TableItem[] items= fMemberTable.getItems(); - int where= items.length; - for (int i= 0; i < where; i++) { - String n= items[i].getText(); - if (n.compareTo(name) > 0) { - where= i; - break; - } - } - - TableItem ti= new TableItem(fMemberTable, where, SWT.NULL); - ti.setImage(te.getImage()); - ti.setText(name); - ti.setData(editions); - } - } - if (fHideIdentical) { - Pair last= fTargetPair; - int size= editions.size(); - if (size > 0) - last= (Pair) editions.get(size-1); - if (last != null && last.equals(pair)) - return; // don't add since the new one is equal to old - } - editions.add(pair); - - if (!fAddMode || editions == fCurrentEditions) - addEdition(pair); - } - - /* - * Returns the number of s since Jan 1st, 1970. - * The given date is converted to GMT and daylight saving is taken into account too. - */ - private long dayNumber(long date) { - int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds - - Calendar calendar= Calendar.getInstance(); - long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); - - return (date + localTimeOffset) / ONE_DAY_MS; - } - - /* - * Adds the given Pair to the edition tree. - * It takes care of creating tree nodes for different dates. - */ - private void addEdition(Pair pair) { - if (fEditionTree == null || fEditionTree.isDisposed()) - return; - - // find last day - TreeItem[] days= fEditionTree.getItems(); - TreeItem lastDay= null; - if (days.length > 0) - lastDay= days[days.length-1]; - - boolean first= lastDay == null; - - ITypedElement edition= pair.getEdition(); - ITypedElement item= pair.getItem(); - - long ldate= ((IModificationDate)edition).getModificationDate(); - long day= dayNumber(ldate); - Date date= new Date(ldate); - if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) { - lastDay= new TreeItem(fEditionTree, SWT.NONE); - if (fDateImage == null) { - String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fDateImage= id.createImage(); - } - lastDay.setImage(fDateImage); - String df= DateFormat.getDateInstance().format(date); - long today= dayNumber(System.currentTimeMillis()); - - String formatKey; - if (day == today) - formatKey= "todayFormat"; //$NON-NLS-1$ - else if (day == today-1) - formatKey= "yesterdayFormat"; //$NON-NLS-1$ - else - formatKey= "dayFormat"; //$NON-NLS-1$ - String pattern= Utilities.getString(fBundle, formatKey); - if (pattern != null) - df= MessageFormat.format(pattern, new String[] { df }); - lastDay.setText(df); - lastDay.setData(date); - } - TreeItem ti= new TreeItem(lastDay, SWT.NONE); - ti.setImage(getEditionImage(edition, item)); - - String s= getShortEditionLabel(edition, item, date); - if (pair.fHasError) { - String pattern= Utilities.getString(fBundle, "parseErrorFormat"); //$NON-NLS-1$ - s= MessageFormat.format(pattern, new String[] { s } ); - } - ti.setText(s); - - ti.setData(pair); - - // determine selected TreeItem - TreeItem selection= first ? ti : null; - if (fMemberSelection != null) { - Object selected= fMemberSelection.get(fCurrentEditions); - if (selected != null) { - if (selected == pair.getItem()) - selection= ti; - else - selection= null; - } - } - if (selection != null) { - fEditionTree.setSelection(new TreeItem[] { selection }); - if (!fAddMode) - fEditionTree.setFocus(); - feedInput(selection); - } - - if (first) // expand first node - lastDay.setExpanded(true); - } - - /* - * Feeds selection from member viewer to edition viewer. - */ - private void handleMemberSelect(Widget w) { - Object data= w.getData(); - if (data instanceof List) { - List editions= (List) data; - if (editions != fCurrentEditions) { - fCurrentEditions= editions; - fEditionTree.removeAll(); - - String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(pattern, new Object[] { ((Item)w).getText() }); - fEditionPane.setText(title); - - Iterator iter= editions.iterator(); - while (iter.hasNext()) { - Object item= iter.next(); - if (item instanceof Pair) - addEdition((Pair) item); - } - } - } - } - - private void setInput(Object input) { - if (!fCompare && input instanceof ICompareInput) { - ICompareInput ci= (ICompareInput) input; - if (fTargetIsRight) - input= ci.getLeft(); - else - input= ci.getRight(); - } - fContentPane.setInput(input); - if (fStructuredComparePane != null) - fStructuredComparePane.setInput(input); - } - - /* - * Feeds selection from edition viewer to content (and structure) viewer. - */ - private void feedInput(Widget w) { - Object input= w.getData(); - boolean isOK= false; - if (input instanceof Pair) { - Pair pair= (Pair) input; - fSelectedItem= pair.getItem(); - isOK= !pair.fHasError; - - ITypedElement edition= pair.getEdition(); - String editionLabel= getEditionLabel(edition, fSelectedItem); - Image editionImage= getEditionImage(edition, fSelectedItem); - - if (fAddMode) { - if (fMemberSelection != null) - fMemberSelection.put(fCurrentEditions, fSelectedItem); - setInput(fSelectedItem); - fContentPane.setText(editionLabel); - fContentPane.setImage(editionImage); - } else { - getCompareConfiguration(); - if (fTargetIsRight) { - fCompareConfiguration.setLeftLabel(editionLabel); - fCompareConfiguration.setLeftImage(editionImage); - setInput(new DiffNode(fSelectedItem, fTargetPair.getItem())); - } else { - fCompareConfiguration.setRightLabel(editionLabel); - fCompareConfiguration.setRightImage(editionImage); - setInput(new DiffNode(fTargetPair.getItem(), fSelectedItem)); - } - } - } else { - fSelectedItem= null; - setInput(null); - } - if (fCommitButton != null) { - if (fMultiSelect) - fCommitButton.setEnabled(isOK && fSelectedItem != null && fArrayList.size() > 0); - else - fCommitButton.setEnabled(isOK && fSelectedItem != null && fTargetPair.getItem() != fSelectedItem); - } - } - - /* - * Feeds selection from structure viewer to content viewer. - */ - private void feedInput2(ISelection sel) { - if (sel instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) sel; - if (ss.size() == 1) - fContentPane.setInput(ss.getFirstElement()); - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java deleted file mode 100644 index 3c9dff749..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.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.compare; - -import java.io.InputStream; -import java.io.BufferedInputStream; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.compare.internal.IResourceProvider; -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IFileState; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; - -/** - * A combination IFileState and ITypedElement that can be used as - * an input to a compare viewer or other places where an IStreamContentAccessor - * is needed. - *

- *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- */ -public class HistoryItem implements IEncodedStreamContentAccessor, ITypedElement, IModificationDate, IResourceProvider { - - private ITypedElement fBase; - private IFileState fFileState; - - /** - * Creates a HistoryItem object which combines the given IFileState - * and ITypedElement into an object - * which is suitable as input for a compare viewer or ReplaceWithEditionDialog. - * - * @param base the implementation of the ITypedElement interface delegates to this base ITypedElement - * @param fileState the IFileState from which the streamable contents and the modification time is derived from - */ - public HistoryItem(ITypedElement base, IFileState fileState) { - fBase= base; - fFileState= fileState; - } - - /* (non-Javadoc) - * see ITypedElement.getName - */ - public String getName() { - return fBase.getName(); - } - - /* (non-Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - return fBase.getImage(); - } - - /* (non-Javadoc) - * see ITypedElement.getType - */ - public String getType() { - return fBase.getType(); - } - - /* (non-Javadoc) - * see IModificationDate.getModificationDate - */ - public long getModificationDate() { - return fFileState.getModificationTime(); - } - - /* (non-Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - return new BufferedInputStream(fFileState.getContents()); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() throws CoreException { - String charset= fFileState.getCharset(); - if (charset == null) { - IResource resource= getResource(); - if (resource instanceof IEncodedStorage) - charset= ((IEncodedStorage)resource).getCharset(); - } - return charset; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.IResourceProvider#getResource() - */ - public IResource getResource() { - IPath fullPath= fFileState.getFullPath(); - return ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java deleted file mode 100644 index d0d3e06a1..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ICompareNavigator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * A ICompareNavigator is used to navigate through the individual - * differences of a CompareEditorInput. - *

- * Please note: the following might change before the final release of Eclipse 3.0. - * You can retrieve an object implementing the ICompareNavigator from a - * CompareEditorInput by calling getAdapter(ICompareNavigator) - * on the CompareEditorInput. - *

- * @since 3.0 - */ -public interface ICompareNavigator { - - /** - * Starting from the current selection selectChange selects and reveals the next (previous) change. - * If the end (or beginning) is reached, the method returns true. - * - * @param next if true the next change is selected, otherwise the previous change - * @return returns true if end (beginning) is reached, false otherwise - */ - public boolean selectChange(boolean next); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.java deleted file mode 100644 index 16aa27c0b..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeListener.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.compare; - -/** - * An IContentChangeListener is informed about content changes of a - * IContentChangeNotifier. - *

- * Clients may implement this interface. - *

- * - * @see IContentChangeNotifier - */ -public interface IContentChangeListener { - - /** - * Called whenever the content of the given source has changed. - * - * @param source the source whose contents has changed - */ - void contentChanged(IContentChangeNotifier source); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java deleted file mode 100644 index 55641c97d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IContentChangeNotifier.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * Interface common to all objects that provide a means for registering - * for content change notification. - *

- * Clients may implement this interface. - *

- * - * @see IContentChangeListener - */ -public interface IContentChangeNotifier { - - /** - * Adds a content change listener to this notifier. - * Has no effect if an identical listener is already registered. - * - * @param listener a content changed listener - */ - void addContentChangeListener(IContentChangeListener listener); - - /** - * Removes the given content changed listener from this notifier. - * Has no effect if the listener is not registered. - * - * @param listener a content changed listener - */ - void removeContentChangeListener(IContentChangeListener listener); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java deleted file mode 100644 index 4d031e69c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.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.compare; - -/** - * Common interface for objects with editable contents. - * Typically it is implemented by objects that also implement - * the IStreamContentAccessor interface. - *

- * Clients may implement this interface. - *

- * Note that implementing IEditableContent does not - * automatically mean that it is editable. An object is only editable if - * it implements IEditableContent and the isEditable method returns true. - * - * @see IStreamContentAccessor - */ -public interface IEditableContent { - - /** - * Returns true if this object can be modified. - * If it returns false the other methods of this API must not be called. - * - * @return true if this object can be modified - */ - boolean isEditable(); - - /** - * Replaces the current content with the given new bytes. - * - * @param newContent this new contents replaces the old contents - */ - void setContent(byte[] newContent); - - /** - * This method is called on a parent to add or remove a child, - * or to copy the contents of a child. - * - * What to do is encoded in the two arguments as follows: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
add:dest == nullsrc != null
remove:dest != nullsrc == null
copy:dest != nullsrc != null
- * @param dest the existing child of this object to be replaced; if null a new child can be added. - * @param src the new child to be added or replaced; if null an existing child can be removed. - * @return the argument dest - */ - ITypedElement replace(ITypedElement dest, ITypedElement src); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java deleted file mode 100644 index 95aa6f5c9..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEncodedStreamContentAccessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.core.runtime.CoreException; - -/** - * Extension for IStreamContentAccessor. Extends the original - * concept of a IStreamContentAccessor to answer the Charset (encoding) used for the stream. - * - * @since 3.0 - */ -public interface IEncodedStreamContentAccessor extends IStreamContentAccessor { - - /** - * Returns the name of a charset encoding to be used when decoding this - * stream accessor's contents into characters. Returns null if a proper - * encoding cannot be determined. - *

- * Note: this method does not check whether the result is a supported - * charset name. Callers should be prepared to handle - * UnsupportedEncodingException where this charset is used. - *

- * @return the name of a charset, or null - * @exception CoreException if an error happens while determining - * the charset. See any refinements for more information. - * @see IStreamContentAccessor#getContents - * @since 3.0 - */ - String getCharset() throws CoreException; -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java deleted file mode 100644 index 1ddeb2b78..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IModificationDate.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -/** - * Common interface for objects with a modification date. The modification date - * can be used in the UI to give the user a general idea of how old an object is. - *

- * Clients may implement this interface. - *

- */ -public interface IModificationDate { - - /** - * Returns the modification time of this object. - *

- * Note that this value should only be used to give the user a general idea of how - * old the object is. - * - * @return the time of last modification, in milliseconds since January 1, 1970, 00:00:00 GMT - */ - long getModificationDate(); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java deleted file mode 100644 index f4ed5212c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IPropertyChangeNotifier.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.jface.util.IPropertyChangeListener; - -/** - * Interface common to all objects that provide a means for registering - * for property change notification. - *

- * Clients may implement this interface. - *

- * - * @see org.eclipse.jface.util.IPropertyChangeListener - */ -public interface IPropertyChangeNotifier { - - /** - * Adds a listener for property changes to this notifier. - * Has no effect if an identical listener is already registered. - * - * @param listener a property change listener - */ - void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Removes the given content change listener from this notifier. - * Has no effect if the identical listener is not registered. - * - * @param listener a property change listener - */ - void removePropertyChangeListener(IPropertyChangeListener listener); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.java deleted file mode 100644 index 453bc6a4e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamContentAccessor.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.compare; - -import java.io.InputStream; - -import org.eclipse.core.runtime.CoreException; - -/** - * An IStreamContentAccessor object represents a set of bytes which can be - * accessed by means of a stream. - *

- * Clients may implement this interface, or use the standard implementation, - * BufferedContent. - * - * @see BufferedContent - */ -public interface IStreamContentAccessor { - /** - * Returns an open InputStream for this object which can be used to retrieve the object's content. - * The client is responsible for closing the stream when finished. - * Returns null if this object has no streamable contents. - * - * @return an input stream containing the contents of this object - * @exception CoreException if the contents of this object could not be accessed - */ - InputStream getContents() throws CoreException; -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java deleted file mode 100644 index bf4c6b072..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -/** - * This interface defines a single operation for performing a three-way merge on three - * input streams. The merged result is written to an output stream. - *

- * Clients must implement this interface when contributing new mergers to the - * org.eclipse.compare.streamMergers extension point. - *

- * - * @since 3.0 - */ -public interface IStreamMerger { - - /** - * Indicates the successful completion of the merge operation (value IStatus.OK) - */ - public static final int OK= IStatus.OK; - - /** - * Indicates that a change conflict prevented the merge from successful completion (value 1) - */ - public static final int CONFLICT= 1; - - /** - * Status code describing an internal error (value 2) - */ - public static final int INTERNAL_ERROR= 2; - - /** - * Performs a merge operation on the given input streams and writes the merge result to the output stream. - * On success a status IStatus.OK is returned, on error a status IStatus.ERROR. - * If the merge operation cannot deal with conflicts, the code of the error status has the value IStreamMerger.CONFLICT. - * For text oriented mergers the encoding for the input and output streams is honored. - * It is the responsibility of callers to close input and output streams. - * - * @param output the byte stream to which the merge result is written; the merger will not close the stream - * @param outputEncoding the encoding to use when writing to the output stream - * @param ancestor the byte stream from which the common ancestor is read - * @param ancestorEncoding the encoding of the ancestor input byte stream - * @param target the byte stream containing the target of the merge - * @param targetEncoding the encoding of the target input byte stream - * @param other the byte stream containing the target of the merge - * @param otherEncoding the encoding of the other input byte stream - * @param monitor reports progress of the merge operation - * @return returns the completion status of the operation - */ - IStatus merge(OutputStream output, String outputEncoding, - InputStream ancestor, String ancestorEncoding, - InputStream target, String targetEncoding, - InputStream other, String otherEncoding, - IProgressMonitor monitor); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java deleted file mode 100644 index 6717c8da2..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ITypedElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.graphics.Image; - -/** - * Interface for getting the name, image, and type for an object. - *

- * These methods are typically used to present an input object in the compare UI - * (getName and getImage) - * and for finding a viewer for a given input type (getType). - *

- * Clients may implement this interface. - */ -public interface ITypedElement { - - /** - * Type for a folder input (value "FOLDER"). - * Folders are comparison elements that have no contents, only a name and children. - */ - public static final String FOLDER_TYPE= "FOLDER"; //$NON-NLS-1$ - - /** - * Type for an element whose actual type is text (value "txt"). - */ - public static final String TEXT_TYPE= "txt"; //$NON-NLS-1$ - - /** - * Type for an element whose actual type could not - * be determined. (value "???"). - */ - public static final String UNKNOWN_TYPE= "???"; //$NON-NLS-1$ - - /** - * Returns the name of this object. - * The name is used when displaying this object in the UI. - * - * @return the name of this object - */ - String getName(); - - /** - * Returns an image for this object. - * This image is used when displaying this object in the UI. - * - * @return the image of this object or null if this type of input has no image - */ - Image getImage(); - - /** - * Returns the type of this object. For objects with a file name - * this is typically the file extension. For folders its the constant - * FOLDER_TYPE. - * The type is used for determining a suitable viewer for this object. - * - * @return the type of this object - */ - String getType(); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java deleted file mode 100644 index 91433c80c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IViewerCreator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; - -/** - * A factory object for Viewer. - *

- * This interface is only required when creating a Viewer from a plugin.xml file. - * Since Viewers have no default constructor they cannot be - * instantiated directly with Class.forName. - */ -public interface IViewerCreator { - - /** - * Creates a new viewer under the given SWT parent control. - * - * @param parent the SWT parent control under which to create the viewer's SWT control - * @param config a compare configuration the newly created viewer might want to use - * @return a new viewer - */ - Viewer createViewer(Composite parent, CompareConfiguration config); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java deleted file mode 100644 index 69d3df826..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.util.ResourceBundle; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.compare.internal.CompareMessages; -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.internal.Utilities; - - -/** - * A NavigationAction is used to navigate through the individual - * differences of a CompareEditorInput. - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * @since 2.0 - */ -public class NavigationAction extends Action { - - private boolean fNext; - private CompareEditorInput fCompareEditorInput; - - - /** - * Creates a NavigationAction. - * - * @param next if true action goes to the next difference; otherwise to the previous difference. - */ - public NavigationAction(boolean next) { - this(CompareUI.getResourceBundle(), next); - } - - /** - * Creates a NavigationAction that initializes its attributes - * from the given ResourceBundle. - * - * @param bundle is used to initialize the action - * @param next if true action goes to the next difference; otherwise to the previous difference. - */ - public NavigationAction(ResourceBundle bundle, boolean next) { - Utilities.initAction(this, bundle, next ? "action.Next." : "action.Previous."); //$NON-NLS-2$ //$NON-NLS-1$ - fNext= next; - } - - public void run() { - if (fCompareEditorInput != null) { - Object adapter= fCompareEditorInput.getAdapter(ICompareNavigator.class); - if (adapter instanceof ICompareNavigator) { - boolean atEnd= ((ICompareNavigator)adapter).selectChange(fNext); - Shell shell= CompareUIPlugin.getShell(); - if (atEnd && shell != null) { - - Display display= shell.getDisplay(); - if (display != null) - display.beep(); - - String title; - String message; - if (fNext) { - title= CompareMessages.getString("CompareNavigator.atEnd.title"); //$NON-NLS-1$ - message= CompareMessages.getString("CompareNavigator.atEnd.message"); //$NON-NLS-1$ - } else { - title= CompareMessages.getString("CompareNavigator.atBeginning.title"); //$NON-NLS-1$ - message= CompareMessages.getString("CompareNavigator.atBeginning.message"); //$NON-NLS-1$ - } - MessageDialog.openInformation(shell, title, message); - } - } - } - } - - /** - * Sets the CompareEditorInput on which this action operates. - * - * @param input the CompareEditorInput on which this action operates; if null action does nothing - */ - public void setCompareEditorInput(CompareEditorInput input) { - fCompareEditorInput= input; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java deleted file mode 100644 index 36380c4ae..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import java.util.ArrayList; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.compare.internal.IResourceProvider; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; - -/** - * A ResourceNode wrappers an IResources so that it can be used - * as input for the differencing engine (interfaces IStructureComparator and ITypedElement) - * and the ReplaceWithEditionDialog (interfaces ITypedElement and IModificationDate). - *

- * Clients may instantiate this class; it is not intended to be subclassed. - *

- * - * @see EditionSelectionDialog - */ -public class ResourceNode extends BufferedContent - implements IEncodedStreamContentAccessor, IStructureComparator, ITypedElement, - IEditableContent, IModificationDate, IResourceProvider { - - private IResource fResource; - private ArrayList fChildren; - - - /** - * Creates a ResourceNode for the given resource. - * - * @param resource the resource - */ - public ResourceNode(IResource resource) { - fResource= resource; - Assert.isNotNull(resource); - } - - /** - * Returns the corresponding resource for this object. - * - * @return the corresponding resource - */ - public IResource getResource() { - return fResource; - } - - /* (non Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() throws CoreException { - if (fResource instanceof IStorage) - return super.getContents(); - return null; - } - - /* (non Javadoc) - * see IModificationDate.getModificationDate - */ - public long getModificationDate() { - IPath path= fResource.getLocation(); - File file= path.toFile(); - return file.lastModified(); - } - - /* (non Javadoc) - * see ITypedElement.getName - */ - public String getName() { - if (fResource != null) - return fResource.getName(); - return null; - } - - /* (non Javadoc) - * see ITypedElement.getType - */ - public String getType() { - if (fResource instanceof IContainer) - return ITypedElement.FOLDER_TYPE; - if (fResource != null) { - String s= fResource.getFileExtension(); - if (s != null) - return s; - } - return ITypedElement.UNKNOWN_TYPE; - } - - /* (non Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - return CompareUI.getImage(fResource); - } - - /* - * Returns true if the other object is of type ITypedElement - * and their names are identical. The content is not considered. - */ - public boolean equals(Object other) { - if (other instanceof ITypedElement) { - String otherName= ((ITypedElement)other).getName(); - return getName().equals(otherName); - } - return super.equals(other); - } - - /** - * Returns the hash code of the name. - * @return a hash code value for this object. - */ - public int hashCode() { - return getName().hashCode(); - } - - /* (non Javadoc) - * see IStructureComparator.getChildren - */ - public Object[] getChildren() { - if (fChildren == null) { - fChildren= new ArrayList(); - if (fResource instanceof IContainer) { - try { - IResource members[]= ((IContainer)fResource).members(); - for (int i= 0; i < members.length; i++) { - IStructureComparator child= createChild(members[i]); - if (child != null) - fChildren.add(child); - } - } catch (CoreException ex) { - // NeedWork - } - } - } - return fChildren.toArray(); - } - - /** - * This hook method is called from getChildren once for every - * member of a container resource. This implementation - * creates a new ResourceNode for the given child resource. - * Clients may override this method to create a different type of - * IStructureComparator or to filter children by returning null. - * - * @param child the child resource for which a IStructureComparator must be returned - * @return a ResourceNode for the given child or null - */ - protected IStructureComparator createChild(IResource child) { - return new ResourceNode(child); - } - - /** - * Returns an open stream if the corresponding resource implements the - * IStorage interface. Otherwise the value null is returned. - * - * @return a buffered input stream containing the contents of this storage - * @exception CoreException if the contents of this storage could not be accessed - */ - protected InputStream createStream() throws CoreException { - if (fResource instanceof IStorage) { - InputStream is= null; - IStorage storage= (IStorage) fResource; - try { - is= storage.getContents(); - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { - fResource.refreshLocal(IResource.DEPTH_INFINITE, null); - is= storage.getContents(); - } else - throw e; - } - if (is != null) - return new BufferedInputStream(is); - } - return null; - } - - /* (non Javadoc) - * see IEditableContent.isEditable - */ - public boolean isEditable() { - return true; - } - - /* (non Javadoc) - * see IEditableContent.replace - */ - public ITypedElement replace(ITypedElement child, ITypedElement other) { - return child; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() { - return Utilities.getCharset(fResource); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java deleted file mode 100644 index 4fb46d6b1..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/Splitter.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.SashForm; - -/** - * The Splitter adds support for nesting to a SashForm. - *

- * If Splitters are nested directly: - *

    - *
  • changing the visibility of a child may propagate upward to the parent Splitter if the child - * is the last child to become invisible or the first to become visible.
  • - *
  • maximizing a child makes it as large as the topmost enclosing Splitter
  • - *
- * - * @since 2.1 - */ -public class Splitter extends SashForm { - - private static final String VISIBILITY= "org.eclipse.compare.internal.visibility"; //$NON-NLS-1$ - - /** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - *

- * The style value is either one of the style constants defined in - * class SWT which is applicable to instances of this - * class, or must be built by bitwise OR'ing together - * (that is, using the int "|" operator) two or more - * of those SWT style constants. The class description - * lists the style constants that are applicable to the class. - * Style bits are also inherited from superclasses. - *

- * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException
    - *
  • ERROR_NULL_ARGUMENT - if the parent is null
  • - *
- * @exception org.eclipse.swt.SWTException
    - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • - *
- */ - public Splitter(Composite parent, int style) { - super(parent, style); - } - - /** - * Sets the visibility of the given child in this Splitter. If this change - * affects the visibility state of the whole Splitter, and if the Splitter - * is directly nested in one or more Splitters, this method recursively - * propagates the new state upward. - * - * @param child the child control for which the visibility is changed - * @param visible the new visibility state - */ - public void setVisible(Control child, boolean visible) { - - boolean wasEmpty= isEmpty(); - - child.setVisible(visible); - child.setData(VISIBILITY, new Boolean(visible)); - - if (wasEmpty != isEmpty()) { - // recursively walk up - Composite parent= getParent(); - if (parent instanceof Splitter) { - Splitter sp= (Splitter) parent; - sp.setVisible(this, visible); - sp.layout(); - } - } else { - layout(); - } - } - - /* (non-Javadoc) - * Recursively calls setMaximizedControl for all direct parents that are - * itself Splitters. - */ - public void setMaximizedControl(Control control) { - if (control == null || control == getMaximizedControl()) - super.setMaximizedControl(null); - else - super.setMaximizedControl(control); - - // recursively walk upward - Composite parent= getParent(); - if (parent instanceof Splitter) - ((Splitter) parent).setMaximizedControl(this); - else - layout(true); - } - - /* (non-Javadoc) - * Returns true if Splitter has no children or if all children are invisible. - */ - private boolean isEmpty() { - Control[] controls= getChildren(); - for (int i= 0; i < controls.length; i++) - if (isVisible(controls[i])) - return false; - return true; - } - - /* (non-Javadoc) - * Returns the visibility state of the given child control. If the - * control is a Sash, this method always returns false. - */ - private boolean isVisible(Control child) { - if (child instanceof Sash) - return false; - Object data= child.getData(VISIBILITY); - if (data instanceof Boolean) - return ((Boolean)data).booleanValue(); - return true; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java deleted file mode 100644 index 15a1851dc..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare; - -import java.io.*; -import java.util.*; -import java.util.zip.*; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * This implementation of the IStructureCreator interface - * makes the contents of a zip archive available as a - * hierarchical structure of IStructureComparators. - *

- * It is used when comparing the internal structure of a zip archive. - * - * @since 2.0 - */ -public class ZipFileStructureCreator implements IStructureCreator { - - /** - * Common base class for ZipFolder and ZipFile - */ - static abstract class ZipResource implements IStructureComparator, ITypedElement { - - private String fName; - - ZipResource(String name) { - fName= name; - } - - public String getName() { - return fName; - } - - public Image getImage() { - return CompareUI.getImage(getType()); - } - - /* - * Returns true if other is ITypedElement and names are equal. - * @see IComparator#equals - */ - public boolean equals(Object other) { - if (other instanceof ITypedElement) - return fName.equals(((ITypedElement) other).getName()); - return super.equals(other); - } - - public int hashCode() { - return fName.hashCode(); - } - } - - static class ZipFolder extends ZipResource { - - private HashMap fChildren= new HashMap(10); - - ZipFolder(String name) { - super(name); - } - - public String getType() { - return ITypedElement.FOLDER_TYPE; - } - - public Object[] getChildren() { - Object[] children= new Object[fChildren.size()]; - Iterator iter= fChildren.values().iterator(); - for (int i= 0; iter.hasNext(); i++) - children[i]= iter.next(); - return children; - } - - ZipFile createContainer(String path) { - String entry= path; - int pos= path.indexOf('/'); - if (pos < 0) - pos= path.indexOf('\\'); - if (pos >= 0) { - entry= path.substring(0, pos); - path= path.substring(pos + 1); - } else if (entry.length() > 0) { - if (CompareUIPlugin.getDefault().filter(path, false, true)) - return null; - ZipFile ze= new ZipFile(entry); - fChildren.put(entry, ze); - return ze; - } else - return null; - - ZipFolder folder= null; - if (fChildren != null) { - Object o= fChildren.get(entry); - if (o instanceof ZipFolder) - folder= (ZipFolder) o; - } - - if (folder == null) { - if (path.length() > 0 && CompareUIPlugin.getDefault().filter(path, true, true)) - return null; - folder= new ZipFolder(entry); - fChildren.put(entry, folder); - } - - return folder.createContainer(path); - } - } - - static class ZipFile extends ZipResource implements IStreamContentAccessor { - - private byte[] fContents; - - ZipFile(String name) { - super(name); - } - - public String getType() { - String s= this.getName(); - int pos= s.lastIndexOf('.'); - if (pos >= 0) - return s.substring(pos + 1); - return ITypedElement.UNKNOWN_TYPE; - } - - public Object[] getChildren() { - return null; - } - - public InputStream getContents() { - if (fContents == null) - fContents= new byte[0]; - return new ByteArrayInputStream(fContents); - } - - byte[] getBytes() { - return fContents; - } - - void setBytes(byte[] buffer) { - fContents= buffer; - } - - void appendBytes(byte[] buffer, int length) { - if (length > 0) { - int oldLen= 0; - if (fContents != null) - oldLen= fContents.length; - byte[] newBuf= new byte[oldLen + length]; - if (oldLen > 0) - System.arraycopy(fContents, 0, newBuf, 0, oldLen); - System.arraycopy(buffer, 0, newBuf, oldLen, length); - fContents= newBuf; - } - } - } - - private String fTitle; - - /** - * Create a new ZipFileStructureCreator. - */ - public ZipFileStructureCreator() { - this(Utilities.getString("ZipStructureCreator.name")); //$NON-NLS-1$ - } - - /** - * Create a new ZipFileStructureCreator with the given title. - * The title is returned by the method getName(). - * @param title the title of this strcuture creator - */ - public ZipFileStructureCreator(String title) { - fTitle= title; - } - - public String getName() { - return fTitle; - } - - public IStructureComparator getStructure(Object input) { - - InputStream is= null; - - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - try { - is= sca.getContents(); - } catch (CoreException ex) { - // NeedWork - } - } - - if (is == null) - return null; - - ZipInputStream zip= new ZipInputStream(is); - ZipFolder root= new ZipFolder(""); //$NON-NLS-1$ - try { - for (;;) { - ZipEntry entry= zip.getNextEntry(); - if (entry == null) - break; - - ZipFile ze= root.createContainer(entry.getName()); - if (ze != null) { - int length= (int) entry.getSize(); - if (length >= 0) { - byte[] buffer= new byte[length]; - int offset= 0; - - do { - int n= zip.read(buffer, offset, length); - offset += n; - length -= n; - } while (length > 0); - - ze.setBytes(buffer); - } else { - byte[] buffer= new byte[1024]; - int n; - do { - n= zip.read(buffer, 0, 1024); - ze.appendBytes(buffer, n); - } while (n >= 0); - } - } - zip.closeEntry(); - } - } catch (IOException ex) { - return null; - } finally { - try { - zip.close(); - } catch (IOException ex) { - // silently ignored - } - } - - if (root.fChildren.size() == 1) { - Iterator iter= root.fChildren.values().iterator(); - return (IStructureComparator) iter.next(); - } - return root; - } - - public String getContents(Object o, boolean ignoreWhitespace) { - if (o instanceof ZipFile) { - byte[] bytes= ((ZipFile)o).getBytes(); - if (bytes != null) - return new String(bytes); - return ""; //$NON-NLS-1$ - } - return null; - } - - /** - * Returns false since we cannot update a zip archive. - * @return false - */ - public boolean canSave() { - return false; - } - - /** - * Called whenever a copy operation has been performed on a tree node. - * This implementation throws an AssertionFailedException - * since we cannot update a zip archive. - * - * @param structure the node for which to save the new content - * @param input the object from which the structure tree was created in getStructure - */ - public void save(IStructureComparator structure, Object input) { - Assert.isTrue(false); // Cannot update zip archive - } - - public IStructureComparator locate(Object path, Object source) { - return null; - } - - /** - * Returns false since this IStructureCreator - * cannot rewrite the diff tree in order to fold certain combinations of - * additons and deletions. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @return false - */ - public boolean canRewriteTree() { - return false; - } - - /** - * Empty implementation since this IStructureCreator - * cannot rewrite the diff tree in order to fold certain combinations of - * additons and deletions. - *

- * Note: this method is for internal use only. Clients should not call this method. - * @param differencer - * @param root - */ - public void rewriteTree(Differencer differencer, IDiffContainer root) { - // empty default implementation - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java deleted file mode 100644 index b5a54ba89..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java +++ /dev/null @@ -1,1043 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.compare.contentmergeviewer; - -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.IWorkbenchPartSite; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.viewers.ContentViewer; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.compare.internal.*; - -/** - * An abstract compare and merge viewer with two side-by-side content areas - * and an optional content area for the ancestor. The implementation makes no - * assumptions about the content type. - *

- * ContentMergeViewer - *

    - *
  • implements the overall layout and defines hooks so that subclasses - * can easily provide an implementation for a specific content type, - *
  • implements the UI for making the areas resizable, - *
  • has an action for controlling whether the ancestor area is visible or not, - *
  • has actions for copying one side of the input to the other side, - *
  • tracks the dirty state of the left and right sides and send out notification - * on state changes. - *
- * A ContentMergeViewer accesses its - * model by means of a content provider which must implement the - * IMergeViewerContentProvider interface. - *

- *

- * Clients may wish to use the standard concrete subclass TextMergeViewer, - * or define their own subclass. - * - * @see IMergeViewerContentProvider - * @see TextMergeViewer - */ -public abstract class ContentMergeViewer extends ContentViewer - implements IPropertyChangeNotifier, ISavable { - - class SaveAction extends MergeViewerAction { - - SaveAction(boolean left) { - super(true, false, false); - Utilities.initAction(this, getResourceBundle(), "action.save."); //$NON-NLS-1$ - } - - public void run() { - saveContent(getInput()); - } - } - - /** - * Property names. - */ - private static final String ANCESTOR_ENABLED= ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE; - - /* package */ static final int HORIZONTAL= 1; - /* package */ static final int VERTICAL= 2; - - static final double HSPLIT= 0.5; - static final double VSPLIT= 0.3; - - private class ContentMergeViewerLayout extends Layout { - - public Point computeSize(Composite c, int w, int h, boolean force) { - return new Point(100, 100); - } - - public void layout(Composite composite, boolean force) { - - // determine some derived sizes - int headerHeight= fLeftLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y; - Rectangle r= composite.getClientArea(); - - int centerWidth= getCenterWidth(); - int width1= (int)((r.width-centerWidth)*fHSplit); - int width2= r.width-width1-centerWidth; - - int height1= 0; - int height2= 0; - if (fAncestorEnabled && fShowAncestor) { - height1= (int)((r.height-(2*headerHeight))*fVSplit); - height2= r.height-(2*headerHeight)-height1; - } else { - height1= 0; - height2= r.height-headerHeight; - } - - int y= 0; - - if (fAncestorEnabled && fShowAncestor) { - fAncestorLabel.setBounds(0, y, r.width, headerHeight); - fAncestorLabel.setVisible(true); - y+= headerHeight; - handleResizeAncestor(0, y, r.width, height1); - y+= height1; - } else { - fAncestorLabel.setVisible(false); - handleResizeAncestor(0, 0, 0, 0); - } - - fLeftLabel.getSize(); // without this resizing would not always work - - if (centerWidth > 3) { - fLeftLabel.setBounds(0, y, width1+1, headerHeight); - fDirectionLabel.setVisible(true); - fDirectionLabel.setBounds(width1+1, y, centerWidth-1, headerHeight); - fRightLabel.setBounds(width1+centerWidth, y, width2, headerHeight); - } else { - fLeftLabel.setBounds(0, y, width1, headerHeight); - fDirectionLabel.setVisible(false); - fRightLabel.setBounds(width1, y, r.width-width1, headerHeight); - } - - y+= headerHeight; - - if (fCenter != null && !fCenter.isDisposed()) - fCenter.setBounds(width1, y, centerWidth, height2); - - handleResizeLeftRight(0, y, width1, centerWidth, width2, height2); - } - } - - class Resizer extends MouseAdapter implements MouseMoveListener { - - Control fControl; - int fX, fY; - int fWidth1, fWidth2; - int fHeight1, fHeight2; - int fDirection; - boolean fLiveResize; - boolean fIsDown; - - public Resizer(Control c, int dir) { - fDirection= dir; - fControl= c; - fLiveResize= !(fControl instanceof Sash); - updateCursor(c, dir); - fControl.addMouseListener(this); - fControl.addMouseMoveListener(this); - fControl.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fControl= null; - } - } - ); - } - - public void mouseDoubleClick(MouseEvent e) { - if ((fDirection & HORIZONTAL) != 0) - fHSplit= HSPLIT; - if ((fDirection & VERTICAL) != 0) - fVSplit= VSPLIT; - fComposite.layout(true); - } - - public void mouseDown(MouseEvent e) { - Composite parent= fControl.getParent(); - - Point s= parent.getSize(); - Point as= fAncestorLabel.getSize(); - Point ys= fLeftLabel.getSize(); - Point ms= fRightLabel.getSize(); - - fWidth1= ys.x; - fWidth2= ms.x; - fHeight1= fLeftLabel.getLocation().y-as.y; - fHeight2= s.y-(fLeftLabel.getLocation().y+ys.y); - - fX= e.x; - fY= e.y; - fIsDown= true; - } - - public void mouseUp(MouseEvent e) { - fIsDown= false; - if (!fLiveResize) - resize(e); - } - - public void mouseMove(MouseEvent e) { - if (fIsDown && fLiveResize) - resize(e); - } - - private void resize(MouseEvent e) { - int dx= e.x-fX; - int dy= e.y-fY; - - int centerWidth= fCenter.getSize().x; - - if (fWidth1 + dx > centerWidth && fWidth2 - dx > centerWidth) { - fWidth1+= dx; - fWidth2-= dx; - if ((fDirection & HORIZONTAL) != 0) - fHSplit= (double)fWidth1/(double)(fWidth1+fWidth2); - } - if (fHeight1 + dy > centerWidth && fHeight2 - dy > centerWidth) { - fHeight1+= dy; - fHeight2-= dy; - if ((fDirection & VERTICAL) != 0) - fVSplit= (double)fHeight1/(double)(fHeight1+fHeight2); - } - - fComposite.layout(true); - fControl.getDisplay().update(); - } - } - - /** Style bits for top level composite */ - private int fStyles; - private ResourceBundle fBundle; - private CompareConfiguration fCompareConfiguration; - private IPropertyChangeListener fPropertyChangeListener; - private ICompareInputChangeListener fCompareInputChangeListener; - private ListenerList fListenerList; - boolean fConfirmSave= true; - - private double fHSplit= HSPLIT; // width ratio of left and right panes - private double fVSplit= VSPLIT; // height ratio of ancestor and bottom panes - - private boolean fAncestorEnabled= true; // show ancestor in case of conflicts - /* package */ boolean fShowAncestor= false; // if current input has conflicts - private boolean fIsThreeWay= false; - private ActionContributionItem fAncestorItem; - - private Action fCopyLeftToRightAction; // copy from left to right - private Action fCopyRightToLeftAction; // copy from right to left - - MergeViewerAction fLeftSaveAction; - MergeViewerAction fRightSaveAction; - - private IKeyBindingService fKeyBindingService; - - // SWT widgets - /* package */ Composite fComposite; - private CLabel fAncestorLabel; - private CLabel fLeftLabel; - private CLabel fRightLabel; - /* package */ CLabel fDirectionLabel; - /* package */ Control fCenter; - - //---- SWT resources to be disposed - private Image fRightArrow; - private Image fLeftArrow; - private Image fBothArrow; - Cursor fNormalCursor; - private Cursor fHSashCursor; - private Cursor fVSashCursor; - private Cursor fHVSashCursor; - - //---- end - - /** - * Creates a new content merge viewer and initializes with a resource bundle and a - * configuration. - * - * @param style SWT style bits - * @param bundle the resource bundle - * @param cc the configuration object - */ - protected ContentMergeViewer(int style, ResourceBundle bundle, CompareConfiguration cc) { - fStyles= style; - fBundle= bundle; - - fAncestorEnabled= Utilities.getBoolean(cc, ANCESTOR_ENABLED, fAncestorEnabled); - fConfirmSave= Utilities.getBoolean(cc, CompareEditor.CONFIRM_SAVE_PROPERTY, fConfirmSave); - - setContentProvider(new MergeViewerContentProvider(cc)); - - fCompareInputChangeListener= new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput input) { - ContentMergeViewer.this.internalRefresh(input); - } - }; - - fCompareConfiguration= cc; - if (fCompareConfiguration != null) { - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - ContentMergeViewer.this.propertyChange(event); - } - }; - fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); - } - - fLeftSaveAction= new SaveAction(true); - fLeftSaveAction.setEnabled(false); - fRightSaveAction= new SaveAction(false); - fRightSaveAction.setEnabled(false); - } - - //---- hooks --------------------- - - /** - * Returns the viewer's name. - * - * @return the viewer's name - */ - public String getTitle() { - return Utilities.getString(getResourceBundle(), "title"); //$NON-NLS-1$ - } - - /** - * Creates the SWT controls for the ancestor, left, and right - * content areas of this compare viewer. - * Implementations typically hold onto the controls - * so that they can be initialized with the input objects in method - * updateContent. - * - * @param composite the container for the three areas - */ - abstract protected void createControls(Composite composite); - - /** - * Lays out the ancestor area of the compare viewer. - * It is called whenever the viewer is resized or when the sashes between - * the areas are moved to adjust the size of the areas. - * - * @param x the horizontal position of the ancestor area within its container - * @param y the vertical position of the ancestor area within its container - * @param width the width of the ancestor area - * @param height the height of the ancestor area - */ - abstract protected void handleResizeAncestor(int x, int y, int width, int height); - - /** - * Lays out the left and right areas of the compare viewer. - * It is called whenever the viewer is resized or when the sashes between - * the areas are moved to adjust the size of the areas. - * - * @param x the horizontal position of the left area within its container - * @param y the vertical position of the left and right area within its container - * @param leftWidth the width of the left area - * @param centerWidth the width of the gap between the left and right areas - * @param rightWidth the width of the right area - * @param height the height of the left and right areas - */ - abstract protected void handleResizeLeftRight(int x, int y, int leftWidth, int centerWidth, - int rightWidth, int height); - - /** - * Contributes items to the given ToolBarManager. - * It is called when this viewer is installed in its container and if the container - * has a ToolBarManager. - * The ContentMergeViewer implementation of this method does nothing. - * Subclasses may reimplement. - * - * @param toolBarManager the toolbar manager to contribute to - */ - protected void createToolItems(ToolBarManager toolBarManager) { - // empty implementation - } - - /** - * Initializes the controls of the three content areas with the given input objects. - * - * @param ancestor the input for the ancestor area - * @param left the input for the left area - * @param right the input for the right area - */ - abstract protected void updateContent(Object ancestor, Object left, Object right); - - /** - * Copies the content of one side to the other side. - * Called from the (internal) actions for copying the sides of the viewer's input object. - * - * @param leftToRight if true, the left side is copied to the right side; - * if false, the right side is copied to the left side - */ - abstract protected void copy(boolean leftToRight); - - /** - * Returns the byte contents of the left or right side. If the viewer - * has no editable content null can be returned. - * - * @param left if true, the byte contents of the left area is returned; - * if false, the byte contents of the right area - * @return the content as an array of bytes, or null - */ - abstract protected byte[] getContents(boolean left); - - //---------------------------- - - /** - * Returns the resource bundle of this viewer. - * - * @return the resource bundle - */ - protected ResourceBundle getResourceBundle() { - return fBundle; - } - - /** - * Returns the compare configuration of this viewer, - * or null if this viewer does not yet have a configuration. - * - * @return the compare configuration, or null if none - */ - protected CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * The ContentMergeViewer implementation of this - * ContentViewer method - * checks to ensure that the content provider is an IMergeViewerContentProvider. - * @param contentProvider the contentprovider to set. Must implement IMergeViewerContentProvider. - */ - public void setContentProvider(IContentProvider contentProvider) { - Assert.isTrue(contentProvider instanceof IMergeViewerContentProvider); - super.setContentProvider(contentProvider); - } - - /* package */ IMergeViewerContentProvider getMergeContentProvider() { - return (IMergeViewerContentProvider) getContentProvider(); - } - - /** - * The ContentMergeViewer implementation of this - * Viewer method returns the empty selection. Subclasses may override. - * @return empty selection. - */ - public ISelection getSelection() { - return new ISelection() { - public boolean isEmpty() { - return true; - } - }; - } - - /* - * The ContentMergeViewer implementation of this - * Viewer method does nothing. Subclasses may reimplement. - */ - public void setSelection(ISelection selection, boolean reveal) { - // empty implementation - } - - /* package */ void propertyChange(PropertyChangeEvent event) { - - String key= event.getProperty(); - - if (key.equals(ANCESTOR_ENABLED)) { - fAncestorEnabled= Utilities.getBoolean(getCompareConfiguration(), ANCESTOR_ENABLED, fAncestorEnabled); - fComposite.layout(true); - - updateCursor(fLeftLabel, VERTICAL); - updateCursor(fDirectionLabel, HORIZONTAL | VERTICAL); - updateCursor(fRightLabel, VERTICAL); - - return; - } - } - - void updateCursor(Control c, int dir) { - if (!(c instanceof Sash)) { - Cursor cursor= null; - switch (dir) { - case VERTICAL: - if (fAncestorEnabled) { - if (fVSashCursor == null) fVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZENS); - cursor= fVSashCursor; - } else { - if (fNormalCursor == null) fNormalCursor= new Cursor(c.getDisplay(), SWT.CURSOR_ARROW); - cursor= fNormalCursor; - } - break; - case HORIZONTAL: - if (fHSashCursor == null) fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE); - cursor= fHSashCursor; - break; - case VERTICAL + HORIZONTAL: - if (fAncestorEnabled) { - if (fHVSashCursor == null) fHVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEALL); - cursor= fHVSashCursor; - } else { - if (fHSashCursor == null) fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE); - cursor= fHSashCursor; - } - break; - } - if (cursor != null) - c.setCursor(cursor); - } - } - - void setAncestorVisibility(boolean visible, boolean enabled) { - if (fAncestorItem != null) { - Action action= (Action) fAncestorItem.getAction(); - if (action != null) { - action.setChecked(visible); - action.setEnabled(enabled); - } - } - if (fCompareConfiguration != null) - fCompareConfiguration.setProperty(ANCESTOR_ENABLED, new Boolean(visible)); - } - - //---- input - - /* package */ boolean isThreeWay() { - return fIsThreeWay; - } - - /** - * Internal hook method called when the input to this viewer is - * initially set or subsequently changed. - *

- * The ContentMergeViewer implementation of this Viewer - * method tries to save the old input by calling doSave(...) and - * then calls internalRefresh(...). - * - * @param input the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - */ - protected final void inputChanged(Object input, Object oldInput) { - - if (input != oldInput) - if (oldInput instanceof ICompareInput) - ((ICompareInput)oldInput).removeCompareInputChangeListener(fCompareInputChangeListener); - - boolean success= doSave(input, oldInput); - - if (input != oldInput) - if (input instanceof ICompareInput) - ((ICompareInput)input).addCompareInputChangeListener(fCompareInputChangeListener); - - if (success) { - setLeftDirty(false); - setRightDirty(false); - } - - if (input != oldInput) - internalRefresh(input); - } - - /** - * This method is called from the Viewer method inputChanged - * to save any unsaved changes of the old input. - *

- * The ContentMergeViewer implementation of this - * method calls saveContent(...). If confirmation has been turned on - * with setConfirmSave(true), a confirmation alert is posted before saving. - *

- * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * @param newInput the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - * @return true if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). - * @since 2.0 - */ - protected boolean doSave(Object newInput, Object oldInput) { - - // before setting the new input we have to save the old - if (fLeftSaveAction.isEnabled() || fRightSaveAction.isEnabled()) { - - // post alert - if (fConfirmSave) { - Shell shell= fComposite.getShell(); - - MessageDialog dialog= new MessageDialog(shell, - Utilities.getString(getResourceBundle(), "saveDialog.title"), //$NON-NLS-1$ - null, // accept the default window icon - Utilities.getString(getResourceBundle(), "saveDialog.message"), //$NON-NLS-1$ - MessageDialog.QUESTION, - new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.NO_LABEL, - }, - 0); // default button index - - switch (dialog.open()) { // open returns index of pressed button - case 0: - saveContent(oldInput); - break; - case 1: - setLeftDirty(false); - setRightDirty(false); - break; - case 2: - throw new ViewerSwitchingCancelled(); - } - } else - saveContent(oldInput); - return true; - } - return false; - } - - /** - * Controls whether doSave(Object, Object) asks for confirmation before saving - * the old input with saveContent(Object). - * @param enable a value of true enables confirmation - * @since 2.0 - */ - public void setConfirmSave(boolean enable) { - fConfirmSave= enable; - } - - /* (non Javadoc) - * see Viewer.refresh - */ - public void refresh() { - internalRefresh(getInput()); - } - - private void internalRefresh(Object input) { - - IMergeViewerContentProvider content= getMergeContentProvider(); - if (content != null) { - Object ancestor= content.getAncestorContent(input); - if (input instanceof ICompareInput) - fIsThreeWay= (((ICompareInput)input).getKind() & Differencer.DIRECTION_MASK) != 0; - else - fIsThreeWay= ancestor != null; - - if (fAncestorItem != null) - fAncestorItem.setVisible(fIsThreeWay); - - boolean oldFlag= fShowAncestor; - fShowAncestor= fIsThreeWay && content.showAncestor(input); - - if (fAncestorEnabled && oldFlag != fShowAncestor) - fComposite.layout(true); - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(fComposite.getParent()); - if (tbm != null) { - updateToolItems(); - tbm.update(true); - tbm.getControl().getParent().layout(true); - } - - updateHeader(); - - Object left= content.getLeftContent(input); - Object right= content.getRightContent(input); - updateContent(ancestor, left, right); - } - } - - //---- layout & SWT control creation - - /** - * Builds the SWT controls for the three areas of a compare/merge viewer. - *

- * Calls the hooks createControls and createToolItems - * to let subclasses build the specific content areas and to add items to - * an enclosing toolbar. - *

- * This method must only be called in the constructor of subclasses. - * - * @param parent the parent control - * @return the new control - */ - protected final Control buildControl(Composite parent) { - - fComposite= new Composite(parent, fStyles) { - public boolean setFocus() { - return internalSetFocus(); - } - }; - fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - - hookControl(fComposite); // hook help & dispose listener - - fComposite.setLayout(new ContentMergeViewerLayout()); - - int style= SWT.SHADOW_OUT; - fAncestorLabel= new CLabel(fComposite, style); - - fLeftLabel= new CLabel(fComposite, style); - new Resizer(fLeftLabel, VERTICAL); - - fDirectionLabel= new CLabel(fComposite, style); - fDirectionLabel.setAlignment(SWT.CENTER); - new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL); - - fRightLabel= new CLabel(fComposite, style); - new Resizer(fRightLabel, VERTICAL); - - if (fCenter == null || fCenter.isDisposed()) - fCenter= createCenter(fComposite); - - createControls(fComposite); - - IWorkbenchPartSite ps= Utilities.findSite(fComposite); - fKeyBindingService= ps != null ? ps.getKeyBindingService() : null; - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - - // define groups - tbm.add(new Separator("modes")); //$NON-NLS-1$ - tbm.add(new Separator("merge")); //$NON-NLS-1$ - tbm.add(new Separator("navigation")); //$NON-NLS-1$ - - CompareConfiguration cc= getCompareConfiguration(); - - if (cc.isRightEditable()) { - fCopyLeftToRightAction= - new Action() { - public void run() { - copy(true); - } - }; - Utilities.initAction(fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); //$NON-NLS-1$ - tbm.appendToGroup("merge", fCopyLeftToRightAction); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); //$NON-NLS-1$ - } - - if (cc.isLeftEditable()) { - fCopyRightToLeftAction= - new Action() { - public void run() { - copy(false); - } - }; - Utilities.initAction(fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); //$NON-NLS-1$ - tbm.appendToGroup("merge", fCopyRightToLeftAction); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$ - } - - Action a= new ChangePropertyAction(fBundle, fCompareConfiguration, "action.EnableAncestor.", ANCESTOR_ENABLED); //$NON-NLS-1$ - a.setChecked(fAncestorEnabled); - fAncestorItem= new ActionContributionItem(a); - fAncestorItem.setVisible(false); - tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$ - - createToolItems(tbm); - updateToolItems(); - - tbm.update(true); - } - - return fComposite; - } - - /* package */ boolean internalSetFocus() { - return false; - } - - /* package */ int getCenterWidth() { - return 3; - } - - /* package */ boolean getAncestorEnabled() { - return fAncestorEnabled; - } - - /* package */ Control createCenter(Composite parent) { - Sash sash= new Sash(parent, SWT.VERTICAL); - new Resizer(sash, HORIZONTAL); - return sash; - } - - /* package */ Control getCenter() { - return fCenter; - } - - /* - * @see Viewer.getControl() - */ - public Control getControl() { - return fComposite; - } - - /* - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - */ - protected void handleDispose(DisposeEvent event) { - - if (fKeyBindingService != null) { - if (fCopyLeftToRightAction != null) - fKeyBindingService.unregisterAction(fCopyLeftToRightAction); - if (fCopyRightToLeftAction != null) - fKeyBindingService.unregisterAction(fCopyRightToLeftAction); - fKeyBindingService= null; - } - - Object input= getInput(); - if (input instanceof ICompareInput) - ((ICompareInput)input).removeCompareInputChangeListener(fCompareInputChangeListener); - - if (fCompareConfiguration != null && fPropertyChangeListener != null) { - fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener); - fPropertyChangeListener= null; - } - - fAncestorLabel= null; - fLeftLabel= null; - fDirectionLabel= null; - fRightLabel= null; - fCenter= null; - - if (fRightArrow != null) { - fRightArrow.dispose(); - fRightArrow= null; - } - if (fLeftArrow != null) { - fLeftArrow.dispose(); - fLeftArrow= null; - } - if (fBothArrow != null) { - fBothArrow.dispose(); - fBothArrow= null; - } - - if (fNormalCursor != null) { - fNormalCursor.dispose(); - fNormalCursor= null; - } - if (fHSashCursor != null) { - fHSashCursor.dispose(); - fHSashCursor= null; - } - if (fVSashCursor != null) { - fVSashCursor.dispose(); - fVSashCursor= null; - } - if (fHVSashCursor != null) { - fHVSashCursor.dispose(); - fHVSashCursor= null; - } - - super.handleDispose(event); - } - - /** - * Updates the enabled state of the toolbar items. - *

- * This method is called whenever the state of the items needs updating. - *

- * Subclasses may extend this method, although this is generally not required. - */ - protected void updateToolItems() { - - IMergeViewerContentProvider content= getMergeContentProvider(); - - Object input= getInput(); - - if (fCopyLeftToRightAction != null) { - boolean enable= content.isRightEditable(input); -// if (enable && input instanceof ICompareInput) { -// ITypedElement e= ((ICompareInput) input).getLeft(); -// if (e == null) -// enable= false; -// } - fCopyLeftToRightAction.setEnabled(enable); - } - - if (fCopyRightToLeftAction != null) { - boolean enable= content.isLeftEditable(input); -// if (enable && input instanceof ICompareInput) { -// ITypedElement e= ((ICompareInput) input).getRight(); -// if (e == null) -// enable= false; -// } - fCopyRightToLeftAction.setEnabled(enable); - } - } - - /** - * Updates the headers of the three areas - * by querying the content provider for a name and image for - * the three sides of the input object. - *

- * This method is called whenever the header must be updated. - *

- * Subclasses may extend this method, although this is generally not required. - */ - protected void updateHeader() { - - IMergeViewerContentProvider content= getMergeContentProvider(); - Object input= getInput(); - - if (fAncestorLabel != null) { - fAncestorLabel.setImage(content.getAncestorImage(input)); - fAncestorLabel.setText(content.getAncestorLabel(input)); - } - if (fLeftLabel != null) { - fLeftLabel.setImage(content.getLeftImage(input)); - fLeftLabel.setText(content.getLeftLabel(input)); - } - if (fRightLabel != null) { - fRightLabel.setImage(content.getRightImage(input)); - fRightLabel.setText(content.getRightLabel(input)); - } - } - -// private Image loadImage(String name) { -// ImageDescriptor id= ImageDescriptor.createFromFile(ContentMergeViewer.class, name); -// if (id != null) -// return id.createImage(); -// return null; -// } - - /* - * Calculates the height of the header. - */ - /* package */ int getHeaderHeight() { - int headerHeight= fLeftLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y; - headerHeight= Math.max(headerHeight, fDirectionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y); - return headerHeight; - } - - //---- merge direction - - /* - * Returns true if both sides are editable. - */ - /* package */ boolean canToggleMergeDirection() { - IMergeViewerContentProvider content= getMergeContentProvider(); - Object input= getInput(); - return content.isLeftEditable(input) && content.isRightEditable(input); - } - - //---- dirty state & saving state - - /* (non Javadoc) - * see IPropertyChangeNotifier.addPropertyChangeListener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListenerList == null) - fListenerList= new ListenerList(); - fListenerList.add(listener); - } - - /* (non Javadoc) - * see IPropertyChangeNotifier.removePropertyChangeListener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - if (fListenerList != null) { - fListenerList.remove(listener); - if (fListenerList.isEmpty()) - fListenerList= null; - } - } - - /* package */ void fireDirtyState(boolean state) { - Utilities.firePropertyChange(fListenerList, this, CompareEditorInput.DIRTY_STATE, null, new Boolean(state)); - } - - /** - * Sets the dirty state of the left side of this viewer. - * If the new value differs from the old - * all registered listener are notified with - * a PropertyChangeEvent with the - * property name CompareEditorInput.DIRTY_STATE. - * - * @param dirty the state of the left side dirty flag - */ - protected void setLeftDirty(boolean dirty) { - if (fLeftSaveAction.isEnabled() != dirty) { - fLeftSaveAction.setEnabled(dirty); - fireDirtyState(dirty); - } - } - - /** - * Sets the dirty state of the right side of this viewer. - * If the new value differs from the old - * all registered listener are notified with - * a PropertyChangeEvent with the - * property name CompareEditorInput.DIRTY_STATE. - * - * @param dirty the state of the right side dirty flag - */ - protected void setRightDirty(boolean dirty) { - if (fRightSaveAction.isEnabled() != dirty) { - fRightSaveAction.setEnabled(dirty); - fireDirtyState(dirty); - } - } - - /* - * Save the viewers's content. - * Note: this method is for internal use only. Clients should not call this method. - * @since 2.0 - */ - public void save(IProgressMonitor pm) throws CoreException { - saveContent(getInput()); - } - - /* - * Save modified content back to input elements via the content provider. - */ - /* package */ void saveContent(Object oldInput) { - - // write back modified contents - IMergeViewerContentProvider content= (IMergeViewerContentProvider) getContentProvider(); - - boolean leftEmpty= content.getLeftContent(oldInput) == null; - boolean rightEmpty= content.getRightContent(oldInput) == null; - - if (fCompareConfiguration.isLeftEditable() && fLeftSaveAction.isEnabled()) { - byte[] bytes= getContents(true); - if (leftEmpty && bytes != null && bytes.length == 0) - bytes= null; - setLeftDirty(false); - content.saveLeftContent(oldInput, bytes); - } - - if (fCompareConfiguration.isRightEditable() && fRightSaveAction.isEnabled()) { - byte[] bytes= getContents(false); - if (rightEmpty && bytes != null && bytes.length == 0) - bytes= null; - setRightDirty(false); - content.saveRightContent(oldInput, bytes); - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java deleted file mode 100644 index fedb53161..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IDocumentRange.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.IDocument; - - -/** - * Defines a subrange in a document. - *

- * It is used by text viewers that can work on a subrange of a document. For example, - * a text viewer for Java compilation units might use this to restrict the view - * to a single method. - *

- *

- * Clients may implement this interface. - *

- * - * @see TextMergeViewer - * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode - */ -public interface IDocumentRange { - - /** - * The position category typically used for an IDocumentRange position - * (value "DocumentRangeCategory"). - * @since 2.0 - */ - public static final String RANGE_CATEGORY= "DocumentRangeCategory"; //$NON-NLS-1$ - - /** - * Returns the underlying document. - * - * @return the underlying document - */ - IDocument getDocument(); - - /** - * Returns a position that specifies a subrange in the underlying document, - * or null if this document range spans the whole underlying document. - * - * @return a position that specifies a subrange in the underlying document, or null - */ - Position getRange(); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java deleted file mode 100644 index 31d78b570..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/IMergeViewerContentProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.jface.viewers.IContentProvider; - - -/** - * A content provider that mediates between a ContentMergeViewer's model - * and the viewer itself. - *

- * Clients may implement this interface. - *

- * - * @see ContentMergeViewer - */ -public interface IMergeViewerContentProvider extends IContentProvider { - - //---- ancestor side - - /** - * Returns the label for the ancestor side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the ancestor side of a ContentMergeViewer - */ - String getAncestorLabel(Object input); - - /** - * Returns an optional image for the ancestor side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the ancestor side of a ContentMergeViewer, - * or null if none - */ - Image getAncestorImage(Object input); - - /** - * Returns the contents for the ancestor side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the ancestor side of a ContentMergeViewer, - * or null if none - */ - Object getAncestorContent(Object input); - - /** - * Returns whether the ancestor side of the given input element should be shown. - * @param input the merge viewer's input - * @return true if the ancestor side of the given input element should be shown - */ - boolean showAncestor(Object input); - - //---- left side - - /** - * Returns the label for the left side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the left side of a ContentMergeViewer - */ - String getLeftLabel(Object input); - - /** - * Returns an optional image for the left side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the left side of a ContentMergeViewer, - * or null if none - */ - Image getLeftImage(Object input); - - /** - * Returns the contents for the left side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the left side of a ContentMergeViewer, - * or null if none - */ - Object getLeftContent(Object input); - - /** - * Returns whether the left side is editable. - * - * @param input the input object of the ContentMergeViewer - * @return true if the left side of a ContentMergeViewer is editable - */ - boolean isLeftEditable(Object input); - - /** - * Saves new contents for the left side of the ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @param bytes the new contents to save for the left side - */ - void saveLeftContent(Object input, byte[] bytes); - - //---- right side - - /** - * Returns the label for the right side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the label for the right side of a ContentMergeViewer - */ - String getRightLabel(Object input); - - /** - * Returns an optional image for the right side of a ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the image for the right side of a ContentMergeViewer, - * or null if none - */ - Image getRightImage(Object input); - - /** - * Returns the contents for the right side of a ContentMergeViewer. - * The interpretation of the returned object depends on the concrete ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @return the content for the right side of a ContentMergeViewer, - * or null if none - */ - Object getRightContent(Object input); - - /** - * Returns whether the right side is editable. - * - * @param input the input object of the ContentMergeViewer - * @return true if the right side of a ContentMergeViewer is editable - */ - boolean isRightEditable(Object input); - - /** - * Saves new contents for the right side of the ContentMergeViewer. - * - * @param input the input object of the ContentMergeViewer - * @param bytes the new contents to save for the right side - */ - void saveRightContent(Object input, byte[] bytes); -} - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ITokenComparator.java deleted file mode 100644 index 43f03f1f4..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/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.compare.contentmergeviewer; - -import org.eclipse.compare.rangedifferencer.IRangeComparator; - - -/** - * For performing a so-called "token compare" on a line of text. - * This interface extends the IRangeComparator interface - * so that it can be used by the TextMergeViewer. - *

- * TextMergeViewer 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. - *

- * TextMergeViewer'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 - * TextMergeViewer.createTokenComparator factory method). - *

- * - * @see TextMergeViewer - */ -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/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java deleted file mode 100644 index f145e12e1..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java +++ /dev/null @@ -1,4303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * channingwalton@mac.com - curved line code - *******************************************************************************/ -package org.eclipse.compare.contentmergeviewer; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; -import java.util.ResourceBundle; -import java.text.MessageFormat; - -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.custom.*; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.resource.ColorRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.*; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.progress.IProgressService; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.MergeSourceViewer; -import org.eclipse.compare.internal.BufferedCanvas; -import org.eclipse.compare.internal.MergeViewerContentProvider; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.internal.TokenComparator; -import org.eclipse.compare.internal.DocLineComparator; -import org.eclipse.compare.internal.ComparePreferencePage; -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.compare.internal.CompareNavigator; -import org.eclipse.compare.internal.DocumentManager; -import org.eclipse.compare.internal.CompareMessages; -import org.eclipse.compare.rangedifferencer.*; -import org.eclipse.compare.structuremergeviewer.*; - -/** - * A text merge viewer uses the RangeDifferencer to perform a - * textual, line-by-line comparison of two (or three) input documents. - * It is based on the ContentMergeViewer and uses TextViewers - * to implement the ancestor, left, and right content areas. - *

- * In the three-way compare case ranges of differing lines are highlighted and framed - * with different colors to show whether the difference is an incoming, outgoing, or conflicting change. - * The TextMergeViewer supports the notion of a current "differing range" - * and provides toolbar buttons to navigate from one range to the next (or previous). - *

- * If there is a current "differing range" and the underlying document is editable - * the TextMergeViewer enables actions in context menu and toolbar to - * copy a range from one side to the other side, thereby performing a merge operation. - *

- * In addition to a line-by-line comparison the TextMergeViewer - * uses a token based compare on differing lines. - * The token compare is activated 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. - *

- * The TextMergeViewer's default token compare works on characters separated - * by whitespace. If a different strategy is needed (for example, Java tokens in - * a Java-aware merge viewer), clients can create their own token - * comparators by implementing the ITokenComparator interface and overriding the - * TextMergeViewer.createTokenComparator factory method). - *

- * Access to the TextMergeViewer's model is by means of an - * IMergeViewerContentProvider. Its getXContent methods must return - * either an IDocument, an IDocumentRange, or an IStreamContentAccessor. - * In the IDocumentRange case the TextMergeViewer - * works on a subrange of a document. In the IStreamContentAccessor case - * a document is created internally and initialized from the stream. - *

- * A TextMergeViewer can be used as is. However clients may subclass - * to customize the behavior. For example a MergeTextViewer for Java would override - * the configureTextViewer method to configure the TextViewer for Java source code, - * the createTokenComparator method to create a Java specific tokenizer. - * - * @see org.eclipse.compare.rangedifferencer.RangeDifferencer - * @see org.eclipse.jface.text.TextViewer - * @see ITokenComparator - * @see IDocumentRange - * @see org.eclipse.compare.IStreamContentAccessor - */ -public class TextMergeViewer extends ContentMergeViewer { - - private static final boolean DEBUG= false; - - private static final boolean FIX_47640= true; - - private static final String[] GLOBAL_ACTIONS= { - ActionFactory.UNDO.getId(), - ActionFactory.REDO.getId(), - ActionFactory.CUT.getId(), - ActionFactory.COPY.getId(), - ActionFactory.PASTE.getId(), - ActionFactory.DELETE.getId(), - ActionFactory.SELECT_ALL.getId(), - ActionFactory.SAVE.getId() - }; - private static final String[] TEXT_ACTIONS= { - MergeSourceViewer.UNDO_ID, - MergeSourceViewer.REDO_ID, - MergeSourceViewer.CUT_ID, - MergeSourceViewer.COPY_ID, - MergeSourceViewer.PASTE_ID, - MergeSourceViewer.DELETE_ID, - MergeSourceViewer.SELECT_ALL_ID, - MergeSourceViewer.SAVE_ID - }; - - private static final String BUNDLE_NAME= "org.eclipse.compare.contentmergeviewer.TextMergeViewerResources"; //$NON-NLS-1$ - - // the following symbolic constants must match the IDs in Compare's plugin.xml - private static final String INCOMING_COLOR= "INCOMING_COLOR"; //$NON-NLS-1$ - private static final String OUTGOING_COLOR= "OUTGOING_COLOR"; //$NON-NLS-1$ - private static final String CONFLICTING_COLOR= "CONFLICTING_COLOR"; //$NON-NLS-1$ - private static final String RESOLVED_COLOR= "RESOLVED_COLOR"; //$NON-NLS-1$ - - // constants - /** Width of left and right vertical bar */ - private static final int MARGIN_WIDTH= 6; - /** Width of center bar */ - private static final int CENTER_WIDTH= 34; - /** Width of birds eye view */ - private static final int BIRDS_EYE_VIEW_WIDTH= 12; - /** Width of birds eye view */ - private static final int BIRDS_EYE_VIEW_INSET= 2; - /** */ - private static final int RESOLVE_SIZE= 5; - /** if true copying conflicts from one side to other concatenates both sides */ - private static final boolean APPEND_CONFLICT= true; - - /** line width of change borders */ - private static final int LW= 1; - /** Selects between smartTokenDiff and mergingTokenDiff */ - private static final boolean USE_MERGING_TOKEN_DIFF= false; - - // determines whether a change between left and right is considered incoming or outgoing - private boolean fLeftIsLocal; - private boolean fShowCurrentOnly= false; - private boolean fShowCurrentOnly2= false; - private int fMarginWidth= MARGIN_WIDTH; - private int fTopInset; - - // Colors - private RGB fBackground; - private RGB fForeground; - private boolean fPollSystemForeground= true; - private boolean fPollSystemBackground= true; - - private RGB SELECTED_INCOMING; - private RGB INCOMING; - private RGB INCOMING_FILL; - - private RGB SELECTED_CONFLICT; - private RGB CONFLICT; - private RGB CONFLICT_FILL; - - private RGB SELECTED_OUTGOING; - private RGB OUTGOING; - private RGB OUTGOING_FILL; - - private RGB RESOLVED; - - private boolean fEndOfDocReached; - private IDocumentListener fDocumentListener; - - private IPreferenceStore fPreferenceStore; - private IPropertyChangeListener fPreferenceChangeListener; - - /** All diffs for calculating scrolling position (includes line ranges without changes) */ - private ArrayList fAllDiffs; - /** Subset of above: just real differences. */ - private ArrayList fChangeDiffs; - /** The current diff */ - private Diff fCurrentDiff; - - private HashMap fNewAncestorRanges= new HashMap(); - private HashMap fNewLeftRanges= new HashMap(); - private HashMap fNewRightRanges= new HashMap(); - - private MergeSourceViewer fAncestor; - private MergeSourceViewer fLeft; - private MergeSourceViewer fRight; - - private int fLeftLineCount; - private int fRightLineCount; - - private String fLeftEncoding; - private String fRightEncoding; - - private boolean fInScrolling; - - private int fPts[]= new int[8]; // scratch area for polygon drawing - - private boolean fIgnoreAncestor= false; - private ActionContributionItem fIgnoreAncestorItem; - private boolean fHighlightRanges; - - private boolean fShowPseudoConflicts= false; - - private boolean fUseSplines= true; - private boolean fUseSingleLine= true; - private boolean fUseResolveUI= true; - - private String fSymbolicFontName; - - private ActionContributionItem fNextItem; // goto next difference - private ActionContributionItem fPreviousItem; // goto previous difference - private ActionContributionItem fCopyDiffLeftToRightItem; - private ActionContributionItem fCopyDiffRightToLeftItem; - - private IKeyBindingService fKeyBindingService; - - private boolean fSynchronizedScrolling= true; - private boolean fShowMoreInfo= false; - - private MergeSourceViewer fFocusPart; - - private boolean fSubDoc= true; - private IPositionUpdater fPositionUpdater; - private boolean fIsMotif; - private boolean fIsCarbon; - - private boolean fHasErrors; - - - // SWT widgets - private BufferedCanvas fAncestorCanvas; - private BufferedCanvas fLeftCanvas; - private BufferedCanvas fRightCanvas; - private Canvas fScrollCanvas; - private ScrollBar fVScrollBar; - private Canvas fBirdsEyeCanvas; - private Canvas fSummaryHeader; - private HeaderPainter fHeaderPainter; - - // SWT resources to be disposed - private Map fColors; - private Cursor fBirdsEyeCursor; - - // points for center curves - private double[] fBasicCenterCurve; - - private Button fCenterButton; - private Diff fButtonDiff; - - class HeaderPainter implements PaintListener { - - private static final int INSET= BIRDS_EYE_VIEW_INSET; - - private RGB fIndicatorColor; - private Color fSeparatorColor; - - public HeaderPainter() { - fSeparatorColor= fSummaryHeader.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); - } - - /* - * Returns true on color change - */ - public boolean setColor(RGB color) { - RGB oldColor= fIndicatorColor; - fIndicatorColor= color; - if (color == null) - return oldColor != null; - if (oldColor != null) - return !color.equals(oldColor); - return true; - } - - private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) { - gc.setForeground(topLeft); - gc.drawLine(x, y, x + w -1, y); - gc.drawLine(x, y, x, y + h -1); - - gc.setForeground(bottomRight); - gc.drawLine(x + w, y, x + w, y + h); - gc.drawLine(x, y + h, x + w, y + h); - } - - public void paintControl(PaintEvent e) { - - Point s= fSummaryHeader.getSize(); - - if (fIndicatorColor != null) { - Display d= fSummaryHeader.getDisplay(); - e.gc.setBackground(getColor(d, fIndicatorColor)); - int min= Math.min(s.x, s.y)-2*INSET; - Rectangle r= new Rectangle((s.x-min)/2, (s.y-min)/2, min, min); - e.gc.fillRectangle(r); - if (d != null) - drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); - - e.gc.setForeground(fSeparatorColor); - e.gc.setLineWidth(1); - e.gc.drawLine(0+1, s.y-1, s.x-1-1, s.y-1); - } - } - } - - /* - * The position updater used to adapt the positions representing - * the child document ranges to changes of the parent document. - */ - class ChildPositionUpdater extends DefaultPositionUpdater { - - /* - * Creates the position updated. - */ - protected ChildPositionUpdater(String category) { - super(category); - } - - /* - * Child document ranges cannot be deleted other then by calling - * freeChildDocument. - */ - protected boolean notDeleted() { - return true; - } - - /* - * If an insertion happens at a child document's start offset, the - * position is extended rather than shifted. Also, if something is added - * right behind the end of the position, the position is extended rather - * than kept stable. - */ - protected void adaptToInsert() { - - if (fPosition == fLeft.getRegion() || fPosition == fRight.getRegion()) { - int myStart= fPosition.offset; - int myEnd= fPosition.offset + fPosition.length; - myEnd= Math.max(myStart, myEnd); - - int yoursStart= fOffset; - int yoursEnd= fOffset + fReplaceLength -1; - yoursEnd= Math.max(yoursStart, yoursEnd); - - if (myEnd < yoursStart) - return; - - if (myStart <= yoursStart) - fPosition.length += fReplaceLength; - else - fPosition.offset += fReplaceLength; - } else { - super.adaptToInsert(); - } - } - } - - /* - * A Diff represents synchronized character ranges in two or three Documents. - * The MergeTextViewer uses Diffs to find differences in line and token ranges. - */ - /* package */ class Diff { - /** character range in ancestor document */ - Position fAncestorPos; - /** character range in left document */ - Position fLeftPos; - /** character range in right document */ - Position fRightPos; - /** if this is a TokenDiff fParent points to the enclosing LineDiff */ - Diff fParent; - /** if Diff has been resolved */ - boolean fResolved; - int fDirection; - boolean fIsToken= false; - /** child token diffs */ - ArrayList fDiffs; - boolean fIsWhitespace= false; - - /* - * Create Diff from two ranges and an optional parent diff. - */ - Diff(Diff parent, int dir, IDocument ancestorDoc, Position aRange, int ancestorStart, int ancestorEnd, - IDocument leftDoc, Position lRange, int leftStart, int leftEnd, - IDocument rightDoc, Position rRange, int rightStart, int rightEnd) { - fParent= parent != null ? parent : this; - fDirection= dir; - - fLeftPos= createPosition(leftDoc, lRange, leftStart, leftEnd); - fRightPos= createPosition(rightDoc, rRange, rightStart, rightEnd); - if (ancestorDoc != null) - fAncestorPos= createPosition(ancestorDoc, aRange, ancestorStart, ancestorEnd); - } - - Position getPosition(char type) { - switch (type) { - case 'A': - return fAncestorPos; - case 'L': - return fLeftPos; - case 'R': - return fRightPos; - } - return null; - } - - boolean isInRange(char type, int pos) { - Position p= getPosition(type); - return (pos >= p.offset) && (pos < (p.offset+p.length)); - } - - String changeType() { - boolean leftEmpty= fLeftPos.length == 0; - boolean rightEmpty= fRightPos.length == 0; - - if (fDirection == RangeDifference.LEFT) { - if (!leftEmpty && rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.addition"); //$NON-NLS-1$ - if (leftEmpty && !rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.deletion"); //$NON-NLS-1$ - } else { - if (leftEmpty && !rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.addition"); //$NON-NLS-1$ - if (!leftEmpty && rightEmpty) - return CompareMessages.getString("TextMergeViewer.changeType.deletion"); //$NON-NLS-1$ - } - return CompareMessages.getString("TextMergeViewer.changeType.change"); //$NON-NLS-1$ - } - - Image getImage() { - int code= Differencer.CHANGE; - switch (fDirection) { - case RangeDifference.RIGHT: - code+= Differencer.LEFT; - break; - case RangeDifference.LEFT: - code+= Differencer.RIGHT; - break; - case RangeDifference.ANCESTOR: - case RangeDifference.CONFLICT: - code+= Differencer.CONFLICTING; - break; - } - if (code != 0) - return getCompareConfiguration().getImage(code); - return null; - } - - Position createPosition(IDocument doc, Position range, int start, int end) { - try { - int l= end-start; - if (range != null) { - int dl= range.length; - if (l > dl) - l= dl; - } else { - int dl= doc.getLength(); - if (start+l > dl) - l= dl-start; - } - - Position p= null; - try { - p= new Position(start, l); - } catch (RuntimeException ex) { - // silently ignored - } - - try { - doc.addPosition(IDocumentRange.RANGE_CATEGORY, p); - } catch (BadPositionCategoryException ex) { - // silently ignored - } - return p; - } catch (BadLocationException ee) { - // silently ignored - } - return null; - } - - void add(Diff d) { - if (fDiffs == null) - fDiffs= new ArrayList(); - fDiffs.add(d); - } - - boolean isDeleted() { - if (fAncestorPos != null && fAncestorPos.isDeleted()) - return true; - return fLeftPos.isDeleted() || fRightPos.isDeleted(); - } - - void setResolved(boolean r) { - fResolved= r; - if (r) - fDiffs= null; - } - - boolean isResolved() { - if (!fResolved && fDiffs != null) { - Iterator e= fDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - if (!d.isResolved()) - return false; - } - return true; - } - return fResolved; - } - -// private boolean isIncoming() { -// switch (fDirection) { -// case RangeDifference.RIGHT: -// if (fLeftIsLocal) -// return true; -// break; -// case RangeDifference.LEFT: -// if (!fLeftIsLocal) -// return true; -// break; -// } -// return false; -// } - - private boolean isIncomingOrConflicting() { - switch (fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return true; - break; - case RangeDifference.LEFT: - if (!fLeftIsLocal) - return true; - break; - case RangeDifference.CONFLICT: - return true; - } - return false; - } - -// private boolean isUnresolvedIncoming() { -// if (fResolved) -// return false; -// return isIncoming(); -// } - - private boolean isUnresolvedIncomingOrConflicting() { - if (fResolved) - return false; - return isIncomingOrConflicting(); - } - - Position getPosition(MergeSourceViewer w) { - if (w == fLeft) - return fLeftPos; - if (w == fRight) - return fRightPos; - if (w == fAncestor) - return fAncestorPos; - return null; - } - - /* - * Returns true if given character range overlaps with this Diff. - */ - boolean overlaps(MergeSourceViewer w, int start, int end) { - Position h= getPosition(w); - if (h != null) { - int ds= h.getOffset(); - int de= ds + h.getLength(); - if ((start < de) && (end >= ds)) - return true; - } - return false; - } - - int getMaxDiffHeight(boolean withAncestor) { - Point region= new Point(0, 0); - int h= fLeft.getLineRange(fLeftPos, region).y; - if (withAncestor) - h= Math.max(h, fAncestor.getLineRange(fAncestorPos, region).y); - return Math.max(h, fRight.getLineRange(fRightPos, region).y); - } - - int getAncestorHeight() { - Point region= new Point(0, 0); - return fAncestor.getLineRange(fAncestorPos, region).y; - } - - int getLeftHeight() { - Point region= new Point(0, 0); - return fLeft.getLineRange(fLeftPos, region).y; - } - - int getRightHeight() { - Point region= new Point(0, 0); - return fRight.getLineRange(fRightPos, region).y; - } - } - - //---- MergeTextViewer - - /** - * Creates a text merge viewer under the given parent control. - * - * @param parent the parent control - * @param configuration the configuration object - */ - public TextMergeViewer(Composite parent, CompareConfiguration configuration) { - this(parent, SWT.NULL, configuration); - } - - /** - * Creates a text merge viewer under the given parent control. - * - * @param parent the parent control - * @param style SWT style bits for top level composite of this viewer - * @param configuration the configuration object - */ - public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { - super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); - - fSymbolicFontName= getClass().getName(); - - String platform= SWT.getPlatform(); - fIsMotif= "motif".equals(platform); //$NON-NLS-1$ - fIsCarbon= "carbon".equals(platform); //$NON-NLS-1$ - - if (fIsMotif) - fMarginWidth= 0; - - Display display= parent.getDisplay(); - - fPreferenceChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - TextMergeViewer.this.propertyChange(event); - } - }; - - fPreferenceStore= configuration.getPreferenceStore(); - if (fPreferenceStore != null) { - fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); - - checkForColorUpdate(display); - - fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - fSynchronizedScrolling= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); - fShowMoreInfo= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO); - fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); - //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); - fUseSingleLine= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); - //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); - } - - fDocumentListener= new IDocumentListener() { - - public void documentAboutToBeChanged(DocumentEvent e) { - // nothing to do - } - - public void documentChanged(DocumentEvent e) { - TextMergeViewer.this.documentChanged(e); - } - }; - - buildControl(parent); - - INavigatable nav= new INavigatable() { - public boolean gotoDifference(boolean next) { - return navigate(next, false, false); - } - }; - fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); - - fBirdsEyeCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); - - JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); - JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); - updateFont(); - } - - private void updateFont() { - Font f= JFaceResources.getFont(fSymbolicFontName); - if (f != null) { - if (fAncestor != null) - fAncestor.setFont(f); - if (fLeft != null) - fLeft.setFont(f); - if (fRight != null) - fRight.setFont(f); - } - } - - private void checkForColorUpdate(Display display) { - if (fPollSystemForeground) { - RGB fg= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(); - if (fForeground == null || !fg.equals(fForeground)) { - fForeground= fg; - updateColors(display); - } - } - if (fPollSystemBackground) { - RGB bg= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); - if (fBackground == null || !bg.equals(fBackground)) { - fBackground= bg; - updateColors(display); - } - } - } - - /** - * Sets the viewer's background color to the given RGB value. - * If the value is null the system's default background color is used. - * @param background the background color or null to use the system's default background color - * @since 2.0 - */ - public void setBackgroundColor(RGB background) { - fPollSystemBackground= (background == null); - fBackground= background; - updateColors(null); - } - - private RGB getBackground(Display display) { - if (fBackground != null) - return fBackground; - if (display == null) - display= fComposite.getDisplay(); - return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); - } - - /** - * Sets the viewer's foreground color to the given RGB value. - * If the value is null the system's default foreground color is used. - * @param foreground the foreground color or null to use the system's default foreground color - * @since 2.0 - */ - public void setForegroundColor(RGB foreground) { - fPollSystemForeground= (foreground == null); - fForeground= foreground; - updateColors(null); - } - - private void updateColors(Display display) { - - if (display == null) - display= fComposite.getDisplay(); - - Color color= null; - if (fBackground != null) - color= getColor(display, fBackground); - - if (fAncestor != null) - fAncestor.setBackgroundColor(color); - if (fLeft != null) - fLeft.setBackgroundColor(color); - if (fRight != null) - fRight.setBackgroundColor(color); - - ColorRegistry registry= JFaceResources.getColorRegistry(); - - RGB bg= getBackground(display); - SELECTED_INCOMING= registry.getRGB(INCOMING_COLOR); - if (SELECTED_INCOMING == null) - SELECTED_INCOMING= new RGB(0, 0, 255); // BLUE - INCOMING= interpolate(SELECTED_INCOMING, bg, 0.6); - INCOMING_FILL= interpolate(SELECTED_INCOMING, bg, 0.97); - - SELECTED_OUTGOING= registry.getRGB(OUTGOING_COLOR); - if (SELECTED_OUTGOING == null) - SELECTED_OUTGOING= new RGB(0, 0, 0); // BLACK - OUTGOING= interpolate(SELECTED_OUTGOING, bg, 0.6); - OUTGOING_FILL= interpolate(SELECTED_OUTGOING, bg, 0.97); - - SELECTED_CONFLICT= registry.getRGB(CONFLICTING_COLOR); - if (SELECTED_CONFLICT == null) - SELECTED_CONFLICT= new RGB(255, 0, 0); // RED - CONFLICT= interpolate(SELECTED_CONFLICT, bg, 0.6); - CONFLICT_FILL= interpolate(SELECTED_CONFLICT, bg, 0.97); - - RESOLVED= registry.getRGB(RESOLVED_COLOR); - if (RESOLVED == null) - RESOLVED= new RGB(0, 255, 0); // GREEN - - refreshBirdsEyeView(); - invalidateLines(); - - updateAllDiffBackgrounds(display); - } - - /** - * Invalidates the current presentation by invalidating the three text viewers. - * @since 2.0 - */ - public void invalidateTextPresentation() { - if (fAncestor != null) - fAncestor.invalidateTextPresentation(); - if (fLeft != null) - fLeft.invalidateTextPresentation(); - if (fRight != null) - fRight.invalidateTextPresentation(); - } - - /** - * Configures the passed text viewer. - * This method is called after the three text viewers have been created for the - * content areas. - * The TextMergeViewer implementation of this method does nothing. - * Subclasses may reimplement to provide a specific configuration for the text viewer. - * - * @param textViewer the text viewer to configure - */ - protected void configureTextViewer(TextViewer textViewer) { - // empty impl - } - - /** - * Creates an ITokenComparator which is used to show the - * intra line differences. - * The TextMergeViewer implementation of this method returns a - * tokenizer that breaks a line into words separated by whitespace. - * Subclasses may reimplement to provide a specific tokenizer. - * @param line the line for which to create the ITokenComparator - * @return a ITokenComparator which is used for a second level token compare. - */ - protected ITokenComparator createTokenComparator(String line) { - return new TokenComparator(line); - } - - /** - * Returns a document partitioner which is suitable for the underlying content type. - * This method is only called if the input provided by the content provider is a - * IStreamContentAccessor and an internal document must be created. This - * document is initialized with the partitioner returned from this method. - *

- * The TextMergeViewer implementation of this method returns - * null. Subclasses may reimplement to create a partitioner for a - * specific content type. - * - * @return a document partitioner, or null - */ - protected IDocumentPartitioner getDocumentPartitioner() { - return null; - } - - /** - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - * @param event - */ - protected void handleDispose(DisposeEvent event) { - - if (fKeyBindingService != null) { - IAction a; - if (fNextItem != null) { - a= fNextItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fPreviousItem != null) { - a= fPreviousItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fCopyDiffLeftToRightItem != null) { - a= fCopyDiffLeftToRightItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - if (fCopyDiffRightToLeftItem != null) { - a= fCopyDiffRightToLeftItem.getAction(); - if (a != null) - fKeyBindingService.unregisterAction(a); - } - fKeyBindingService= null; - } - - Object input= getInput(); - DocumentManager.remove(getDocument2('A', input)); - DocumentManager.remove(getDocument2('L', input)); - DocumentManager.remove(getDocument2('R', input)); - - if (DEBUG) - DocumentManager.dump(); - - if (fPreferenceChangeListener != null) { - JFaceResources.getFontRegistry().removeListener(fPreferenceChangeListener); - JFaceResources.getColorRegistry().removeListener(fPreferenceChangeListener); - if (fPreferenceStore != null) - fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); - fPreferenceChangeListener= null; - } - - fLeftCanvas= null; - fRightCanvas= null; - fVScrollBar= null; - fBirdsEyeCanvas= null; - fSummaryHeader= null; - - unsetDocument(fAncestor); - unsetDocument(fLeft); - unsetDocument(fRight); - - if (fColors != null) { - Iterator i= fColors.values().iterator(); - while (i.hasNext()) { - Color color= (Color) i.next(); - if (!color.isDisposed()) - color.dispose(); - } - fColors= null; - } - - if (fBirdsEyeCursor != null) { - fBirdsEyeCursor.dispose(); - fBirdsEyeCursor= null; - } - - super.handleDispose(event); - } - - //------------------------------------------------------------------------------------------------------------- - //--- internal ------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------- - - /* - * Creates the specific SWT controls for the content areas. - * Clients must not call or override this method. - */ - protected void createControls(Composite composite) { - - WorkbenchHelp.setHelp(composite, ICompareContextIds.TEXT_MERGE_VIEW); - - // 1st row - if (fMarginWidth > 0) { - fAncestorCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fAncestor, fAncestorCanvas, false); - } - }; - fAncestorCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fAncestorCanvas, fAncestor, e.y), false); - } - } - ); - } - - fAncestor= createPart(composite); - fAncestor.setEditable(false); - - fSummaryHeader= new Canvas(composite, SWT.NONE); - fHeaderPainter= new HeaderPainter(); - fSummaryHeader.addPaintListener(fHeaderPainter); - updateResolveStatus(); - - // 2nd row - if (fMarginWidth > 0) { - fLeftCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fLeft, fLeftCanvas, false); - } - }; - fLeftCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fLeftCanvas, fLeft, e.y), false); - } - } - ); - } - - fLeft= createPart(composite); - fLeft.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fLeft.addAction(MergeSourceViewer.SAVE_ID, fLeftSaveAction); - - fRight= createPart(composite); - fRight.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fRight.addAction(MergeSourceViewer.SAVE_ID, fRightSaveAction); - - hsynchViewport(fAncestor, fLeft, fRight); - hsynchViewport(fLeft, fAncestor, fRight); - hsynchViewport(fRight, fAncestor, fLeft); - - if (fMarginWidth > 0) { - fRightCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintSides(gc, fRight, fRightCanvas, fSynchronizedScrolling); - } - }; - fRightCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handleMouseInSides(fRightCanvas, fRight, e.y), false); - } - } - ); - } - - fScrollCanvas= new Canvas(composite, SWT.V_SCROLL); - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - fTopInset= trim.y; - - fVScrollBar= fScrollCanvas.getVerticalBar(); - fVScrollBar.setIncrement(1); - fVScrollBar.setVisible(true); - fVScrollBar.addListener(SWT.Selection, - new Listener() { - public void handleEvent(Event e) { - int vpos= ((ScrollBar)e.widget).getSelection(); - scrollVertical(vpos, vpos, vpos, null); - workaround65205(); - } - } - ); - - fBirdsEyeCanvas= new BufferedCanvas(composite, SWT.NONE) { - public void doPaint(GC gc) { - paintBirdsEyeView(this, gc); - } - }; - fBirdsEyeCanvas.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - setCurrentDiff2(handlemouseInBirdsEyeView(fBirdsEyeCanvas, e.y), true); - } - } - ); - fBirdsEyeCanvas.addMouseMoveListener( - new MouseMoveListener() { - - private Cursor fLastCursor; - - public void mouseMove(MouseEvent e) { - Cursor cursor= null; - Diff diff= handlemouseInBirdsEyeView(fBirdsEyeCanvas, e.y); - if (diff != null && diff.fDirection != RangeDifference.NOCHANGE) - cursor= fBirdsEyeCursor; - if (fLastCursor != cursor) { - fBirdsEyeCanvas.setCursor(cursor); - fLastCursor= cursor; - } - } - } - ); - } - - private void hsynchViewport(final TextViewer tv1, final TextViewer tv2, final TextViewer tv3) { - final StyledText st1= tv1.getTextWidget(); - final StyledText st2= tv2.getTextWidget(); - final StyledText st3= tv3.getTextWidget(); - final ScrollBar sb1= st1.getHorizontalBar(); - sb1.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (fSynchronizedScrolling) { - int max= sb1.getMaximum()-sb1.getThumb(); - double v= 0.0; - if (max > 0) - v= (float)sb1.getSelection() / (float)max; - if (st2.isVisible()) { - ScrollBar sb2= st2.getHorizontalBar(); - st2.setHorizontalPixel((int)((sb2.getMaximum()-sb2.getThumb()) * v)); - } - if (st3.isVisible()) { - ScrollBar sb3= st3.getHorizontalBar(); - st3.setHorizontalPixel((int)((sb3.getMaximum()-sb3.getThumb()) * v)); - } - workaround65205(); - } - } - }); - } - - /** - * A workaround for bug #65205. - * On MacOS X a Display.update() is required to flush pending paint requests after - * programmatical scolling. - */ - private void workaround65205() { - if (fIsCarbon && fComposite != null && !fComposite.isDisposed()) - fComposite.getDisplay().update(); - } - - private void setCurrentDiff2(Diff diff, boolean reveal) { - if (diff != null && diff.fDirection != RangeDifference.NOCHANGE) { - //fCurrentDiff= null; - setCurrentDiff(diff, reveal); - } - } - - private Diff handleMouseInSides(Canvas canvas, MergeSourceViewer tp, int my) { - - int lineHeight= tp.getTextWidget().getLineHeight(); - int visibleHeight= tp.getViewportHeight(); - - if (! fHighlightRanges) - return null; - - if (fChangeDiffs != null) { - int shift= tp.getVerticalScrollOffset() + (2-LW); - - Point region= new Point(0, 0); - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), region); - int y= (region.x * lineHeight) + shift; - int h= region.y * lineHeight; - - if (y+h < 0) - continue; - if (y >= visibleHeight) - break; - - if (my >= y && my < y+h) - return diff; - } - } - return null; - } - - private Diff getDiffUnderMouse(Canvas canvas, int mx, int my, Rectangle r) { - - if (! fSynchronizedScrolling) - return null; - - int lineHeight= fLeft.getTextWidget().getLineHeight(); - int visibleHeight= fRight.getViewportHeight(); - - Point size= canvas.getSize(); - int w= size.x; - - if (! fHighlightRanges) - return null; - - if (fChangeDiffs != null) { - int lshift= fLeft.getVerticalScrollOffset(); - int rshift= fRight.getVerticalScrollOffset(); - - Point region= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - fLeft.getLineRange(diff.fLeftPos, region); - int ly= (region.x * lineHeight) + lshift; - int lh= region.y * lineHeight; - - fRight.getLineRange(diff.fRightPos, region); - int ry= (region.x * lineHeight) + rshift; - int rh= region.y * lineHeight; - - if (Math.max(ly+lh, ry+rh) < 0) - continue; - if (Math.min(ly, ry) >= visibleHeight) - break; - - int cx= (w-RESOLVE_SIZE)/2; - int cy= ((ly+lh/2) + (ry+rh/2) - RESOLVE_SIZE)/2; - if (my >= cy && my < cy+RESOLVE_SIZE && mx >= cx && mx < cx+RESOLVE_SIZE) { - if (r != null) { - int SIZE= fIsCarbon ? 30 : 20; - r.x= cx+(RESOLVE_SIZE-SIZE)/2; - r.y= cy+(RESOLVE_SIZE-SIZE)/2; - r.width= SIZE; - r.height= SIZE; - } - return diff; - } - } - } - return null; - } - - private Diff handlemouseInBirdsEyeView(Canvas canvas, int my) { - int yy, hh; - - Point size= canvas.getSize(); - - int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight(); - if (virtualHeight < getViewportHeight()) - return null; - - int y= 0; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor) - : diff.getRightHeight(); - if (useChange(diff.fDirection) && !diff.fIsWhitespace) { - - yy= (y*size.y)/virtualHeight; - hh= (h*size.y)/virtualHeight; - if (hh < 3) - hh= 3; - - if (my >= yy && my < yy+hh) - return diff; - } - y+= h; - } - } - return null; - } - - private void paintBirdsEyeView(Canvas canvas, GC gc) { - - Color c; - Rectangle r= new Rectangle(0, 0, 0, 0); - int yy, hh; - - Point size= canvas.getSize(); - - int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight(); - if (virtualHeight < getViewportHeight()) - return; - - Display display= canvas.getDisplay(); - int y= 0; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor) - : diff.getRightHeight(); - - if (useChange(diff.fDirection) && !diff.fIsWhitespace) { - - yy= (y*size.y)/virtualHeight; - hh= (h*size.y)/virtualHeight; - if (hh < 3) - hh= 3; - - c= getColor(display, getFillColor(diff)); - if (c != null) { - gc.setBackground(c); - gc.fillRectangle(BIRDS_EYE_VIEW_INSET, yy, size.x-(2*BIRDS_EYE_VIEW_INSET),hh); - } - c= getColor(display, getStrokeColor(diff)); - if (c != null) { - gc.setForeground(c); - r.x= BIRDS_EYE_VIEW_INSET; - r.y= yy; - r.width= size.x-(2*BIRDS_EYE_VIEW_INSET)-1; - r.height= hh; - if (diff == fCurrentDiff || - (fCurrentDiff != null && diff == fCurrentDiff.fParent)) { - gc.setLineWidth(2); - r.x++; - r.y++; - r.width--; - r.height--; - } else { - gc.setLineWidth(1); - } - gc.drawRectangle(r); - } - } - - y+= h; - } - } - } - - private void refreshBirdsEyeView() { - if (fBirdsEyeCanvas != null) - fBirdsEyeCanvas.redraw(); - } - - /* - * Called whenever setFocus() is called on the ContentViewer's top level SWT Composite. - * This implementation sets the focus to the first enabled text widget. - */ - /* package */ boolean internalSetFocus() { - if (fFocusPart == null) { - if (fLeft != null && fLeft.getEnabled()) { - fFocusPart= fLeft; - } else if (fRight != null && fRight.getEnabled()) { - fFocusPart= fRight; - } else if (fAncestor != null && fAncestor.getEnabled()) { - fFocusPart= fAncestor; - } - } - if (fFocusPart != null) { - StyledText st= fFocusPart.getTextWidget(); - if (st != null) - return st.setFocus(); - } - return false; // could not set focus - } - - - class HoverResizer extends Resizer { - Canvas fCanvas; - public HoverResizer(Canvas c, int dir) { - super(c, dir); - fCanvas= c; - } - public void mouseMove(MouseEvent e) { - if (!fIsDown && fUseSingleLine && showResolveUI() && handleMouseMoveOverCenter(fCanvas, e.x, e.y)) - return; - super.mouseMove(e); - } - } - - /* - * Creates the central Canvas. - * Called from ContentMergeViewer. - */ - /* package */ Control createCenter(Composite parent) { - if (fSynchronizedScrolling) { - final Canvas canvas= new BufferedCanvas(parent, SWT.NONE) { - public void doPaint(GC gc) { - paintCenter(this, gc); - } - }; - if (fUseResolveUI) { - - new HoverResizer(canvas, HORIZONTAL); - - fCenterButton= new Button(canvas, fIsCarbon ? SWT.FLAT : SWT.PUSH); - if (fNormalCursor == null) fNormalCursor= new Cursor(canvas.getDisplay(), SWT.CURSOR_ARROW); - fCenterButton.setCursor(fNormalCursor); - fCenterButton.setText("<"); //$NON-NLS-1$ - fCenterButton.pack(); - fCenterButton.setVisible(false); - fCenterButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fCenterButton.setVisible(false); - if (fButtonDiff != null) { - setCurrentDiff(fButtonDiff, false); - copy(fCurrentDiff, false, fCurrentDiff.fDirection == RangeDifference.CONFLICT); - } - } - } - ); - } else { - new Resizer(canvas, HORIZONTAL); - } - - return canvas; - } - return super.createCenter(parent); - } - - private boolean handleMouseMoveOverCenter(Canvas canvas, int x, int y) { - Rectangle r= new Rectangle(0, 0, 0, 0); - Diff diff= getDiffUnderMouse(canvas, x, y, r); - if (diff != null && !diff.isUnresolvedIncomingOrConflicting()) - diff= null; - if (diff != fButtonDiff) { - if (diff != null) { - if (fLeft.isEditable()) { - fButtonDiff= diff; - fCenterButton.setText("<"); //$NON-NLS-1$ - String tt= fCopyDiffRightToLeftItem.getAction().getToolTipText(); - fCenterButton.setToolTipText(tt); - fCenterButton.setBounds(r); - fCenterButton.setVisible(true); - } else if (fRight.isEditable()) { - fButtonDiff= diff; - fCenterButton.setText(">"); //$NON-NLS-1$ - String tt= fCopyDiffLeftToRightItem.getAction().getToolTipText(); - fCenterButton.setToolTipText(tt); - fCenterButton.setBounds(r); - fCenterButton.setVisible(true); - } else - fButtonDiff= null; - } else { - fCenterButton.setVisible(false); - fButtonDiff= null; - } - } - return fButtonDiff != null; - } - - /* - * Returns width of central canvas. - * Overridden from ContentMergeViewer. - */ - /* package */ int getCenterWidth() { - if (fSynchronizedScrolling) - return CENTER_WIDTH; - return super.getCenterWidth(); - } - - /* - * Creates and initializes a text part. - */ - private MergeSourceViewer createPart(Composite parent) { - - final MergeSourceViewer part= new MergeSourceViewer(parent, getResourceBundle()); - final StyledText te= part.getTextWidget(); - - if (!fConfirmSave) - part.hideSaveAction(); - - te.addPaintListener( - new PaintListener() { - public void paintControl(PaintEvent e) { - paint(e, part); - } - } - ); - te.addKeyListener( - new KeyAdapter() { - public void keyPressed(KeyEvent e) { - handleSelectionChanged(part); - } - } - ); - te.addMouseListener( - new MouseAdapter() { - public void mouseDown(MouseEvent e) { - //syncViewport(part); - handleSelectionChanged(part); - } - } - ); - - te.addFocusListener( - new FocusAdapter() { - public void focusGained(FocusEvent fe) { - fFocusPart= part; - connectGlobalActions(fFocusPart); - } - public void focusLost(FocusEvent fe) { - connectGlobalActions(null); - } - } - ); - - part.addViewportListener( - new IViewportListener() { - public void viewportChanged(int verticalPosition) { - syncViewport(part); - } - } - ); - - Font font= JFaceResources.getFont(fSymbolicFontName); - if (font != null) - te.setFont(font); - - if (fBackground != null) // not default - te.setBackground(getColor(parent.getDisplay(), fBackground)); - - configureTextViewer(part); - - return part; - } - - private void connectGlobalActions(MergeSourceViewer part) { - IActionBars actionBars= Utilities.findActionBars(fComposite); - if (actionBars != null) { - for (int i= 0; i < GLOBAL_ACTIONS.length; i++) { - IAction action= null; - if (part != null) { - action= part.getAction(TEXT_ACTIONS[i]); - if (action == null && TEXT_ACTIONS[i].equals(MergeSourceViewer.SAVE_ID)) { - if (part == fLeft) - action= fLeftSaveAction; - else - action= fRightSaveAction; - } - } - actionBars.setGlobalActionHandler(GLOBAL_ACTIONS[i], action); - } - actionBars.updateActionBars(); - } - } - - ITypedElement getLeg(char type, Object input) { - if (input instanceof ICompareInput) { - switch (type) { - case 'A': - return ((ICompareInput)input).getAncestor(); - case 'L': - return ((ICompareInput)input).getLeft(); - case 'R': - return ((ICompareInput)input).getRight(); - } - } - return null; - } - - IDocument getDocument(char type, Object input) { - ITypedElement te= getLeg(type, input); - if (te instanceof IDocument) - return (IDocument) te; - if (te instanceof IDocumentRange) - return ((IDocumentRange) te).getDocument(); - if (te instanceof IStreamContentAccessor) - return DocumentManager.get(te); - return null; - } - - IDocument getDocument2(char type, Object input) { - IDocument doc= getDocument(type, input); - if (doc != null) - return doc; - - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - return getDocument(type, parent); - } - return null; - } - - /* - * Returns true if the given inputs map to the same documents - */ - boolean sameDoc(char type, Object newInput, Object oldInput) { - IDocument newDoc= getDocument2(type, newInput); - IDocument oldDoc= getDocument2(type, oldInput); - return newDoc == oldDoc; - } - - /** - * Overridden to prevent save confirmation if new input is sub document of current input. - * @param newInput the new input of this viewer, or null if there is no new input - * @param oldInput the old input element, or null if there was previously no input - * @return true if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). - * @since 2.0 - */ - protected boolean doSave(Object newInput, Object oldInput) { - - if (oldInput != null && newInput != null) { - // check whether underlying documents have changed. - if (sameDoc('A', newInput, oldInput) && - sameDoc('L', newInput, oldInput) && - sameDoc('R', newInput, oldInput)) { - if (DEBUG) System.out.println("----- Same docs !!!!"); //$NON-NLS-1$ - return false; - } - } - - if (DEBUG) System.out.println("***** New docs !!!!"); //$NON-NLS-1$ - - IDocument aDoc= getDocument2('A', oldInput); - DocumentManager.remove(aDoc); - IDocument lDoc= getDocument2('L', oldInput); - DocumentManager.remove(lDoc); - IDocument rDoc= getDocument2('R', oldInput); - DocumentManager.remove(rDoc); - - if (DEBUG) - DocumentManager.dump(); - - return super.doSave(newInput, oldInput); - } - - private ITypedElement getParent(char type) { - Object input= getInput(); - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - return getLeg(type, parent); - } - return null; - } - - /* - * Initializes the text viewers of the three content areas with the given input objects. - * Subclasses may extend. - */ - protected void updateContent(Object ancestor, Object left, Object right) { - - boolean emptyInput= (ancestor == null && left == null && right == null); - - Object input= getInput(); - - Position leftRange= null; - Position rightRange= null; - - // if one side is empty use container - if (FIX_47640 && !emptyInput && (left == null || right == null)) { - if (input instanceof IDiffElement) { - IDiffContainer parent= ((IDiffElement)input).getParent(); - if (parent instanceof ICompareInput) { - ICompareInput ci= (ICompareInput) parent; - - if (ci.getAncestor() instanceof IDocumentRange - || ci.getLeft() instanceof IDocumentRange - || ci.getRight() instanceof IDocumentRange) { - - if (left instanceof IDocumentRange) - leftRange= ((IDocumentRange)left).getRange(); - if (right instanceof IDocumentRange) - rightRange= ((IDocumentRange)right).getRange(); - - ancestor= ci.getAncestor(); - left= ci.getLeft(); - right= ci.getRight(); - } - } - } - } - - int n= 0; - if (left != null) - n++; - if (right != null) - n++; - fHighlightRanges= n > 1; - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - fEndOfDocReached= false; - fHasErrors= false; // start with no errors - - CompareConfiguration cc= getCompareConfiguration(); - IMergeViewerContentProvider cp= getMergeContentProvider(); - - if (cp instanceof MergeViewerContentProvider) { - MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp; - mcp.setAncestorError(null); - mcp.setLeftError(null); - mcp.setRightError(null); - } - - // set new documents - setDocument(fLeft, 'L', left); - fLeftLineCount= fLeft.getLineCount(); - fLeftEncoding= getEncoding(left); - - setDocument(fRight, 'R', right); - fRightLineCount= fRight.getLineCount(); - fRightEncoding= getEncoding(right); - - setDocument(fAncestor, 'A', ancestor); - - updateHeader(); - updateControls(); - updateToolItems(); - - if (!fHasErrors) - doDiff(); - - fRight.setEditable(cc.isRightEditable() && cp.isRightEditable(input)); - fLeft.setEditable(cc.isLeftEditable() && cp.isLeftEditable(input)); - - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - if (!fHasErrors && !emptyInput && !fComposite.isDisposed()) { - Diff selectDiff= null; - if (FIX_47640) { - if (leftRange != null) - selectDiff= findDiff('L', leftRange); - else if (rightRange != null) - selectDiff= findDiff('R', rightRange); - } - if (selectDiff != null) - setCurrentDiff(selectDiff, true); - else - selectFirstDiff(); - } - } - - private Diff findDiff(char c, Position range) { - - MergeSourceViewer v; - int start= range.getOffset(); - int end= start + range.getLength(); - if (c == 'L') - v= fLeft; - else if (c == 'R') - v= fRight; - else - return null; - - if (fChangeDiffs != null) { - Iterator iter= fChangeDiffs.iterator(); - while (iter.hasNext()) { - Diff diff= (Diff) iter.next(); - if (diff.isDeleted() || diff.fDirection == RangeDifference.NOCHANGE) - continue; - if (diff.overlaps(v, start, end)) - return diff; - } - } - return null; - } - - private static String getEncoding(Object o) { - String encoding= null; - if (o instanceof IEncodedStreamContentAccessor) { - try { - encoding= ((IEncodedStreamContentAccessor)o).getCharset(); - } catch (CoreException e) { - // ignored - } - } - if (encoding == null) - encoding= ResourcesPlugin.getEncoding(); - return encoding; - } - - private void updateDiffBackground(Diff diff) { - - if (! fHighlightRanges) - return; - - if (diff == null || diff.fIsToken) - return; - - if (fShowCurrentOnly && !isCurrentDiff(diff)) - return; - - Color c= getColor(null, getFillColor(diff)); - if (c == null) - return; - - if (isThreeWay()) - fAncestor.setLineBackground(diff.fAncestorPos, c); - fLeft.setLineBackground(diff.fLeftPos, c); - fRight.setLineBackground(diff.fRightPos, c); - } - - private void updateAllDiffBackgrounds(Display display) { - if (fChangeDiffs != null) { - boolean threeWay= isThreeWay(); - Iterator iter= fChangeDiffs.iterator(); - while (iter.hasNext()) { - Diff diff= (Diff) iter.next(); - Color c= getColor(display, getFillColor(diff)); - if (threeWay) - fAncestor.setLineBackground(diff.fAncestorPos, c); - fLeft.setLineBackground(diff.fLeftPos, c); - fRight.setLineBackground(diff.fRightPos, c); - } - } - } - - boolean isCurrentDiff(Diff diff) { - if (diff == null) - return false; - if (diff == fCurrentDiff) - return true; - if (fCurrentDiff != null && fCurrentDiff.fParent == diff) - return true; - return false; - } - - /* - * Called whenver one of the documents changes. - * Sets the dirty state of this viewer and updates the lines. - * Implements IDocumentListener. - */ - private void documentChanged(DocumentEvent e) { - - IDocument doc= e.getDocument(); - - if (doc == fLeft.getDocument()) { - setLeftDirty(true); - } else if (doc == fRight.getDocument()) { - setRightDirty(true); - } - - updateLines(doc); - } - - /* - * This method is called if a range of text on one side is copied into an empty subdocument - * on the other side. The method returns the position where the subdocument is placed into the base document. - * This default implementation determines the position by using the text range differencer. - * However this position is not always optimal for specific types of text. - * So subclasses (which are aware of the type of text they are dealing with) - * may override this method to find a better position where to insert a newly added - * piece of text. - * @param type the side for which the insertion position should be determined: 'A' for ancestor, 'L' for left hand side, 'R' for right hand side. - * @param input the current input object of this viewer - * @since 2.0 - */ - protected int findInsertionPosition(char type, ICompareInput input) { - - ITypedElement other= null; - char otherType= 0; - - switch (type) { - case 'A': - other= input.getLeft(); - otherType= 'L'; - if (other == null) { - other= input.getRight(); - otherType= 'R'; - } - break; - case 'L': - other= input.getRight(); - otherType= 'R'; - if (other == null) { - other= input.getAncestor(); - otherType= 'A'; - } - break; - case 'R': - other= input.getLeft(); - otherType= 'L'; - if (other == null) { - other= input.getAncestor(); - otherType= 'A'; - } - break; - } - - if (other instanceof IDocumentRange) { - IDocumentRange dr= (IDocumentRange) other; - Position p= dr.getRange(); - Diff diff= findDiff(otherType, p.offset); - if (diff != null) { - switch (type) { - case 'A': - if (diff.fAncestorPos != null) - return diff.fAncestorPos.offset; - break; - case 'L': - if (diff.fLeftPos != null) - return diff.fLeftPos.offset; - break; - case 'R': - if (diff.fRightPos != null) - return diff.fRightPos.offset; - break; - } - } - } - return 0; - } - - private void setError(char type, String message) { - IMergeViewerContentProvider cp= getMergeContentProvider(); - if (cp instanceof MergeViewerContentProvider) { - MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp; - switch (type) { - case 'A': - mcp.setAncestorError(message); - break; - case 'L': - mcp.setLeftError(message); - break; - case 'R': - mcp.setRightError(message); - break; - } - } - fHasErrors= true; - } - - /* - * Returns true if a new Document could be installed. - */ - private boolean setDocument(MergeSourceViewer tp, char type, Object o) { - - if (tp == null) - return false; - - IDocument newDoc= null; - Position range= null; - - if (o instanceof IDocumentRange) { - newDoc= ((IDocumentRange)o).getDocument(); - range= ((IDocumentRange)o).getRange(); - - } else if (o instanceof IDocument) { - newDoc= (IDocument) o; - - } else if (o instanceof IStreamContentAccessor) { - - newDoc= DocumentManager.get(o); - if (newDoc == null) { - IStreamContentAccessor sca= (IStreamContentAccessor) o; - String s= null; - - try { - s= Utilities.readString(sca); - } catch (CoreException ex) { - setError(type, ex.getMessage()); - } - - newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$ - DocumentManager.put(o, newDoc); - IDocumentPartitioner partitioner= getDocumentPartitioner(); - if (partitioner != null) { - newDoc.setDocumentPartitioner(partitioner); - partitioner.connect(newDoc); - } - } - } else if (o == null) { // deletion on one side - - ITypedElement parent= getParent(type); // we try to find an insertion position within the deletion's parent - - if (parent instanceof IDocumentRange) { - newDoc= ((IDocumentRange)parent).getDocument(); - newDoc.addPositionCategory(IDocumentRange.RANGE_CATEGORY); - Object input= getInput(); - range= getNewRange(type, input); - if (range == null) { - int pos= 0; - if (input instanceof ICompareInput) - pos= findInsertionPosition(type, (ICompareInput)input); - range= new Position(pos, 0); - try { - newDoc.addPosition(IDocumentRange.RANGE_CATEGORY, range); - } catch (BadPositionCategoryException ex) { - // silently ignored - if (DEBUG) System.out.println("BadPositionCategoryException: " + ex); //$NON-NLS-1$ - } catch (BadLocationException ex) { - // silently ignored - if (DEBUG) System.out.println("BadLocationException: " + ex); //$NON-NLS-1$ - } - addNewRange(type, input, range); - } - } else if (parent instanceof IDocument) { - newDoc= ((IDocumentRange)o).getDocument(); - } - } - - boolean enabled= true; - if (newDoc == null) { - //System.out.println("setDocument: create new Document"); - newDoc= new Document(""); //$NON-NLS-1$ - enabled= false; - } - - IDocument oldDoc= tp.getDocument(); - - if (newDoc != oldDoc) { - - // got a new document - - unsetDocument(tp); - - if (newDoc != null) { - newDoc.addPositionCategory(IDocumentRange.RANGE_CATEGORY); - if (fPositionUpdater == null) - fPositionUpdater= new ChildPositionUpdater(IDocumentRange.RANGE_CATEGORY); - else - newDoc.removePositionUpdater(fPositionUpdater); - newDoc.addPositionUpdater(fPositionUpdater); - } - - // install new document - if (newDoc != null) { - - tp.setRegion(range); - if (fSubDoc) { - if (range != null) { - IRegion r= normalizeDocumentRegion(newDoc, toRegion(range)); - tp.setDocument(newDoc, r.getOffset(), r.getLength()); - } else - tp.setDocument(newDoc); - } else - tp.setDocument(newDoc); - - tp.rememberDocument(newDoc); - newDoc.addDocumentListener(fDocumentListener); - //LeakTester.add(newDoc); - } - - } else { // same document but different range - - tp.setRegion(range); - if (fSubDoc) { - if (range != null) { - IRegion r= normalizeDocumentRegion(newDoc, toRegion(range)); - tp.setVisibleRegion(r.getOffset(), r.getLength()); - } else - tp.resetVisibleRegion(); - } else - tp.resetVisibleRegion(); - } - - tp.setEnabled(enabled); - - return enabled; - } - - private Position getNewRange(char type, Object input) { - switch (type) { - case 'A': - return (Position) fNewAncestorRanges.get(input); - case 'L': - return (Position) fNewLeftRanges.get(input); - case 'R': - return (Position) fNewRightRanges.get(input); - } - return null; - } - - private void addNewRange(char type, Object input, Position range) { - switch (type) { - case 'A': - fNewAncestorRanges.put(input, range); - break; - case 'L': - fNewLeftRanges.put(input, range); - break; - case 'R': - fNewRightRanges.put(input, range); - break; - } - } - - private void unsetDocument(MergeSourceViewer tp) { - IDocument oldDoc= tp.getDocument(); - if (oldDoc == null) { - oldDoc= tp.getRememberedDocument(); -// if (oldDoc != null) -// System.err.println("TextMergeViewer.unsetDocument: would leak"); - } - if (oldDoc != null) { - tp.rememberDocument(null); - // deinstall old positions - if (fPositionUpdater != null) - oldDoc.removePositionUpdater(fPositionUpdater); - try { - oldDoc.removePositionCategory(IDocumentRange.RANGE_CATEGORY); - } catch (BadPositionCategoryException ex) { - // NeedWork - } - - oldDoc.removeDocumentListener(fDocumentListener); - //LeakTester.remove(oldDoc); - } - } - - /** - * Returns the contents of the underlying document as an array of bytes using the current workbench encoding. - * - * @param left if true the contents of the left side is returned; otherwise the right side - * @return the contents of the left or right document or null - */ - protected byte[] getContents(boolean left) { - MergeSourceViewer v= left ? fLeft : fRight; - if (v != null) { - IDocument d= v.getDocument(); - if (d != null) { - String contents= d.get(); - if (contents != null) { - byte[] bytes; - try { - bytes= contents.getBytes(left ? fLeftEncoding : fRightEncoding); - } catch(UnsupportedEncodingException ex) { - // use default encoding - bytes= contents.getBytes(); - } - return bytes; - } - } - } - return null; - } - - private IRegion normalizeDocumentRegion(IDocument doc, IRegion region) { - - if (region == null || doc == null) - return region; - - int maxLength= doc.getLength(); - - int start= region.getOffset(); - if (start < 0) - start= 0; - else if (start > maxLength) - start= maxLength; - - int length= region.getLength(); - if (length < 0) - length= 0; - else if (start + length > maxLength) - length= maxLength - start; - - return new Region(start, length); - } - - protected final void handleResizeAncestor(int x, int y, int width, int height) { - if (width > 0) { - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height; - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.setVisible(true); - if (fAncestor.isControlOkToUse()) - fAncestor.getTextWidget().setVisible(true); - - if (fAncestorCanvas != null) { - fAncestorCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - width-= fMarginWidth; - } - fAncestor.getTextWidget().setBounds(x, y, width, height); - } else { - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.setVisible(false); - if (fAncestor.isControlOkToUse()) { - StyledText t= fAncestor.getTextWidget(); - t.setVisible(false); - t.setBounds(0, 0, 0, 0); - if (fFocusPart == fAncestor) { - fFocusPart= fLeft; - fFocusPart.getTextWidget().setFocus(); - } - } - } - } - - /* - * Lays out everything. - */ - protected final void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height) { - - if (fBirdsEyeCanvas != null) - width2-= BIRDS_EYE_VIEW_WIDTH; - - Rectangle trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height + trim.x; - - Composite composite= (Composite) getControl(); - - int leftTextWidth= width1; - if (fLeftCanvas != null) { - fLeftCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - leftTextWidth-= fMarginWidth; - } - - fLeft.getTextWidget().setBounds(x, y, leftTextWidth, height); - x+= leftTextWidth; - - if (fCenter == null || fCenter.isDisposed()) - fCenter= createCenter(composite); - fCenter.setBounds(x, y, centerWidth, height-scrollbarHeight); - x+= centerWidth; - - if (!fSynchronizedScrolling) { // canvas is to the left of text - if (fRightCanvas != null) { - fRightCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - fRightCanvas.redraw(); - x+= fMarginWidth; - } - // we draw the canvas to the left of the text widget - } - - int scrollbarWidth= 0; - if (fSynchronizedScrolling && fScrollCanvas != null) { - trim= fLeft.getTextWidget().computeTrim(0, 0, 0, 0); - scrollbarWidth= trim.width + 2*trim.x; - } - int rightTextWidth= width2-scrollbarWidth; - if (fRightCanvas != null) - rightTextWidth-= fMarginWidth; - fRight.getTextWidget().setBounds(x, y, rightTextWidth, height); - x+= rightTextWidth; - - if (fSynchronizedScrolling) { - if (fRightCanvas != null) { // canvas is to the right of the text - fRightCanvas.setBounds(x, y, fMarginWidth, height-scrollbarHeight); - x+= fMarginWidth; - } - if (fScrollCanvas != null) - fScrollCanvas.setBounds(x, y, scrollbarWidth, height-scrollbarHeight); - } - - if (fBirdsEyeCanvas != null) { - int verticalScrollbarButtonHeight= scrollbarWidth; - int horizontalScrollbarButtonHeight= scrollbarHeight; - if (fIsCarbon) { - verticalScrollbarButtonHeight+= 2; - horizontalScrollbarButtonHeight= 18; - } - if (fSummaryHeader != null) - fSummaryHeader.setBounds(x+scrollbarWidth, y, BIRDS_EYE_VIEW_WIDTH, verticalScrollbarButtonHeight); - y+= verticalScrollbarButtonHeight; - fBirdsEyeCanvas.setBounds(x+scrollbarWidth, y, BIRDS_EYE_VIEW_WIDTH, height-(2*verticalScrollbarButtonHeight+horizontalScrollbarButtonHeight)); - } - - // doesn't work since TextEditors don't have their correct size yet. - updateVScrollBar(); - refreshBirdsEyeView(); - } - - /* - * Track selection changes to update the current Diff. - */ - private void handleSelectionChanged(MergeSourceViewer tw) { - Point p= tw.getSelectedRange(); - Diff d= findDiff(tw, p.x, p.x+p.y); - updateStatus(d); - setCurrentDiff(d, false); // don't select or reveal - } - - private static IRegion toRegion(Position position) { - if (position != null) - return new Region(position.getOffset(), position.getLength()); - return null; - } - - //---- the differencing - - private static int maxWork(IRangeComparator a, IRangeComparator l, IRangeComparator r) { - int ln= l.getRangeCount(); - int rn= r.getRangeCount(); - if (a != null) { - int an= a.getRangeCount(); - return (2 * Math.max(an, ln)) + (2 * Math.max(an, rn)); - } - return 2 * Math.max(ln, rn); - } - - /** - * Perform a two level 2- or 3-way diff. - * The first level is based on line comparison, the second level on token comparison. - */ - private void doDiff() { - - fAllDiffs= new ArrayList(); - fChangeDiffs= new ArrayList(); - fCurrentDiff= null; - - IDocument aDoc= null; - IDocument lDoc= fLeft.getDocument(); - IDocument rDoc= fRight.getDocument(); - if (lDoc == null || rDoc == null) - return; - - Position aRegion= null; - Position lRegion= fLeft.getRegion(); - Position rRegion= fRight.getRegion(); - - boolean threeWay= isThreeWay(); - - if (threeWay && !fIgnoreAncestor) { - aDoc= fAncestor.getDocument(); - aRegion= fAncestor.getRegion(); - } - - fAncestor.resetLineBackground(); - fLeft.resetLineBackground(); - fRight.resetLineBackground(); - - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - - DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); - DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); - DocLineComparator sancestor= null; - if (aDoc != null) - sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); - - if (!fSubDoc && rRegion != null && lRegion != null) { - // we have to add a diff for the ignored lines - - int astart= 0; - int as= 0; - if (aRegion != null) { - astart= aRegion.getOffset(); - as= Math.max(0, astart-1); - } - int ys= Math.max(0, lRegion.getOffset()-1); - int ms= Math.max(0, rRegion.getOffset()-1); - - if (as > 0 || ys > 0 || ms > 0) { - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, 0, astart, - lDoc, lRegion, 0, lRegion.getOffset(), - rDoc, rRegion, 0, rRegion.getOffset()); - fAllDiffs.add(diff); - } - } - - final ResourceBundle bundle= getResourceBundle(); - - final Object[] result= new Object[1]; - final DocLineComparator sa= sancestor, sl= sleft, sr= sright; - IRunnableWithProgress runnable= new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - String progressTitle= Utilities.getString(bundle, "compareProgressTask.title"); //$NON-NLS-1$ - monitor.beginTask(progressTitle, maxWork(sa, sl, sr)); - try { - result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); - } catch (OutOfMemoryError ex) { - System.gc(); - throw new InvocationTargetException(ex); - } - if (monitor.isCanceled()) { // cancelled - throw new InterruptedException(); - } - monitor.done(); - } - }; - IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); - - RangeDifference[] e= null; - try { - progressService.run(true, true, runnable); - e= (RangeDifference[]) result[0]; - } catch (InvocationTargetException ex) { - String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ - String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ - String msg= MessageFormat.format(format, new Object[] { Integer.toString(progressService.getLongOperationTime()/1000) } ); - MessageDialog.openError(fComposite.getShell(), title, msg); - e= null; - } catch (InterruptedException ex) { - // - } - - if (e == null) { - // we create a NOCHANGE range for the whole document - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, 0, aDoc != null ? aDoc.getLength() : 0, - lDoc, lRegion, 0, lDoc.getLength(), - rDoc, rRegion, 0, rDoc.getLength()); - - fAllDiffs.add(diff); - } else { - for (int i= 0; i < e.length; i++) { - String a= null, s= null, d= null; - RangeDifference es= e[i]; - - int kind= es.kind(); - - int ancestorStart= 0; - int ancestorEnd= 0; - if (sancestor != null) { - ancestorStart= sancestor.getTokenStart(es.ancestorStart()); - ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart= sleft.getTokenStart(es.leftStart()); - int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - - int rightStart= sright.getTokenStart(es.rightStart()); - int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(null, kind, - aDoc, aRegion, ancestorStart, ancestorEnd, - lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); - - fAllDiffs.add(diff); // remember all range diffs for scrolling - - if (ignoreWhiteSpace) { - if (sancestor != null) - a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength()); - s= extract2(lDoc, sleft, es.leftStart(), es.leftLength()); - d= extract2(rDoc, sright, es.rightStart(), es.rightLength()); - - if ((a == null || a.trim().length() == 0) && s.trim().length() == 0 && d.trim().length() == 0) { - diff.fIsWhitespace= true; - continue; - } - } - - if (useChange(kind)) { - fChangeDiffs.add(diff); // here we remember only the real diffs - updateDiffBackground(diff); - - if (s == null) - s= extract2(lDoc, sleft, es.leftStart(), es.leftLength()); - if (d == null) - d= extract2(rDoc, sright, es.rightStart(), es.rightLength()); - - if (s.length() > 0 && d.length() > 0) { - if (a == null && sancestor != null) - a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength()); - if (USE_MERGING_TOKEN_DIFF) - mergingTokenDiff(diff, aDoc, a, rDoc, d, lDoc, s); - else - simpleTokenDiff(diff, aDoc, a, rDoc, d, lDoc, s); - } - } - } - } - - if (!fSubDoc && rRegion != null && lRegion != null) { - // we have to add a diff for the ignored lines - - int aEnd= 0; - int aLen= 0; - if (aRegion != null && aDoc != null) { - aEnd= aRegion.getOffset()+aRegion.getLength(); - aLen= aDoc.getLength(); - } - Diff diff= new Diff(null, RangeDifference.NOCHANGE, - aDoc, aRegion, aEnd, aLen, - lDoc, lRegion, lRegion.getOffset()+lRegion.getLength(), lDoc.getLength(), - rDoc, rRegion, rRegion.getOffset()+rRegion.getLength(), rDoc.getLength()); - fAllDiffs.add(diff); - } - } - - private Diff findDiff(char type, int pos) { - - IDocument aDoc= null; - IDocument lDoc= fLeft.getDocument(); - IDocument rDoc= fRight.getDocument(); - if (lDoc == null || rDoc == null) - return null; - - Position aRegion= null; - Position lRegion= null; - Position rRegion= null; - - boolean threeWay= isThreeWay(); - - if (threeWay && !fIgnoreAncestor) - aDoc= fAncestor.getDocument(); - - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - - DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); - DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); - DocLineComparator sancestor= null; - if (aDoc != null) - sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); - - final ResourceBundle bundle= getResourceBundle(); - - final Object[] result= new Object[1]; - final DocLineComparator sa= sancestor, sl= sleft, sr= sright; - IRunnableWithProgress runnable= new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - String progressTitle= Utilities.getString(bundle, "compareProgressTask.title"); //$NON-NLS-1$ - monitor.beginTask(progressTitle, maxWork(sa, sl, sr)); - try { - result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); - } catch (OutOfMemoryError ex) { - System.gc(); - throw new InvocationTargetException(ex); - } - if (monitor.isCanceled()) { // cancelled - throw new InterruptedException(); - } - monitor.done(); - } - }; - IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); - - RangeDifference[] e= null; - try { - progressService.run(true, true, runnable); - e= (RangeDifference[]) result[0]; - } catch (InvocationTargetException ex) { - String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ - String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ - String msg= MessageFormat.format(format, new Object[] { Integer.toString(progressService.getLongOperationTime()/1000) } ); - MessageDialog.openError(fComposite.getShell(), title, msg); - e= null; - } catch (InterruptedException ex) { - // - } - - if (e != null) { - for (int i= 0; i < e.length; i++) { - RangeDifference es= e[i]; - - int kind= es.kind(); - - int ancestorStart= 0; - int ancestorEnd= 0; - if (sancestor != null) { - ancestorStart= sancestor.getTokenStart(es.ancestorStart()); - ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart= sleft.getTokenStart(es.leftStart()); - int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - - int rightStart= sright.getTokenStart(es.rightStart()); - int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(null, kind, - aDoc, aRegion, ancestorStart, ancestorEnd, - lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); - - if (diff.isInRange(type, pos)) - return diff; - } - } - - return null; - } - - /* - * Returns true if kind of change should be shown. - */ - private boolean useChange(int kind) { - if (kind == RangeDifference.NOCHANGE) - return false; - if (kind == RangeDifference.ANCESTOR) - return fShowPseudoConflicts; - return true; - } - - private int getTokenEnd(ITokenComparator tc, int start, int count) { - if (count <= 0) - return tc.getTokenStart(start); - int index= start + count - 1; - return tc.getTokenStart(index) + tc.getTokenLength(index); - } - - private static int getTokenEnd2(ITokenComparator tc, int start, int length) { - return tc.getTokenStart(start + length); - } - - /* - * Returns the content of lines in the specified range as a String. - * This includes the line separators. - * - * @param doc the document from which to extract the characters - * @param start index of first line - * @param length number of lines - * @return the contents of the specified line range as a String - */ - private String extract2(IDocument doc, ITokenComparator tc, int start, int length) { - int count= tc.getRangeCount(); - if (length > 0 && count > 0) { - -// -// int startPos= tc.getTokenStart(start); -// int endPos= startPos; -// -// if (length > 1) -// endPos= tc.getTokenStart(start + (length-1)); -// endPos+= tc.getTokenLength(start + (length-1)); -// - - int startPos= tc.getTokenStart(start); - int endPos; - - if (length == 1) { - endPos= startPos + tc.getTokenLength(start); - } else { - endPos= tc.getTokenStart(start + length); - } - - try { - return doc.get(startPos, endPos - startPos); - } catch (BadLocationException e) { - // silently ignored - } - - } - return ""; //$NON-NLS-1$ - } - - /* - * Performs a token based 3-way diff on the character range specified by the given baseDiff. - */ - private void simpleTokenDiff(final Diff baseDiff, - IDocument ancestorDoc, String a, - IDocument rightDoc, String d, - IDocument leftDoc, String s) { - - int ancestorStart= 0; - ITokenComparator sa= null; - if (ancestorDoc != null) { - ancestorStart= baseDiff.fAncestorPos.getOffset(); - sa= createTokenComparator(a); - } - - int rightStart= baseDiff.fRightPos.getOffset(); - ITokenComparator sm= createTokenComparator(d); - - int leftStart= baseDiff.fLeftPos.getOffset(); - ITokenComparator sy= createTokenComparator(s); - - RangeDifference[] e= RangeDifferencer.findRanges(sa, sy, sm); - for (int i= 0; i < e.length; i++) { - RangeDifference es= e[i]; - int kind= es.kind(); - if (kind != RangeDifference.NOCHANGE) { - - int ancestorStart2= ancestorStart; - int ancestorEnd2= ancestorStart; - if (ancestorDoc != null) { - ancestorStart2 += sa.getTokenStart(es.ancestorStart()); - ancestorEnd2 += getTokenEnd(sa, es.ancestorStart(), es.ancestorLength()); - } - - int leftStart2= leftStart + sy.getTokenStart(es.leftStart()); - int leftEnd2= leftStart + getTokenEnd(sy, es.leftStart(), es.leftLength()); - - int rightStart2= rightStart + sm.getTokenStart(es.rightStart()); - int rightEnd2= rightStart + getTokenEnd(sm, es.rightStart(), es.rightLength()); - - Diff diff= new Diff(baseDiff, kind, - ancestorDoc, null, ancestorStart2, ancestorEnd2, - leftDoc, null, leftStart2, leftEnd2, - rightDoc, null, rightStart2, rightEnd2); - - // ensure that token diff is smaller than basediff - int leftS= baseDiff.fLeftPos.offset; - int leftE= baseDiff.fLeftPos.offset+baseDiff.fLeftPos.length; - int rightS= baseDiff.fRightPos.offset; - int rightE= baseDiff.fRightPos.offset+baseDiff.fRightPos.length; - if (leftS != leftStart2 || leftE != leftEnd2 || - rightS != rightStart2 || rightE != rightEnd2) { - diff.fIsToken= true; - // add to base Diff - baseDiff.add(diff); - } - } - } - } - - /* - * Performs a "smart" token based 3-way diff on the character range specified by the given baseDiff. - * It is "smart" because it tries to minimize the number of token diffs by merging them. - */ - private void mergingTokenDiff(Diff baseDiff, - IDocument ancestorDoc, String a, - IDocument rightDoc, String d, - IDocument leftDoc, String s) { - ITokenComparator sa= null; - int ancestorStart= 0; - if (ancestorDoc != null) { - sa= createTokenComparator(a); - ancestorStart= baseDiff.fAncestorPos.getOffset(); - } - - int rightStart= baseDiff.fRightPos.getOffset(); - ITokenComparator sm= createTokenComparator(d); - - int leftStart= baseDiff.fLeftPos.getOffset(); - ITokenComparator sy= createTokenComparator(s); - - RangeDifference[] r= RangeDifferencer.findRanges(sa, sy, sm); - for (int i= 0; i < r.length; i++) { - RangeDifference es= r[i]; - // determine range of diffs in one line - int start= i; - int leftLine= -1; - int rightLine= -1; - try { - leftLine= leftDoc.getLineOfOffset(leftStart+sy.getTokenStart(es.leftStart())); - rightLine= rightDoc.getLineOfOffset(rightStart+sm.getTokenStart(es.rightStart())); - } catch (BadLocationException e) { - // silently ignored - } - i++; - for (; i < r.length; i++) { - es= r[i]; - try { - if (leftLine != leftDoc.getLineOfOffset(leftStart+sy.getTokenStart(es.leftStart()))) - break; - if (rightLine != rightDoc.getLineOfOffset(rightStart+sm.getTokenStart(es.rightStart()))) - break; - } catch (BadLocationException e) { - // silently ignored - } - } - int end= i; - - // find first diff from left - RangeDifference first= null; - for (int ii= start; ii < end; ii++) { - es= r[ii]; - if (useChange(es.kind())) { - first= es; - break; - } - } - - // find first diff from mine - RangeDifference last= null; - for (int ii= end-1; ii >= start; ii--) { - es= r[ii]; - if (useChange(es.kind())) { - last= es; - break; - } - } - - if (first != null && last != null) { - - int ancestorStart2= 0; - int ancestorEnd2= 0; - if (ancestorDoc != null) { - ancestorStart2= ancestorStart+sa.getTokenStart(first.ancestorStart()); - ancestorEnd2= ancestorStart+getTokenEnd(sa, last.ancestorStart(), last.ancestorLength()); - } - - int leftStart2= leftStart+sy.getTokenStart(first.leftStart()); - int leftEnd2= leftStart+getTokenEnd(sy, last.leftStart(), last.leftLength()); - - int rightStart2= rightStart+sm.getTokenStart(first.rightStart()); - int rightEnd2= rightStart+getTokenEnd(sm, last.rightStart(), last.rightLength()); - Diff diff= new Diff(baseDiff, first.kind(), - ancestorDoc, null, ancestorStart2, ancestorEnd2+1, - leftDoc, null, leftStart2, leftEnd2+1, - rightDoc, null, rightStart2, rightEnd2+1); - diff.fIsToken= true; - baseDiff.add(diff); - } - } - } - - //---- update UI stuff - - private void updateControls() { - - boolean leftToRight= false; - boolean rightToLeft= false; - - updateStatus(fCurrentDiff); - updateResolveStatus(); - - if (fCurrentDiff != null) { - IMergeViewerContentProvider cp= getMergeContentProvider(); - if (cp != null) { - rightToLeft= cp.isLeftEditable(getInput()); - leftToRight= cp.isRightEditable(getInput()); - } - } - - if (fDirectionLabel != null) { - if (fHighlightRanges && fCurrentDiff != null && isThreeWay() && !fIgnoreAncestor) { - fDirectionLabel.setImage(fCurrentDiff.getImage()); - } else { - fDirectionLabel.setImage(null); - } - } - - if (fCopyDiffLeftToRightItem != null) - ((Action)fCopyDiffLeftToRightItem.getAction()).setEnabled(leftToRight); - if (fCopyDiffRightToLeftItem != null) - ((Action)fCopyDiffRightToLeftItem.getAction()).setEnabled(rightToLeft); - - boolean enableNavigation= false; - if (fCurrentDiff == null && fChangeDiffs != null && fChangeDiffs.size() > 0) - enableNavigation= true; - else if (fChangeDiffs != null && fChangeDiffs.size() > 1) - enableNavigation= true; - else if (fCurrentDiff != null && fCurrentDiff.fDiffs != null) - enableNavigation= true; - else if (fCurrentDiff != null && fCurrentDiff.fIsToken) - enableNavigation= true; - - if (fNextItem != null) { - IAction a= fNextItem.getAction(); - a.setEnabled(enableNavigation); - } - if (fPreviousItem != null) { - IAction a= fPreviousItem.getAction(); - a.setEnabled(enableNavigation); - } - } - - private void updateResolveStatus() { - - RGB rgb= null; - - if (showResolveUI()) { - // we only show red or green if there is at least one incoming or conflicting change - int incomingOrConflicting= 0; - int unresolvedIncoming= 0; - int unresolvedConflicting= 0; - - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - if (d.isIncomingOrConflicting() /* && useChange(d.fDirection) && !d.fIsWhitespace */) { - incomingOrConflicting++; - if (!d.fResolved) { - if (d.fDirection == RangeDifference.CONFLICT) { - unresolvedConflicting++; - break; // we can stop here because a conflict has the maximum priority - } - unresolvedIncoming++; - } - } - } - } - - if (incomingOrConflicting > 0) { - if (unresolvedConflicting > 0) - rgb= SELECTED_CONFLICT; - else if (unresolvedIncoming > 0) - rgb= SELECTED_INCOMING; - else - rgb= RESOLVED; - } - } - - if (fHeaderPainter.setColor(rgb)) - fSummaryHeader.redraw(); - } - - private void updateStatus(Diff diff) { - - if (! fShowMoreInfo) - return; - - IActionBars bars= Utilities.findActionBars(fComposite); - if (bars == null) - return; - IStatusLineManager slm= bars.getStatusLineManager(); - if (slm == null) - return; - - String diffDescription; - - if (diff == null) { - diffDescription= CompareMessages.getString("TextMergeViewer.diffDescription.noDiff.format"); //$NON-NLS-1$ - } else { - - if (diff.fIsToken) // we don't show special info for token diffs - diff= diff.fParent; - - String format= CompareMessages.getString("TextMergeViewer.diffDescription.diff.format"); //$NON-NLS-1$ - diffDescription= MessageFormat.format(format, - new String[] { - getDiffType(diff), // 0: diff type - getDiffNumber(diff), // 1: diff number - getDiffRange(fLeft, diff.fLeftPos), // 2: left start line - getDiffRange(fRight, diff.fRightPos) // 3: left end line - } - ); - } - - String format= CompareMessages.getString("TextMergeViewer.statusLine.format"); //$NON-NLS-1$ - String s= MessageFormat.format(format, - new String[] { - getCursorPosition(fLeft), // 0: left column - getCursorPosition(fRight), // 1: right column - diffDescription // 2: diff description - } - ); - - slm.setMessage(s); - } - - private void clearStatus() { - - IActionBars bars= Utilities.findActionBars(fComposite); - if (bars == null) - return; - IStatusLineManager slm= bars.getStatusLineManager(); - if (slm == null) - return; - - slm.setMessage(null); - } - - private String getDiffType(Diff diff) { - String s= ""; //$NON-NLS-1$ - switch(diff.fDirection) { - case RangeDifference.LEFT: - s= CompareMessages.getString("TextMergeViewer.direction.outgoing"); //$NON-NLS-1$ - break; - case RangeDifference.RIGHT: - s= CompareMessages.getString("TextMergeViewer.direction.incoming"); //$NON-NLS-1$ - break; - case RangeDifference.CONFLICT: - s= CompareMessages.getString("TextMergeViewer.direction.conflicting"); //$NON-NLS-1$ - break; - } - String format= CompareMessages.getString("TextMergeViewer.diffType.format"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] { s, diff.changeType() } ); - } - - private String getDiffNumber(Diff diff) { - // find the diff's number - int diffNumber= 0; - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff d= (Diff) e.next(); - diffNumber++; - if (d == diff) - break; - } - } - return Integer.toString(diffNumber); - } - - private String getDiffRange(MergeSourceViewer v, Position pos) { - Point p= v.getLineRange(pos, new Point(0, 0)); - int startLine= p.x+1; - int endLine= p.x+p.y; - - String format; - if (endLine < startLine) - format= CompareMessages.getString("TextMergeViewer.beforeLine.format"); //$NON-NLS-1$ - else - format= CompareMessages.getString("TextMergeViewer.range.format"); //$NON-NLS-1$ - return MessageFormat.format(format, - new String[] { Integer.toString(startLine), - Integer.toString(endLine) } ); - } - - /* - * Returns a description of the cursor position. - * - * @return a description of the cursor position - */ - private String getCursorPosition(MergeSourceViewer v) { - if (v != null) { - StyledText styledText= v.getTextWidget(); - - IDocument document= v.getDocument(); - if (document != null) { - int offset= v.getVisibleRegion().getOffset(); - int caret= offset + styledText.getCaretOffset(); - - try { - - int line=document.getLineOfOffset(caret); - - int lineOffset= document.getLineOffset(line); - int occurrences= 0; - for (int i= lineOffset; i < caret; i++) - if ('\t' == document.getChar(i)) - ++ occurrences; - - int tabWidth= styledText.getTabs(); - int column= caret - lineOffset + (tabWidth -1) * occurrences; - - String format= CompareMessages.getString("TextMergeViewer.cursorPosition.format"); //$NON-NLS-1$ - return MessageFormat.format(format, - new String[] { Integer.toString(line + 1), Integer.toString(column + 1) } ); - - } catch (BadLocationException x) { - // silently ignored - } - } - } - return ""; //$NON-NLS-1$ - } - - protected void updateHeader() { - - super.updateHeader(); - - updateControls(); - } - - /* - * Creates the two items for copying a difference range from one side to the other - * and adds them to the given toolbar manager. - */ - protected void createToolItems(ToolBarManager tbm) { - - IWorkbenchPartSite ps= Utilities.findSite(fComposite); - fKeyBindingService= ps != null ? ps.getKeyBindingService() : null; - - final String ignoreAncestorActionKey= "action.IgnoreAncestor."; //$NON-NLS-1$ - Action ignoreAncestorAction= new Action() { - public void run() { - setIgnoreAncestor(! fIgnoreAncestor); - Utilities.initToggleAction(this, getResourceBundle(), ignoreAncestorActionKey, fIgnoreAncestor); - } - }; - ignoreAncestorAction.setChecked(fIgnoreAncestor); - Utilities.initAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey); - Utilities.initToggleAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey, fIgnoreAncestor); - - fIgnoreAncestorItem= new ActionContributionItem(ignoreAncestorAction); - fIgnoreAncestorItem.setVisible(false); - tbm.appendToGroup("modes", fIgnoreAncestorItem); //$NON-NLS-1$ - - tbm.add(new Separator()); - - Action a= new Action() { - public void run() { - navigate(true, true, true); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.NextDiff."); //$NON-NLS-1$ - fNextItem= new ActionContributionItem(a); - tbm.appendToGroup("navigation", fNextItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.selectNextChange"); //$NON-NLS-1$ - - a= new Action() { - public void run() { - navigate(false, true, true); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.PrevDiff."); //$NON-NLS-1$ - fPreviousItem= new ActionContributionItem(a); - tbm.appendToGroup("navigation", fPreviousItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.selectPreviousChange"); //$NON-NLS-1$ - - - CompareConfiguration cc= getCompareConfiguration(); - - if (cc.isRightEditable()) { - a= new Action() { - public void run() { - copyDiffLeftToRight(); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.CopyDiffLeftToRight."); //$NON-NLS-1$ - fCopyDiffLeftToRightItem= new ActionContributionItem(a); - fCopyDiffLeftToRightItem.setVisible(true); - tbm.appendToGroup("merge", fCopyDiffLeftToRightItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.copyLeftToRight"); //$NON-NLS-1$ - } - - if (cc.isLeftEditable()) { - a= new Action() { - public void run() { - copyDiffRightToLeft(); - } - }; - Utilities.initAction(a, getResourceBundle(), "action.CopyDiffRightToLeft."); //$NON-NLS-1$ - fCopyDiffRightToLeftItem= new ActionContributionItem(a); - fCopyDiffRightToLeftItem.setVisible(true); - tbm.appendToGroup("merge", fCopyDiffRightToLeftItem); //$NON-NLS-1$ - Utilities.registerAction(fKeyBindingService, a, "org.eclipse.compare.copyRightToLeft"); //$NON-NLS-1$ - } - } - - /* package */ void propertyChange(PropertyChangeEvent event) { - - String key= event.getProperty(); - - if (key.equals(CompareConfiguration.IGNORE_WHITESPACE) - || key.equals(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS)) { - - fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - - doDiff(); - - updateControls(); - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - selectFirstDiff(); - -// } else if (key.equals(ComparePreferencePage.USE_SPLINES)) { -// fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); -// invalidateLines(); - - } else if (key.equals(ComparePreferencePage.USE_SINGLE_LINE)) { - fUseSingleLine= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); -// fUseResolveUI= fUseSingleLine; - fBasicCenterCurve= null; - updateResolveStatus(); - invalidateLines(); - -// } else if (key.equals(ComparePreferencePage.USE_RESOLVE_UI)) { -// fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); -// updateResolveStatus(); -// invalidateLines(); - - } else if (key.equals(fSymbolicFontName)) { - updateFont(); - invalidateLines(); - - } else if (key.equals(INCOMING_COLOR) || key.equals(OUTGOING_COLOR) || key.equals(CONFLICTING_COLOR) || key.equals(RESOLVED_COLOR)) { - updateColors(null); - invalidateLines(); - - } else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) { - - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); - if (b != fSynchronizedScrolling) - toggleSynchMode(); - - } else if (key.equals(ComparePreferencePage.SHOW_MORE_INFO)) { - - boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO); - if (b != fShowMoreInfo) { - fShowMoreInfo= b; - if (fShowMoreInfo) - updateStatus(fCurrentDiff); - else - clearStatus(); - } - - } else - super.propertyChange(event); - } - - private void setIgnoreAncestor(boolean ignore) { - if (ignore != fIgnoreAncestor) { - fIgnoreAncestor= ignore; - setAncestorVisibility(false, !fIgnoreAncestor); - - // clear stuff - fCurrentDiff= null; - fChangeDiffs= null; - fAllDiffs= null; - - doDiff(); - - invalidateLines(); - updateVScrollBar(); - refreshBirdsEyeView(); - - selectFirstDiff(); - } - } - - private void selectFirstDiff() { - - if (fLeft == null || fRight == null) { - return; - } - if (fLeft.getDocument() == null || fRight.getDocument() == null) { - return; - } - - Diff firstDiff= null; - if (CompareNavigator.getDirection(fComposite)) - firstDiff= findNext(fRight, fChangeDiffs, -1, -1, false); - else - firstDiff= findPrev(fRight, fChangeDiffs, 9999999, 9999999, false); - setCurrentDiff(firstDiff, true); - } - - private void toggleSynchMode() { - fSynchronizedScrolling= ! fSynchronizedScrolling; - - scrollVertical(0, 0, 0, null); - - // throw away central control (Sash or Canvas) - Control center= getCenter(); - if (center != null && !center.isDisposed()) - center.dispose(); - - fLeft.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - fRight.getTextWidget().getVerticalBar().setVisible(!fSynchronizedScrolling); - - fComposite.layout(true); - } - - protected void updateToolItems() { - - if (fIgnoreAncestorItem != null) - fIgnoreAncestorItem.setVisible(isThreeWay()); - - if (fCopyDiffLeftToRightItem != null) { - IAction a= fCopyDiffLeftToRightItem.getAction(); - if (a != null) - a.setEnabled(a.isEnabled() && !fHasErrors); - } - if (fCopyDiffRightToLeftItem != null) { - IAction a= fCopyDiffRightToLeftItem.getAction(); - if (a != null) - a.setEnabled(a.isEnabled() && !fHasErrors); - } - - super.updateToolItems(); - } - - //---- painting lines - - private void updateLines(IDocument d) { - - boolean left= false; - boolean right= false; - - // FIXME: this optimization is incorrect because - // it doesn't take replace operations into account where - // the old and new line count does not differ - if (d == fLeft.getDocument()) { - int l= fLeft.getLineCount(); - left= fLeftLineCount != l; - fLeftLineCount= l; - } else if (d == fRight.getDocument()) { - int l= fRight.getLineCount(); - right= fRightLineCount != l; - fRightLineCount= l; - } - - if (left || right) { - - if (left) { - if (fLeftCanvas != null) - fLeftCanvas.redraw(); - } else { - if (fRightCanvas != null) - fRightCanvas.redraw(); - } - Control center= getCenter(); - if (center != null) - center.redraw(); - - updateVScrollBar(); - refreshBirdsEyeView(); - } - } - - private void invalidateLines() { - if (isThreeWay()) { - if (Utilities.okToUse(fAncestorCanvas)) - fAncestorCanvas.redraw(); - if (fAncestor != null && fAncestor.isControlOkToUse()) - fAncestor.getTextWidget().redraw(); - } - - if (Utilities.okToUse(fLeftCanvas)) - fLeftCanvas.redraw(); - - if (fLeft != null && fLeft.isControlOkToUse()) - fLeft.getTextWidget().redraw(); - - if (Utilities.okToUse(getCenter())) - getCenter().redraw(); - - if (fRight != null && fRight.isControlOkToUse()) - fRight.getTextWidget().redraw(); - - if (Utilities.okToUse(fRightCanvas)) - fRightCanvas.redraw(); - } - - private boolean showResolveUI() { - if (!fUseResolveUI || !isThreeWay() || fIgnoreAncestor) - return false; - CompareConfiguration cc= getCompareConfiguration(); - if (cc == null) - return false; - // we only enable the new resolve ui if exactly one side is editable - boolean l= cc.isLeftEditable(); - boolean r= cc.isRightEditable(); - //return (l && !r) || (r && !l); - return l || r; - } - - private void paintCenter(Canvas canvas, GC g) { - - Display display= canvas.getDisplay(); - - checkForColorUpdate(display); - - if (! fSynchronizedScrolling) - return; - - int lineHeight= fLeft.getTextWidget().getLineHeight(); - int visibleHeight= fRight.getViewportHeight(); - - Point size= canvas.getSize(); - int x= 0; - int w= size.x; - - g.setBackground(canvas.getBackground()); - g.fillRectangle(x+1, 0, w-2, size.y); - - if (!fIsMotif) { - // draw thin line between center ruler and both texts - g.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); - g.fillRectangle(0, 0, 1, size.y); - g.fillRectangle(w-1, 0, 1, size.y); - } - - if (! fHighlightRanges) - return; - - boolean showResolveUI= showResolveUI(); - - if (fChangeDiffs != null) { - int lshift= fLeft.getVerticalScrollOffset(); - int rshift= fRight.getVerticalScrollOffset(); - - Point region= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - fLeft.getLineRange(diff.fLeftPos, region); - int ly= (region.x * lineHeight) + lshift; - int lh= region.y * lineHeight; - - fRight.getLineRange(diff.fRightPos, region); - int ry= (region.x * lineHeight) + rshift; - int rh= region.y * lineHeight; - - if (Math.max(ly+lh, ry+rh) < 0) - continue; - if (Math.min(ly, ry) >= visibleHeight) - break; - - fPts[0]= x; fPts[1]= ly; fPts[2]= w; fPts[3]= ry; - fPts[6]= x; fPts[7]= ly+lh; fPts[4]= w; fPts[5]= ry+rh; - - Color fillColor= getColor(display, getFillColor(diff)); - Color strokeColor= getColor(display, getStrokeColor(diff)); - - if (fUseSingleLine) { - int w2= 3; - - g.setBackground(fillColor); - g.fillRectangle(0, ly, w2, lh); // left - g.fillRectangle(w-w2, ry, w2, rh); // right - - g.setLineWidth(LW); - g.setForeground(strokeColor); - g.drawRectangle(0-1, ly, w2, lh); // left - g.drawRectangle(w-w2, ry, w2, rh); // right - - if (fUseSplines) { - int[] points= getCenterCurvePoints(w2, ly+lh/2, w-w2, ry+rh/2); - for (int i= 1; i < points.length; i++) - g.drawLine(w2+i-1, points[i-1], w2+i, points[i]); - } else { - g.drawLine(w2, ly+lh/2, w-w2, ry+rh/2); - } - } else { - // two lines - if (fUseSplines) { - g.setBackground(fillColor); - - g.setLineWidth(LW); - g.setForeground(strokeColor); - - int[] topPoints= getCenterCurvePoints(fPts[0], fPts[1], fPts[2], fPts[3]); - int[] bottomPoints= getCenterCurvePoints(fPts[6], fPts[7], fPts[4], fPts[5]); - g.setForeground(fillColor); - g.drawLine(0, bottomPoints[0], 0, topPoints[0]); - for (int i= 1; i < bottomPoints.length; i++) { - g.setForeground(fillColor); - g.drawLine(i, bottomPoints[i], i, topPoints[i]); - g.setForeground(strokeColor); - g.drawLine(i-1, topPoints[i-1], i, topPoints[i]); - g.drawLine(i-1, bottomPoints[i-1], i, bottomPoints[i]); - } - } else { - g.setBackground(fillColor); - g.fillPolygon(fPts); - - g.setLineWidth(LW); - g.setForeground(strokeColor); - g.drawLine(fPts[0], fPts[1], fPts[2], fPts[3]); - g.drawLine(fPts[6], fPts[7], fPts[4], fPts[5]); - } - } - - if (fUseSingleLine && showResolveUI && diff.isUnresolvedIncomingOrConflicting()) { - // draw resolve state - int cx= (w-RESOLVE_SIZE)/2; - int cy= ((ly+lh/2) + (ry+rh/2) - RESOLVE_SIZE)/2; - - g.setBackground(fillColor); - g.fillRectangle(cx, cy, RESOLVE_SIZE, RESOLVE_SIZE); - - g.setForeground(strokeColor); - g.drawRectangle(cx, cy, RESOLVE_SIZE, RESOLVE_SIZE); - } - } - } - } - - private int[] getCenterCurvePoints(int startx, int starty, int endx, int endy) { - if (fBasicCenterCurve == null) - buildBaseCenterCurve(endx-startx); - double height= endy - starty; - height= height/2; - int width= endx-startx; - int[] points= new int[width]; - for (int i= 0; i < width; i++) { - points[i]= (int) (-height * fBasicCenterCurve[i] + height + starty); - } - return points; - } - - private void buildBaseCenterCurve(int w) { - double width= w; - fBasicCenterCurve= new double[getCenterWidth()]; - for (int i= 0; i < getCenterWidth(); i++) { - double r= i / width; - fBasicCenterCurve[i]= Math.cos(Math.PI * r); - } - } - - private void paintSides(GC g, MergeSourceViewer tp, Canvas canvas, boolean right) { - - Display display= canvas.getDisplay(); - - int lineHeight= tp.getTextWidget().getLineHeight(); - int visibleHeight= tp.getViewportHeight(); - - Point size= canvas.getSize(); - int x= 0; - int w= fMarginWidth; - int w2= w/2; - - g.setBackground(canvas.getBackground()); - g.fillRectangle(x, 0, w, size.y); - - if (!fIsMotif) { - // draw thin line between ruler and text - g.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); - if (right) - g.fillRectangle(0, 0, 1, size.y); - else - g.fillRectangle(size.x-1, 0, 1, size.y); - } - - if (! fHighlightRanges) - return; - - if (fChangeDiffs != null) { - int shift= tp.getVerticalScrollOffset() + (2-LW); - - Point region= new Point(0, 0); - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly2 && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), region); - int y= (region.x * lineHeight) + shift; - int h= region.y * lineHeight; - - if (y+h < 0) - continue; - if (y >= visibleHeight) - break; - - g.setBackground(getColor(display, getFillColor(diff))); - if (right) - g.fillRectangle(x, y, w2, h); - else - g.fillRectangle(x+w2, y, w2, h); - - g.setLineWidth(LW); - g.setForeground(getColor(display, getStrokeColor(diff))); - if (right) - g.drawRectangle(x-1, y-1, w2, h); - else - g.drawRectangle(x+w2, y-1, w2, h); - } - } - } - - private void paint(PaintEvent event, MergeSourceViewer tp) { - - if (! fHighlightRanges) - return; - if (fChangeDiffs == null) - return; - - Control canvas= (Control) event.widget; - GC g= event.gc; - - Display display= canvas.getDisplay(); - - int lineHeight= tp.getTextWidget().getLineHeight(); - int w= canvas.getSize().x; - int shift= tp.getVerticalScrollOffset() + (2-LW); - int maxh= event.y+event.height; // visibleHeight - - //if (fIsMotif) - shift+= fTopInset; - - Point range= new Point(0, 0); - - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.isDeleted()) - continue; - - if (fShowCurrentOnly && !isCurrentDiff(diff)) - continue; - - tp.getLineRange(diff.getPosition(tp), range); - int y= (range.x * lineHeight) + shift; - int h= range.y * lineHeight; - - if (y+h < event.y) - continue; - if (y > maxh) - break; - - g.setBackground(getColor(display, getStrokeColor(diff))); - g.fillRectangle(0, y-1, w, LW); - g.fillRectangle(0, y+h-1, w, LW); - } - } - - private RGB getFillColor(Diff diff) { - boolean selected= fCurrentDiff != null && fCurrentDiff.fParent == diff; - - RGB selected_fill= getBackground(null); - - if (isThreeWay() && !fIgnoreAncestor) { - switch (diff.fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return selected ? selected_fill : INCOMING_FILL; - return selected ? selected_fill : OUTGOING_FILL; - case RangeDifference.ANCESTOR: - return selected ? selected_fill : CONFLICT_FILL; - case RangeDifference.LEFT: - if (fLeftIsLocal) - return selected ? selected_fill : OUTGOING_FILL; - return selected ? selected_fill : INCOMING_FILL; - case RangeDifference.CONFLICT: - return selected ? selected_fill : CONFLICT_FILL; - } - return null; - } - return selected ? selected_fill : OUTGOING_FILL; - } - - private RGB getStrokeColor(Diff diff) { - boolean selected= fCurrentDiff != null && fCurrentDiff.fParent == diff; - - if (isThreeWay() && !fIgnoreAncestor) { - switch (diff.fDirection) { - case RangeDifference.RIGHT: - if (fLeftIsLocal) - return selected ? SELECTED_INCOMING : INCOMING; - return selected ? SELECTED_OUTGOING : OUTGOING; - case RangeDifference.ANCESTOR: - return selected ? SELECTED_CONFLICT : CONFLICT; - case RangeDifference.LEFT: - if (fLeftIsLocal) - return selected ? SELECTED_OUTGOING : OUTGOING; - return selected ? SELECTED_INCOMING : INCOMING; - case RangeDifference.CONFLICT: - return selected ? SELECTED_CONFLICT : CONFLICT; - } - return null; - } - return selected ? SELECTED_OUTGOING : OUTGOING; - } - - private Color getColor(Display display, RGB rgb) { - if (rgb == null) - return null; - if (fColors == null) - fColors= new HashMap(20); - Color c= (Color) fColors.get(rgb); - if (c == null) { - c= new Color(display, rgb); - fColors.put(rgb, c); - } - return c; - } - - static RGB interpolate(RGB fg, RGB bg, double scale) { - if (fg != null && bg != null) - return new RGB( - (int)((1.0-scale) * fg.red + scale * bg.red), - (int)((1.0-scale) * fg.green + scale * bg.green), - (int)((1.0-scale) * fg.blue + scale * bg.blue) - ); - if (fg != null) - return fg; - if (bg != null) - return bg; - return new RGB(128, 128, 128); // a gray - } - - //---- Navigating and resolving Diffs - - /* - * Returns true if end (or beginning) of document reached. - */ - private boolean navigate(boolean down, boolean wrap, boolean deep) { - - Diff diff= null; - - for (;;) { - - if (fChangeDiffs != null) { - MergeSourceViewer part= fFocusPart; - if (part == null) - part= fRight; - - if (part != null) { - Point s= part.getSelectedRange(); - if (down) - diff= findNext(part, fChangeDiffs, s.x, s.x+s.y, deep); - else - diff= findPrev(part, fChangeDiffs, s.x, s.x+s.y, deep); - } - } - - if (diff == null) { // at end or beginning - if (wrap) { - if (!fEndOfDocReached) { - fEndOfDocReached= true; - if (! endOfDocumentReached(down)) - return true; - } - fEndOfDocReached= false; - if (fChangeDiffs != null && fChangeDiffs.size() > 0) { - if (down) - diff= (Diff) fChangeDiffs.get(0); - else - diff= (Diff) fChangeDiffs.get(fChangeDiffs.size()-1); - } - } else { - fEndOfDocReached= false; - return true; - } - } - - setCurrentDiff(diff, true); - - if (diff != null && diff.fDirection == RangeDifference.ANCESTOR - && !getAncestorEnabled()) - continue; - - break; - } - - return false; - } - - private boolean endOfDocumentReached(boolean down) { - Control c= getControl(); - if (Utilities.okToUse(c)) { - - c.getDisplay().beep(); - - String key= down ? "atEnd" : "atBeginning"; //$NON-NLS-1$ //$NON-NLS-2$ - return MessageDialog.openQuestion(c.getShell(), - CompareMessages.getString("TextMergeViewer."+key+".title"), //$NON-NLS-1$ //$NON-NLS-2$ - CompareMessages.getString("TextMergeViewer."+key+".message")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return false; - } - - /* - * Find the Diff that overlaps with the given TextPart's text range. - * If the range doesn't overlap with any range null - * is returned. - */ - private Diff findDiff(MergeSourceViewer tp, int rangeStart, int rangeEnd) { - if (fChangeDiffs != null) { - Iterator e= fChangeDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - if (diff.overlaps(tp, rangeStart, rangeEnd)) - return diff; - } - } - return null; - } - - private static Diff findNext(MergeSourceViewer tp, List v, int start, int end, boolean deep) { - for (int i= 0; i < v.size(); i++) { - Diff diff= (Diff) v.get(i); - Position p= diff.getPosition(tp); - if (p != null) { - int startOffset= p.getOffset(); - if (end < startOffset) // <= - return diff; - if (deep && diff.fDiffs != null) { - Diff d= null; - int endOffset= startOffset + p.getLength(); - if (start == startOffset && (end == endOffset || end == endOffset-1)) { - d= findNext(tp, diff.fDiffs, start-1, start-1, deep); - } else if (end < endOffset) { - d= findNext(tp, diff.fDiffs, start, end, deep); - } - if (d != null) - return d; - } - } - } - return null; - } - - private static Diff findPrev(MergeSourceViewer tp, List v, int start, int end, boolean deep) { - for (int i= v.size()-1; i >= 0; i--) { - Diff diff= (Diff) v.get(i); - Position p= diff.getPosition(tp); - if (p != null) { - int startOffset= p.getOffset(); - int endOffset= startOffset + p.getLength(); - if (start > endOffset) - return diff; - if (deep && diff.fDiffs != null) { - Diff d= null; - if (start == startOffset && end == endOffset) { - d= findPrev(tp, diff.fDiffs, end, end, deep); - } else if (start >= startOffset) { - d= findPrev(tp, diff.fDiffs, start, end, deep); - } - if (d != null) - return d; - } - } - } - return null; - } - - /* - * Set the currently active Diff and update the toolbars controls and lines. - * If revealAndSelect is true the Diff is revealed and - * selected in both TextParts. - */ - private void setCurrentDiff(Diff d, boolean revealAndSelect) { - -// if (d == fCurrentDiff) -// return; - - if (fCenterButton != null) - fCenterButton.setVisible(false); - - fEndOfDocReached= false; - - Diff oldDiff= fCurrentDiff; - - if (d != null && revealAndSelect) { - - // before we set fCurrentDiff we change the selection - // so that the paint code uses the old background colors - // otherwise selection isn't drawn correctly - if (isThreeWay() && !fIgnoreAncestor) - fAncestor.setSelection(d.fAncestorPos); - fLeft.setSelection(d.fLeftPos); - fRight.setSelection(d.fRightPos); - - // now switch diffs - fCurrentDiff= d; - revealDiff(d, d.fIsToken); - } else { - fCurrentDiff= d; - } - - Diff d1= oldDiff != null ? oldDiff.fParent : null; - Diff d2= fCurrentDiff != null ? fCurrentDiff.fParent : null; - if (d1 != d2) { - updateDiffBackground(d1); - updateDiffBackground(d2); - } - - updateControls(); - invalidateLines(); - refreshBirdsEyeView(); - } - - /* - * Smart determines whether - */ - private void revealDiff(Diff d, boolean smart) { - - boolean ancestorIsVisible= false; - boolean leftIsVisible= false; - boolean rightIsVisible= false; - - if (smart) { - Point region= new Point(0, 0); - // find the starting line of the diff in all text widgets - int ls= fLeft.getLineRange(d.fLeftPos, region).x; - int rs= fRight.getLineRange(d.fRightPos, region).x; - - if (isThreeWay() && !fIgnoreAncestor) { - int as= fAncestor.getLineRange(d.fAncestorPos, region).x; - if (as >= fAncestor.getTopIndex() && as <= fAncestor.getBottomIndex()) - ancestorIsVisible= true; - } - - if (ls >= fLeft.getTopIndex() && ls <= fLeft.getBottomIndex()) - leftIsVisible= true; - - if (rs >= fRight.getTopIndex() && rs <= fRight.getBottomIndex()) - rightIsVisible= true; - } - - // vertical scrolling - if (!leftIsVisible || !rightIsVisible) { - int avpos= 0, lvpos= 0, rvpos= 0; - - MergeSourceViewer allButThis= null; - if (leftIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fLeft, fLeft.getTopIndex()); - allButThis= fLeft; - } else if (rightIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fRight, fRight.getTopIndex()); - allButThis= fRight; - } else if (ancestorIsVisible) { - avpos= lvpos= rvpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex()); - allButThis= fAncestor; - } else { - if (fAllDiffs != null) { - int vpos= 0; - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - if (diff == d) - break; - if (fSynchronizedScrolling) { - vpos+= diff.getMaxDiffHeight(fShowAncestor); - } else { - avpos+= diff.getAncestorHeight(); - lvpos+= diff.getLeftHeight(); - rvpos+= diff.getRightHeight(); - } - } - if (fSynchronizedScrolling) - avpos= lvpos= rvpos= vpos; - } - int delta= fRight.getViewportLines()/4; - avpos-= delta; - if (avpos < 0) - avpos= 0; - lvpos-= delta; - if (lvpos < 0) - lvpos= 0; - rvpos-= delta; - if (rvpos < 0) - rvpos= 0; - } - - scrollVertical(avpos, lvpos, rvpos, allButThis); - - if (fVScrollBar != null) - fVScrollBar.setSelection(avpos); - } - - // horizontal scrolling - if (d.fIsToken) { - // we only scroll horizontally for token diffs - reveal(fAncestor, d.fAncestorPos); - reveal(fLeft, d.fLeftPos); - reveal(fRight, d.fRightPos); - } else { - // in all other cases we reset the horizontal offset - hscroll(fAncestor); - hscroll(fLeft); - hscroll(fRight); - } - } - - private static void reveal(MergeSourceViewer v, Position p) { - if (v != null && p != null) { - StyledText st= v.getTextWidget(); - if (st != null) { - Rectangle r= st.getClientArea(); - if (!r.isEmpty()) // workaround for #7320: Next diff scrolls when going into current diff - v.revealRange(p.offset, p.length); - } - } - } - - private static void hscroll(MergeSourceViewer v) { - if (v != null) { - StyledText st= v.getTextWidget(); - if (st != null) - st.setHorizontalIndex(0); - } - } - - //-------------------------------------------------------------------------------- - - void copyAllUnresolved(boolean leftToRight) { - if (fChangeDiffs != null && isThreeWay() && !fIgnoreAncestor) { - IRewriteTarget target= leftToRight ? fRight.getRewriteTarget() : fLeft.getRewriteTarget(); - boolean compoundChangeStarted= false; - Iterator e= fChangeDiffs.iterator(); - try { - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - switch (diff.fDirection) { - case RangeDifference.LEFT: - if (leftToRight) { - if (!compoundChangeStarted) { - target.beginCompoundChange(); - compoundChangeStarted= true; - } - copy(diff, leftToRight); - } - break; - case RangeDifference.RIGHT: - if (!leftToRight) { - if (!compoundChangeStarted) { - target.beginCompoundChange(); - compoundChangeStarted= true; - } - copy(diff, leftToRight); - } - break; - default: - continue; - } - } - } finally { - if (compoundChangeStarted) { - target.endCompoundChange(); - } - } - } - } - - /* - * Copy whole document from one side to the other. - */ - protected void copy(boolean leftToRight) { - - if (showResolveUI()) { - copyAllUnresolved(leftToRight); - invalidateLines(); - return; - } - - if (leftToRight) { - if (fLeft.getEnabled()) { - // copy text - String text= fLeft.getTextWidget().getText(); - fRight.getTextWidget().setText(text); - fRight.setEnabled(true); - } else { - // delete - fRight.getTextWidget().setText(""); //$NON-NLS-1$ - fRight.setEnabled(false); - } - fRightLineCount= fRight.getLineCount(); - setRightDirty(true); - } else { - if (fRight.getEnabled()) { - // copy text - String text= fRight.getTextWidget().getText(); - fLeft.getTextWidget().setText(text); - fLeft.setEnabled(true); - } else { - // delete - fLeft.getTextWidget().setText(""); //$NON-NLS-1$ - fLeft.setEnabled(false); - } - fLeftLineCount= fLeft.getLineCount(); - setLeftDirty(true); - } - doDiff(); - invalidateLines(); - updateVScrollBar(); - selectFirstDiff(); - refreshBirdsEyeView(); - } - - private void copyDiffLeftToRight() { - copy(fCurrentDiff, true, false); - } - - private void copyDiffRightToLeft() { - copy(fCurrentDiff, false, false); - } - - /* - * Copy the contents of the given diff from one side to the other. - */ - private void copy(Diff diff, boolean leftToRight, boolean gotoNext) { - if (copy(diff, leftToRight)) { - if (gotoNext) { - navigate(true, true, true); - } else { - revealDiff(diff, true); - updateControls(); - } - } - } - - /* - * Copy the contents of the given diff from one side to the other but - * doesn't reveal anything. - * Returns true if copy was succesful. - */ - private boolean copy(Diff diff, boolean leftToRight) { - - if (diff != null && !diff.isResolved()) { - - Position fromPos= null; - Position toPos= null; - IDocument fromDoc= null; - IDocument toDoc= null; - - if (leftToRight) { - fRight.setEnabled(true); - fromPos= diff.fLeftPos; - toPos= diff.fRightPos; - fromDoc= fLeft.getDocument(); - toDoc= fRight.getDocument(); - } else { - fLeft.setEnabled(true); - fromPos= diff.fRightPos; - toPos= diff.fLeftPos; - fromDoc= fRight.getDocument(); - toDoc= fLeft.getDocument(); - } - - if (fromDoc != null) { - - int fromStart= fromPos.getOffset(); - int fromLen= fromPos.getLength(); - - int toStart= toPos.getOffset(); - int toLen= toPos.getLength(); - - try { - String s= null; - - switch (diff.fDirection) { - case RangeDifference.RIGHT: - case RangeDifference.LEFT: - s= fromDoc.get(fromStart, fromLen); - break; - case RangeDifference.ANCESTOR: - break; - case RangeDifference.CONFLICT: - if (APPEND_CONFLICT) { - s= toDoc.get(toStart, toLen); - s+= fromDoc.get(fromStart, fromLen); - } else - s= fromDoc.get(fromStart, fromLen); - break; - } - if (s != null) { - toDoc.replace(toStart, toLen, s); - toPos.setOffset(toStart); - toPos.setLength(s.length()); - } - - } catch (BadLocationException e) { - // silently ignored - } - } - - diff.setResolved(true); - updateResolveStatus(); - - return true; - } - return false; - } - - //---- scrolling - - /* - * Calculates virtual height (in lines) of views by adding the maximum of corresponding diffs. - */ - private int getVirtualHeight() { - int h= 1; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - h+= diff.getMaxDiffHeight(fShowAncestor); - } - } - return h; - } - - /* - * Calculates height (in lines) of right view by adding the height of the right diffs. - */ - private int getRightHeight() { - int h= 1; - if (fAllDiffs != null) { - Iterator e= fAllDiffs.iterator(); - for (int i= 0; e.hasNext(); i++) { - Diff diff= (Diff) e.next(); - h+= diff.getRightHeight(); - } - } - return h; - } - - /* - * The height of the TextEditors in lines. - */ - private int getViewportHeight() { - StyledText te= fLeft.getTextWidget(); - - int vh= te.getClientArea().height; - if (vh == 0) { - Rectangle trim= te.computeTrim(0, 0, 0, 0); - int scrollbarHeight= trim.height; - - int headerHeight= getHeaderHeight(); - - Composite composite= (Composite) getControl(); - Rectangle r= composite.getClientArea(); - - vh= r.height-headerHeight-scrollbarHeight; - } - - return vh / te.getLineHeight(); - } - - /* - * Returns the virtual position for the given view position. - */ - private int realToVirtualPosition(MergeSourceViewer w, int vpos) { - - if (! fSynchronizedScrolling || fAllDiffs == null) - return vpos; - - int viewPos= 0; // real view position - int virtualPos= 0; // virtual position - Point region= new Point(0, 0); - - Iterator e= fAllDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - Position pos= diff.getPosition(w); - w.getLineRange(pos, region); - int realHeight= region.y; - int virtualHeight= diff.getMaxDiffHeight(fShowAncestor); - if (vpos <= viewPos + realHeight) { // OK, found! - vpos-= viewPos; // make relative to this slot - // now scale position within this slot to virtual slot - if (realHeight <= 0) - vpos= 0; - else - vpos= (vpos*virtualHeight)/realHeight; - return virtualPos+vpos; - } - viewPos+= realHeight; - virtualPos+= virtualHeight; - } - return virtualPos; - } - - private void scrollVertical(int avpos, int lvpos, int rvpos, MergeSourceViewer allBut) { - - int s= 0; - - if (fSynchronizedScrolling) { - s= getVirtualHeight() - rvpos; - int height= fRight.getViewportLines()/4; - if (s < 0) - s= 0; - if (s > height) - s= height; - } - - fInScrolling= true; - - if (isThreeWay() && allBut != fAncestor) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fAncestor, avpos+s)-s; - fAncestor.vscroll(y); - } - } - - if (allBut != fLeft) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fLeft, lvpos+s)-s; - fLeft.vscroll(y); - } - } - - if (allBut != fRight) { - if (fSynchronizedScrolling || allBut == null) { - int y= virtualToRealPosition(fRight, rvpos+s)-s; - fRight.vscroll(y); - } - } - - fInScrolling= false; - - if (isThreeWay() && fAncestorCanvas != null) - fAncestorCanvas.repaint(); - - if (fLeftCanvas != null) - fLeftCanvas.repaint(); - - Control center= getCenter(); - if (center instanceof BufferedCanvas) - ((BufferedCanvas)center).repaint(); - - if (fRightCanvas != null) - fRightCanvas.repaint(); - } - - /* - * Updates Scrollbars with viewports. - */ - private void syncViewport(MergeSourceViewer w) { - - if (fInScrolling) - return; - - int ix= w.getTopIndex(); - int ix2= w.getDocumentRegionOffset(); - - int viewPosition= realToVirtualPosition(w, ix-ix2); - - scrollVertical(viewPosition, viewPosition, viewPosition, w); // scroll all but the given views - - if (fVScrollBar != null) { - int value= Math.max(0, Math.min(viewPosition, getVirtualHeight() - getViewportHeight())); - fVScrollBar.setSelection(value); - //refreshBirdEyeView(); - } - } - - /** - */ - private void updateVScrollBar() { - - if (Utilities.okToUse(fVScrollBar) && fSynchronizedScrolling) { - int virtualHeight= getVirtualHeight(); - int viewPortHeight= getViewportHeight(); - int pageIncrement= viewPortHeight-1; - int thumb= (viewPortHeight > virtualHeight) ? virtualHeight : viewPortHeight; - - fVScrollBar.setPageIncrement(pageIncrement); - fVScrollBar.setMaximum(virtualHeight); - fVScrollBar.setThumb(thumb); - } - } - - /* - * maps given virtual position into a real view position of this view. - */ - private int virtualToRealPosition(MergeSourceViewer part, int v) { - - if (! fSynchronizedScrolling || fAllDiffs == null) - return v; - - int virtualPos= 0; - int viewPos= 0; - Point region= new Point(0, 0); - - Iterator e= fAllDiffs.iterator(); - while (e.hasNext()) { - Diff diff= (Diff) e.next(); - Position pos= diff.getPosition(part); - int viewHeight= part.getLineRange(pos, region).y; - int virtualHeight= diff.getMaxDiffHeight(fShowAncestor); - if (v < (virtualPos + virtualHeight)) { - v-= virtualPos; // make relative to this slot - if (viewHeight <= 0) { - v= 0; - } else { - v= (v*viewHeight)/virtualHeight; - } - return viewPos+v; - } - virtualPos+= virtualHeight; - viewPos+= viewHeight; - } - return viewPos; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties deleted file mode 100644 index e9ea13317..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties +++ /dev/null @@ -1,98 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)TextMergeViewerResources.properties -# -# Resource strings for TextMergeViewer.java - -title= Text Compare - -saveDialog.title= Save Resource -saveDialog.message= Resource has been modified. Save changes? - -compareProgressTask.title= Computing Differences... - -tooComplexError.title= Error -tooComplexError.format= Too many differences. Turn on the ''Ignore White Space'' option or do a structure compare first. - -##################################################### -# Toolbar actions -##################################################### - -action.CopyLeftToRight.label=Copy Left to Right -action.CopyLeftToRight.tooltip=Copy All from Left to Right -action.CopyLeftToRight.image=copy_r_co.gif - -action.CopyRightToLeft.label=Copy Right to Left -action.CopyRightToLeft.tooltip=Copy All Non-Conflicting Changes from Right to Left -action.CopyRightToLeft.image=copy_l_co.gif - -action.CopyDiffLeftToRight.label=Copy Current Change to Right -action.CopyDiffLeftToRight.tooltip=Copy Current Change from Left to Right -action.CopyDiffLeftToRight.image=copycont_r_co.gif - -action.CopyDiffRightToLeft.label=Copy Current Change to Left -action.CopyDiffRightToLeft.tooltip=Copy Current Change from Right to Left -action.CopyDiffRightToLeft.image=copycont_l_co.gif - -action.NextDiff.label=Next -action.NextDiff.tooltip=Select Next Change -action.NextDiff.image=next_nav.gif - -action.PrevDiff.label=Previous -action.PrevDiff.tooltip=Select Previous Change -action.PrevDiff.image=prev_nav.gif - -action.EnableAncestor.label=Enable Ancestor Pane -action.EnableAncestor.tooltip.unchecked=Show Ancestor Pane -action.EnableAncestor.tooltip.checked=Hide Ancestor Pane -action.EnableAncestor.description.unchecked=Show Ancestor Pane -action.EnableAncestor.description.checked=Hide Ancestor Pane -action.EnableAncestor.image=ancestorpane_co.gif - -action.IgnoreAncestor.label=Ignore Ancestor -action.IgnoreAncestor.tooltip.unchecked=Two-Way Compare (Ignore Ancestor) -action.IgnoreAncestor.tooltip.checked=Three-Way Compare -action.IgnoreAncestor.description.unchecked=Two-Way Compare (Ignore Ancestor) -action.IgnoreAncestor.description.checked=Three-Way Compare -action.IgnoreAncestor.image=twowaycompare_co.gif - - -##################################################### -# Context menu actions -##################################################### - -action.undo.label=Undo@Ctrl+Z -action.undo.tooltip=Undo Last Operation - -action.redo.label=Redo@Ctrl+Y -action.redo.tooltip=Redo Last Operation - -action.cut.label=Cut@Ctrl+X -action.cut.tooltip=Cut Text Selection to Clipboard - -action.copy.label=Copy@Ctrl+C -action.copy.tooltip=Copy Text Selection to Clipboard - -action.paste.label=Paste@Ctrl+V -action.paste.tooltip=Replace Text Selection with Clipboard Contents - -action.delete.label=Delete -action.delete.tooltip=Delete Current Text Selection - -action.find.label=Find...@Ctrl+F -action.find.tooltip=Find Occurrence - -action.selectAll.label=Select All@Ctrl+A -action.selectAll.tooltip=Select All Changes - -action.save.label=Save@Ctrl+S -action.save.tooltip=Save Changes diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html deleted file mode 100644 index 9f606fb95..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/package.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - Package-level Javadoc - - -Support for compare and merge viewers which show the -content side-by-side. -

-Package Specification

- -The ContentMergeViewer is an abstract compare and merge viewer -with two side-by-side content areas and an optional content area for a -common ancestor (for three-way compare). Because the implementation makes -no assumptions about the content type it is a subclass responsibility to -deal with a specific type. Its subclass ImageMergeViewer in -package org.eclipse.compare.internal shows how to base a simple -mergeviewer for images on ContentMergeViewer. -

- -A ContentMergeViewer accesses its model by means of a content -provider which must implement the IMergeViewerContentProvider interface. -

- -The TextMergeViewer is the standard concrete subclass of -ContentMergeViewer for comparing and merging text content. -
-A text merge viewer uses the org.eclipse.compare.rangedifferencer.RangeDifferencer -to perform a textual, line-by-line comparison of two (or three) input documents. -For text lines that differ the TextMergeViewer uses an ITokenComparator -to find longest sequences of matching and non-matching tokens. -The TextMergeViewer's -default token compare works on characters separated by whitespace. If a -different strategy is needed (for example, Java tokens in a Java-aware -merge viewer), clients can create their own token comparators by implementing -the ITokenComparator interface. -

The TextMergeViewer not only works on whole documents but on -subranges of documents too. In this case the viewer's input must be an -IDocumentRange instead of an IDocument. - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java deleted file mode 100644 index 84e8f945c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.Viewer; - - -public abstract class AbstractViewer extends Viewer { - - public void setInput(Object input) { - // empty default implementation - } - - public Object getInput() { - return null; - } - - public ISelection getSelection() { - return null; - } - - public void setSelection(ISelection s, boolean reveal) { - // empty default implementation - } - - public void refresh() { - // empty default implementation - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java deleted file mode 100644 index 6708a0f69..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - - -public class AddFromHistoryAction extends BaseCompareAction { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.AddFromHistoryAction"; //$NON-NLS-1$ - - public AddFromHistoryAction() { - // empty default implementation - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getResources(selection).length == 1; - } - - protected void run(ISelection selection) { - - ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME); - String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - - Shell parentShell= CompareUIPlugin.getShell(); - AddFromHistoryDialog dialog= null; - - Object[] s= Utilities.getResources(selection); - - for (int i= 0; i < s.length; i++) { - Object o= s[i]; - if (o instanceof IContainer) { - IContainer container= (IContainer) o; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); - IProgressMonitor pm= pmdialog.getProgressMonitor(); - IFile[] states= null; - try { - states= container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, pm); - } catch (CoreException ex) { - pm.done(); - } - - if (states == null || states.length <= 0) { - String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ - MessageDialog.openInformation(parentShell, title, msg); - return; - } - - if (dialog == null) { - dialog= new AddFromHistoryDialog(parentShell, bundle); - dialog.setHelpContextId(ICompareContextIds.ADD_FROM_HISTORY_DIALOG); - } - - if (dialog.select(container, states)) { - - AddFromHistoryDialog.HistoryInput[] selected= dialog.getSelected(); - - if (selected != null && selected.length > 0) { - try { - updateWorkspace(bundle, parentShell, selected); - - } catch (InterruptedException x) { - // Do nothing. Operation has been canceled by user. - - } catch (InvocationTargetException x) { - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$ - } - } - } - } - } - } - - void createContainers(IResource resource) throws CoreException { - IContainer container= resource.getParent(); - if (container instanceof IFolder) { - IFolder parent= (IFolder) container; - if (parent != null && !parent.exists()) { - createContainers(parent); - parent.create(false, true, null); - } - } - } - - private void updateWorkspace(final ResourceBundle bundle, Shell shell, - final AddFromHistoryDialog.HistoryInput[] selected) - throws InvocationTargetException, InterruptedException { - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws InvocationTargetException { - try { - String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$ - pm.beginTask(taskName, selected.length); - - for (int i= 0; i < selected.length; i++) { - IFile file= selected[i].fFile; - IFileState fileState= selected[i].fFileState; - createContainers(file); - - SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 1); - try { - file.create(fileState.getContents(), false, subMonitor); - } finally { - subMonitor.done(); - } - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - pm.done(); - } - } - }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties deleted file mode 100644 index 2b5c046ea..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)AddFromHistoryAction.properties -# -# Resources for AddFromHistoryAction.java - -title= Restore from Local History - -memberPaneTitle= {0} - Available Files in Local History: - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -memberDescription= Check files to restore from local history: -editionDescription= Select an edition of a file: - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= {0} - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -buttonLabel= Restore - -noLocalHistoryError= No deleted resources in local history for selected container. -replaceError=Cannot replace resource (reason: {0}). - -taskName=Restoring diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java deleted file mode 100644 index 642c682f3..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java +++ /dev/null @@ -1,475 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.text.*; -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; - - -public class AddFromHistoryDialog extends ResizableDialog { - - static class HistoryInput implements ITypedElement, IEncodedStreamContentAccessor, IModificationDate { - IFile fFile; - IFileState fFileState; - - HistoryInput(IFile file, IFileState fileState) { - fFile= file; - fFileState= fileState; - } - public InputStream getContents() throws CoreException { - return new BufferedInputStream(fFileState.getContents()); - } - public String getCharset() { - String charset= null; - try { - charset= fFileState.getCharset(); - } catch (CoreException e) { - // fall through - } - if (charset == null) - charset= Utilities.getCharset(fFile); - return charset; - } - public String getName() { - return fFile.getName(); - } - public String getType() { - return fFile.getFileExtension(); - } - public Image getImage() { - return CompareUI.getImage(fFile); - } - public long getModificationDate() { - return fFileState.getModificationTime(); - } - } - - static class FileHistory { - private IFile fFile; - private IFileState[] fStates; - private int fSelected; - - FileHistory(IFile file) { - fFile= file; - } - - IFile getFile() { - return fFile; - } - - IFileState[] getStates() { - if (fStates == null) { - try { - fStates= fFile.getHistory(new NullProgressMonitor()); - } catch (CoreException ex) { - // NeedWork - } - } - return fStates; - } - - IFileState getSelectedState() { - return getStates()[fSelected]; - } - - void setSelected(IFileState state) { - for (int i= 0; i < fStates.length; i++) { - if (fStates[i] == state) { - fSelected= i; - return; - } - } - } - - HistoryInput getHistoryInput() { - return new HistoryInput(fFile, getSelectedState()); - } - - boolean isSelected(int index) { - return index == fSelected; - } - } - - private CompareConfiguration fCompareConfiguration; - private ArrayList fArrayList= new ArrayList(); - private FileHistory fCurrentFileHistory; - - // SWT controls - private CompareViewerSwitchingPane fContentPane; - private Button fCommitButton; - private Table fMemberTable; - private CompareViewerPane fMemberPane; - private Tree fEditionTree; - private CompareViewerPane fEditionPane; - private Image fDateImage; - private Image fTimeImage; - - - public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) { - super(parent, bundle); - - String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fDateImage= id.createImage(); - iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - id= CompareUIPlugin.getImageDescriptor(iconName); - if (id != null) - fTimeImage= id.createImage(); - } - - public boolean select(IContainer root, IFile[] inputFiles) { - - create(); // create widgets - - String format= Utilities.getString(fBundle, "memberPaneTitle"); //$NON-NLS-1$ - String title= MessageFormat.format(format, new Object[] { root.getName() }); - fMemberPane.setImage(CompareUI.getImage(root)); - fMemberPane.setText(title); - - // sort input files - final int count= inputFiles.length; - final IFile[] files= new IFile[count]; - for (int i= 0; i < count; i++) - files[i]= inputFiles[i]; - if (count > 1) - internalSort(files, 0, count-1); - - - String prefix= root.getFullPath().toString(); - - if (fMemberTable != null && !fMemberTable.isDisposed()) { - for (int i= 0; i < files.length; i++) { - IFile file= files[i]; - String path= file.getFullPath().toString(); - if (path.startsWith(prefix)) - path= path.substring(prefix.length()+1); - TableItem ti= new TableItem(fMemberTable, SWT.NONE); - ti.setImage(CompareUI.getImage(file)); - ti.setText(path); - ti.setData(new FileHistory(file)); - } - } - - open(); - - return (getReturnCode() == OK) && (fArrayList.size() > 0); - } - - HistoryInput[] getSelected() { - HistoryInput[] selected= new HistoryInput[fArrayList.size()]; - Iterator iter= fArrayList.iterator(); - for (int i= 0; iter.hasNext(); i++) { - FileHistory h= (FileHistory) iter.next(); - selected[i]= h.getHistoryInput(); - } - return selected; - } - - protected synchronized Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - org.eclipse.compare.Splitter vsplitter= new org.eclipse.compare.Splitter(parent, SWT.VERTICAL); - vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - vsplitter.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fDateImage != null) - fDateImage.dispose(); - if (fTimeImage != null) - fTimeImage.dispose(); - } - } - ); - - // we need two panes: the left for the elements, the right one for the editions - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - Composite c= new Composite(hsplitter, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 2; - layout.verticalSpacing= 2; - layout.numColumns= 1; - c.setLayout(layout); - Label l1= new Label(c, SWT.NONE); - l1.setText(Utilities.getString(fBundle, "memberDescription")); //$NON-NLS-1$ - fMemberPane= new CompareViewerPane(c, SWT.BORDER | SWT.FLAT); - GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - fMemberPane.setLayoutData(gd); - - fMemberTable= new Table(fMemberPane, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL); - fMemberTable.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (e.detail == SWT.CHECK) { - if (e.item instanceof TableItem) { - TableItem ti= (TableItem) e.item; - if (ti.getChecked()) - fArrayList.add(ti.getData()); - else - fArrayList.remove(ti.getData()); - - if (fCommitButton != null) - fCommitButton.setEnabled(fArrayList.size() > 0); - } - } else { - handleMemberSelect(e.item); - } - } - } - ); - - fMemberPane.setContent(fMemberTable); - - c= new Composite(hsplitter, SWT.NONE); - layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 2; - layout.verticalSpacing= 2; - layout.numColumns= 1; - c.setLayout(layout); - Label l2= new Label(c, SWT.NONE); - l2.setText(Utilities.getString(fBundle, "editionDescription")); //$NON-NLS-1$ - fEditionPane= new CompareViewerPane(c, SWT.BORDER | SWT.FLAT); - gd= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - fEditionPane.setLayoutData(gd); - - fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL | SWT.V_SCROLL); - fEditionTree.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - feedContent(e.item); - } - } - ); - fEditionPane.setContent(fEditionTree); - - applyDialogFont(parent); // to avoid applying font to compare viewer - fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, input, this, fCompareConfiguration); - } - }; - vsplitter.setWeights(new int[] { 30, 70 }); - - return parent; - } - - /* - * Feeds selection from member viewer to edition viewer. - */ - private void handleMemberSelect(Widget w) { - Object data= null; - if (w != null) - data= w.getData(); - if (data instanceof FileHistory) { - - FileHistory h= (FileHistory) data; - fCurrentFileHistory= h; - - IFile file= h.getFile(); - IFileState[] states= h.getStates(); - - fEditionPane.setImage(CompareUI.getImage(file)); - String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$ - String title= MessageFormat.format(pattern, new Object[] { file.getName() }); - fEditionPane.setText(title); - - if (fEditionTree != null) { - fEditionTree.setRedraw(false); - fEditionTree.removeAll(); - for (int i= 0; i < states.length; i++) { - addEdition(new HistoryInput(file, states[i]), h.isSelected(i)); - } - fEditionTree.setRedraw(true); - } - } else - fCurrentFileHistory= null; - } - - /* - * Adds the given Pair to the edition tree. - * It takes care of creating tree nodes for different dates. - */ - private void addEdition(HistoryInput input, boolean isSelected) { - if (fEditionTree == null || fEditionTree.isDisposed()) - return; - - IFileState state= input.fFileState; - - // find last day - TreeItem[] days= fEditionTree.getItems(); - TreeItem lastDay= null; - if (days.length > 0) - lastDay= days[days.length-1]; - - long ldate= state.getModificationTime(); - long day= dayNumber(ldate); - Date date= new Date(ldate); - if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) { - lastDay= new TreeItem(fEditionTree, SWT.NONE); - lastDay.setImage(fDateImage); - String df= DateFormat.getDateInstance().format(date); - long today= dayNumber(System.currentTimeMillis()); - - String formatKey; - if (day == today) - formatKey= "todayFormat"; //$NON-NLS-1$ - else if (day == today-1) - formatKey= "yesterdayFormat"; //$NON-NLS-1$ - else - formatKey= "dayFormat"; //$NON-NLS-1$ - String pattern= Utilities.getString(fBundle, formatKey); - if (pattern != null) - df= MessageFormat.format(pattern, new String[] { df }); - lastDay.setText(df); - lastDay.setData(date); - } - TreeItem ti= new TreeItem(lastDay, SWT.NONE); - ti.setImage(fTimeImage); - ti.setText(DateFormat.getTimeInstance().format(date)); - ti.setData(input); - - if (isSelected) { - lastDay.setExpanded(true); - fEditionTree.setSelection(new TreeItem[] { ti }); - feedContent(ti); - } - } - - /* - * Returns the number of s since Jan 1st, 1970. - * The given date is converted to GMT and daylight saving is taken into account too. - */ - private long dayNumber(long date) { - int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds - - Calendar calendar= Calendar.getInstance(); - long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); - - return (date + localTimeOffset) / ONE_DAY_MS; - } - - /* - * Feeds the tree viewer's selection to the contentviewer - */ - private void feedContent(Widget w) { - if (fContentPane != null && !fContentPane.isDisposed()) { - Object o= w.getData(); - if (o instanceof HistoryInput) { - HistoryInput selected= (HistoryInput) o; - fContentPane.setInput(selected); - fContentPane.setText(getEditionLabel(selected)); - fContentPane.setImage(fTimeImage); - - if (fCurrentFileHistory != null) - fCurrentFileHistory.setSelected(selected.fFileState); - } else { - fContentPane.setInput(null); - } - } - } - - protected String getEditionLabel(HistoryInput input) { - String format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$ - if (format == null) - format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$ - if (format == null) - format= "x{0}"; //$NON-NLS-1$ - - long modDate= input.getModificationDate(); - String date= DateFormat.getDateTimeInstance().format(new Date(modDate)); - - return MessageFormat.format(format, new Object[] { date }); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$ - // a 'Cancel' and a 'Add' button - fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true); - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /* - * Returns true if the pathname of f1 comes after f2 - */ - private static boolean greaterThan(IFile f1, IFile f2) { - String[] ss1= f1.getFullPath().segments(); - String[] ss2= f2.getFullPath().segments(); - int l1= ss1.length; - int l2= ss2.length; - int n= Math.max(l1, l2); - - for (int i= 0; i < n; i++) { - String s1= i < l1 ? ss1[i] : ""; //$NON-NLS-1$ - String s2= i < l2 ? ss2[i] : ""; //$NON-NLS-1$ - int rc= s1.compareToIgnoreCase(s2); - if (rc != 0) - return rc < 0; - } - return false; - } - - private static void internalSort(IFile[] keys, int left, int right) { - - int original_left= left; - int original_right= right; - - IFile mid= keys[(left + right) / 2]; - do { - while (greaterThan(keys[left], mid)) - left++; - - while (greaterThan(mid, keys[right])) - right--; - - if (left <= right) { - IFile tmp= keys[left]; - keys[left]= keys[right]; - keys[right]= tmp; - left++; - right--; - } - } while (left <= right); - - if (original_left < right) - internalSort(keys, original_left, right); - - if (left < original_right) - internalSort(keys, left, original_right); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java deleted file mode 100644 index 7771b93d3..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IActionDelegate; - - -public abstract class BaseCompareAction implements IActionDelegate { - - private ISelection fSelection; - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - final public void run(IAction action) { - run(fSelection); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - final public void selectionChanged(IAction action, ISelection selection) { - fSelection= selection; - if (action != null) - action.setEnabled(isEnabled(fSelection)); - } - - protected boolean isEnabled(ISelection selection) { - return false; - } - - abstract protected void run(ISelection selection); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java deleted file mode 100644 index 708bd181e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.util.ResourceBundle; -import java.text.MessageFormat; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - -/** - * A simple compare viewer for binary files. - * Shows the position of the first non-matching byte. - */ -public class BinaryCompareViewer extends AbstractViewer { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$ - - private static final int EOF= -1; - private Label fControl; - private ICompareInput fInput; - private ResourceBundle fBundle; - private boolean fLeftIsLocal; - - - public BinaryCompareViewer(Composite parent, CompareConfiguration cc) { - - WorkbenchHelp.setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW); - - fBundle= ResourceBundle.getBundle(BUNDLE_NAME); - - fControl= new Label(parent, SWT.WRAP); - fControl.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - - fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - } - - public Control getControl() { - return fControl; - } - - public void setInput(Object input) { - if (fControl != null && input instanceof ICompareInput) { - fInput= (ICompareInput) input; - - InputStream left= null; - InputStream right= null; - - String message= null; - try { - left= getStream(fInput.getLeft()); - right= getStream(fInput.getRight()); - - if (left != null && right != null) { - int pos= 0; - while (true) { - int l= left.read(); - int r= right.read(); - if (l != r) { - String format= Utilities.getString(fBundle, "diffMessageFormat"); //$NON-NLS-1$ - message= MessageFormat.format(format, new String[] { Integer.toString(pos) } ); - break; - } - if (l == EOF) - break; - pos++; - } - } else if (left == null && right == null) { - message= Utilities.getString(fBundle, "deleteConflictMessage"); //$NON-NLS-1$ - } else if (left == null) { - if (fLeftIsLocal) - message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ - else - message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ - } else if (right == null) { - if (fLeftIsLocal) - message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ - else - message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ - } - } catch (CoreException ex) { - message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ - } catch (IOException ex) { - message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ - } finally { - Utilities.close(left); - Utilities.close(right); - } - if (message != null) - fControl.setText(message); - } - } - - public Object getInput() { - return fInput; - } - - private InputStream getStream(ITypedElement input) throws CoreException { - if (input instanceof IStreamContentAccessor) - return ((IStreamContentAccessor)input).getContents(); - return null; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java deleted file mode 100644 index 8c98ec6ff..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerCreator.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; - -/** - * A factory object for the BinaryCompareViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class BinaryCompareViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new BinaryCompareViewer(parent, mp); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties deleted file mode 100644 index dbfc7d70e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)BinaryCompareViewerResources.properties -# -# Resource strings for BinaryCompareViewer.java - -title= Binary Compare - -diffMessageFormat= First bytes differ at position {0} -deleteConflictMessage= Delete Conflict -addedMessage= Added Resource -deletedMessage= Removed Resource -errorMessage= Internal Error diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java deleted file mode 100644 index 3e20f3d67..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.events.*; - -/** - * A Canvas which reduces flicker by drawing in an off screen buffer. - */ -public abstract class BufferedCanvas extends Canvas { - - //private static final boolean USE_DOUBLE_BUFFER= !"carbon".equals(SWT.getPlatform()); //$NON-NLS-1$ - private static final boolean USE_DOUBLE_BUFFER= true; - - /** The drawable for double buffering */ - Image fBuffer; - - public BufferedCanvas(Composite parent, int flags) { - super(parent, flags + SWT.NO_BACKGROUND); - - addPaintListener( - new PaintListener() { - public void paintControl(PaintEvent event) { - doubleBufferPaint(event.gc); - } - } - ); - - addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fBuffer != null) { - fBuffer.dispose(); - fBuffer= null; - } - } - } - ); - } - - public void repaint() { - if (!isDisposed()) { - GC gc= new GC(this); - doubleBufferPaint(gc); - gc.dispose(); - } - } - - /* - * Double buffer drawing. - */ - void doubleBufferPaint(GC dest) { - - if (!USE_DOUBLE_BUFFER) { - doPaint(dest); - return; - } - - Point size= getSize(); - - if (size.x <= 1 || size.y <= 1) // we test for <= 1 because on X11 controls have initial size 1,1 - return; - - if (fBuffer != null) { - Rectangle r= fBuffer.getBounds(); - if (r.width != size.x || r.height != size.y) { - fBuffer.dispose(); - fBuffer= null; - } - } - if (fBuffer == null) - fBuffer= new Image(getDisplay(), size.x, size.y); - - GC gc= new GC(fBuffer); - try { - gc.setBackground(getBackground()); - gc.fillRectangle(0, 0, size.x, size.y); - doPaint(gc); - } finally { - gc.dispose(); - } - - dest.drawImage(fBuffer, 0, 0); - } - - abstract public void doPaint(GC gc); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java deleted file mode 100644 index 4ab61058b..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; - -/** - * A buffer for a workspace resource. - */ -public class BufferedResourceNode extends ResourceNode { - - private boolean fDirty= false; - private IFile fDeleteFile; - - /** - * Creates a ResourceNode for the given resource. - * - * @param resource the resource - */ - public BufferedResourceNode(IResource resource) { - super(resource); - } - - /* - * Returns true if buffer contains uncommitted changes. - */ - public boolean isDirty() { - return fDirty; - } - - protected IStructureComparator createChild(IResource child) { - return new BufferedResourceNode(child); - } - - public void setContent(byte[] contents) { - fDirty= true; - super.setContent(contents); - } - - /* - * Commits buffered contents to resource. - */ - public void commit(IProgressMonitor pm) throws CoreException { - if (fDirty) { - - if (fDeleteFile != null) { - fDeleteFile.delete(true, true, pm); - return; - } - - IResource resource= getResource(); - if (resource instanceof IFile) { - - byte[] bytes= getContent(); - ByteArrayInputStream is= new ByteArrayInputStream(bytes); - try { - IFile file= (IFile) resource; - if (file.exists()) - file.setContents(is, false, true, pm); - else - file.create(is, false, pm); - fDirty= false; - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // Silently ignored - } - } - } - } - } - - public ITypedElement replace(ITypedElement child, ITypedElement other) { - - if (child == null) { // add resource - // create a node without a resource behind it! - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(other.getName()); - child= new BufferedResourceNode(file); - } - } - - if (other == null) { // delete resource - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(child.getName()); - if (file != null && file.exists()) { - fDeleteFile= file; - fDirty= true; - } - } - return null; - } - - if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) { - IEditableContent dst= (IEditableContent) child; - - try { - InputStream is= ((IStreamContentAccessor)other).getContents(); - byte[] bytes= Utilities.readBytes(is); - if (bytes != null) - dst.setContent(bytes); - } catch (CoreException ex) { - // NeedWork - } - } - return child; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java deleted file mode 100644 index 824ed3e1c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.jface.action.Action; -import org.eclipse.compare.CompareConfiguration; - -/** - * Toggles a boolean property of an ICompareConfiguration. - */ -public class ChangePropertyAction extends Action { - - private CompareConfiguration fCompareConfiguration; - private String fPropertyKey; - private ResourceBundle fBundle; - private String fPrefix; - - - public ChangePropertyAction(ResourceBundle bundle, CompareConfiguration cc, String rkey, String pkey) { - fPropertyKey= pkey; - fBundle= bundle; - fPrefix= rkey; - Utilities.initAction(this, fBundle, fPrefix); - setCompareConfiguration(cc); - } - - public void run() { - boolean b= !Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false); - setChecked(b); - if (fCompareConfiguration != null) - fCompareConfiguration.setProperty(fPropertyKey, new Boolean(b)); - } - - public void setChecked(boolean state) { - super.setChecked(state); - Utilities.initToggleAction(this, fBundle, fPrefix, state); - } - - public void setCompareConfiguration(CompareConfiguration cc) { - fCompareConfiguration= cc; - setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false)); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java deleted file mode 100644 index 7495c6158..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareUI; - - -/* - * The "Compare with each other" action - */ -public class CompareAction extends BaseCompareAction implements IObjectActionDelegate { - - private ResourceCompareInput fInput; - private IWorkbenchPage fWorkbenchPage; - - - public void run(ISelection selection) { - if (fInput != null) { - fInput.setSelection(selection); - fInput.initializeCompareConfiguration(); - CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage); - fInput= null; // don't reuse this input! - } - } - - protected boolean isEnabled(ISelection selection) { - if (fInput == null) { - CompareConfiguration cc= new CompareConfiguration(); - // buffered merge mode: don't ask for confirmation - // when switching between modified resources - cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false)); - - // uncomment following line to have separate outline view - //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, new Boolean(true)); - - fInput= new ResourceCompareInput(cc); - } - return fInput.isEnabled(selection); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fWorkbenchPage= targetPart.getSite().getPage(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java deleted file mode 100644 index 3116aca44..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -import org.eclipse.swt.layout.GridData; -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.ui.actions.WorkspaceModifyOperation; - - -public class CompareDialog extends ResizableDialog implements IPropertyChangeListener { - - private CompareEditorInput fCompareEditorInput; - private Button fCommitButton; - - - CompareDialog(Shell shell, CompareEditorInput input) { - super(shell, null); - - Assert.isNotNull(input); - fCompareEditorInput= input; - fCompareEditorInput.addPropertyChangeListener(this); - setHelpContextId(ICompareContextIds.COMPARE_DIALOG); - } - - public boolean close() { - if (super.close()) { - if (fCompareEditorInput != null) - fCompareEditorInput.addPropertyChangeListener(this); - return true; - } - return false; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - fCommitButton= createButton(parent, IDialogConstants.OK_ID, Utilities.getString("CompareDialog.commitAction.label"), true); //$NON-NLS-1$ - fCommitButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - public void propertyChange(PropertyChangeEvent event) { - if (fCommitButton != null && fCompareEditorInput != null) - fCommitButton.setEnabled(fCompareEditorInput.isSaveNeeded()); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent2) { - - Composite parent= (Composite) super.createDialogArea(parent2); - - Control c= fCompareEditorInput.createContents(parent); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Shell shell= c.getShell(); - shell.setText(fCompareEditorInput.getTitle()); - shell.setImage(fCompareEditorInput.getTitleImage()); - applyDialogFont(parent); - return parent; - } - - /* (non-Javadoc) - * Method declared on Window. - */ - public int open() { - - int rc= super.open(); - - if (rc == OK && fCompareEditorInput.isSaveNeeded()) { - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws CoreException { - fCompareEditorInput.saveChanges(pm); - } - }; - - Shell shell= getParentShell(); - ProgressMonitorDialog pmd= new ProgressMonitorDialog(shell); - try { - operation.run(pmd.getProgressMonitor()); - - } catch (InterruptedException x) { - // NeedWork - } catch (OperationCanceledException x) { - // NeedWork - } catch (InvocationTargetException x) { - String title= Utilities.getString("CompareDialog.saveErrorTitle"); //$NON-NLS-1$ - String msg= Utilities.getString("CompareDialog.saveErrorMessage"); //$NON-NLS-1$ - MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage()); - } - } - - return rc; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java deleted file mode 100644 index 9be68cb7d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.util.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.EditorPart; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; - - -/** - * A CompareEditor takes a ICompareEditorInput as input. - * Most functionality is delegated to the ICompareEditorInput. - */ -public class CompareEditor extends EditorPart implements IReusableEditor { - - /** - * Internal property change listener for handling changes in the editor's input. - */ - class PropertyChangeListener implements IPropertyChangeListener { - /* - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - CompareEditor.this.propertyChange(event); - } - } - - public final static String CONFIRM_SAVE_PROPERTY= "org.eclipse.compare.internal.CONFIRM_SAVE_PROPERTY"; //$NON-NLS-1$ - - private IActionBars fActionBars; - /** The editor's property change listener. */ - private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener(); - /** the SWT control */ - private Control fControl; - /** the outline page */ - private CompareOutlinePage fOutlinePage; - /** enable outline */ - - - public CompareEditor() { - // empty default implementation - } - - /* (non-Javadoc) - * Method declared on IAdaptable - */ - public Object getAdapter(Class key) { - - if (key.equals(IContentOutlinePage.class)) { - Object object= getCompareConfiguration().getProperty(CompareConfiguration.USE_OUTLINE_VIEW); - if (object instanceof Boolean && ((Boolean)object).booleanValue()) { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) { - fOutlinePage= new CompareOutlinePage((CompareEditorInput) input); - return fOutlinePage; - } - } - } - return super.getAdapter(key); - } - - /* package */ CompareConfiguration getCompareConfiguration() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - return ((CompareEditorInput)input).getCompareConfiguration(); - return null; - } - - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - - if (!(input instanceof CompareEditorInput)) - throw new PartInitException(Utilities.getString("CompareEditor.invalidInput")); //$NON-NLS-1$ - - setSite(site); - setInput(input); - } - - public void setInput(IEditorInput input) { - try { - doSetInput(input); - } catch (CoreException x) { - String title= Utilities.getString("CompareEditor.error.setinput.title"); //$NON-NLS-1$ - String msg= Utilities.getString("CompareEditor.error.setinput.message"); //$NON-NLS-1$ - ErrorDialog.openError(getSite().getShell(), title, msg, x.getStatus()); - } - } - - public void doSetInput(IEditorInput input) throws CoreException { - - if (!(input instanceof CompareEditorInput)) { - IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, Utilities.getString("CompareEditor.invalidInput"), null); //$NON-NLS-1$ - throw new CoreException(s); - } - - IEditorInput oldInput= getEditorInput(); - if (oldInput instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).removePropertyChangeListener(fPropertyChangeListener); - - super.setInput(input); - - CompareEditorInput cei= (CompareEditorInput) input; - - setTitleImage(cei.getTitleImage()); - setPartName(cei.getTitle()); // was setTitle(cei.getTitle()); - - if (input instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).addPropertyChangeListener(fPropertyChangeListener); - - if (oldInput != null) { - if (fControl != null && !fControl.isDisposed()) { - Point oldSize= fControl.getSize(); - Composite parent= fControl.getParent(); - fControl.dispose(); - createPartControl(parent); - if (fControl != null) - fControl.setSize(oldSize); - } - } - } - - public IActionBars getActionBars() { - return fActionBars; - } - - public void setActionBars(IActionBars actionBars) { - fActionBars= actionBars; - } - - /* - * @see IDesktopPart#createPartControl(Composite) - */ - public void createPartControl(Composite parent) { - parent.setData(this); - - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) { - fControl= ((CompareEditorInput) input).createContents(parent); - WorkbenchHelp.setHelp(fControl, ICompareContextIds.COMPARE_EDITOR); - } - } - - /* - * @see DesktopPart#dispose - */ - public void dispose() { - - IEditorInput input= getEditorInput(); - if (input instanceof IPropertyChangeNotifier) - ((IPropertyChangeNotifier)input).removePropertyChangeListener(fPropertyChangeListener); - - super.dispose(); - - fPropertyChangeListener= null; - } - - /* - * @see IDesktopPart#setFocus - */ - public void setFocus() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - ((CompareEditorInput)input).setFocus(); - } - - /* - * @see IEditorPart#isSaveAsAllowed() - */ - public boolean isSaveAsAllowed() { - return false; - } - - public void gotoMarker(IMarker marker) { - // empty default implemenatation - } - - /** - * Always throws an AssertionFailedException. - */ - /* - * @see IEditorPart#doSaveAs() - */ - public void doSaveAs() { - Assert.isTrue(false); // Save As not supported for CompareEditor - } - - /* - * @see IEditorPart#doSave() - */ - public void doSave(IProgressMonitor progressMonitor) { - - final IEditorInput input= getEditorInput(); - - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws CoreException { - if (input instanceof CompareEditorInput) - ((CompareEditorInput)input).saveChanges(pm); - } - }; - - Shell shell= getSite().getShell(); - - try { - - operation.run(progressMonitor); - - firePropertyChange(PROP_DIRTY); - - } catch (InterruptedException x) { - // NeedWork - } catch (OperationCanceledException x) { - // NeedWork - } catch (InvocationTargetException x) { - String title= Utilities.getString("CompareEditor.saveError.title"); //$NON-NLS-1$ - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(shell, title, Utilities.getFormattedString("CompareEditor.cantSaveError", reason)); //$NON-NLS-1$ - } - } - - /* - * @see IEditorPart#isDirty() - */ - public boolean isDirty() { - IEditorInput input= getEditorInput(); - if (input instanceof CompareEditorInput) - return ((CompareEditorInput)input).isSaveNeeded(); - return false; - } - - public void propertyChange(PropertyChangeEvent event) { - Object old_value= event.getOldValue(); - Object new_value= event.getNewValue(); - if (old_value == null || new_value == null || !old_value.equals(new_value)) - firePropertyChange(PROP_DIRTY); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java deleted file mode 100644 index 672b1327d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.jface.action.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.EditorActionBarContributor; - -import org.eclipse.compare.*; - - -public class CompareEditorContributor extends EditorActionBarContributor { - - private IEditorPart fActiveEditorPart= null; - - private IgnoreWhiteSpaceAction fIgnoreWhitespace; - private NavigationAction fNext; - private NavigationAction fPrevious; - - private NavigationAction fToolbarNext; - private NavigationAction fToolbarPrevious; - - - public CompareEditorContributor() { - ResourceBundle bundle= CompareUI.getResourceBundle(); - - fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null); - WorkbenchHelp.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION); - - fNext= new NavigationAction(bundle, true); - WorkbenchHelp.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION); - - fPrevious= new NavigationAction(bundle, false); - WorkbenchHelp.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION); - - fToolbarNext= new NavigationAction(bundle, true); - WorkbenchHelp.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION); - - fToolbarPrevious= new NavigationAction(bundle, false); - WorkbenchHelp.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION); - } - - /* - * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public void contributeToToolBar(IToolBarManager tbm) { - tbm.add(new Separator()); - tbm.add(fIgnoreWhitespace); - tbm.add(fToolbarNext); - tbm.add(fToolbarPrevious); - } - - /* - * @see EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public void contributeToMenu(IMenuManager menuManager) { - // empty implementation - } - - public void setActiveEditor(IEditorPart targetEditor) { - - if (fActiveEditorPart == targetEditor) - return; - - fActiveEditorPart= targetEditor; - - if (fActiveEditorPart != null) { - IEditorInput input= fActiveEditorPart.getEditorInput(); - if (input instanceof CompareEditorInput) { - CompareEditorInput compareInput= (CompareEditorInput) input; - fNext.setCompareEditorInput(compareInput); - fPrevious.setCompareEditorInput(compareInput); - // Begin fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105 - fToolbarNext.setCompareEditorInput(compareInput); - fToolbarPrevious.setCompareEditorInput(compareInput); - // End fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105 - } - } - - if (targetEditor instanceof CompareEditor) { - IActionBars actionBars= getActionBars(); - - CompareEditor editor= (CompareEditor) targetEditor; - editor.setActionBars(actionBars); - - actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNext); - actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPrevious); - - CompareConfiguration cc= editor.getCompareConfiguration(); - fIgnoreWhitespace.setCompareConfiguration(cc); - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java deleted file mode 100644 index abcea3bae..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilter.java +++ /dev/null @@ -1,397 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.text.MessageFormat; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.runtime.IStatus; - - -public class CompareFilter { - private static final char[][] NO_CHAR_CHAR= new char[0][]; - - private char[][] fExtraResourceFileFilters; - private String[] fExtraResourceFolderFilters; - - - public CompareFilter() { - // nothing to do - } - - /* - * Returns true if path matches filter, that is if path should be filtered. - */ - public boolean filter(String path0, boolean folder, boolean isArchive) { - if (!folder && fExtraResourceFileFilters != null) { - char[] name= path0.toCharArray(); - for (int i= 0, l= fExtraResourceFileFilters.length; i < l; i++) - if (match(fExtraResourceFileFilters[i], name, true)) - return true; - } - if (folder && fExtraResourceFolderFilters != null) { - for (int i= 0, l= fExtraResourceFolderFilters.length; i < l; i++) - if (fExtraResourceFolderFilters[0].equals(path0)) - return true; - } - return false; - } - - public static String validateResourceFilters(String text) { - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - String[] filters= getTokens(text, ","); //$NON-NLS-1$ - for (int i= 0; i < filters.length; i++) { - String fileName= filters[i].replace('*', 'x'); - int resourceType= IResource.FILE; - int lastCharacter= fileName.length() - 1; - if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') { - fileName= fileName.substring(0, lastCharacter); - resourceType= IResource.FOLDER; - } - IStatus status= workspace.validateName(fileName, resourceType); - if (status.matches(IStatus.ERROR)) { - String format= Utilities.getString("ComparePreferencePage.filter.invalidsegment.error"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] { status.getMessage() } ); - } - } - return null; - } - - public void setFilters(String filterSequence) { - char[][] filters= filterSequence != null && filterSequence.length() > 0 - ? splitAndTrimOn(',', filterSequence.toCharArray()) - : null; - if (filters == null) { - fExtraResourceFileFilters= null; - fExtraResourceFolderFilters= null; - } else { - int fileCount= 0, folderCount= 0; - for (int i= 0, l= filters.length; i < l; i++) { - char[] f= filters[i]; - if (f.length == 0) - continue; - if (f[f.length - 1] == '/') - folderCount++; - else - fileCount++; - } - fExtraResourceFileFilters= new char[fileCount][]; - fExtraResourceFolderFilters= new String[folderCount]; - for (int i= 0, l= filters.length; i < l; i++) { - char[] f= filters[i]; - if (f.length == 0) - continue; - if (f[f.length - 1] == '/') - fExtraResourceFolderFilters[--folderCount]= new String(subarray(f, 0, f.length - 1)); - else - fExtraResourceFileFilters[--fileCount]= f; - } - } - } - - ///////// - - private static String[] getTokens(String text, String separator) { - StringTokenizer tok= new StringTokenizer(text, separator); //$NON-NLS-1$ - int nTokens= tok.countTokens(); - String[] res= new String[nTokens]; - for (int i= 0; i < res.length; i++) - res[i]= tok.nextToken().trim(); - return res; - } - - /** - * Answers true if the pattern matches the given name, false otherwise. - * This char[] pattern matching accepts wild-cards '*' and '?'. - * - * When not case sensitive, the pattern is assumed to already be - * lowercased, the name will be lowercased character per character as - * comparing. If name is null, the answer is false. If pattern is null, the - * answer is true if name is not null.

For example: - *

    - *
  1. - * - *
    -	 *  pattern = { '?', 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => true
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  pattern = { '?', 'b', '?' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  4. - *
  5. - * - *
    -	 *  pattern = { 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  6. - *
- * - * @param pattern - * the given pattern - * @param name - * the given name - * @param isCaseSensitive - * flag to know whether or not the matching should be case - * sensitive - * @return true if the pattern matches the given name, false otherwise - */ - private boolean match(char[] pattern, char[] name, boolean isCaseSensitive) { - if (name == null) - return false; // null name cannot match - if (pattern == null) - return true; // null pattern is equivalent to '*' - return match(pattern, 0, pattern.length, name, 0, name.length, isCaseSensitive); - } - - /** - * Answers true if the a sub-pattern matches the subpart of the given name, - * false otherwise. char[] pattern matching, accepting wild-cards '*' and - * '?'. Can match only subset of name/pattern. end positions are - * non-inclusive. The subpattern is defined by the patternStart and - * pattternEnd positions. When not case sensitive, the pattern is assumed - * to already be lowercased, the name will be lowercased character per - * character as comparing.

For example: - *
    - *
  1. - * - *
    -	 *  pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 3 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 4 isCaseSensitive = true result => true
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 2 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 2 isCaseSensitive = true result => false
    -	 * 
    - * - * - *
  4. - *
- * - * @param pattern - * the given pattern - * @param patternStart - * the given pattern start - * @param patternEnd - * the given pattern end - * @param name - * the given name - * @param nameStart - * the given name start - * @param nameEnd - * the given name end - * @param isCaseSensitive - * flag to know if the matching should be case sensitive - * @return true if the a sub-pattern matches the subpart of the given name, - * false otherwise - */ - private boolean match(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, - boolean isCaseSensitive) { - if (name == null) - return false; // null name cannot match - if (pattern == null) - return true; // null pattern is equivalent to '*' - int iPattern= patternStart; - int iName= nameStart; - if (patternEnd < 0) - patternEnd= pattern.length; - if (nameEnd < 0) - nameEnd= name.length; - /* check first segment */ - char patternChar= 0; - while ((iPattern < patternEnd) && (patternChar= pattern[iPattern]) != '*') { - if (iName == nameEnd) - return false; - if (patternChar != (isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) && patternChar != '?') { - return false; - } - iName++; - iPattern++; - } - /* check sequence of star+segment */ - int segmentStart; - if (patternChar == '*') { - segmentStart= ++iPattern; // skip star - } else { - segmentStart= 0; // force iName check - } - int prefixStart= iName; - checkSegment : while (iName < nameEnd) { - if (iPattern == patternEnd) { - iPattern= segmentStart; // mismatch - restart current segment - iName= ++prefixStart; - continue checkSegment; - } - /* segment is ending */ - if ((patternChar= pattern[iPattern]) == '*') { - segmentStart= ++iPattern; // skip start - if (segmentStart == patternEnd) { - return true; - } - prefixStart= iName; - continue checkSegment; - } - /* check current name character */ - if ((isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) != patternChar && patternChar != '?') { - iPattern= segmentStart; // mismatch - restart current segment - iName= ++prefixStart; - continue checkSegment; - } - iName++; - iPattern++; - } - return (segmentStart == patternEnd) || (iName == nameEnd && iPattern == patternEnd) - || (iPattern == patternEnd - 1 && pattern[iPattern] == '*'); - } - - /** - * Return a new array which is the split of the given array using the given - * divider and triming each subarray to remove whitespaces equals to ' '. - *

For example: - *
    - *
  1. - * - *
    -	 *  divider = 'b' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } }
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  divider = 'c' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
    -	 * 
    - * - * - *
  4. - *
  5. - * - *
    -	 *  divider = 'b' array = { 'a' , ' ', 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } }
    -	 * 
    - * - * - *
  6. - *
  7. - * - *
    -	 *  divider = 'c' array = { ' ', ' ', 'a' , 'b', 'b', 'a', 'b', 'a', ' ' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
    -	 * 
    - * - * - *
  8. - *
- * - * @param divider - * the given divider - * @param array - * the given array - * @return a new array which is the split of the given array using the - * given divider and triming each subarray to remove whitespaces - * equals to ' ' - */ - private char[][] splitAndTrimOn(char divider, char[] array) { - int length= array == null ? 0 : array.length; - if (length == 0) - return NO_CHAR_CHAR; - int wordCount= 1; - for (int i= 0; i < length; i++) - if (array[i] == divider) - wordCount++; - char[][] split= new char[wordCount][]; - int last= 0, currentWord= 0; - for (int i= 0; i < length; i++) { - if (array[i] == divider) { - int start= last, end= i - 1; - while (start < i && array[start] == ' ') - start++; - while (end > start && array[end] == ' ') - end--; - split[currentWord]= new char[end - start + 1]; - System.arraycopy(array, start, split[currentWord++], 0, end - start + 1); - last= i + 1; - } - } - int start= last, end= length - 1; - while (start < length && array[start] == ' ') - start++; - while (end > start && array[end] == ' ') - end--; - split[currentWord]= new char[end - start + 1]; - System.arraycopy(array, start, split[currentWord++], 0, end - start + 1); - return split; - } - - /** - * Answers a new array which is a copy of the given array starting at the - * given start and ending at the given end. The given start is inclusive - * and the given end is exclusive. Answers null if start is greater than - * end, if start is lower than 0 or if end is greater than the length of - * the given array. If end equals -1, it is converted to the array length. - *

For example: - *
    - *
  1. - * - *
    -	 *  array = { 'a' , 'b' } start = 0 end = 1 result => { 'a' }
    -	 * 
    - * - * - *
  2. - *
  3. - * - *
    -	 *  array = { 'a', 'b' } start = 0 end = -1 result => { 'a' , 'b' }
    -	 * 
    - * - * - *
  4. - *
- * - * @param array - * the given array - * @param start - * the given starting index - * @param end - * the given ending index - * @return a new array which is a copy of the given array starting at the - * given start and ending at the given end - * @exception NullPointerException - * if the given array is null - */ - private char[] subarray(char[] array, int start, int end) { - if (end == -1) - end= array.length; - if (start > end) - return null; - if (start < 0) - return null; - if (end > array.length) - return null; - char[] result= new char[end - start]; - System.arraycopy(array, start, result, 0, end - start); - return result; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java deleted file mode 100644 index bc2d1464f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class CompareMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.CompareMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private CompareMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties deleted file mode 100644 index eb3dd5c8f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties +++ /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 -############################################################################### - -ComparePlugin.internal_error= Internal Error -ExceptionDialog.seeErrorLogMessage= See error log for details. - -# -# Title format for CompareViewerSwitchingPane -# -CompareViewerSwitchingPane.Titleformat= {0} ({1}) - -# -# Title message for StructureDiffViewer if no structural differences could be found -# -StructureDiffViewer.NoStructuralDifferences= No Structural Differences -StructureDiffViewer.StructureError= Cannot Compare Structures - -# -# TextMergeViewer -# -TextMergeViewer.cursorPosition.format= {0} : {1} - -TextMergeViewer.beforeLine.format= before line {0} -TextMergeViewer.range.format= {0} : {1} - -TextMergeViewer.changeType.addition= addition -TextMergeViewer.changeType.deletion= deletion -TextMergeViewer.changeType.change= change - -TextMergeViewer.direction.outgoing= outgoing -TextMergeViewer.direction.incoming= incoming -TextMergeViewer.direction.conflicting= conflicting - -TextMergeViewer.diffType.format= {0} {1} - -TextMergeViewer.diffDescription.noDiff.format= no diff -TextMergeViewer.diffDescription.diff.format= {0} #{1} (Left: {2}, Right: {3}) -TextMergeViewer.statusLine.format= Left: {0}, Right: {1}, {2} - -TextMergeViewer.atEnd.title= Go to Next Difference -TextMergeViewer.atEnd.message= End of document reached. Continue from beginning? - -TextMergeViewer.atBeginning.title= Go to Previous Difference -TextMergeViewer.atBeginning.message= Beginning of document reached. Continue from end? - -CompareNavigator.atEnd.title= Go to Next Difference -CompareNavigator.atEnd.message= Last difference reached. - -CompareNavigator.atBeginning.title= Go to Previous Difference -CompareNavigator.atBeginning.message= First difference reached. diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java deleted file mode 100644 index 295f4cc7c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Control; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.*; - -/** - * Supports cross-pane navigation through differences. - * XXX: Design is as it is because the feature had to be added without touching API. - */ -public class CompareNavigator implements ICompareNavigator { - - private boolean fLastDirection= true; - private CompareViewerSwitchingPane[] fPanes; - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - private boolean fNextFirstTime= true; - - public CompareNavigator(CompareViewerSwitchingPane[] panes) { - fPanes= panes; - } - - public CompareViewerSwitchingPane[] getPanes() { - return fPanes; - } - - public boolean selectChange(boolean next) { - - fLastDirection= next; - - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - if (next && fNextFirstTime && mustOpen()) { - fNextFirstTime= false; - openElement(); - } - - // find most down stream CompareViewerPane - int n= 0; - INavigatable[] navigators= new INavigatable[4]; - for (int i= 0; i < fPanes.length; i++) { - navigators[n]= getNavigator(fPanes[i]); - if (navigators[n] != null) - n++; - } - - while (n > 0) { - n--; - if (navigators[n].gotoDifference(next)) { - // at end of this navigator - continue; - } - // not at end - return false; - } - - return true; - } - - private static INavigatable getNavigator(CompareViewerSwitchingPane pane) { - if (pane == null) - return null; - if (pane.isEmpty()) - return null; - Viewer viewer= pane.getViewer(); - if (viewer == null) - return null; - Control control= viewer.getControl(); - if (control == null) - return null; - Object data= control.getData(INavigatable.NAVIGATOR_PROPERTY); - if (data instanceof INavigatable) - return (INavigatable) data; - return null; - } - - private static CompareNavigator findNavigator(Control c) { - while (c != null && !c.isDisposed()) { // PR 1GEUVV2 - Object data= c.getData(); - if (data instanceof CompareEditorInput) { - CompareEditorInput cei= (CompareEditorInput) data; - Object adapter= cei.getAdapter(CompareNavigator.class); - if (adapter instanceof CompareNavigator) - return (CompareNavigator)adapter; - } - c= c.getParent(); - } - return null; - } - - private boolean resetDirection() { - boolean last= fLastDirection; - fLastDirection= true; - return last; - } - - public static boolean getDirection(Control c) { - CompareNavigator nav= findNavigator(c); - if (nav != null) - return nav.resetDirection(); - return true; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private boolean mustOpen() { - if (fPanes == null || fPanes.length == 0) - return false; - for (int i= 1; i < fPanes.length; i++) { - CompareViewerSwitchingPane pane= fPanes[i]; - if (pane != null && pane.getInput() != null) - return false; - } - return true; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private void openElement() { - if (fPanes == null || fPanes.length == 0) - return; - IOpenable openable= getOpenable(fPanes[0]); - if (openable != null) { - openable.openSelected(); - } - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private static IOpenable getOpenable(CompareViewerSwitchingPane pane) { - if (pane == null) - return null; - if (pane.isEmpty()) - return null; - Viewer viewer= pane.getViewer(); - if (viewer == null) - return null; - Control control= viewer.getControl(); - if (control == null) - return null; - Object data= control.getData(IOpenable.OPENABLE_PROPERTY); - if (data instanceof IOpenable) - return (IOpenable) data; - return null; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java deleted file mode 100644 index bc599075d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.CompareEditorInput; - -/** - */ -public class CompareOutlinePage implements IContentOutlinePage { - - private Control fControl; - private ListenerList fListeners= new ListenerList(); - private ISelection fSelection; - //private IActionBars fActionBars; - private CompareEditorInput fCompareEditorInput; - - CompareOutlinePage(CompareEditorInput input) { - fCompareEditorInput= input; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - if (fCompareEditorInput != null) { - fControl= fCompareEditorInput.createOutlineContents(parent, SWT.VERTICAL); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#dispose() - */ - public void dispose() { - if (fControl != null) - fControl.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - public Control getControl() { - return fControl; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - //fActionBars= actionBars; - //if (fControl != null) - // fControl.setData("actionBars", actionBars); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - public void setFocus() { - if (fControl != null) - fControl.setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - fListeners.add(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return fSelection; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - fListeners.remove(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - fSelection= selection; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java deleted file mode 100644 index 3fcd49cf0..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java +++ /dev/null @@ -1,389 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.util.*; - -import org.eclipse.ui.*; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.texteditor.AbstractTextEditor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.util.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.contentmergeviewer.TextMergeViewer; -import org.eclipse.compare.structuremergeviewer.*; - - -public class ComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - - class FakeInput implements ITypedElement, IEncodedStreamContentAccessor { - static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - String fContent; - - FakeInput(String name) { - fContent= loadPreviewContentFromFile(name); - } - public Image getImage() { - return null; - } - public String getName() { - return "no name"; //$NON-NLS-1$ - } - public String getType() { - return "no type"; //$NON-NLS-1$ - } - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); - } - public String getCharset() { - return UTF_16; - } - } - - private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ - public static final String OPEN_STRUCTURE_COMPARE= PREFIX + "OpenStructureCompare"; //$NON-NLS-1$ - public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$ - public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$ - public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$ - public static final String PREF_SAVE_ALL_EDITORS= PREFIX + "SaveAllEditors"; //$NON-NLS-1$ - public static final String SHOW_MORE_INFO= PREFIX + "ShowMoreInfo"; //$NON-NLS-1$ - public static final String IGNORE_WHITESPACE= PREFIX + "IgnoreWhitespace"; //$NON-NLS-1$ - //public static final String USE_SPLINES= PREFIX + "UseSplines"; //$NON-NLS-1$ - public static final String USE_SINGLE_LINE= PREFIX + "UseSingleLine"; //$NON-NLS-1$ - //public static final String USE_RESOLVE_UI= PREFIX + "UseResolveUI"; //$NON-NLS-1$ - public static final String PATH_FILTER= PREFIX + "PathFilter"; //$NON-NLS-1$ - - - private TextMergeViewer fPreviewViewer; - private IPropertyChangeListener fPreferenceChangeListener; - private CompareConfiguration fCompareConfiguration; - private OverlayPreferenceStore fOverlayStore; - private Map fCheckBoxes= new HashMap(); - private Text fFilters; - private SelectionListener fCheckBoxListener; - - - public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] { - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, OPEN_STRUCTURE_COMPARE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IGNORE_WHITESPACE), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PREF_SAVE_ALL_EDITORS), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT), - - //new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SPLINES), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SINGLE_LINE), - //new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_RESOLVE_UI), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PATH_FILTER), - }; - - - public static void initDefaults(IPreferenceStore store) { - store.setDefault(OPEN_STRUCTURE_COMPARE, true); - store.setDefault(SYNCHRONIZE_SCROLLING, true); - store.setDefault(SHOW_PSEUDO_CONFLICTS, false); - store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false); - store.setDefault(SHOW_MORE_INFO, false); - store.setDefault(IGNORE_WHITESPACE, false); - store.setDefault(PREF_SAVE_ALL_EDITORS, false); - //store.setDefault(USE_SPLINES, false); - store.setDefault(USE_SINGLE_LINE, true); - //store.setDefault(USE_RESOLVE_UI, false); - store.setDefault(PATH_FILTER, ""); //$NON-NLS-1$ - - store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true); - } - - public ComparePreferencePage() { - - //setDescription(Utilities.getString("ComparePreferencePage.description")); //$NON-NLS-1$ - - setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore()); - - fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); - fPreferenceChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - String key= event.getProperty(); - if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) { - boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE); - if (fCompareConfiguration != null) { - fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b)); - } - } - } - }; - fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener); - } - - /* - * @see IWorkbenchPreferencePage#init() - */ - public void init(IWorkbench workbench) { - // empty - } - - /* - * @see PreferencePage#performOk() - */ - public boolean performOk() { - fOverlayStore.propagate(); - return true; - } - - /* - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() { - - fOverlayStore.loadDefaults(); - initializeFields(); - - super.performDefaults(); - } - - /* - * @see DialogPage#dispose() - */ - public void dispose() { - - if (fOverlayStore != null) { - if (fPreferenceChangeListener != null) { - fOverlayStore.removePropertyChangeListener(fPreferenceChangeListener); - fPreferenceChangeListener= null; - } - fOverlayStore.stop(); - fOverlayStore= null; - } - - super.dispose(); - } - - static public boolean getSaveAllEditors() { - IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(PREF_SAVE_ALL_EDITORS); - } - - static public void setSaveAllEditors(boolean value) { - IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); - store.setValue(PREF_SAVE_ALL_EDITORS, value); - } - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - - WorkbenchHelp.setHelp(parent, ICompareContextIds.COMPARE_PREFERENCE_PAGE); - - fOverlayStore.load(); - fOverlayStore.start(); - - TabFolder folder= new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); - folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem item= new TabItem(folder, SWT.NONE); - item.setText(Utilities.getString("ComparePreferencePage.generalTab.label")); //$NON-NLS-1$ - //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); - item.setControl(createGeneralPage(folder)); - - item= new TabItem(folder, SWT.NONE); - item.setText(Utilities.getString("ComparePreferencePage.textCompareTab.label")); //$NON-NLS-1$ - //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); - item.setControl(createTextComparePage(folder)); - - initializeFields(); - Dialog.applyDialogFont(folder); - return folder; - } - - private Control createGeneralPage(Composite parent) { - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 1; - composite.setLayout(layout); - - addCheckBox(composite, "ComparePreferencePage.structureCompare.label", OPEN_STRUCTURE_COMPARE, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.ignoreWhitespace.label", IGNORE_WHITESPACE, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - addCheckBox(composite, "ComparePreferencePage.saveBeforePatching.label", PREF_SAVE_ALL_EDITORS, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - Label l= new Label(composite, SWT.WRAP); - l.setText(Utilities.getString("ComparePreferencePage.filter.description")); //$NON-NLS-1$ - - Composite c2= new Composite(composite, SWT.NONE); - c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - layout= new GridLayout(2, false); - layout.marginWidth= 0; - c2.setLayout(layout); - - l= new Label(c2, SWT.NONE); - l.setText(Utilities.getString("ComparePreferencePage.filter.label")); //$NON-NLS-1$ - - fFilters= new Text(c2, SWT.BORDER); - fFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fFilters.setText(fOverlayStore.getString(PATH_FILTER)); - fFilters.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - String filters= fFilters.getText(); - String message= CompareFilter.validateResourceFilters(filters); - setValid(message == null); - setMessage(null); - setErrorMessage(message); - fOverlayStore.setValue(PATH_FILTER, filters); - } - } - ); - - return composite; - } - - private Control createTextComparePage(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.numColumns= 1; - composite.setLayout(layout); - - addCheckBox(composite, "ComparePreferencePage.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$ - - //addCheckBox(composite, "ComparePreferencePage.useSplines.label", USE_SPLINES, 0); //$NON-NLS-1$ - addCheckBox(composite, "ComparePreferencePage.useSingleLine.label", USE_SINGLE_LINE, 0); //$NON-NLS-1$ - //addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$ - - // a spacer - new Label(composite, SWT.NONE); - - Label previewLabel= new Label(composite, SWT.NULL); - previewLabel.setText(Utilities.getString("ComparePreferencePage.preview.label")); //$NON-NLS-1$ - - Control previewer= createPreviewer(composite); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.widthHint= convertWidthInCharsToPixels(60); - gd.heightHint= convertHeightInCharsToPixels(13); - previewer.setLayoutData(gd); - - return composite; - } - - private Control createPreviewer(Composite parent) { - - fCompareConfiguration= new CompareConfiguration(fOverlayStore); - fCompareConfiguration.setAncestorLabel(Utilities.getString("ComparePreferencePage.ancestor.label")); //$NON-NLS-1$ - - fCompareConfiguration.setLeftLabel(Utilities.getString("ComparePreferencePage.left.label")); //$NON-NLS-1$ - fCompareConfiguration.setLeftEditable(false); - - fCompareConfiguration.setRightLabel(Utilities.getString("ComparePreferencePage.right.label")); //$NON-NLS-1$ - fCompareConfiguration.setRightEditable(false); - - fPreviewViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration); - - fPreviewViewer.setInput( - new DiffNode(Differencer.CONFLICTING, - new FakeInput("ComparePreferencePage.previewAncestor"), //$NON-NLS-1$ - new FakeInput("ComparePreferencePage.previewLeft"), //$NON-NLS-1$ - new FakeInput("ComparePreferencePage.previewRight") //$NON-NLS-1$ - ) - ); - - Control c= fPreviewViewer.getControl(); - c.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fCompareConfiguration != null) - fCompareConfiguration.dispose(); - } - }); - - return c; - } - - private void initializeFields() { - - Iterator e= fCheckBoxes.keySet().iterator(); - while (e.hasNext()) { - Button b= (Button) e.next(); - String key= (String) fCheckBoxes.get(b); - b.setSelection(fOverlayStore.getBoolean(key)); - } - - if (fFilters != null) - fFilters.setText(fOverlayStore.getString(PATH_FILTER)); - } - - // overlay stuff - - private Button addCheckBox(Composite parent, String labelKey, String key, int indentation) { - - String label= Utilities.getString(labelKey); - - Button checkBox= new Button(parent, SWT.CHECK); - checkBox.setText(label); - - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalIndent= indentation; - gd.horizontalSpan= 2; - checkBox.setLayoutData(gd); - - if (fCheckBoxListener == null) { - fCheckBoxListener= new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - Button button= (Button) e.widget; - fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); - } - }; - } - checkBox.addSelectionListener(fCheckBoxListener); - - fCheckBoxes.put(checkBox, key); - - return checkBox; - } - - private String loadPreviewContentFromFile(String key) { - - String preview= Utilities.getString(key); - String separator= System.getProperty("line.separator"); //$NON-NLS-1$ - StringBuffer buffer= new StringBuffer(); - for (int i= 0; i < preview.length(); i++) { - char c= preview.charAt(i); - if (c == '\n') - buffer.append(separator); - else - buffer.append(c); - } - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java deleted file mode 100644 index d90b72759..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java +++ /dev/null @@ -1,1155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.net.*; -import java.util.*; -import java.util.List; - -import org.eclipse.ui.*; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.content.IContentTypeManager; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.osgi.framework.BundleContext; - - -/** - * The Compare UI plug-in defines the entry point to initiate a configurable - * compare operation on arbitrary resources. The result of the compare - * is opened into a compare editor where the details can be browsed and - * edited in dynamically selected structure and content viewers. - *

- * The Compare UI provides a registry for content and structure compare viewers, - * which is initialized from extensions contributed to extension points - * declared by this plug-in. - *

- * This class is the plug-in runtime class for the - * "org.eclipse.compare" plug-in. - *

- */ -public final class CompareUIPlugin extends AbstractUIPlugin { - - static class CompareRegistry { - - private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$ - - private HashMap fIdMap; - private HashMap fExtensionMap; - private HashMap fContentTypeBindings; // maps content type bindings to datas - - - void register(IConfigurationElement element, Object data) { - String id= element.getAttribute(ID_ATTRIBUTE); - if (id != null) { - if (fIdMap == null) - fIdMap= new HashMap(); - fIdMap.put(id, data); - } - - String types= element.getAttribute(EXTENSIONS_ATTRIBUTE); - if (types != null) { - if (fExtensionMap == null) - fExtensionMap= new HashMap(); - StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreElements()) { - String extension= tokenizer.nextToken().trim(); - fExtensionMap.put(normalizeCase(extension), data); - } - } - } - - void createBinding(IConfigurationElement element, String idAttributeName) { - String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE); - String id= element.getAttribute(idAttributeName); - if (id == null) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$ - if (type != null && id != null && fIdMap != null) { - Object o= fIdMap.get(id); - if (o != null) { - IContentType ct= fgContentTypeManager.getContentType(type); - if (ct != null) { - if (fContentTypeBindings == null) - fContentTypeBindings= new HashMap(); - fContentTypeBindings.put(ct, o); - } else { - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$ - } - } else { - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$ - } - } - } - - Object search(IContentType type) { - if (type != null && fContentTypeBindings != null) { - Object b= fContentTypeBindings.get(type); - if (b != null) - return b; - Iterator iter= fContentTypeBindings.keySet().iterator(); - while (iter.hasNext()) { - IContentType ct= (IContentType) iter.next(); - if (type.isKindOf(ct)) { - return fContentTypeBindings.get(ct); - } - } - } - return null; - } - - Object search(String extension) { - if (fExtensionMap != null) - return fExtensionMap.get(normalizeCase(extension)); - return null; - } - } - - public static final String DTOOL_NEXT= "dlcl16/next_nav.gif"; //$NON-NLS-1$ - public static final String ETOOL_NEXT= "elcl16/next_nav.gif"; //$NON-NLS-1$ - public static final String CTOOL_NEXT= ETOOL_NEXT; - - public static final String DTOOL_PREV= "dlcl16/prev_nav.gif"; //$NON-NLS-1$ - public static final String ETOOL_PREV= "elcl16/prev_nav.gif"; //$NON-NLS-1$ - public static final String CTOOL_PREV= ETOOL_PREV; - - /** Status code describing an internal error */ - public static final int INTERNAL_ERROR= 1; - - private static boolean NORMALIZE_CASE= true; - - public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$ - - private static final String BINARY_TYPE= "binary"; //$NON-NLS-1$ - - private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$ - private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$ - private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$ - private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$ - - private static final String VIEWER_TAG= "viewer"; //$NON-NLS-1$ - private static final String STRUCTURE_MERGE_VIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$ - private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$ - private static final String CONTENT_MERGE_VIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$ - private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$ - private static final String CONTENT_VIEWER_EXTENSION_POINT= "contentViewers"; //$NON-NLS-1$ - private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$ - - private static final String CONTENT_TYPE_BINDING= "contentTypeBinding"; //$NON-NLS-1$ - - - private static final String COMPARE_EDITOR= PLUGIN_ID + ".CompareEditor"; //$NON-NLS-1$ - - private static final String STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME= "StructureViewerAliases"; //$NON-NLS-1$ - - // content type - private static final IContentTypeManager fgContentTypeManager= Platform.getContentTypeManager(); - - /** - * The plugin singleton. - */ - private static CompareUIPlugin fgComparePlugin; - - /** Maps type to icons */ - private static Map fgImages= new Hashtable(10); - /** Maps type to ImageDescriptors */ - private static Map fgImageDescriptors= new Hashtable(10); - /** Maps ImageDescriptors to Images */ - private static Map fgImages2= new Hashtable(10); - - private static List fgDisposeOnShutdownImages= new ArrayList(); - - private ResourceBundle fResourceBundle; - - private boolean fRegistriesInitialized; - private CompareRegistry fStreamMergers= new CompareRegistry(); - private CompareRegistry fStructureCreators= new CompareRegistry(); - private CompareRegistry fStructureMergeViewers= new CompareRegistry(); - private CompareRegistry fContentViewers= new CompareRegistry(); - private CompareRegistry fContentMergeViewers= new CompareRegistry(); - - private Map fStructureViewerAliases; - private CompareFilter fFilter; - private IPropertyChangeListener fPropertyChangeListener; - - /** - * Creates the CompareUIPlugin object and registers all - * structure creators, content merge viewers, and structure merge viewers - * contributed to this plug-in's extension points. - *

- * Note that instances of plug-in runtime classes are automatically created - * by the platform in the course of plug-in activation. - */ - public CompareUIPlugin() { - super(); - Assert.isTrue(fgComparePlugin == null); - fgComparePlugin= this; - } - - public void start(BundleContext context) throws Exception { - super.start(context); - ComparePreferencePage.initDefaults(getPreferenceStore()); - } - - public void stop(BundleContext context) throws Exception { - - IPreferenceStore ps= getPreferenceStore(); - rememberAliases(ps); - if (fPropertyChangeListener != null) { - ps.removePropertyChangeListener(fPropertyChangeListener); - fPropertyChangeListener= null; - } - - super.stop(context); - - if (fgDisposeOnShutdownImages != null) { - Iterator i= fgDisposeOnShutdownImages.iterator(); - while (i.hasNext()) { - Image img= (Image) i.next(); - if (!img.isDisposed()) - img.dispose(); - } - fgImages= null; - } - } - - /** - * Returns the singleton instance of this plug-in runtime class. - * - * @return the compare plug-in instance - */ - public static CompareUIPlugin getDefault() { - return fgComparePlugin; - } - - /** - * Returns this plug-in's resource bundle. - * - * @return the plugin's resource bundle - */ - public ResourceBundle getResourceBundle() { - if (fResourceBundle == null) - fResourceBundle= Platform.getResourceBundle(getBundle()); - return fResourceBundle; - } - - /** - * Returns this plug-in's unique identifier. - * - * @return the plugin's unique identifier - */ - public static String getPluginId() { - return getDefault().getBundle().getSymbolicName(); - } - - private void initializeRegistries() { - if (!fRegistriesInitialized) { - registerExtensions(); - fRegistriesInitialized= true; - } - } - - /** - * Registers all stream mergers, structure creators, content merge viewers, and structure merge viewers - * that are found in the XML plugin files. - */ - private void registerExtensions() { - IExtensionRegistry registry= Platform.getExtensionRegistry(); - - // collect all IStreamMergers - IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STREAM_MERGER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (STREAM_MERGER.equals(element.getName())) - fStreamMergers.register(element, new StreamMergerDescriptor(element)); - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStreamMergers.createBinding(element, STREAM_MERGER_ID_ATTRIBUTE); - } - - // collect all IStructureCreators - elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!STRUCTURE_CREATOR.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, STRUCTURE_CREATOR)); //$NON-NLS-1$ - fStructureCreators.register(element, new StructureCreatorDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStructureCreators.createBinding(element, STRUCTURE_CREATOR_ID_ATTRIBUTE); - } - - // collect all viewers which define the structure mergeviewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGE_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fStructureMergeViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fStructureMergeViewers.createBinding(element, STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE); - } - - // collect all viewers which define the content mergeviewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGE_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fContentMergeViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fContentMergeViewers.createBinding(element, CONTENT_MERGE_VIEWER_ID_ATTRIBUTE); - } - - // collect all viewers which define the content viewer extension point - elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_VIEWER_EXTENSION_POINT); - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - String name= element.getName(); - if (!CONTENT_TYPE_BINDING.equals(name)) { - if (!VIEWER_TAG.equals(name)) - logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.unexpectedTag", name, VIEWER_TAG)); //$NON-NLS-1$ - fContentViewers.register(element, new ViewerDescriptor(element)); - } - } - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (CONTENT_TYPE_BINDING.equals(element.getName())) - fContentViewers.createBinding(element, CONTENT_VIEWER_ID_ATTRIBUTE); - } - } - - public static IWorkbench getActiveWorkbench() { - CompareUIPlugin plugin= getDefault(); - if (plugin == null) - return null; - return plugin.getWorkbench(); - } - - public static IWorkbenchWindow getActiveWorkbenchWindow() { - IWorkbench workbench= getActiveWorkbench(); - if (workbench == null) - return null; - return workbench.getActiveWorkbenchWindow(); - } - - /** - * Returns the active workkbench page or null if - * no active workkbench page can be determined. - * - * @return the active workkbench page or null if - * no active workkbench page can be determined - */ - private static IWorkbenchPage getActivePage() { - IWorkbenchWindow window= getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getActivePage(); - } - - /** - * Returns the SWT Shell of the active workbench window or null if - * no workbench window is active. - * - * @return the SWT Shell of the active workbench window, or null if - * no workbench window is active - */ - public static Shell getShell() { - IWorkbenchWindow window= getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getShell(); - } - - /** - * Registers the given image for being disposed when this plug-in is shutdown. - * - * @param image the image to register for disposal - */ - public static void disposeOnShutdown(Image image) { - if (image != null) - fgDisposeOnShutdownImages.add(image); - } - - /** - * Performs the comparison described by the given input and opens a - * compare editor on the result. - * - * @param input the input on which to open the compare editor - * @param page the workbench page on which to create a new compare editor - * @param editor if not null the input is opened in this editor - * @see CompareEditorInput - */ - public void openCompareEditor(CompareEditorInput input, IWorkbenchPage page, IReusableEditor editor) { - - if (compareResultOK(input)) { - - if (editor != null) { // reuse the given editor - editor.setInput(input); - return; - } - - if (page == null) - page= getActivePage(); - if (page != null) { - // open new CompareEditor on page - try { - page.openEditor(input, COMPARE_EDITOR); - } catch (PartInitException e) { - MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), e.getMessage()); //$NON-NLS-1$ - } - } else { - MessageDialog.openError(getShell(), - Utilities.getString("CompareUIPlugin.openEditorError"), //$NON-NLS-1$ - Utilities.getString("CompareUIPlugin.noActiveWorkbenchPage")); //$NON-NLS-1$ - } - } - } - - /** - * Performs the comparison described by the given input and opens a - * compare dialog on the result. - * - * @param input the input on which to open the compare editor - * @see CompareEditorInput - */ - public void openCompareDialog(final CompareEditorInput input) { - - if (compareResultOK(input)) { - CompareDialog dialog= new CompareDialog(getShell(), input); - dialog.open(); - } - } - - /* - * @return true if compare result is OK to show, false otherwise - */ - private boolean compareResultOK(CompareEditorInput input) { - final Shell shell= getShell(); - try { - - // run operation in separate thread and make it canceable - PlatformUI.getWorkbench().getProgressService().run(true, true, input); - - String message= input.getMessage(); - if (message != null) { - MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), message); //$NON-NLS-1$ - return false; - } - - if (input.getCompareResult() == null) { - MessageDialog.openInformation(shell, Utilities.getString("CompareUIPlugin.dialogTitle"), Utilities.getString("CompareUIPlugin.noDifferences")); //$NON-NLS-2$ //$NON-NLS-1$ - return false; - } - - return true; - - } catch (InterruptedException x) { - // cancelled by user - } catch (InvocationTargetException x) { - MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), x.getTargetException().getMessage()); //$NON-NLS-1$ - } - return false; - } - - /* - * Registers an image for the given type. - */ - private static void registerImage(String type, Image image, boolean dispose) { - fgImages.put(normalizeCase(type), image); - if (image != null && dispose) { - fgDisposeOnShutdownImages.add(image); - } - } - - /** - * Registers an image descriptor for the given type. - * - * @param type the type - * @param descriptor the image descriptor - */ - public static void registerImageDescriptor(String type, ImageDescriptor descriptor) { - fgImageDescriptors.put(normalizeCase(type), descriptor); - } - - public static ImageDescriptor getImageDescriptor(String relativePath) { - - URL installURL= null; - if (fgComparePlugin != null) - installURL= fgComparePlugin.getBundle().getEntry("/"); //$NON-NLS-1$ - - if (installURL != null) { - try { - URL url= new URL(installURL, Utilities.getIconPath(null) + relativePath); - return ImageDescriptor.createFromURL(url); - } catch (MalformedURLException e) { - Assert.isTrue(false); - } - } - return null; - } - - /** - * Returns a shared image for the given type, or a generic image if none - * has been registered for the given type. - *

- * Note: Images returned from this method will be automitically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param type the type - * @return the image - */ - public static Image getImage(String type) { - - type= normalizeCase(type); - - boolean dispose= false; - Image image= null; - if (type != null) - image= (Image) fgImages.get(type); - if (image == null) { - ImageDescriptor id= (ImageDescriptor) fgImageDescriptors.get(type); - if (id != null) { - image= id.createImage(); - dispose= true; - } - - if (image == null) { - if (fgComparePlugin != null) { - if (ITypedElement.FOLDER_TYPE.equals(type)) { - image= getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - //image= SharedImages.getImage(ISharedImages.IMG_OBJ_FOLDER); - } else { - image= createWorkbenchImage(type); - dispose= true; - } - } else { - id= (ImageDescriptor) fgImageDescriptors.get(normalizeCase("file")); //$NON-NLS-1$ - image= id.createImage(); - dispose= true; - } - } - if (image != null) - registerImage(type, image, dispose); - } - return image; - } - - /** - * Returns a shared image for the given adaptable. - * This convenience method queries the given adaptable - * for its IWorkbenchAdapter.getImageDescriptor, which it - * uses to create an image if it does not already have one. - *

- * Note: Images returned from this method will be automitically disposed - * of when this plug-in shuts down. Callers must not dispose of these - * images themselves. - *

- * - * @param adaptable the adaptable for which to find an image - * @return an image - */ - public static Image getImage(IAdaptable adaptable) { - if (adaptable != null) { - Object o= adaptable.getAdapter(IWorkbenchAdapter.class); - if (o instanceof IWorkbenchAdapter) { - ImageDescriptor id= ((IWorkbenchAdapter) o).getImageDescriptor(adaptable); - if (id != null) { - Image image= (Image)fgImages2.get(id); - if (image == null) { - image= id.createImage(); - try { - fgImages2.put(id, image); - } catch (NullPointerException ex) { - // NeedWork - } - fgDisposeOnShutdownImages.add(image); - - } - return image; - } - } - } - return null; - } - - private static Image createWorkbenchImage(String type) { - IEditorRegistry er= getDefault().getWorkbench().getEditorRegistry(); - ImageDescriptor id= er.getImageDescriptor("foo." + type); //$NON-NLS-1$ - return id.createImage(); - } - - /** - * Returns an structure creator descriptor for the given type. - * - * @param type the type for which to find a descriptor - * @return a descriptor for the given type, or null if no - * descriptor has been registered - */ - public StructureCreatorDescriptor getStructureCreator(String type) { - initializeRegistries(); - return (StructureCreatorDescriptor) fStructureCreators.search(type); - } - - /** - * Returns a stream merger for the given type. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public IStreamMerger createStreamMerger(String type) { - initializeRegistries(); - StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fStreamMergers.search(type); - if (descriptor != null) - return descriptor.createStreamMerger(); - return null; - } - - /** - * Returns a stream merger for the given content type. - * - * @param type the type for which to find a stream merger - * @return a stream merger for the given type, or null if no - * stream merger has been registered - */ - public IStreamMerger createStreamMerger(IContentType type) { - initializeRegistries(); - StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fStreamMergers.search(type); - if (descriptor != null) - return descriptor.createStreamMerger(); - return null; - } - - /** - * Returns a structure compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input, the old viewer - * is returned. Otherwise, the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a structure compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param input the input object for which to find a structure viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param configuration a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, - CompareConfiguration configuration) { - - if (input.getLeft() == null || input.getRight() == null) // we don't show the structure of additions or deletions - return null; - - // content type search - IContentType ctype= getCommonType(getContentTypes(input)); - if (ctype != null) { - initializeRegistries(); - Viewer viewer= getViewer(fStructureMergeViewers.search(ctype), oldViewer, parent, configuration); - if (viewer != null) - return viewer; - } - - // old style search - String[] types= getTypes(input); - String type= null; - if (isHomogenous(types)) { - type= normalizeCase(types[0]); - initializeRegistries(); - IViewerDescriptor vd= (IViewerDescriptor) fStructureMergeViewers.search(type); - if (vd == null) { - String alias= getStructureViewerAlias(type); - if (alias != null) - vd= (IViewerDescriptor) fStructureMergeViewers.search(alias); - } - if (vd != null) - return vd.createViewer(oldViewer, parent, configuration); - } - - // we didn't found any viewer so far. - // now we try to find a structurecreator for the generic StructureDiffViewer - - StructureCreatorDescriptor scc= null; - initializeRegistries(); - Object desc= fStructureCreators.search(ctype); // search for content type - if (desc instanceof StructureCreatorDescriptor) - scc= (StructureCreatorDescriptor) desc; - if (scc == null && type != null) - scc= getStructureCreator(type); // search for old-style type scheme - if (scc != null) { - IStructureCreator sc= scc.createStructureCreator(); - if (sc != null) { - StructureDiffViewer sdv= new StructureDiffViewer(parent, configuration); - sdv.setStructureCreator(sc); - return sdv; - } - } - return null; - } - - /** - * Returns a content compare viewer based on an old viewer and an input object. - * If the old viewer is suitable for showing the input the old viewer - * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry - * which in turn is used to create a content compare viewer under the given parent composite. - * If no viewer descriptor can be found null is returned. - * - * @param oldViewer a new viewer is only created if this old viewer cannot show the given input - * @param in the input object for which to find a content viewer - * @param parent the SWT parent composite under which the new viewer is created - * @param cc a configuration which is passed to a newly created viewer - * @return the compare viewer which is suitable for the given input object or null - */ - public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) { - - if (in instanceof IStreamContentAccessor) { - String type= ITypedElement.TEXT_TYPE; - - if (in instanceof ITypedElement) { - ITypedElement tin= (ITypedElement) in; - - IContentType ct= getContentType(tin); - if (ct != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentViewers.search(ct), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - String ty= tin.getType(); - if (ty != null) - type= ty; - } - - initializeRegistries(); - Viewer viewer= getViewer(fContentViewers.search(type), oldViewer, parent, cc); - if (viewer != null) - return viewer; - // fallback - return new SimpleTextViewer(parent); - } - - if (!(in instanceof ICompareInput)) - return null; - - ICompareInput input= (ICompareInput) in; - - IContentType ctype= getCommonType(getContentTypes(input)); - if (ctype != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - String[] types= getTypes(input); - String type= null; - if (isHomogenous(types)) - type= types[0]; - - if (ITypedElement.FOLDER_TYPE.equals(type)) - return null; - - if (type == null) { - int n= 0; - for (int i= 0; i < types.length; i++) - if (!ITypedElement.UNKNOWN_TYPE.equals(types[i])) { - n++; - if (type == null) - type= types[i]; // remember the first known type - } - if (n > 1) // don't use the type if there were more than one - type= null; - } - - if (type != null) { - initializeRegistries(); - Viewer viewer= getViewer(fContentMergeViewers.search(type), oldViewer, parent, cc); - if (viewer != null) - return viewer; - } - - // fallback - String leftType= guessType(input.getLeft()); - String rightType= guessType(input.getRight()); - - if (leftType != null || rightType != null) { - boolean right_text= rightType != null && ITypedElement.TEXT_TYPE.equals(rightType); - boolean left_text= leftType != null && ITypedElement.TEXT_TYPE.equals(leftType); - if ((leftType == null && right_text) || (left_text && rightType == null) || (left_text && right_text)) - type= ITypedElement.TEXT_TYPE; - else - type= BINARY_TYPE; - - initializeRegistries(); - IViewerDescriptor vd= (IViewerDescriptor) fContentMergeViewers.search(type); - if (vd != null) - return vd.createViewer(oldViewer, parent, cc); - } - return null; - } - - private static Viewer getViewer(Object descriptor, Viewer oldViewer, Composite parent, CompareConfiguration cc) { - if (descriptor instanceof IViewerDescriptor) - return ((IViewerDescriptor)descriptor).createViewer(oldViewer, parent, cc); - return null; - } - - private static String[] getTypes(ICompareInput input) { - ITypedElement ancestor= input.getAncestor(); - ITypedElement left= input.getLeft(); - ITypedElement right= input.getRight(); - - ArrayList tmp= new ArrayList(); - if (ancestor != null) { - String type= ancestor.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - if (left != null) { - String type= left.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - if (right != null) { - String type= right.getType(); - if (type != null) - tmp.add(normalizeCase(type)); - } - return (String[]) tmp.toArray(new String[tmp.size()]); - } - - private static IContentType[] getContentTypes(ICompareInput input) { - ITypedElement ancestor= input.getAncestor(); - ITypedElement left= input.getLeft(); - ITypedElement right= input.getRight(); - - ArrayList tmp= new ArrayList(); - IContentType type= getContentType(ancestor); - if (type != null) - tmp.add(type); - type= getContentType(left); - if (type != null) - tmp.add(type); - type= getContentType(right); - if (type != null) - tmp.add(type); - - return (IContentType[]) tmp.toArray(new IContentType[tmp.size()]); - } - - private static IContentType getContentType(ITypedElement element) { - if (element == null) - return null; - String name= element.getName(); - IContentType[] associated= fgContentTypeManager.findContentTypesFor(name); - if (associated.length > 0) - return associated[0]; - IContentType ct= null; - if (element instanceof IStreamContentAccessor) { - IStreamContentAccessor isa= (IStreamContentAccessor) element; - try { - InputStream is= isa.getContents(); - if (is != null) { - InputStream bis= new BufferedInputStream(is); - try { - ct= fgContentTypeManager.findContentTypeFor(is, name); - } catch (IOException e) { - // silently ignored - } - try { - bis.close(); - } catch (IOException e2) { - // silently ignored - } - } - } catch (CoreException e1) { - // silently ignored - } - } - return ct; - } - - /* - * Returns true if the given types are homogenous. - */ - private static boolean isHomogenous(String[] types) { - switch (types.length) { - case 1: - return true; - case 2: - return types[0].equals(types[1]); - case 3: - return types[0].equals(types[1]) && types[1].equals(types[2]); - } - return false; - } - - /* - * Returns the most specific content type that is common to the given inputs or null. - */ - private static IContentType getCommonType(IContentType[] types) { - Set s= null; - ArrayList l= null; - switch (types.length) { - case 1: - return types[0]; - case 2: - l= new ArrayList(); - s= toSet(l, types[0]); - s.retainAll(toSet(l, types[1])); - break; - case 3: - l= new ArrayList(); - s= toSet(l, types[0]); - s.retainAll(toSet(l, types[1])); - s.retainAll(toSet(l, types[2])); - break; - } - if (s != null && !s.isEmpty()) { - Iterator iter= l.iterator(); - while (iter.hasNext()) { - IContentType ct= (IContentType) iter.next(); - if (s.contains(ct)) - return ct; - } - } - return null; - } - - private static Set toSet(ArrayList l, IContentType ct) { - Set set= new HashSet(); - for (; ct != null; ct= ct.getBaseType()) { - l.add(ct); - set.add(ct); - } - return set; - } - - /* - * Guesses the file type of the given input. - * Returns ITypedElement.TEXT_TYPE if none of the first 10 lines is longer than 1000 bytes. - * Returns ITypedElement.UNKNOWN_TYPE otherwise. - * Returns null if the input isn't an IStreamContentAccessor. - */ - private static String guessType(ITypedElement input) { - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - InputStream is= null; - try { - is= sca.getContents(); - if (is == null) - return null; - int lineLength= 0; - int lines= 0; - while (lines < 10) { - int c= is.read(); - if (c == -1) // EOF - break; - if (c == '\n' || c == '\r') { // reset line length - lineLength= 0; - lines++; - } else - lineLength++; - if (lineLength > 1000) - return ITypedElement.UNKNOWN_TYPE; - } - return ITypedElement.TEXT_TYPE; - } catch (CoreException ex) { - // be silent and return UNKNOWN_TYPE - } catch (IOException ex) { - // be silent and return UNKNOWN_TYPE - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - return ITypedElement.UNKNOWN_TYPE; - } - return null; - } - - private static String normalizeCase(String s) { - if (NORMALIZE_CASE && s != null) - return s.toUpperCase(); - return s; - } - - //---- alias mgmt - - private String getStructureViewerAlias(String type) { - return (String) getStructureViewerAliases().get(type); - } - - public void addStructureViewerAlias(String type, String alias) { - getStructureViewerAliases().put(normalizeCase(alias), normalizeCase(type)); - } - - private Map getStructureViewerAliases() { - if (fStructureViewerAliases == null) { - fStructureViewerAliases= new Hashtable(10); - String aliases= getPreferenceStore().getString(STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME); - if (aliases != null && aliases.length() > 0) { - StringTokenizer st= new StringTokenizer(aliases, " "); //$NON-NLS-1$ - while (st.hasMoreTokens()) { - String pair= st.nextToken(); - int pos= pair.indexOf('.'); - if (pos > 0) { - String key= pair.substring(0, pos); - String alias= pair.substring(pos+1); - fStructureViewerAliases.put(key, alias); - } - } - } - } - return fStructureViewerAliases; - } - - public void removeAllStructureViewerAliases(String type) { - if (fStructureViewerAliases == null) - return; - String t= normalizeCase(type); - Set entrySet= fStructureViewerAliases.entrySet(); - for (Iterator iter= entrySet.iterator(); iter.hasNext(); ) { - Map.Entry entry= (Map.Entry)iter.next(); - if (entry.getValue().equals(t)) - iter.remove(); - } - } - - /* - * Converts the aliases into a single string before they are stored - * in the preference store. - * The format is: - * '.' ' ' '.' ... - */ - private void rememberAliases(IPreferenceStore ps) { - if (fStructureViewerAliases == null) - return; - StringBuffer buffer= new StringBuffer(); - Iterator iter= fStructureViewerAliases.keySet().iterator(); - while (iter.hasNext()) { - String key= (String) iter.next(); - String alias= (String) fStructureViewerAliases.get(key); - buffer.append(key); - buffer.append('.'); - buffer.append(alias); - buffer.append(' '); - } - ps.setValue(STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME, buffer.toString()); - } - - //---- filters - - public boolean filter(String name, boolean isFolder, boolean isArchive) { - if (fFilter == null) { - fFilter= new CompareFilter(); - final IPreferenceStore ps= getPreferenceStore(); - fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER)); - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (ComparePreferencePage.PATH_FILTER.equals(event.getProperty())) - fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER)); - } - }; - ps.addPropertyChangeListener(fPropertyChangeListener); - } - return fFilter.filter(name, isFolder, isArchive); - } - - //---- more utilities - - /** - * Returns an array of all editors that have an unsaved content. If the identical content is - * presented in more than one editor, only one of those editor parts is part of the result. - * - * @return an array of all dirty editor parts. - */ - public static IEditorPart[] getDirtyEditors() { - Set inputs= new HashSet(); - List result= new ArrayList(0); - IWorkbench workbench= getDefault().getWorkbench(); - IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); - for (int i= 0; i < windows.length; i++) { - IWorkbenchPage[] pages= windows[i].getPages(); - for (int x= 0; x < pages.length; x++) { - IEditorPart[] editors= pages[x].getDirtyEditors(); - for (int z= 0; z < editors.length; z++) { - IEditorPart ep= editors[z]; - IEditorInput input= ep.getEditorInput(); - if (!inputs.contains(input)) { - inputs.add(input); - result.add(ep); - } - } - } - } - return (IEditorPart[])result.toArray(new IEditorPart[result.size()]); - } - - public static void logErrorMessage(String message) { - if (message == null) - message= ""; //$NON-NLS-1$ - log(new Status(IStatus.ERROR, getPluginId(), INTERNAL_ERROR, message, null)); - } - - public static void log(Throwable e) { - log(new Status(IStatus.ERROR, getPluginId(), INTERNAL_ERROR, CompareMessages.getString("ComparePlugin.internal_error"), e)); //$NON-NLS-1$ - } - - public static void log(IStatus status) { - getDefault().getLog().log(status); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java deleted file mode 100644 index f8cef54d1..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -public class CompareWithEditionAction extends EditionAction { - - public CompareWithEditionAction() { - super(false, "org.eclipse.compare.internal.CompareWithEditionAction"); //$NON-NLS-1$ - this.fHelpContextId= ICompareContextIds.COMPARE_WITH_EDITION_DIALOG; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties deleted file mode 100644 index 154531afa..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.properties +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)CompareWithEditionAction.properties -# -# Resources for CompareWithEditionAction.java - -title= Compare with Local History - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= Editor Buffer -workspaceTargetLabel= Workspace File - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -closeButton.label=Close - -noLocalHistoryError= No local history available for selected resource. diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java deleted file mode 100644 index 1c17ded85..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImage.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.graphics.*; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Combines an image with an overlay. - */ -public class DiffImage extends CompositeImageDescriptor { - - static final int HEIGHT= 16; - - private Image fBaseImage; - private ImageDescriptor fOverlayImage; - private int fWidth; - private boolean fLeft= true; - - public DiffImage(Image base, ImageDescriptor overlay, int w) { - fBaseImage= base; - fOverlayImage= overlay; - fWidth= w; - } - - public DiffImage(Image base, ImageDescriptor overlay, int w, boolean onLeft) { - fBaseImage= base; - fOverlayImage= overlay; - fWidth= w; - fLeft= onLeft; - } - - protected Point getSize() { - return new Point(fWidth, HEIGHT); - } - - protected void drawCompositeImage(int width, int height) { - if (fLeft) { - if (fBaseImage != null) { - ImageData base= fBaseImage.getImageData(); - if (base == null) - base= DEFAULT_IMAGE_DATA; - drawImage(base, fWidth - base.width, 0); - } - - if (fOverlayImage != null) { - ImageData overlay= fOverlayImage.getImageData(); - if (overlay == null) - overlay= DEFAULT_IMAGE_DATA; - drawImage(overlay, 0, (HEIGHT - overlay.height) / 2); - } - } else { - if (fBaseImage != null) { - ImageData base= fBaseImage.getImageData(); - if (base == null) - base= DEFAULT_IMAGE_DATA; - drawImage(base, 0, 0); - } - - if (fOverlayImage != null) { - ImageData overlay= fOverlayImage.getImageData(); - if (overlay == null) - overlay= DEFAULT_IMAGE_DATA; - drawImage(overlay, fWidth - overlay.width, (HEIGHT - overlay.height) / 2); - } - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java deleted file mode 100644 index d1671df31..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.text.*; -import org.eclipse.compare.contentmergeviewer.ITokenComparator; -import org.eclipse.compare.rangedifferencer.IRangeComparator; - -/** - * Implements the IRangeComparator interface for lines in a document. - * A DocLineComparator is used as the input for the RangeDifferencer - * engine to perform a line oriented compare on documents. - *

- * A DocLineComparator doesn't know anything about line separators because - * its notion of lines is solely defined in the underlying IDocument. - */ -public class DocLineComparator implements ITokenComparator { - - private IDocument fDocument; - private int fLineOffset; - private int fLineCount; - private int fLength; - private boolean fIgnoreWhiteSpace; - - /** - * Creates a DocLineComparator for the given document range. - * ignoreWhiteSpace controls whether comparing lines (in method - * rangesEqual) should ignore whitespace. - * - * @param document the document from which the lines are taken - * @param region if non-null only lines within this range are taken - * @param ignoreWhiteSpace if true white space is ignored when comparing lines - */ - public DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) { - - fDocument= document; - fIgnoreWhiteSpace= ignoreWhiteSpace; - - fLineOffset= 0; - if (region != null) { - fLength= region.getLength(); - int start= region.getOffset(); - try { - fLineOffset= fDocument.getLineOfOffset(start); - } catch (BadLocationException ex) { - // silently ignored - } - - if (fLength == 0) - fLineCount= 0; - else { - int endLine= fDocument.getNumberOfLines(); - try { - endLine= fDocument.getLineOfOffset(start + fLength); - } catch (BadLocationException ex) { - // silently ignored - } - fLineCount= endLine - fLineOffset + 1; - } - - } else { - fLength= document.getLength(); - fLineCount= fDocument.getNumberOfLines(); - } - } - - /** - * Returns the number of lines in the document. - * - * @return number of lines - */ - public int getRangeCount() { - return fLineCount; - } - - /* (non Javadoc) - * see ITokenComparator.getTokenStart - */ - public int getTokenStart(int line) { - try { - IRegion r= fDocument.getLineInformation(fLineOffset + line); - return r.getOffset(); - } catch (BadLocationException ex) { - return fDocument.getLength(); - } - } - - /* (non Javadoc) - * Returns the length of the given line. - * see ITokenComparator.getTokenLength - */ - public int getTokenLength(int line) { - return getTokenStart(line+1) - getTokenStart(line); - } - - /** - * Returns true if a line given by the first index - * matches a line specified by the other IRangeComparator and index. - * - * @param thisIndex the number of the line within this range comparator - * @param otherComparator the range comparator to compare this with - * @param otherIndex the number of the line within the other comparator - * @return true if the lines are equal - */ - public boolean rangesEqual(int thisIndex, IRangeComparator otherComparator, int otherIndex) { - - if (otherComparator != null && otherComparator.getClass() == getClass()) { - DocLineComparator other= (DocLineComparator) otherComparator; - - if (fIgnoreWhiteSpace) { - String s1= extract(thisIndex); - String s2= other.extract(otherIndex); - //return s1.trim().equals(s2.trim()); - return compare(s1, s2); - } - - int tlen= getTokenLength(thisIndex); - int olen= other.getTokenLength(otherIndex); - if (tlen == olen) { - String s1= extract(thisIndex); - String s2= other.extract(otherIndex); - return s1.equals(s2); - } - } - return false; - } - - /** - * Aborts the comparison if the number of tokens is too large. - * - * @param length a number on which to base the decision whether to return - * true or false - * @param maxLength another number on which to base the decision whether to return - * true or false - * @param other the other IRangeComparator to compare with - * @return true to avoid a too lengthy range comparison - */ - public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { - return false; - } - - //---- private methods - - /** - * Extract a single line from the underlying document without the line separator. - * - * @param line the number of the line to extract - * @return the contents of the line as a String - */ - private String extract(int line) { - if (line < fLineCount) { - try { - IRegion r= fDocument.getLineInformation(fLineOffset + line); - return fDocument.get(r.getOffset(), r.getLength()); - } catch(BadLocationException e) { - // silently ignored - } - } - return ""; //$NON-NLS-1$ - } - - private boolean compare(String s1, String 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/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java deleted file mode 100644 index b2db19190..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.*; - -import org.eclipse.jface.text.IDocument; - -/** - * No API yet. - */ -public class DocumentManager { - - private static final boolean DEBUG= false; - - private static ArrayList fgKeys= new ArrayList(); - private static ArrayList fgValues= new ArrayList(); - - public static IDocument get(Object o) { - - for (int i= 0; i < fgKeys.size(); i++) { - if (fgKeys.get(i) == o) - return (IDocument) fgValues.get(i); - } - return null; - } - - public static void put(Object o, IDocument document) { - if (DEBUG) System.out.println("DocumentManager.put: " + document); //$NON-NLS-1$ - for (int i= 0; i < fgKeys.size(); i++) { - if (fgKeys.get(i) == o) { - fgValues.set(i, document); - return; - } - } - fgKeys.add(o); - fgValues.add(document); - } - - public static void remove(IDocument document) { - if (document != null) { - if (DEBUG) System.out.println("DocumentManager.remove: " + document); //$NON-NLS-1$ - for (int i= 0; i < fgValues.size(); i++) { - if (fgValues.get(i) == document) { - fgKeys.remove(i); - fgValues.remove(i); - return; - } - } - if (DEBUG) System.out.println("DocumentManager.remove: not found"); //$NON-NLS-1$ - } - } - - public static void dump() { - if (DEBUG) System.out.println("DocumentManager: managed docs:" + fgValues.size()); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java deleted file mode 100644 index 43c09b13d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.ResourceBundle; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.BadLocationException; - -import org.eclipse.ui.*; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.compare.*; -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.IStreamContentAccessor; - - -public class EditionAction extends BaseCompareAction { - - /** - * Implements the IStreamContentAccessor and ITypedElement protocols - * for a Document. - */ - class DocumentBufferNode implements ITypedElement, IEncodedStreamContentAccessor { - private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - private IDocument fDocument; - private IFile fFile; - - DocumentBufferNode(IDocument document, IFile file) { - fDocument= document; - fFile= file; - } - - public String getName() { - return fFile.getName(); - } - - public String getType() { - return fFile.getFileExtension(); - } - - public Image getImage() { - return null; - } - - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fDocument.get(), UTF_16)); - } - - public String getCharset() { - return UTF_16; - } - } - - private String fBundleName; - private boolean fReplaceMode; - protected boolean fPrevious= false; - protected String fHelpContextId; - - EditionAction(boolean replaceMode, String bundleName) { - fReplaceMode= replaceMode; - fBundleName= bundleName; - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getFiles(selection).length == 1; // we don't support multiple selection for now - } - - protected void run(ISelection selection) { - IFile[] files= Utilities.getFiles(selection); - for (int i= 0; i < files.length; i++) - doFromHistory(files[i]); - } - - private void doFromHistory(final IFile file) { - - ResourceBundle bundle= ResourceBundle.getBundle(fBundleName); - String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - - Shell parentShell= CompareUIPlugin.getShell(); - - IFileState states[]= null; - try { - states= file.getHistory(null); - } catch (CoreException ex) { - MessageDialog.openError(parentShell, title, ex.getMessage()); - return; - } - - if (states == null || states.length <= 0) { - String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ - MessageDialog.openInformation(parentShell, title, msg); - return; - } - - ITypedElement base= new ResourceNode(file); - - IDocument document= getDocument(file); - ITypedElement target= base; - if (document != null) - target= new DocumentBufferNode(document, file); - - ITypedElement[] editions= new ITypedElement[states.length+1]; - editions[0]= base; - for (int i= 0; i < states.length; i++) - editions[i+1]= new HistoryItem(base, states[i]); - - EditionSelectionDialog d= new EditionSelectionDialog(parentShell, bundle); - d.setEditionTitleArgument(file.getName()); - d.setEditionTitleImage(CompareUIPlugin.getImage(file)); - //d.setHideIdenticalEntries(false); - if (fHelpContextId != null) - d.setHelpContextId(fHelpContextId); - - if (fReplaceMode) { - - ITypedElement ti= null; - if (fPrevious) - ti= d.selectPreviousEdition(target, editions, null); - else - ti= d.selectEdition(target, editions, null); - - if (ti instanceof IStreamContentAccessor) { - IStreamContentAccessor sa= (IStreamContentAccessor)ti; - - if (Utilities.validateResource(file, parentShell, title)) { - try { - - if (document != null) - updateDocument(document, sa); - else - updateWorkspace(bundle, parentShell, sa, file); - - } catch (InterruptedException x) { - // Do nothing. Operation has been canceled by user. - - } catch (InvocationTargetException x) { - String reason= x.getTargetException().getMessage(); - MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$ - } - } - } - } else { - d.setCompareMode(true); - - d.selectEdition(target, editions, null); - } - } - - private void updateWorkspace(final ResourceBundle bundle, Shell shell, - final IStreamContentAccessor sa, final IFile file) - throws InvocationTargetException, InterruptedException { - WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { - public void execute(IProgressMonitor pm) throws InvocationTargetException { - try { - String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$ - pm.beginTask(taskName, IProgressMonitor.UNKNOWN); - file.setContents(sa.getContents(), false, true, pm); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - pm.done(); - } - } - }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); - } - - private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { - try { - String text= Utilities.readString(sa); - document.replace(0, document.getLength(), text); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } catch (BadLocationException e) { - throw new InvocationTargetException(e); - } - } - - private IDocument getDocument(IFile file) { - IWorkbench wb= PlatformUI.getWorkbench(); - if (wb == null) - return null; - IWorkbenchWindow[] ws= wb.getWorkbenchWindows(); - if (ws == null) - return null; - - FileEditorInput test= new FileEditorInput(file); - - for (int i= 0; i < ws.length; i++) { - IWorkbenchWindow w= ws[i]; - IWorkbenchPage[] wps= w.getPages(); - if (wps != null) { - for (int j= 0; j < wps.length; j++) { - IWorkbenchPage wp= wps[j]; - IEditorPart ep= wp.findEditor(test); - if (ep instanceof ITextEditor) { - ITextEditor te= (ITextEditor) ep; - IDocumentProvider dp= te.getDocumentProvider(); - if (dp != null) { - IDocument doc= dp.getDocument(ep); - if (doc != null) - return doc; - } - } - } - } - } - return null; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java deleted file mode 100644 index 58d12b4fb..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; - -/** - * The default exception handler shows an error dialog when one of its handle methods - * is called. If the passed exception is a CoreException an error dialog - * pops up showing the exception's status information. For a InvocationTargetException - * a normal message dialog pops up showing the exception's message. Additionally the exception - * is written to the platform log. - */ -public class ExceptionHandler { - - private static ExceptionHandler fgInstance= new ExceptionHandler(); - - /* - * Logs the given exception using the platform's logging mechanism. The exception is - * logged as an error with the error code JavaStatusConstants.INTERNAL_ERROR. - */ - public static void log(Throwable t, String message) { - CompareUIPlugin.log(new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), - CompareUIPlugin.INTERNAL_ERROR, message, t)); - } - - /** - * Handles the given CoreException. The workbench shell is used as a parent - * for the dialog window. - * - * @param e the CoreException to be handled - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(CoreException e, String title, String message) { - handle(e, CompareUIPlugin.getShell(), title, message); - } - - /** - * Handles the given CoreException. - * - * @param e the CoreException to be handled - * @param parent the dialog window's parent shell - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(CoreException e, Shell parent, String title, String message) { - fgInstance.perform(e, parent, title, message); - } - - /** - * Handles the given InvocationTargetException. The workbench shell is used - * as a parent for the dialog window. - * - * @param e the InvocationTargetException to be handled - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(InvocationTargetException e, String title, String message) { - handle(e, CompareUIPlugin.getShell(), title, message); - } - - /** - * Handles the given InvocationTargetException. - * - * @param e the InvocationTargetException to be handled - * @param parent the dialog window's parent shell - * @param title the dialog window's window title - * @param message message to be displayed by the dialog window - */ - public static void handle(InvocationTargetException e, Shell parent, String title, String message) { - fgInstance.perform(e, parent, title, message); - } - - //---- Hooks for subclasses to control exception handling ------------------------------------ - - protected void perform(CoreException e, Shell shell, String title, String message) { - CompareUIPlugin.log(e); - IStatus status= e.getStatus(); - if (status != null) { - ErrorDialog.openError(shell, title, message, status); - } else { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } - } - - protected void perform(InvocationTargetException e, Shell shell, String title, String message) { - Throwable target= e.getTargetException(); - if (target instanceof CoreException) { - perform((CoreException)target, shell, title, message); - } else { - CompareUIPlugin.log(e); - if (e.getMessage() != null && e.getMessage().length() > 0) { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } else { - displayMessageDialog(e, target.getMessage(), shell, title, message); - } - } - } - - //---- Helper methods ----------------------------------------------------------------------- - - private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) { - StringWriter msg= new StringWriter(); - if (message != null) { - msg.write(message); - msg.write("\n\n"); //$NON-NLS-1$ - } - if (exceptionMessage == null || exceptionMessage.length() == 0) - msg.write(CompareMessages.getString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$ - else - msg.write(exceptionMessage); - MessageDialog.openError(shell, title, msg.toString()); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java deleted file mode 100644 index a6df241e4..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.compare.CompareUI; - -/** - * Help context ids for the Compare UI. - *

- * This interface contains constants only; it is not intended to be implemented - * or extended. - *

- * - */ -public interface ICompareContextIds { - - public static final String PREFIX= CompareUI.PLUGIN_ID + '.'; - - // Dialogs - public static final String EDITION_DIALOG= PREFIX + "edition_dialog_context"; //$NON-NLS-1$ - - public static final String COMPARE_EDITOR= PREFIX + "compare_editor_context"; //$NON-NLS-1$ - public static final String PATCH_INPUT_WIZARD_PAGE= PREFIX + "patch_input_wizard_page_context"; //$NON-NLS-1$ - public static final String PATCH_PREVIEW_WIZARD_PAGE= PREFIX + "patch_preview_wizard_page_context"; //$NON-NLS-1$ - public static final String ADD_FROM_HISTORY_DIALOG= PREFIX + "add_from_history_dialog_context"; //$NON-NLS-1$ - public static final String COMPARE_DIALOG= PREFIX + "compare_dialog_context"; //$NON-NLS-1$ - public static final String COMPARE_WITH_EDITION_DIALOG= PREFIX + "compare_with_edition_dialog_context"; //$NON-NLS-1$ - public static final String REPLACE_WITH_EDITION_DIALOG= PREFIX + "replace_with_edition_dialog_context"; //$NON-NLS-1$ - - // Viewer - public static final String TEXT_MERGE_VIEW= PREFIX + "text_merge_view_context"; //$NON-NLS-1$ - public static final String IMAGE_COMPARE_VIEW= PREFIX + "image_compare_view_context"; //$NON-NLS-1$ - public static final String BINARY_COMPARE_VIEW= PREFIX + "binary_compare_view_context"; //$NON-NLS-1$ - public static final String DIFF_VIEW= PREFIX + "diff_view_context"; //$NON-NLS-1$ - - // Actions - public static final String GLOBAL_NEXT_DIFF_ACTION= PREFIX + "global_next_diff_action_context"; //$NON-NLS-1$ - public static final String GLOBAL_PREVIOUS_DIFF_ACTION= PREFIX + "global_previous_diff_action_context"; //$NON-NLS-1$ - public static final String NEXT_DIFF_ACTION= PREFIX + "next_diff_action_context"; //$NON-NLS-1$ - public static final String PREVIOUS_DIFF_ACTION= PREFIX + "previous_diff_action_context"; //$NON-NLS-1$ - public static final String IGNORE_WHITESPACE_ACTION= PREFIX + "ignore_whitespace_action_context"; //$NON-NLS-1$ - - // Preference page - public static final String COMPARE_PREFERENCE_PAGE= PREFIX + "compare_preference_page_context"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java deleted file mode 100644 index eab7f523d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/INavigatable.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -public interface INavigatable { - - static final String NAVIGATOR_PROPERTY= "org.eclipse.compare.internal.Navigator"; //$NON-NLS-1$ - - /* - * Returns true if at end or beginning. - */ - boolean gotoDifference(boolean next); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java deleted file mode 100644 index 013885909..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IOpenable.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -/* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ -public interface IOpenable { - - static final String OPENABLE_PROPERTY= "org.eclipse.compare.internal.Openable"; //$NON-NLS-1$ - - /** - * Opens the selected element - */ - void openSelected(); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java deleted file mode 100644 index 359d6a293..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IResourceProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.resources.IResource; - -public interface IResourceProvider { - - /** - * Returns the corresponding resource for this object or null. - * - * @return the corresponding resource or null - */ - IResource getResource(); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java deleted file mode 100644 index a15db7c68..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavable.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -public interface ISavable { - - void save(IProgressMonitor pm) throws CoreException; -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java deleted file mode 100644 index 2dda66e0d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IViewerDescriptor.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.compare.CompareConfiguration; - -/** - * A factory object for creating a Viewers from a descriptor. - *

- * It is used when registering a viewer for a specific type - * in CompareUIPlugin.registerContentViewerDescriptor and - * in CompareUIPlugin.registerStructureViewerDescriptor. - * - * @see org.eclipse.compare.structuremergeviewer.IStructureCreator - * @see CompareUIPlugin - */ -public interface IViewerDescriptor { - - /** - * Creates a new viewer from this descriptor under the given STW parent control. - * If the current viewer has the same type as a new viewer - * the implementation of this method is free to return the current viewer instead. - * - * @param currentViewer the current viewer which is going to be replaced with a new viewer. - * @param parent the SWT parent control under which the new viewer has to be created. - * @param config a compare configuration the new viewer might be interested in. - * @return a new viewer or the current viewer. - */ - Viewer createViewer(Viewer currentViewer, Composite parent, CompareConfiguration config); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java deleted file mode 100644 index b6b0fa14d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.compare.*; - -/** - * Toggles the ICompareConfiguration.IGNORE_WS property of an - * ICompareConfiguration. - */ -public class IgnoreWhiteSpaceAction extends ChangePropertyAction { - - public IgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration cc) { - super(bundle, cc, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java deleted file mode 100644 index 7a9266b49..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; - -/** - * A Canvas showing a single centered SWT Image. - * If the Image is larger than the Canvas, - * Scrollbars will appear. - */ -class ImageCanvas extends Canvas { - - private Image fImage; - - /* - * Create a new ImageCanvas with the given SWT stylebits. - * (SWT.H_SCROLL and SWT.V_SCROLL are automtically added). - */ - public ImageCanvas(Composite parent, int style) { - super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL); - - ScrollBar sb= getHorizontalBar(); - sb.setIncrement(20); - sb.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - repaint(); - } - }); - - sb= getVerticalBar(); - sb.setIncrement(20); - sb.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - repaint(); - } - }); - - addListener(SWT.Resize, new Listener() { - public void handleEvent(Event e) { - updateScrollbars(); - } - }); - - addListener(SWT.Paint, new Listener() { - public void handleEvent(Event event) { - paint(event.gc); - } - }); - } - - /* - * Set the SWT Image to use as the ImageCanvas contents. - */ - public void setImage(Image img) { - fImage= img; - - if (!isDisposed()) { - getHorizontalBar().setSelection(0); - getVerticalBar().setSelection(0); - updateScrollbars(); - getParent().layout(); - redraw(); - } - } - - public void repaint() { - if (!isDisposed()) { - GC gc= new GC(this); - paint(gc); - gc.dispose(); - } - } - - void paint(GC gc) { - if (fImage != null) { - Rectangle bounds= fImage.getBounds(); - Rectangle clientArea= getClientArea(); - - int x; - if (bounds.width < clientArea.width) - x= (clientArea.width - bounds.width) / 2; - else - x= -getHorizontalBar().getSelection(); - - int y; - if (bounds.height < clientArea.height) - y= (clientArea.height - bounds.height) / 2; - else - y= -getVerticalBar().getSelection(); - - gc.drawImage(fImage, x, y); - } - } - - /** - * @private - */ - void updateScrollbars() { - Rectangle bounds= fImage != null ? fImage.getBounds() : new Rectangle(0, 0, 0, 0); - Point size= getSize(); - Rectangle clientArea= getClientArea(); - - ScrollBar horizontal= getHorizontalBar(); - if (bounds.width <= clientArea.width) { - horizontal.setVisible(false); - horizontal.setSelection(0); - } else { - horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement()); - int max= bounds.width + (size.x - clientArea.width); - horizontal.setMaximum(max); - horizontal.setThumb(size.x > max ? max : size.x); - horizontal.setVisible(true); - } - - ScrollBar vertical= getVerticalBar(); - if (bounds.height <= clientArea.height) { - vertical.setVisible(false); - vertical.setSelection(0); - } else { - vertical.setPageIncrement(clientArea.height - vertical.getIncrement()); - int max= bounds.height + (size.y - clientArea.height); - vertical.setMaximum(max); - vertical.setThumb(size.y > max ? max : size.y); - vertical.setVisible(true); - } - } - -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java deleted file mode 100644 index fd733547a..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.InputStream; -import java.io.IOException; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.compare.*; -import org.eclipse.compare.contentmergeviewer.ContentMergeViewer; - -/** - */ -public class ImageMergeViewer extends ContentMergeViewer { - - private static final String BUNDLE_NAME= "org.eclipse.compare.internal.ImageMergeViewerResources"; //$NON-NLS-1$ - - private Object fLeftImage; - private Object fRightImage; - - private ImageCanvas fAncestor; - private ImageCanvas fLeft; - private ImageCanvas fRight; - - - public ImageMergeViewer(Composite parent, int styles, CompareConfiguration mp) { - super(styles, ResourceBundle.getBundle(BUNDLE_NAME), mp); - - WorkbenchHelp.setHelp(parent, ICompareContextIds.IMAGE_COMPARE_VIEW); - - buildControl(parent); - String title= Utilities.getString(getResourceBundle(), "title"); //$NON-NLS-1$ - getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, title); - } - - protected void updateContent(Object ancestor, Object left, Object right) { - - setInput(fAncestor, ancestor); - - fLeftImage= left; - setInput(fLeft, left); - - fRightImage= right; - setInput(fRight, right); - } - - /* - * We can't modify the contents of either side we just return null. - */ - protected byte[] getContents(boolean left) { - return null; - } - - public void createControls(Composite composite) { - fAncestor= new ImageCanvas(composite, SWT.NO_FOCUS); - fLeft= new ImageCanvas(composite, SWT.NO_FOCUS); - fRight= new ImageCanvas(composite, SWT.NO_FOCUS); - } - - private static void setInput(ImageCanvas canvas, Object input) { - if (canvas != null) { - - InputStream stream= null; - if (input instanceof IStreamContentAccessor) { - IStreamContentAccessor sca= (IStreamContentAccessor) input; - if (sca != null) { - try { - stream= sca.getContents(); - } catch (CoreException ex) { - // NeedWork - } - } - } - - Image image= null; - Display display= canvas.getDisplay(); - if (stream != null) { - try { - image= new Image(display, stream); - } catch (SWTException ex) { - // silently ignored - } - } - - canvas.setImage(image); - if (image != null) { - canvas.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - } else { - canvas.setBackground(null); - } - - if (stream != null) { - try { - stream.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - } - - protected void handleResizeAncestor(int x, int y, int width, int height) { - if (width > 0) { - fAncestor.setVisible(true); - fAncestor.setBounds(x, y, width, height); - } else { - fAncestor.setVisible(false); - } - } - - protected void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height) { - fLeft.setBounds(x, y, width1, height); - fRight.setBounds(x+width1+centerWidth, y, width2, height); - } - - protected void copy(boolean leftToRight) { - if (leftToRight) { - fRightImage= fLeftImage; - setInput(fRight, fRightImage); - setRightDirty(true); - } else { - fLeftImage= fRightImage; - setInput(fLeft, fLeftImage); - setLeftDirty(true); - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java deleted file mode 100644 index ae0ab7813..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerCreator.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.compare.*; -import org.eclipse.jface.viewers.Viewer; - -/** - * A factory object for the ImageMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class ImageMergeViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new ImageMergeViewer(parent, SWT.NULL, mp); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties deleted file mode 100644 index cb23466b0..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)ImageMergeViewerResources.properties -# -# Resource strings for ImageMergeViewer.java - -title= Image Compare - -##################################################### -# Actions -##################################################### - -action.CopyLeftToRight.label= Copy Left to Right -action.CopyLeftToRight.tooltip= Copy Image from Left to Right -action.CopyLeftToRight.image= elcl16/copy_r_co.gif - -action.CopyRightToLeft.label= Copy Right to Left -action.CopyRightToLeft.tooltip= Copy Image from Right to Left -action.CopyRightToLeft.image= elcl16/copy_l_co.gif - -action.EnableAncestor.label= Enable Ancestor Pane -action.EnableAncestor.tooltip= Control Visibility of Ancestor Pane -action.EnableAncestor.image= elcl16/ancestorpane_co.gif diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java deleted file mode 100644 index 8de56aa1d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * A specialized content provider to show a list of editor parts. - */ -public class ListContentProvider implements IStructuredContentProvider { - List fContents; - - public ListContentProvider() { - // nothing to do - } - - public Object[] getElements(Object input) { - if (fContents != null && fContents == input) - return fContents.toArray(); - return new Object[0]; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof List) - fContents= (List)newInput; - else - fContents= null; - // we use a fixed set. - } - - public void dispose() { - // empty default implementation - } - - public boolean isDeleted(Object o) { - return fContents != null && !fContents.contains(o); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java deleted file mode 100644 index 5df991bc3..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; - -import org.eclipse.ui.dialogs.SelectionDialog; - -public class ListDialog extends SelectionDialog { - - private IStructuredContentProvider fContentProvider; - private ILabelProvider fLabelProvider; - private Object fInput; - private TableViewer fTableViewer; - private boolean fAddCancelButton; - - public ListDialog(Shell parent) { - super(parent); - fAddCancelButton= false; - } - - public void setInput(Object input) { - fInput= input; - } - - public void setContentProvider(IStructuredContentProvider sp){ - fContentProvider= sp; - } - - public void setLabelProvider(ILabelProvider lp){ - fLabelProvider= lp; - } - - public void setAddCancelButton(boolean addCancelButton) { - fAddCancelButton= addCancelButton; - } - - public TableViewer getTableViewer(){ - return fTableViewer; - } - - public boolean hasFilters(){ - return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0; - } - - public void create() { - setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE); - super.create(); - } - - protected void createButtonsForButtonBar(Composite parent) { - if (! fAddCancelButton) - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - else - super.createButtonsForButtonBar(parent); - } - - protected Control createDialogArea(Composite container) { - Composite parent= (Composite) super.createDialogArea(container); - createMessageArea(parent); - fTableViewer= new TableViewer(parent, getTableStyle()); - fTableViewer.setContentProvider(fContentProvider); - Table table= fTableViewer.getTable(); - fTableViewer.setLabelProvider(fLabelProvider); - fTableViewer.setInput(fInput); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= convertHeightInCharsToPixels(15); - gd.widthHint= convertWidthInCharsToPixels(55); - table.setLayoutData(gd); - applyDialogFont(parent); - return parent; - } - - protected int getTableStyle() { - return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java deleted file mode 100644 index d162414d7..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.graphics.Font; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.text.*; -import org.eclipse.jface.text.source.*; - -import org.eclipse.jface.viewers.SelectionChangedEvent; -/** - * Extends the JFace SourceViewer with some convenience methods. - */ -public class MergeSourceViewer extends SourceViewer - implements ISelectionChangedListener, ITextListener, IMenuListener { - - public static final String UNDO_ID= "undo"; //$NON-NLS-1$ - public static final String REDO_ID= "redo"; //$NON-NLS-1$ - public static final String CUT_ID= "cut"; //$NON-NLS-1$ - public static final String COPY_ID= "copy"; //$NON-NLS-1$ - public static final String PASTE_ID= "paste"; //$NON-NLS-1$ - public static final String DELETE_ID= "delete"; //$NON-NLS-1$ - public static final String SELECT_ALL_ID= "selectAll"; //$NON-NLS-1$ - public static final String SAVE_ID= "save"; //$NON-NLS-1$ - - class TextOperationAction extends MergeViewerAction { - - private int fOperationCode; - - TextOperationAction(int operationCode, boolean mutable, boolean selection, boolean content) { - super(mutable, selection, content); - fOperationCode= operationCode; - update(); - } - - public void run() { - if (isEnabled()) - doOperation(fOperationCode); - } - - public boolean isEnabled() { - return fOperationCode != -1 && canDoOperation(fOperationCode); - } - - public void update() { - this.setEnabled(isEnabled()); - } - } - - private ResourceBundle fResourceBundle; - private Position fRegion; - private boolean fEnabled= true; - private HashMap fActions= new HashMap(); - private IDocument fRememberedDocument; - - private boolean fAddSaveAction= true; - - - public MergeSourceViewer(Composite parent, ResourceBundle bundle) { - super(parent, null, SWT.H_SCROLL + SWT.V_SCROLL); - - fResourceBundle= bundle; - - MenuManager menu= new MenuManager(); - menu.setRemoveAllWhenShown(true); - menu.addMenuListener(this); - StyledText te= getTextWidget(); - te.setMenu(menu.createContextMenu(te)); - } - - public void rememberDocument(IDocument doc) { -// if (doc != null && fRememberedDocument != null) { -// System.err.println("MergeSourceViewer.rememberDocument: fRememberedDocument != null: shouldn't happen"); //$NON-NLS-1$ -// } - fRememberedDocument= doc; - } - - public IDocument getRememberedDocument() { - return fRememberedDocument; - } - - public void hideSaveAction() { - fAddSaveAction= false; - } - - public void setFont(Font font) { - StyledText te= getTextWidget(); - if (te != null) - te.setFont(font); - } - - public void setBackgroundColor(Color color) { - StyledText te= getTextWidget(); - if (te != null) - te.setBackground(color); - } - - public void setEnabled(boolean enabled) { - if (enabled != fEnabled) { - fEnabled= enabled; - StyledText c= getTextWidget(); - if (c != null) { - c.setEnabled(enabled); - Display d= c.getDisplay(); - c.setBackground(enabled ? d.getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null); - } - } - } - - public boolean getEnabled() { - return fEnabled; - } - - public void setRegion(Position region) { - fRegion= region; - } - - public Position getRegion() { - return fRegion; - } - - public boolean isControlOkToUse() { - StyledText t= getTextWidget(); - return t != null && !t.isDisposed(); - } - - public void setSelection(Position position) { - if (position != null) - setSelectedRange(position.getOffset(), position.getLength()); - } - - public void setLineBackground(Position position, Color c) { - StyledText t= getTextWidget(); - if (t != null && !t.isDisposed()) { - Point region= new Point(0, 0); - getLineRange(position, region); - - region.x-= getDocumentRegionOffset(); - - try { - t.setLineBackground(region.x, region.y, c); - } catch (IllegalArgumentException ex) { - // silently ignored - } - } - } - - public void resetLineBackground() { - StyledText t= getTextWidget(); - if (t != null && !t.isDisposed()) { - int lines= getLineCount(); - t.setLineBackground(0, lines, null); - } - } - - /* - * Returns number of lines in document region. - */ - public int getLineCount() { - IRegion region= getVisibleRegion(); - - int length= region.getLength(); - if (length == 0) - return 0; - - IDocument doc= getDocument(); - int startLine= 0; - int endLine= 0; - - int start= region.getOffset(); - try { - startLine= doc.getLineOfOffset(start); - } catch(BadLocationException ex) { - // silently ignored - } - try { - endLine= doc.getLineOfOffset(start+length); - } catch(BadLocationException ex) { - // silently ignored - } - - return endLine-startLine+1; - } - - public int getViewportLines() { - StyledText te= getTextWidget(); - Rectangle clArea= te.getClientArea(); - if (!clArea.isEmpty()) - return clArea.height / te.getLineHeight(); - return 0; - } - - public int getViewportHeight() { - StyledText te= getTextWidget(); - Rectangle clArea= te.getClientArea(); - if (!clArea.isEmpty()) - return clArea.height; - return 0; - } - - /* - * Returns lines - */ - public int getDocumentRegionOffset() { - int start= getVisibleRegion().getOffset(); - IDocument doc= getDocument(); - if (doc != null) { - try { - return doc.getLineOfOffset(start); - } catch(BadLocationException ex) { - // silently ignored - } - } - return 0; - } - - public int getVerticalScrollOffset() { - StyledText st= getTextWidget(); - int lineHeight= st.getLineHeight(); - return getTopInset() - ((getDocumentRegionOffset()*lineHeight) + st.getTopPixel()); - } - - /* - * Returns the start line and the number of lines which correspond to the given position. - * Starting line number is 0 based. - */ - public Point getLineRange(Position p, Point region) { - - IDocument doc= getDocument(); - - if (p == null || doc == null) { - region.x= 0; - region.y= 0; - return region; - } - - int start= p.getOffset(); - int length= p.getLength(); - - int startLine= 0; - try { - startLine= doc.getLineOfOffset(start); - } catch (BadLocationException e) { - // silently ignored - } - - int lineCount= 0; - - if (length == 0) { -// // if range length is 0 and if range starts a new line -// try { -// if (start == doc.getLineStartOffset(startLine)) { -// lines--; -// } -// } catch (BadLocationException e) { -// lines--; -// } - - } else { - int endLine= 0; - try { - endLine= doc.getLineOfOffset(start + length - 1); // why -1? - } catch (BadLocationException e) { - // silently ignored - } - lineCount= endLine-startLine+1; - } - - region.x= startLine; - region.y= lineCount; - return region; - } - - /* - * Scroll TextPart to the given line. - */ - public void vscroll(int line) { - - int srcViewSize= getLineCount(); - int srcExtentSize= getViewportLines(); - - if (srcViewSize > srcExtentSize) { - - if (line < 0) - line= 0; - - int cp= getTopIndex(); - if (cp != line) - setTopIndex(line + getDocumentRegionOffset()); - } - } - - public void addAction(String actionId, MergeViewerAction action) { - fActions.put(actionId, action); - } - - public MergeViewerAction getAction(String actionId) { - MergeViewerAction action= (MergeViewerAction) fActions.get(actionId); - if (action == null) { - action= createAction(actionId); - if (action == null) - return null; - - if (action.isContentDependent()) - addTextListener(this); - if (action.isSelectionDependent()) - addSelectionChangedListener(this); - - Utilities.initAction(action, fResourceBundle, "action." + actionId + "."); //$NON-NLS-1$ //$NON-NLS-2$ - fActions.put(actionId, action); - } - if (action.isEditableDependent() && !isEditable()) - return null; - return action; - } - - protected MergeViewerAction createAction(String actionId) { - if (UNDO_ID.equals(actionId)) - return new TextOperationAction(UNDO, true, false, true); - if (REDO_ID.equals(actionId)) - return new TextOperationAction(REDO, true, false, true); - if (CUT_ID.equals(actionId)) - return new TextOperationAction(CUT, true, true, false); - if (COPY_ID.equals(actionId)) - return new TextOperationAction(COPY, false, true, false); - if (PASTE_ID.equals(actionId)) - return new TextOperationAction(PASTE, true, false, false); - if (DELETE_ID.equals(actionId)) - return new TextOperationAction(DELETE, true, false, false); - if (SELECT_ALL_ID.equals(actionId)) - return new TextOperationAction(SELECT_ALL, false, false, false); - return null; - } - - public void selectionChanged(SelectionChangedEvent event) { - Iterator e= fActions.values().iterator(); - while (e.hasNext()) { - MergeViewerAction action= (MergeViewerAction) e.next(); - if (action.isSelectionDependent()) - action.update(); - } - } - - public void textChanged(TextEvent event) { - Iterator e= fActions.values().iterator(); - while (e.hasNext()) { - MergeViewerAction action= (MergeViewerAction) e.next(); - if (action.isContentDependent()) - action.update(); - } - } - - /* - * Allows the viewer to add menus and/or tools to the context menu. - */ - public void menuAboutToShow(IMenuManager menu) { - - menu.add(new Separator("undo")); //$NON-NLS-1$ - addMenu(menu, UNDO_ID); - addMenu(menu, REDO_ID); - - menu.add(new Separator("ccp")); //$NON-NLS-1$ - addMenu(menu, CUT_ID); - addMenu(menu, COPY_ID); - addMenu(menu, PASTE_ID); - addMenu(menu, DELETE_ID); - addMenu(menu, SELECT_ALL_ID); - - menu.add(new Separator("edit")); //$NON-NLS-1$ - menu.add(new Separator("find")); //$NON-NLS-1$ - //addMenu(menu, FIND_ID); - - menu.add(new Separator("save")); //$NON-NLS-1$ - if (fAddSaveAction) - addMenu(menu, SAVE_ID); - - menu.add(new Separator("rest")); //$NON-NLS-1$ - } - - private void addMenu(IMenuManager menu, String actionId) { - IAction action= getAction(actionId); - if (action != null) - menu.add(action); - } - - protected void handleDispose() { - - removeTextListener(this); - removeSelectionChangedListener(this); - - super.handleDispose(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java deleted file mode 100644 index d0e53995e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.ui.texteditor.IUpdate; -import org.eclipse.jface.action.Action; - - -public abstract class MergeViewerAction extends Action implements IUpdate { - - private boolean fMutable; - private boolean fSelection; - private boolean fContent; - - public MergeViewerAction(boolean mutable, boolean selection, boolean content) { - fMutable= mutable; - fSelection= selection; - fContent= content; - } - - public boolean isSelectionDependent() { - return fSelection; - } - - public boolean isContentDependent() { - return fContent; - } - - public boolean isEditableDependent() { - return fMutable; - } - - public void update() { - // empty default implementation - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java deleted file mode 100644 index d36ec19d5..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider; - -/** - * Adapts any ContentMergeViewer to work on an ICompareInput - * e.g. a DiffNode. - */ -public class MergeViewerContentProvider implements IMergeViewerContentProvider { - - private CompareConfiguration fCompareConfiguration; - private String fAncestorError; - private String fLeftError; - private String fRightError; - - public MergeViewerContentProvider(CompareConfiguration cc) { - fCompareConfiguration= cc; - } - - private boolean hasError() { - return fAncestorError != null || fLeftError != null || fRightError != null; - } - - public void dispose() { - // empty default implementation - } - - public void inputChanged(Viewer v, Object o1, Object o2) { - // we are not interested since we have no state - } - - //---- ancestor - - public void setAncestorError(String errorMessage) { - fAncestorError= errorMessage; - } - - public String getAncestorLabel(Object element) { - if (fAncestorError != null) - return fAncestorError; - return fCompareConfiguration.getAncestorLabel(element); - } - - public Image getAncestorImage(Object element) { - if (fAncestorError != null) - return null; - return fCompareConfiguration.getAncestorImage(element); - } - - public Object getAncestorContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getAncestor(); - return null; - } - - public boolean showAncestor(Object element) { - if (element instanceof ICompareInput) - return true; // fix for #45239: Show ancestor for incoming and outgoing changes - //return (((ICompareInput)element).getKind() & Differencer.DIRECTION_MASK) == Differencer.CONFLICTING; - return false; - } - - //---- left - - public void setLeftError(String errorMessage) { - fLeftError= errorMessage; - } - - public String getLeftLabel(Object element) { - if (fLeftError != null) - return fLeftError; - return fCompareConfiguration.getLeftLabel(element); - } - - public Image getLeftImage(Object element) { - if (fLeftError != null) - return null; - return fCompareConfiguration.getLeftImage(element); - } - - public Object getLeftContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getLeft(); - return null; - } - - public boolean isLeftEditable(Object element) { - if (hasError()) - return false; - if (element instanceof ICompareInput) { - Object left= ((ICompareInput) element).getLeft(); - if (left == null) { - IDiffElement parent= ((IDiffElement)element).getParent(); - if (parent instanceof ICompareInput) - left= ((ICompareInput) parent).getLeft(); - } - if (left instanceof IEditableContent) - return ((IEditableContent)left).isEditable(); - } - return false; - } - - public void saveLeftContent(Object element, byte[] bytes) { - if (element instanceof ICompareInput) { - ICompareInput node= (ICompareInput) element; - if (bytes != null) { - ITypedElement left= node.getLeft(); - // #9869: problem if left is null (because no resource exists yet) nothing is done! - if (left == null) { - node.copy(false); - left= node.getLeft(); - } - if (left instanceof IEditableContent) - ((IEditableContent)left).setContent(bytes); - if (node instanceof ResourceCompareInput.MyDiffNode) - ((ResourceCompareInput.MyDiffNode)node).fireChange(); - } else { - node.copy(false); - } - } - } - - //---- right - - public void setRightError(String errorMessage) { - fRightError= errorMessage; - } - - public String getRightLabel(Object element) { - if (fRightError != null) - return fRightError; - return fCompareConfiguration.getRightLabel(element); - } - - public Image getRightImage(Object element) { - if (fRightError != null) - return null; - return fCompareConfiguration.getRightImage(element); - } - - public Object getRightContent(Object element) { - if (element instanceof ICompareInput) - return ((ICompareInput) element).getRight(); - return null; - } - - public boolean isRightEditable(Object element) { - if (hasError()) - return false; - if (element instanceof ICompareInput) { - Object right= ((ICompareInput) element).getRight(); - if (right == null) { - IDiffContainer parent= ((IDiffElement)element).getParent(); - if (parent instanceof ICompareInput) - right= ((ICompareInput) parent).getRight(); - } - if (right instanceof IEditableContent) - return ((IEditableContent)right).isEditable(); - } - return false; - } - - public void saveRightContent(Object element, byte[] bytes) { - if (element instanceof ICompareInput) { - ICompareInput node= (ICompareInput) element; - if (bytes != null) { - ITypedElement right= node.getRight(); - // #9869: problem if right is null (because no resource exists yet) nothing is done! - if (right == null) { - node.copy(true); - right= node.getRight(); - } - if (right instanceof IEditableContent) - ((IEditableContent)right).setContent(bytes); - if (node instanceof ResourceCompareInput.MyDiffNode) - ((ResourceCompareInput.MyDiffNode)node).fireChange(); - } else { - node.copy(true); - } - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java deleted file mode 100644 index 495a8cf28..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; - -import org.eclipse.compare.CompareViewerPane; - -/** - * Used whenever the input is null or no viewer can be found. - */ -public class NullViewer extends AbstractViewer { - - private Control fDummy; - - public NullViewer(Composite parent) { - - fDummy= new Tree(parent, SWT.NULL); - - CompareViewerPane.clearToolBar(parent); - } - - public Control getControl() { - return fDummy; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java deleted file mode 100644 index 9cc039d26..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java +++ /dev/null @@ -1,452 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * An overlaying preference store. - */ -public class OverlayPreferenceStore implements IPreferenceStore { - - - public static final class TypeDescriptor { - private TypeDescriptor() { - // nothing to do - } - } - - public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); - public static final TypeDescriptor DOUBLE= new TypeDescriptor(); - public static final TypeDescriptor FLOAT= new TypeDescriptor(); - public static final TypeDescriptor INT= new TypeDescriptor(); - public static final TypeDescriptor LONG= new TypeDescriptor(); - public static final TypeDescriptor STRING= new TypeDescriptor(); - - public static class OverlayKey { - - TypeDescriptor fDescriptor; - String fKey; - - public OverlayKey(TypeDescriptor descriptor, String key) { - fDescriptor= descriptor; - fKey= key; - } - } - - private class PropertyListener implements IPropertyChangeListener { - - /* - * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - OverlayKey key= findOverlayKey(event.getProperty()); - if (key != null) - propagateProperty(fParent, key, fStore); - } - } - - - private IPreferenceStore fParent; - private IPreferenceStore fStore; - private OverlayKey[] fOverlayKeys; - - private PropertyListener fPropertyListener; - - - public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { - fParent= parent; - fOverlayKeys= overlayKeys; - fStore= new PreferenceStore(); - } - - private OverlayKey findOverlayKey(String key) { - for (int i= 0; i < fOverlayKeys.length; i++) { - if (fOverlayKeys[i].fKey.equals(key)) - return fOverlayKeys[i]; - } - return null; - } - - private boolean covers(String key) { - return (findOverlayKey(key) != null); - } - - private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { - - if (orgin.isDefault(key.fKey)) { - if (!target.isDefault(key.fKey)) - target.setToDefault(key.fKey); - return; - } - - TypeDescriptor d= key.fDescriptor; - if (BOOLEAN == d) { - - boolean originValue= orgin.getBoolean(key.fKey); - boolean targetValue= target.getBoolean(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (DOUBLE == d) { - - double originValue= orgin.getDouble(key.fKey); - double targetValue= target.getDouble(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (FLOAT == d) { - - float originValue= orgin.getFloat(key.fKey); - float targetValue= target.getFloat(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (INT == d) { - - int originValue= orgin.getInt(key.fKey); - int targetValue= target.getInt(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (LONG == d) { - - long originValue= orgin.getLong(key.fKey); - long targetValue= target.getLong(key.fKey); - if (targetValue != originValue) - target.setValue(key.fKey, originValue); - - } else if (STRING == d) { - - String originValue= orgin.getString(key.fKey); - String targetValue= target.getString(key.fKey); - if (targetValue != null && originValue != null && !targetValue.equals(originValue)) - target.setValue(key.fKey, originValue); - - } - } - - public void propagate() { - for (int i= 0; i < fOverlayKeys.length; i++) - propagateProperty(fStore, fOverlayKeys[i], fParent); - } - - private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { - TypeDescriptor d= key.fDescriptor; - if (BOOLEAN == d) { - - if (forceInitialization) - target.setValue(key.fKey, true); - target.setValue(key.fKey, orgin.getBoolean(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); - - } else if (DOUBLE == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1.0D); - target.setValue(key.fKey, orgin.getDouble(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); - - } else if (FLOAT == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1.0F); - target.setValue(key.fKey, orgin.getFloat(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); - - } else if (INT == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1); - target.setValue(key.fKey, orgin.getInt(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); - - } else if (LONG == d) { - - if (forceInitialization) - target.setValue(key.fKey, 1L); - target.setValue(key.fKey, orgin.getLong(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); - - } else if (STRING == d) { - - if (forceInitialization) - target.setValue(key.fKey, "1"); //$NON-NLS-1$ - target.setValue(key.fKey, orgin.getString(key.fKey)); - target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); - - } - } - - public void load() { - for (int i= 0; i < fOverlayKeys.length; i++) - loadProperty(fParent, fOverlayKeys[i], fStore, true); - } - - public void loadDefaults() { - for (int i= 0; i < fOverlayKeys.length; i++) - setToDefault(fOverlayKeys[i].fKey); - } - - public void start() { - if (fPropertyListener == null) { - fPropertyListener= new PropertyListener(); - fParent.addPropertyChangeListener(fPropertyListener); - } - } - - public void stop() { - if (fPropertyListener != null) { - fParent.removePropertyChangeListener(fPropertyListener); - fPropertyListener= null; - } - } - - /* - * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - fStore.addPropertyChangeListener(listener); - } - - /* - * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fStore.removePropertyChangeListener(listener); - } - - /* - * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - fStore.firePropertyChangeEvent(name, oldValue, newValue); - } - - /* - * @see IPreferenceStore#contains(String) - */ - public boolean contains(String name) { - return fStore.contains(name); - } - - /* - * @see IPreferenceStore#getBoolean(String) - */ - public boolean getBoolean(String name) { - return fStore.getBoolean(name); - } - - /* - * @see IPreferenceStore#getDefaultBoolean(String) - */ - public boolean getDefaultBoolean(String name) { - return fStore.getDefaultBoolean(name); - } - - /* - * @see IPreferenceStore#getDefaultDouble(String) - */ - public double getDefaultDouble(String name) { - return fStore.getDefaultDouble(name); - } - - /* - * @see IPreferenceStore#getDefaultFloat(String) - */ - public float getDefaultFloat(String name) { - return fStore.getDefaultFloat(name); - } - - /* - * @see IPreferenceStore#getDefaultInt(String) - */ - public int getDefaultInt(String name) { - return fStore.getDefaultInt(name); - } - - /* - * @see IPreferenceStore#getDefaultLong(String) - */ - public long getDefaultLong(String name) { - return fStore.getDefaultLong(name); - } - - /* - * @see IPreferenceStore#getDefaultString(String) - */ - public String getDefaultString(String name) { - return fStore.getDefaultString(name); - } - - /* - * @see IPreferenceStore#getDouble(String) - */ - public double getDouble(String name) { - return fStore.getDouble(name); - } - - /* - * @see IPreferenceStore#getFloat(String) - */ - public float getFloat(String name) { - return fStore.getFloat(name); - } - - /* - * @see IPreferenceStore#getInt(String) - */ - public int getInt(String name) { - return fStore.getInt(name); - } - - /* - * @see IPreferenceStore#getLong(String) - */ - public long getLong(String name) { - return fStore.getLong(name); - } - - /* - * @see IPreferenceStore#getString(String) - */ - public String getString(String name) { - return fStore.getString(name); - } - - /* - * @see IPreferenceStore#isDefault(String) - */ - public boolean isDefault(String name) { - return fStore.isDefault(name); - } - - /* - * @see IPreferenceStore#needsSaving() - */ - public boolean needsSaving() { - return fStore.needsSaving(); - } - - /* - * @see IPreferenceStore#putValue(String, String) - */ - public void putValue(String name, String value) { - if (covers(name)) - fStore.putValue(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, double) - */ - public void setDefault(String name, double value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, float) - */ - public void setDefault(String name, float value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, int) - */ - public void setDefault(String name, int value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, long) - */ - public void setDefault(String name, long value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, String) - */ - public void setDefault(String name, String value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setDefault(String, boolean) - */ - public void setDefault(String name, boolean value) { - if (covers(name)) - fStore.setDefault(name, value); - } - - /* - * @see IPreferenceStore#setToDefault(String) - */ - public void setToDefault(String name) { - fStore.setToDefault(name); - } - - /* - * @see IPreferenceStore#setValue(String, double) - */ - public void setValue(String name, double value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, float) - */ - public void setValue(String name, float value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, int) - */ - public void setValue(String name, int value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, long) - */ - public void setValue(String name, long value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, String) - */ - public void setValue(String name, String value) { - if (covers(name)) - fStore.setValue(name, value); - } - - /* - * @see IPreferenceStore#setValue(String, boolean) - */ - public void setValue(String name, boolean value) { - if (covers(name)) - fStore.setValue(name, value); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java deleted file mode 100644 index fdcc7bf68..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ReplaceWithEditionAction extends EditionAction { - - public ReplaceWithEditionAction() { - super(true, "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ - fHelpContextId= ICompareContextIds.REPLACE_WITH_EDITION_DIALOG; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties deleted file mode 100644 index 76e8d323b..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)ReplaceWithEditionAction.properties -# -# Resources for ReplaceWithEditionAction.java - -title= Replace from Local History - -treeTitleFormat= Local History of ''{0}'' -dateIcon= obj16/day_obj.gif -timeIcon= obj16/resource_obj.gif - -treeFormat= {0} -workspaceTreeFormat= {0} (Workspace File) -parseErrorFormat= {0} (Parse Error) - -editionLabel= Local History ({0}) -workspaceEditionLabel= Workspace File - -targetLabel= {0} - -todayFormat= Today ({0}) -yesterdayFormat= Yesterday ({0}) -dayFormat= {0} - -buttonLabel= Replace - -noLocalHistoryError= No local history available for selected resource. -replaceError=Cannot replace resource (reason: {0}). - -taskName=Replacing diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java deleted file mode 100644 index 3fa6b07aa..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ReplaceWithPreviousEditionAction extends EditionAction { - - public ReplaceWithPreviousEditionAction() { - super(true, - "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ - fPrevious= true; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java deleted file mode 100644 index 669aec61d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.DialogSettings; - - -/** - * Base class for resizable Dialogs with persistent window bounds. - */ -public abstract class ResizableDialog extends Dialog { - - // dialog store id constants - private final static String DIALOG_BOUNDS_KEY= "ResizableDialogBounds"; //$NON-NLS-1$ - private static final String X= "x"; //$NON-NLS-1$ - private static final String Y= "y"; //$NON-NLS-1$ - private static final String WIDTH= "width"; //$NON-NLS-1$ - private static final String HEIGHT= "height"; //$NON-NLS-1$ - - protected ResourceBundle fBundle; - private Rectangle fNewBounds; - private IDialogSettings fSettings; - private String fContextId; - - - public ResizableDialog(Shell parent, ResourceBundle bundle) { - super(parent); - setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); - - fBundle= bundle; - - fSettings= CompareUIPlugin.getDefault().getDialogSettings(); - } - - public void setHelpContextId(String contextId) { - fContextId= contextId; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (fContextId != null) - WorkbenchHelp.setHelp(newShell, fContextId); - } - - protected Point getInitialSize() { - - int width= 0; - int height= 0; - - final Shell s= getShell(); - if (s != null) { - s.addControlListener( - new ControlListener() { - public void controlMoved(ControlEvent arg0) { - fNewBounds= s.getBounds(); - } - public void controlResized(ControlEvent arg0) { - fNewBounds= s.getBounds(); - } - } - ); - } - - IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); //$NON-NLS-1$ - if (bounds == null) { - if (fBundle != null) { - width= Utilities.getInteger(fBundle, WIDTH, 0); - height= Utilities.getInteger(fBundle, HEIGHT, 0); - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - if (width <= 0) - width= parentSize.x-300; - if (height <= 0) - height= parentSize.y-200; - } - } else { - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - width= parentSize.x-100; - height= parentSize.y-100; - } - } - if (width < 700) - width= 700; - if (height < 500) - height= 500; - } else { - try { - width= bounds.getInt(WIDTH); - } catch (NumberFormatException e) { - width= 700; - } - try { - height= bounds.getInt(HEIGHT); - } catch (NumberFormatException e) { - height= 500; - } - } - - return new Point(width, height); - } - - protected Point getInitialLocation(Point initialSize) { - Point loc= super.getInitialLocation(initialSize); - - IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); - if (bounds != null) { - try { - loc.x= bounds.getInt(X); - } catch (NumberFormatException e) { - // silently ignored - } - try { - loc.y= bounds.getInt(Y); - } catch (NumberFormatException e) { - // silently ignored - } - } - return loc; - } - - public boolean close() { - boolean closed= super.close(); - if (closed && fNewBounds != null) - saveBounds(fNewBounds); - return closed; - } - - private void saveBounds(Rectangle bounds) { - IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY); - if (dialogBounds == null) { - dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY); - fSettings.addSection(dialogBounds); - } - dialogBounds.put(X, bounds.x); - dialogBounds.put(Y, bounds.y); - dialogBounds.put(WIDTH, bounds.width); - dialogBounds.put(HEIGHT, bounds.height); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java deleted file mode 100644 index d2de626b2..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * A two-way or three-way compare for arbitrary IResources. - */ -class ResourceCompareInput extends CompareEditorInput { - - private static final boolean NORMALIZE_CASE= true; - - private boolean fThreeWay= false; - private Object fRoot; - private IStructureComparator fAncestor; - private IStructureComparator fLeft; - private IStructureComparator fRight; - private IResource fAncestorResource; - private IResource fLeftResource; - private IResource fRightResource; - private DiffTreeViewer fDiffViewer; - private IAction fOpenAction; - - class MyDiffNode extends DiffNode { - - private boolean fDirty= false; - private ITypedElement fLastId; - private String fLastName; - - - public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - super(parent, description, ancestor, left, right); - } - public void fireChange() { - super.fireChange(); - setDirty(true); - fDirty= true; - if (fDiffViewer != null) - fDiffViewer.refresh(this); - } - void clearDirty() { - fDirty= false; - } - public String getName() { - if (fLastName == null) - fLastName= super.getName(); - if (fDirty) - return '<' + fLastName + '>'; - return fLastName; - } - - public ITypedElement getId() { - ITypedElement id= super.getId(); - if (id == null) - return fLastId; - fLastId= id; - return id; - } - } - - static class FilteredBufferedResourceNode extends BufferedResourceNode { - FilteredBufferedResourceNode(IResource resource) { - super(resource); - } - protected IStructureComparator createChild(IResource child) { - String name= child.getName(); - if (CompareUIPlugin.getDefault().filter(name, child instanceof IContainer, false)) - return null; - return new FilteredBufferedResourceNode(child); - } - } - - /* - * Creates an compare editor input for the given selection. - */ - ResourceCompareInput(CompareConfiguration config) { - super(config); - } - - public Viewer createDiffViewer(Composite parent) { - fDiffViewer= new DiffTreeViewer(parent, getCompareConfiguration()) { - protected void fillContextMenu(IMenuManager manager) { - - if (fOpenAction == null) { - fOpenAction= new Action() { - public void run() { - handleOpen(null); - } - }; - Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents."); //$NON-NLS-1$ - } - - boolean enable= false; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection)selection; - if (ss.size() == 1) { - Object element= ss.getFirstElement(); - if (element instanceof MyDiffNode) { - ITypedElement te= ((MyDiffNode) element).getId(); - if (te != null) - enable= !ITypedElement.FOLDER_TYPE.equals(te.getType()); - } else - enable= true; - } - } - fOpenAction.setEnabled(enable); - - manager.add(fOpenAction); - - super.fillContextMenu(manager); - } - }; - return fDiffViewer; - } - - void setSelection(ISelection s) { - - IResource[] selection= Utilities.getResources(s); - - fThreeWay= selection.length == 3; - - fAncestorResource= null; - fLeftResource= selection[0]; - fRightResource= selection[1]; - if (fThreeWay) { - fLeftResource= selection[1]; - fRightResource= selection[2]; - } - - fAncestor= null; - fLeft= getStructure(fLeftResource); - fRight= getStructure(fRightResource); - - if (fThreeWay) { - fAncestorResource= selection[0]; - fAncestor= getStructure(fAncestorResource); - } - } - - /* - * Returns true if compare can be executed for the given selection. - */ - public boolean isEnabled(ISelection s) { - - IResource[] selection= Utilities.getResources(s); - if (selection.length < 2 || selection.length > 3) - return false; - - fThreeWay= selection.length == 3; - - fLeftResource= selection[0]; - fRightResource= selection[1]; - if (fThreeWay) { - fLeftResource= selection[1]; - fRightResource= selection[2]; - } - - if (!comparable(fLeftResource, fRightResource)) - return false; - - if (fThreeWay) { - fAncestorResource= selection[0]; - - if (!comparable(fLeftResource, fRightResource)) - return false; - } - - return true; - } - - /** - * Initializes the images in the compare configuration. - */ - void initializeCompareConfiguration() { - CompareConfiguration cc= getCompareConfiguration(); - if (fLeftResource != null) { - cc.setLeftLabel(buildLabel(fLeftResource)); - cc.setLeftImage(CompareUIPlugin.getImage(fLeftResource)); - } - if (fRightResource != null) { - cc.setRightLabel(buildLabel(fRightResource)); - cc.setRightImage(CompareUIPlugin.getImage(fRightResource)); - } - if (fThreeWay && fAncestorResource != null) { - cc.setAncestorLabel(buildLabel(fAncestorResource)); - cc.setAncestorImage(CompareUIPlugin.getImage(fAncestorResource)); - } - } - - /* - * Returns true if both resources are either structured or unstructured. - */ - private boolean comparable(IResource c1, IResource c2) { - return hasStructure(c1) == hasStructure(c2); - } - - /* - * Returns true if the given argument has a structure. - */ - private boolean hasStructure(IResource input) { - - if (input instanceof IContainer) - return true; - - if (input instanceof IFile) { - IFile file= (IFile) input; - String type= file.getFileExtension(); - if (type != null) { - type= normalizeCase(type); - return "JAR".equals(type) || "ZIP".equals(type); //$NON-NLS-2$ //$NON-NLS-1$ - } - } - - return false; - } - - /* - * Creates a IStructureComparator for the given input. - * Returns null if no IStructureComparator - * can be found for the IResource. - */ - private IStructureComparator getStructure(IResource input) { - - if (input instanceof IContainer) - return new FilteredBufferedResourceNode(input); - - if (input instanceof IFile) { - IStructureComparator rn= new FilteredBufferedResourceNode(input); - IFile file= (IFile) input; - String type= normalizeCase(file.getFileExtension()); - if ("JAR".equals(type) || "ZIP".equals(type)) //$NON-NLS-2$ //$NON-NLS-1$ - return new ZipFileStructureCreator().getStructure(rn); - return rn; - } - return null; - } - - /* - * Performs a two-way or three-way diff on the current selection. - */ - public Object prepareInput(IProgressMonitor pm) throws InvocationTargetException { - - try { - // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty - fLeftResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - fRightResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - if (fThreeWay && fAncestorResource != null) - fAncestorResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - // end fix - - pm.beginTask(Utilities.getString("ResourceCompare.taskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - - String leftLabel= fLeftResource.getName(); - String rightLabel= fRightResource.getName(); - - String title; - if (fThreeWay) { - String format= Utilities.getString("ResourceCompare.threeWay.title"); //$NON-NLS-1$ - String ancestorLabel= fAncestorResource.getName(); - title= MessageFormat.format(format, new String[] {ancestorLabel, leftLabel, rightLabel}); - } else { - String format= Utilities.getString("ResourceCompare.twoWay.title"); //$NON-NLS-1$ - title= MessageFormat.format(format, new String[] {leftLabel, rightLabel}); - } - setTitle(title); - - Differencer d= new Differencer() { - protected Object visit(Object parent, int description, Object ancestor, Object left, Object right) { - return new MyDiffNode((IDiffContainer) parent, description, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); - } - }; - - fRoot= d.findDifferences(fThreeWay, pm, null, fAncestor, fLeft, fRight); - return fRoot; - - } catch (CoreException ex) { - throw new InvocationTargetException(ex); - } finally { - pm.done(); - } - } - - public String getToolTipText() { - if (fLeftResource != null && fRightResource != null) { - String leftLabel= fLeftResource.getFullPath().makeRelative().toString(); - String rightLabel= fRightResource.getFullPath().makeRelative().toString(); - if (fThreeWay) { - String format= Utilities.getString("ResourceCompare.threeWay.tooltip"); //$NON-NLS-1$ - String ancestorLabel= fAncestorResource.getFullPath().makeRelative().toString(); - return MessageFormat.format(format, new String[] {ancestorLabel, leftLabel, rightLabel}); - } - String format= Utilities.getString("ResourceCompare.twoWay.tooltip"); //$NON-NLS-1$ - return MessageFormat.format(format, new String[] {leftLabel, rightLabel}); - } - // fall back - return super.getToolTipText(); - } - - private String buildLabel(IResource r) { - String n= r.getFullPath().toString(); - if (n.charAt(0) == IPath.SEPARATOR) - return n.substring(1); - return n; - } - - public void saveChanges(IProgressMonitor pm) throws CoreException { - super.saveChanges(pm); - if (fRoot instanceof DiffNode) { - try { - commit(pm, (DiffNode) fRoot); - } finally { - if (fDiffViewer != null) - fDiffViewer.refresh(); - setDirty(false); - } - } - } - - /* - * Recursively walks the diff tree and commits all changes. - */ - private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - - if (node instanceof MyDiffNode) - ((MyDiffNode)node).clearDirty(); - - ITypedElement left= node.getLeft(); - if (left instanceof BufferedResourceNode) - ((BufferedResourceNode) left).commit(pm); - - ITypedElement right= node.getRight(); - if (right instanceof BufferedResourceNode) - ((BufferedResourceNode) right).commit(pm); - - IDiffElement[] children= node.getChildren(); - if (children != null) { - for (int i= 0; i < children.length; i++) { - IDiffElement element= children[i]; - if (element instanceof DiffNode) - commit(pm, (DiffNode) element); - } - } - } - - /* (non Javadoc) - * see IAdaptable.getAdapter - */ - public Object getAdapter(Class adapter) { - if (IFile[].class.equals(adapter)) { - HashSet collector= new HashSet(); - collectDirtyResources(fRoot, collector); - return (IFile[]) collector.toArray(new IFile[collector.size()]); - } - return super.getAdapter(adapter); - } - - private void collectDirtyResources(Object o, Set collector) { - if (o instanceof DiffNode) { - DiffNode node= (DiffNode) o; - - ITypedElement left= node.getLeft(); - if (left instanceof BufferedResourceNode) { - BufferedResourceNode bn= (BufferedResourceNode) left; - if (bn.isDirty()) { - IResource resource= bn.getResource(); - if (resource instanceof IFile) - collector.add(resource); - } - } - - ITypedElement right= node.getRight(); - if (right instanceof BufferedResourceNode) { - BufferedResourceNode bn= (BufferedResourceNode) right; - if (bn.isDirty()) { - IResource resource= bn.getResource(); - if (resource instanceof IFile) - collector.add(resource); - } - } - - IDiffElement[] children= node.getChildren(); - if (children != null) { - for (int i= 0; i < children.length; i++) { - IDiffElement element= children[i]; - if (element instanceof DiffNode) - collectDirtyResources(element, collector); - } - } - } - } - - private static String normalizeCase(String s) { - if (NORMALIZE_CASE && s != null) - return s.toUpperCase(); - return s; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java deleted file mode 100644 index 581527039..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.util.ResourceBundle; - -import org.eclipse.compare.*; - -/** - * Toggles the ICompareConfiguration.SHOW_PSEUDO_CONFLICTS property of an - * ICompareConfiguration. - */ -public class ShowPseudoConflicts extends ChangePropertyAction { - - public ShowPseudoConflicts(ResourceBundle bundle, CompareConfiguration cc) { - super(bundle, cc, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java deleted file mode 100644 index a28339bfb..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.Document; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.ICompareInput; - - -public class SimpleTextViewer extends AbstractViewer { - - private SourceViewer fSourceViewer; - private ICompareInput fInput; - - - SimpleTextViewer(Composite parent) { - fSourceViewer= new SourceViewer(parent, null, SWT.H_SCROLL + SWT.V_SCROLL); - fSourceViewer.setEditable(false); - } - - public Control getControl() { - return fSourceViewer.getTextWidget(); - } - - public void setInput(Object input) { - if (input instanceof IStreamContentAccessor) { - fSourceViewer.setDocument(new Document(getString(input))); - } else if (input instanceof ICompareInput) { - fInput= (ICompareInput) input; - ITypedElement left= fInput.getLeft(); - fSourceViewer.setDocument(new Document(getString(left))); - } - } - - public Object getInput() { - return fInput; - } - - private String getString(Object input) { - - if (input instanceof IStreamContentAccessor) { - try { - return Utilities.readString((IStreamContentAccessor) input); - } catch (CoreException ex) { - // NeedWork - } - } - return ""; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java deleted file mode 100644 index 16225ecb4..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.compare.IStreamMerger; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -/** - * A factory proxy for creating a StructureCreator. - */ -class StreamMergerDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - - private IConfigurationElement fElement; - - /* - * Creates a new sorter node with the given configuration element. - */ - public StreamMergerDescriptor(IConfigurationElement element) { - fElement= element; - } - - /* - * Creates a new stream merger from this node. - */ - public IStreamMerger createStreamMerger() { - try { - return (IStreamMerger)fElement.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException ex) { - //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } catch (ClassCastException ex) { - //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java deleted file mode 100644 index be8a4d6b9..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -import org.eclipse.compare.structuremergeviewer.IStructureCreator; - -/** - * A factory proxy for creating a StructureCreator. - */ -public class StructureCreatorDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - - private IConfigurationElement fElement; - - /* - * Creates a new sorter node with the given configuration element. - */ - public StructureCreatorDescriptor(IConfigurationElement element) { - fElement= element; - } - - /* - * Creates a new sorter from this node. - */ - public IStructureCreator createStructureCreator() { - try { - return (IStructureCreator)fElement.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException ex) { - CompareUIPlugin.log(ex.getStatus()); - //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } catch (ClassCastException ex) { - //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$ - return null; - } - } - - /* - * Returns the structure creator's extensions. - */ - public String getExtension() { - return fElement.getAttribute(EXTENSIONS_ATTRIBUTE); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java deleted file mode 100644 index 739b82f0e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; - -public class TabFolderLayout extends Layout { - - protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - - Control [] children = composite.getChildren (); - int count = children.length; - int maxWidth = 0, maxHeight = 0; - for (int i=0; iTextMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class TextMergeViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new TextMergeViewer(parent, mp); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java deleted file mode 100644 index 66eaba9f8..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextViewerCreator.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.IViewerCreator; - - -/** - * A factory object for the TextMergeViewer. - * This indirection is necessary because only objects with a default - * constructor can be created via an extension point - * (this precludes Viewers). - */ -public class TextViewerCreator implements IViewerCreator { - - public Viewer createViewer(Composite parent, CompareConfiguration mp) { - return new SimpleTextViewer(parent); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java deleted file mode 100644 index e2ecaf7eb..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TokenComparator.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.compare.rangedifferencer.IRangeComparator; -import org.eclipse.compare.contentmergeviewer.ITokenComparator; - -/** - * Implements the ITokenComparator interface for words (or tokens) - * in a string. - * A TokenComparator is used as the input for the RangeDifferencer - * engine to perform a token oriented compare on strings. - */ -public class TokenComparator implements ITokenComparator { - - private boolean fShouldEscape= true; - private String fText; - private int fCount; - private int[] fStarts; - private int[] fLengths; - - /** - * Creates a TokenComparator for the given string. - * - * @param text the string that is split into token - */ - public TokenComparator(String text) { - - Assert.isNotNull(text); - - fText= text; - - int length= fText.length(); - fStarts= new int[length]; // pessimistic assumption! - fLengths= new int[length]; - fCount= 0; - - char lastCategory= 0; // 0: no category - for (int i= 0; i < length; i++) { - char c= fText.charAt(i); - - char category= '?'; // unspecified category - if (Character.isWhitespace(c)) - category= ' '; // white space category - else if (Character.isDigit(c)) - category= '0'; // digits - else if (Character.isLetter(c)) - category= 'a'; // letters - - if (category != lastCategory) { - // start a new token - fStarts[fCount++]= i; - lastCategory= category; - } - fLengths[fCount-1]++; - } - } - - /** - * Creates a TokenComparator for the given string. - * - * @param text the string that is split into token - * @param shouldEscape - */ - public TokenComparator(String text, boolean shouldEscape) { - this(text); - fShouldEscape= shouldEscape; - } - - /** - * Returns the number of token in the string. - * - * @return number of token in the string - */ - public int getRangeCount() { - return fCount; - } - - /* (non Javadoc) - * see ITokenComparator.getTokenStart - */ - public int getTokenStart(int index) { - if (index < fCount) - return fStarts[index]; - return fText.length(); - } - - /* (non Javadoc) - * see ITokenComparator.getTokenLength - */ - public int getTokenLength(int index) { - if (index < fCount) - return fLengths[index]; - return 0; - } - - /** - * Returns true if a token given by the first index - * matches a token specified by the other IRangeComparator and index. - * - * @param thisIndex the number of the token within this range comparator - * @param other the range comparator to compare this with - * @param otherIndex the number of the token within the other comparator - * @return true if the token are equal - */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) { - if (other != null && getClass() == other.getClass()) { - TokenComparator tc= (TokenComparator) other; - int thisLen= getTokenLength(thisIndex); - int otherLen= tc.getTokenLength(otherIndex); - if (thisLen == otherLen) - return fText.regionMatches(false, getTokenStart(thisIndex), tc.fText, tc.getTokenStart(otherIndex), thisLen); - } - return false; - } - - /* - * Aborts the comparison if the number of tokens is too large. - * @return true to abort a token comparison - */ - public boolean skipRangeComparison(int length, int max, IRangeComparator other) { - - if (!fShouldEscape) - return false; - - if (getRangeCount() < 50 || other.getRangeCount() < 50) - return false; - - if (max < 100) - return false; - - if (length < 100) - return false; - - if (max > 800) - return true; - - if (length < max / 4) - return false; - - return true; - } - -// public static void main(String args[]) { -// //String in= "private static boolean isWhitespace(char c) {"; -// //String in= "for (int j= 0; j < l-1; j++) {"; -// String in= "for do i= 123; i++"; -// TokenComparator tc= new TokenComparator(in, false); -// -// System.out.println("n: " + tc.getRangeCount()); -// System.out.println(in); -// -// int p= 0; -// for (int i= 0; i < tc.getRangeCount(); i++) { -// int l= tc.getTokenLength(i); -// System.out.print("<"); -// -// for (int j= 0; j < l-1; j++) -// System.out.print(" "); -// } -// System.out.println(); -// -// //System.out.println("extract: <" + tc.extract(16, 1) + ">"); -// } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java deleted file mode 100644 index ef697931f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java +++ /dev/null @@ -1,592 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import java.util.List; - -import org.eclipse.swt.widgets.*; - -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.dialogs.ErrorDialog; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.ui.*; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareUI; -import org.eclipse.compare.IEncodedStreamContentAccessor; -import org.eclipse.compare.IStreamContentAccessor; - -/** - * Convenience and utility methods. - */ -public class Utilities { - - public static void registerAction(IKeyBindingService kbs, IAction a, String id) { - if (kbs != null) { - a.setActionDefinitionId(id); - kbs.registerAction(a); - } - } - - public static IWorkbenchPartSite findSite(Control c) { - while (c != null && !c.isDisposed()) { - Object data= c.getData(); - if (data instanceof IWorkbenchPart) - return ((IWorkbenchPart)data).getSite(); - c= c.getParent(); - } - return null; - } - - public static IActionBars findActionBars(Control c) { - while (c != null && !c.isDisposed()) { - Object data= c.getData(); - if (data instanceof CompareEditor) - return ((CompareEditor)data).getActionBars(); - - // PR 1GDVZV7: ITPVCM:WIN98 - CTRL + C does not work in Java source compare - if (data instanceof IViewPart) - return ((IViewPart)data).getViewSite().getActionBars(); - // end PR 1GDVZV7 - - c= c.getParent(); - } - return null; - } - - public static void setEnableComposite(Composite composite, boolean enable) { - Control[] children= composite.getChildren(); - for (int i= 0; i < children.length; i++) - children[i].setEnabled(enable); - } - - public static boolean getBoolean(CompareConfiguration cc, String key, boolean dflt) { - if (cc != null) { - Object value= cc.getProperty(key); - if (value instanceof Boolean) - return ((Boolean) value).booleanValue(); - } - return dflt; - } - - public static void firePropertyChange(ListenerList ll, Object source, String property, Object old, Object newValue) { - if (ll != null) { - PropertyChangeEvent event= null; - Object[] listeners= ll.getListeners(); - for (int i= 0; i < listeners.length; i++) { - IPropertyChangeListener l= (IPropertyChangeListener) listeners[i]; - if (event == null) - event= new PropertyChangeEvent(source, property, old, newValue); - l.propertyChange(event); - } - } - } - - public static boolean okToUse(Widget widget) { - return widget != null && !widget.isDisposed(); - } - - private static ArrayList internalGetResources(ISelection selection, Class type) { - - ArrayList tmp= new ArrayList(); - - if (selection instanceof IStructuredSelection) { - - Object[] s= ((IStructuredSelection)selection).toArray(); - - for (int i= 0; i < s.length; i++) { - - IResource resource= null; - - Object o= s[i]; - if (type.isInstance(o)) { - resource= (IResource) o; - - } else if (o instanceof IAdaptable) { - IAdaptable a= (IAdaptable) o; - Object adapter= a.getAdapter(IResource.class); - if (type.isInstance(adapter)) - resource= (IResource) adapter; - } - - if (resource != null && resource.isAccessible()) - tmp.add(resource); - } - } - - return tmp; - } - - /* - * Convenience method: extract all accessible IResources from given selection. - * Never returns null. - */ - public static IResource[] getResources(ISelection selection) { - ArrayList tmp= internalGetResources(selection, IResource.class); - return (IResource[]) tmp.toArray(new IResource[tmp.size()]); - } - - /* - * Convenience method: extract all accessible IFiles from given selection. - * Never returns null. - */ - public static IFile[] getFiles(ISelection selection) { - ArrayList tmp= internalGetResources(selection, IFile.class); - return (IFile[]) tmp.toArray(new IFile[tmp.size()]); - } - - public static byte[] readBytes(InputStream in) { - ByteArrayOutputStream bos= new ByteArrayOutputStream(); - try { - while (true) { - int c= in.read(); - if (c == -1) - break; - bos.write(c); - } - - } catch (IOException ex) { - return null; - - } finally { - Utilities.close(in); - try { - bos.close(); - } catch (IOException x) { - // silently ignored - } - } - - return bos.toByteArray(); - } - - public static String getIconPath(Display display) { - return "icons/full/"; //$NON-NLS-1$ - } - - /* - * Initialize the given Action from a ResourceBundle. - */ - public static void initAction(IAction a, 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; - } - - a.setText(getString(bundle, labelKey, labelKey)); - a.setToolTipText(getString(bundle, tooltipKey, null)); - a.setDescription(getString(bundle, descriptionKey, null)); - - String relPath= getString(bundle, imageKey, null); - if (relPath != null && relPath.trim().length() > 0) { - - String dPath; - String ePath; - - if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$ - String path= relPath.substring(1); - dPath= 'd' + path; - ePath= 'e' + path; - } else { - dPath= "dlcl16/" + relPath; //$NON-NLS-1$ - ePath= "elcl16/" + relPath; //$NON-NLS-1$ - } - - ImageDescriptor id= CompareUIPlugin.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87) - if (id != null) - a.setDisabledImageDescriptor(id); - id= CompareUIPlugin.getImageDescriptor(ePath); - if (id != null) { - a.setImageDescriptor(id); - a.setHoverImageDescriptor(id); - } - } - } - - public static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) { - - String tooltip= null; - if (checked) - tooltip= getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$ - else - tooltip= getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$ - if (tooltip == null) - tooltip= getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$ - - if (tooltip != null) - a.setToolTipText(tooltip); - - String description= null; - if (checked) - description= getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$ - else - description= getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$ - if (description == null) - description= getString(bundle, prefix + "description", null); //$NON-NLS-1$ - - if (description != null) - a.setDescription(description); - - } - - public static String getString(ResourceBundle bundle, String key, String dfltValue) { - - if (bundle != null) { - try { - return bundle.getString(key); - } catch (MissingResourceException x) { - // NeedWork - } - } - return dfltValue; - } - - public static String getFormattedString(ResourceBundle bundle, String key, String arg) { - - if (bundle != null) { - try { - return MessageFormat.format(bundle.getString(key), new String[] { arg }); - } catch (MissingResourceException x) { - // NeedWork - } - } - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - - public static String getString(String key) { - try { - return CompareUI.getResourceBundle().getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getFormattedString(String key, String arg) { - try { - return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg }); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getFormattedString(String key, String arg0, String arg1) { - try { - return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg0, arg1 }); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } - - public static String getString(ResourceBundle bundle, String key) { - return getString(bundle, key, key); - } - - public static int getInteger(ResourceBundle bundle, String key, int dfltValue) { - - if (bundle != null) { - try { - String s= bundle.getString(key); - if (s != null) - return Integer.parseInt(s); - } catch (NumberFormatException x) { - // NeedWork - } catch (MissingResourceException x) { - // NeedWork - } - } - return dfltValue; - } - - /** - * Answers true if the given selection contains resources that don't - * have overlapping paths and false otherwise. - */ - /* - public static boolean isSelectionNonOverlapping() throws TeamException { - IResource[] resources = getSelectedResources(); - // allow operation for non-overlapping resource selections - if(resources.length>0) { - List validPaths = new ArrayList(2); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - - // only allow cvs resources to be selected - if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) { - return false; - } - - // check if this resource overlaps other selections - IPath resourceFullPath = resource.getFullPath(); - if(!validPaths.isEmpty()) { - for (Iterator it = validPaths.iterator(); it.hasNext();) { - IPath path = (IPath) it.next(); - if(path.isPrefixOf(resourceFullPath) || - resourceFullPath.isPrefixOf(path)) { - return false; - } - } - } - validPaths.add(resourceFullPath); - - // ensure that resources are managed - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if(cvsResource.isFolder()) { - if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false; - } else { - if( ! cvsResource.isManaged()) return false; - } - } - return true; - } - return false; - } - */ - - /* validate edit utilities */ - - /** - * Status constant indicating that an validateEdit call has changed the - * content of a file on disk. - */ - private static final int VALIDATE_EDIT_PROBLEM= 10004; - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResource(IResource resource, Shell shell, String title) { - return validateResources(new IResource[] { resource }, shell, title); - } - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResources(List resources, Shell shell, String title) { - IResource r[]= (IResource[]) resources.toArray(new IResource[resources.size()]); - return validateResources(r, shell, title); - } - - /* - * Makes the given resources committable. Committable means that all - * resources are writeable and that the content of the resources hasn't - * changed by calling validateEdit for a given file on - * IWorkspace. - * - * @param resources the resources to be checked - * @param shell the Shell passed to validateEdit as a context - * @return returns true if all resources are committable, false otherwise - * - * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public static boolean validateResources(IResource[] resources, Shell shell, String title) { - - // get all readonly files - List readOnlyFiles= getReadonlyFiles(resources); - if (readOnlyFiles.size() == 0) - return true; - - // get timestamps of readonly files before validateEdit - Map oldTimeStamps= createModificationStampMap(readOnlyFiles); - - IFile[] files= (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]); - IStatus status= ResourcesPlugin.getWorkspace().validateEdit(files, shell); - if (! status.isOK()) { - String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, message, status); //$NON-NLS-1$ - return false; - } - - IStatus modified= null; - Map newTimeStamps= createModificationStampMap(readOnlyFiles); - for (Iterator iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) { - IFile file= (IFile) iter.next(); - if (file.isReadOnly()) { - IStatus entry= new Status(IStatus.ERROR, - CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), //$NON-NLS-1$ - null); - modified= addStatus(modified, entry); - } else if (! oldTimeStamps.get(file).equals(newTimeStamps.get(file))) { - IStatus entry= new Status(IStatus.ERROR, - CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), //$NON-NLS-1$ - null); - modified= addStatus(modified, entry); - } - } - if (modified != null) { - String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ - ErrorDialog.openError(shell, title, message, modified); - return false; - } - return true; - } - - private static List getReadonlyFiles(IResource[] resources) { - List readOnlyFiles= new ArrayList(); - for (int i= 0; i < resources.length; i++) { - IResource resource= resources[i]; - ResourceAttributes resourceAttributes= resource.getResourceAttributes(); - if (resource.getType() == IResource.FILE && resourceAttributes != null && resourceAttributes.isReadOnly()) - readOnlyFiles.add(resource); - } - return readOnlyFiles; - } - - private static Map createModificationStampMap(List files) { - Map map= new HashMap(); - for (Iterator iter= files.iterator(); iter.hasNext(); ) { - IFile file= (IFile)iter.next(); - map.put(file, new Long(file.getModificationStamp())); - } - return map; - } - - private static IStatus addStatus(IStatus status, IStatus entry) { - - if (status == null) - return entry; - - if (status.isMultiStatus()) { - ((MultiStatus)status).add(entry); - return status; - } - - MultiStatus result= new MultiStatus(CompareUIPlugin.getPluginId(), - VALIDATE_EDIT_PROBLEM, - getString("ValidateEdit.error.unable_to_perform"), null); //$NON-NLS-1$ - result.add(status); - result.add(entry); - return result; - } - - // encoding - - /* - * Returns null if an error occurred. - */ - public static String readString(InputStream is, String encoding) { - if (is == null) - return null; - BufferedReader reader= null; - try { - StringBuffer buffer= new StringBuffer(); - char[] part= new char[2048]; - int read= 0; - reader= new BufferedReader(new InputStreamReader(is, encoding)); - - while ((read= reader.read(part)) != -1) - buffer.append(part, 0, read); - - return buffer.toString(); - - } catch (IOException ex) { - // NeedWork - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException ex) { - // silently ignored - } - } - } - return null; - } - - public static String getCharset(IResource resource) { - if (resource instanceof IEncodedStorage) { - try { - return ((IEncodedStorage)resource).getCharset(); - } catch (CoreException ex) { - // fall through - } - } - return ResourcesPlugin.getEncoding(); - } - - public static byte[] getBytes(String s, String encoding) { - byte[] bytes= null; - if (s != null) { - try { - bytes= s.getBytes(encoding); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - bytes= s.getBytes(); - } - } - return bytes; - } - - public static String readString(IStreamContentAccessor sa) throws CoreException { - InputStream is= sa.getContents(); - String encoding= null; - if (sa instanceof IEncodedStreamContentAccessor) - encoding= ((IEncodedStreamContentAccessor)sa).getCharset(); - if (encoding == null) - encoding= ResourcesPlugin.getEncoding(); - return Utilities.readString(is, encoding); - } - - public static void close(InputStream is) { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - // silently ignored - } - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java deleted file mode 100644 index 3d5dbcc6f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.compare.*; - -import org.eclipse.jface.viewers.Viewer; - -/** - * Creates Viewers from an IConfigurationElement. - */ -public class ViewerDescriptor implements IViewerDescriptor { - - private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - - private IConfigurationElement fConfiguration; - private IViewerCreator fViewerCreator; - private Class fViewerClass; - - public ViewerDescriptor(IConfigurationElement config) { - fConfiguration= config; - } - - public Viewer createViewer(Viewer currentViewer, Composite parent, CompareConfiguration mp) { - - if (currentViewer != null && currentViewer.getClass() == fViewerClass) { - //System.out.println("reused viewer: " + currentViewer.getClass().getName()); - return currentViewer; - } - - if (fViewerCreator == null) { - try { - fViewerCreator= (IViewerCreator) fConfiguration.createExecutableExtension(CLASS_ATTRIBUTE); - } catch (CoreException e) { - // NeedWork - } - } - - if (fViewerCreator != null) { - Viewer viewer= fViewerCreator.createViewer(parent, mp); - if (viewer != null) - fViewerClass= viewer.getClass(); - return viewer; - } - - return null; - } - - public String getExtension() { - return fConfiguration.getAttribute(EXTENSIONS_ATTRIBUTE); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java deleted file mode 100644 index 0be0b1396..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerSwitchingCancelled.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal; - - -public class ViewerSwitchingCancelled extends RuntimeException { - - private static final long serialVersionUID = 1L; - -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java deleted file mode 100644 index ce923314a..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.io.*; -import java.util.ArrayList; -import org.eclipse.compare.rangedifferencer.IRangeComparator; - -/** - * This implementation of IRangeComparator breaks an input stream into lines. - */ -class LineComparator implements IRangeComparator { - - private String[] fLines; - - public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException { - - BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding)); - String line; - ArrayList ar = new ArrayList(); - try { - while ((line = br.readLine()) != null) - ar.add(line); - } catch (IOException e) { - // silently ignored - } -// try { -// is.close(); -// } catch (IOException e1) { -// } - fLines = (String[]) ar.toArray(new String[ar.size()]); - } - - String getLine(int ix) { - return fLines[ix]; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount() - */ - public int getRangeCount() { - return fLines.length; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int) - */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, - int otherIndex) { - String s1 = fLines[thisIndex]; - String s2 = ((LineComparator) other).fLines[otherIndex]; - return s1.equals(s2); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator) - */ - public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { - return false; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java deleted file mode 100644 index 21c7939cf..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -class MergeMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.merge.MergeMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private MergeMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties deleted file mode 100644 index 8b55acb6c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -TextAutoMerge.inputEncodingError= Unsupported encoding for input streams -TextAutoMerge.outputEncodingError= Unsupported encoding for output streams -TextAutoMerge.outputIOError= IO error on writing -TextAutoMerge.conflict= Conflict: cannot auto merge \ No newline at end of file diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java deleted file mode 100644 index c7bc3fe30..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.merge; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import org.eclipse.compare.*; -import org.eclipse.compare.rangedifferencer.RangeDifference; -import org.eclipse.compare.rangedifferencer.RangeDifferencer; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * A simple merger for streams containing text lines. - */ -public class TextStreamMerger implements IStreamMerger { - - /* - * (non-Javadoc) - * - * @see org.eclipse.compare.internal.merge.IAutoMerger#automerge(java.io.OutputStream, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.resources.IEncodedStorage, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus merge(OutputStream output, String outputEncoding, - InputStream ancestor, String ancestorEncoding, - InputStream target, String targetEncoding, - InputStream other, String otherEncoding, - IProgressMonitor monitor) { - - LineComparator a, t, o; - - try { - a= new LineComparator(ancestor, ancestorEncoding); - t= new LineComparator(target, targetEncoding); - o= new LineComparator(other, otherEncoding); - } catch (UnsupportedEncodingException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.inputEncodingError"), e); //$NON-NLS-1$ - } - - try { - char lineSeparator= '\n'; - - RangeDifference[] diffs = RangeDifferencer.findRanges(monitor, a, t, o); - - for (int i = 0; i < diffs.length; i++) { - RangeDifference rd = diffs[i]; - switch (rd.kind()) { - case RangeDifference.ANCESTOR: // pseudo conflict - case RangeDifference.NOCHANGE: - case RangeDifference.RIGHT: - for (int j = rd.rightStart(); j < rd.rightEnd(); j++) { - String s= o.getLine(j); - output.write(s.getBytes(outputEncoding)); - output.write(lineSeparator); - } - break; - - case RangeDifference.LEFT: - for (int j = rd.leftStart(); j < rd.leftEnd(); j++) { - String s= t.getLine(j); - output.write(s.getBytes(outputEncoding)); - output.write(lineSeparator); - } - break; - - case RangeDifference.CONFLICT: - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, CONFLICT, MergeMessages.getString("TextAutoMerge.conflict"), null); //$NON-NLS-1$ - - default: - break; - } - } - - } catch (UnsupportedEncodingException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputEncodingError"), e); //$NON-NLS-1$ - } catch (IOException e) { - return new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputIOError"), e); //$NON-NLS-1$ - } - - return Status.OK_STATUS; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Attic/LineReader.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Attic/LineReader.java deleted file mode 100644 index f4ceeeb01..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Attic/LineReader.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.util.*; - -import org.eclipse.jface.util.Assert; - -/* package */ class LineReader { - - private boolean fHaveChar= false; - private int fLastChar; - private boolean fSawEOF= false; - private BufferedReader fReader; - private boolean fIgnoreSingleCR= false; - - - /* package */ LineReader(BufferedReader reader) { - fReader= reader; - Assert.isNotNull(reader); - } - - void ignoreSingleCR() { - fIgnoreSingleCR= true; - } - - /** - * Reads a line of text. A line is considered to be terminated by any one - * of a line feed ('\n'), a carriage return ('\r'), or a carriage return - * followed immediately by a linefeed. - * @return A string containing the contents of the line including - * the line-termination characters, or null if the end of the - * stream has been reached - * @exception IOException If an I/O error occurs - */ - /* package */ String readLine() throws IOException { - StringBuffer sb= null; - - while (!fSawEOF) { - int c= readChar(); - if (c == -1) { - fSawEOF= true; - break; - } - if (sb == null) - sb= new StringBuffer(); - sb.append((char)c); - if (c == '\n') - break; - if (c == '\r') { - c= readChar(); - if (c == -1) { - fSawEOF= true; - break; // EOF - } - if (c != '\n') { - if (fIgnoreSingleCR) { - sb.append((char)c); - continue; - } - fHaveChar= true; - fLastChar= c; - } else - sb.append((char)c); - break; - } - } - - if (sb != null) - return sb.toString(); - return null; - } - - /* package */ void close() { - try { - fReader.close(); - } catch (IOException ex) { - // silently ignored - } - } - - /* package */ List readLines() { - try { - List lines= new ArrayList(); - String line; - while ((line= readLine()) != null) - lines.add(line); - return lines; - } catch (IOException ex) { - // NeedWork - //System.out.println("error while reading file: " + fileName + "(" + ex + ")"); - } finally { - close(); - } - return null; - } - - /* - * Returns the number of characters in the given string without - * counting a trailing line separator. - */ - /* package */ int lineContentLength(String line) { - if (line == null) - return 0; - int length= line.length(); - for (int i= length-1; i >= 0; i--) { - char c= line.charAt(i); - if (c =='\n' || c == '\r') - length--; - else - break; - } - return length; - } - - //---- private - - private int readChar() throws IOException { - if (fHaveChar) { - fHaveChar= false; - return fLastChar; - } - return fReader.read(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java deleted file mode 100644 index 08b7b9556..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -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.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.ui.IEditorPart; - -import org.eclipse.compare.internal.*; - - -public class CompareWithPatchAction extends BaseCompareAction { - - static class PatchWizardDialog extends WizardDialog { - - PatchWizardDialog(Shell parent, IWizard wizard) { - super(parent, wizard); - - setShellStyle(getShellStyle() | SWT.RESIZE); - setMinimumPageSize(700, 500); - } - } - - protected boolean isEnabled(ISelection selection) { - return Utilities.getResources(selection).length == 1; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.BaseCompareAction#run(org.eclipse.jface.viewers.ISelection) - */ - protected void run(ISelection selection) { - PatchWizard wizard= new PatchWizard(selection); - - if (areAllEditorsSaved()) { - PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard); - dialog.open(); - } - } - - private boolean areAllEditorsSaved(){ - if (CompareUIPlugin.getDirtyEditors().length == 0) - return true; - if (! saveAllDirtyEditors()) - return false; - Shell shell= CompareUIPlugin.getShell(); - try { - // Save isn't cancelable. - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceDescription description= workspace.getDescription(); - boolean autoBuild= description.isAutoBuilding(); - description.setAutoBuilding(false); - workspace.setDescription(description); - try { - new ProgressMonitorDialog(shell).run(false, false, createRunnable()); - } finally { - description.setAutoBuilding(autoBuild); - workspace.setDescription(description); - } - return true; - } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, shell, PatchMessages.getString("PatchAction.ExceptionTitle"), PatchMessages.getString("Exception")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } catch (CoreException e) { - ExceptionHandler.handle(e, shell, PatchMessages.getString("PatchAction.ExceptionTitle"), PatchMessages.getString("Exception")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } catch (InterruptedException e) { - Assert.isTrue(false); // Can't happen. Operation isn't cancelable. - return false; - } - } - - private IRunnableWithProgress createRunnable() { - return new IRunnableWithProgress() { - public void run(IProgressMonitor pm) { - IEditorPart[] editorsToSave= CompareUIPlugin.getDirtyEditors(); - pm.beginTask(PatchMessages.getString("PatchAction.SavingDirtyEditorsTask"), editorsToSave.length); //$NON-NLS-1$ - for (int i= 0; i < editorsToSave.length; i++) { - editorsToSave[i].doSave(new SubProgressMonitor(pm, 1)); - pm.worked(1); - } - pm.done(); - } - }; - } - - private boolean saveAllDirtyEditors() { - if (ComparePreferencePage.getSaveAllEditors()) //must save everything - return true; - ListDialog dialog= new ListDialog(CompareUIPlugin.getShell()) { - protected Control createDialogArea(Composite parent) { - Composite result= (Composite) super.createDialogArea(parent); - final Button check= new Button(result, SWT.CHECK); - check.setText(PatchMessages.getString("PatchAction.AlwaysSaveQuestion")); //$NON-NLS-1$ - check.setSelection(ComparePreferencePage.getSaveAllEditors()); - check.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - ComparePreferencePage.setSaveAllEditors(check.getSelection()); - } - } - ); - applyDialogFont(result); - return result; - } - }; - dialog.setTitle(PatchMessages.getString("PatchAction.SaveAllQuestion")); //$NON-NLS-1$ - dialog.setAddCancelButton(true); - dialog.setLabelProvider(createDialogLabelProvider()); - dialog.setMessage(PatchMessages.getString("PatchAction.SaveAllDescription")); //$NON-NLS-1$ - dialog.setContentProvider(new ListContentProvider()); - dialog.setInput(Arrays.asList(CompareUIPlugin.getDirtyEditors())); - return dialog.open() == Window.OK; - } - - private ILabelProvider createDialogLabelProvider() { - return new LabelProvider() { - public Image getImage(Object element) { - return ((IEditorPart) element).getTitleImage(); - } - public String getText(Object element) { - return ((IEditorPart) element).getTitle(); - } - }; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java deleted file mode 100644 index ad5899bbe..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.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.compare.internal.patch; - -import java.util.*; - -import org.eclipse.core.runtime.IPath; - -import org.eclipse.compare.structuremergeviewer.Differencer; - - -/* package */ class Diff { - - IPath fOldPath, fNewPath; - long fOldDate, fNewDate; // if 0: no file - List fHunks= new ArrayList(); - boolean fMatches= false; - private boolean fIsEnabled2= true; - String fRejected; - - - /* package */ Diff(IPath oldPath, long oldDate, IPath newPath, long newDate) { - fOldPath= oldPath; - fOldDate= oldPath == null ? 0 : oldDate; - fNewPath= newPath; - fNewDate= newPath == null ? 0 : newDate; - } - - boolean isEnabled() { - return fIsEnabled2; - } - - void setEnabled(boolean b) { - fIsEnabled2= b; - } - - void reverse() { - IPath tp= fOldPath; - fOldPath= fNewPath; - fNewPath= tp; - - long t= fOldDate; - fOldDate= fNewDate; - fNewDate= t; - - Iterator iter= fHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - hunk.reverse(); - } - } - - Hunk[] getHunks() { - return (Hunk[]) fHunks.toArray(new Hunk[fHunks.size()]); - } - - IPath getPath() { - if (fOldPath != null) - return fOldPath; - return fNewPath; - } - - void finish() { - if (fHunks.size() == 1) { - Hunk h= (Hunk) fHunks.get(0); - if (h.fNewLength == 0) { - fNewDate= 0; - fNewPath= fOldPath; - } - } - } - - /* package */ void add(Hunk hunk) { - fHunks.add(hunk); - } - - /* package */ int getType() { - if (fOldDate == 0) - return Differencer.ADDITION; - if (fNewDate == 0) - return Differencer.DELETION; - return Differencer.CHANGE; - } - - /* package */ String getDescription(int strip) { - IPath path= fOldPath; - if (fOldDate == 0) - path= fNewPath; - if (strip > 0 && strip < path.segmentCount()) - path= path.removeFirstSegments(strip); - return path.toOSString(); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java deleted file mode 100644 index 24a336532..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.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.compare.internal.patch; - -import java.util.List; - -/** - * A Hunk describes a range of changed lines and some context lines. - */ -/* package */ class Hunk { - - Diff fParent; - int fOldStart, fOldLength; - int fNewStart, fNewLength; - String[] fLines; - boolean fMatches= false; - private boolean fIsEnabled= true; - - - /* package */ Hunk(Diff parent, int[] oldRange, int[] newRange, List lines) { - - fParent= parent; - if (fParent != null) - fParent.add(this); - - if (oldRange[0] > 0) - fOldStart= oldRange[0]-1; // line number start at 0! - else - fOldStart= 0; - fOldLength= oldRange[1]; - if (newRange[0] > 0) - fNewStart= newRange[0]-1; // line number start at 0! - else - fNewStart= 0; - fNewLength= newRange[1]; - - fLines= (String[]) lines.toArray(new String[lines.size()]); - } - - boolean isEnabled() { - return fIsEnabled; - } - - void setEnabled(boolean enable) { - fIsEnabled= enable; - } - - void reverse() { - int t= fOldStart; - fOldStart= fNewStart; - fNewStart= t; - - t= fOldLength; - fOldLength= fNewLength; - fNewLength= t; - - for (int i= 0; i < fLines.length; i++) { - String line= fLines[i]; - char c= line.charAt(0); - switch (c) { - case '+': - fLines[i]= '-' + line.substring(1); - break; - case '-': - fLines[i]= '+' + line.substring(1); - break; - default: - break; - } - } - } - - /* - * Returns the contents of this hunk. - * Each line starts with a control character. Their meaning is as follows: - *

    - *
  • - * '+': add the line - *
  • - * '-': delete the line - *
  • - * ' ': no change, context line - *
- */ - String getContent() { - StringBuffer sb= new StringBuffer(); - for (int i= 0; i < fLines.length; i++) { - String line= fLines[i]; - sb.append(line.substring(0, Patcher.length(line))); - sb.append('\n'); - } - return sb.toString(); - } - - /* - * Returns a descriptive String for this hunk. - * It is in the form old_start,old_length -> new_start,new_length. - */ - String getDescription() { - StringBuffer sb= new StringBuffer(); - sb.append(Integer.toString(fOldStart)); - sb.append(','); - sb.append(Integer.toString(fOldLength)); - sb.append(" -> "); //$NON-NLS-1$ - sb.append(Integer.toString(fNewStart)); - sb.append(','); - sb.append(Integer.toString(fNewLength)); - return sb.toString(); - } - - String getRejectedDescription() { - StringBuffer sb= new StringBuffer(); - sb.append("@@ -"); //$NON-NLS-1$ - sb.append(Integer.toString(fOldStart)); - sb.append(','); - sb.append(Integer.toString(fOldLength)); - sb.append(" +"); //$NON-NLS-1$ - sb.append(Integer.toString(fNewStart)); - sb.append(','); - sb.append(Integer.toString(fNewLength)); - sb.append(" @@"); //$NON-NLS-1$ - return sb.toString(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java deleted file mode 100644 index 6ec5fd293..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java +++ /dev/null @@ -1,532 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.text.MessageFormat; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.*; - -import org.eclipse.ui.help.*; -import org.eclipse.ui.model.*; - -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - - -/* package */ class InputPatchPage extends WizardPage { - - // constants - protected static final int SIZING_TEXT_FIELD_WIDTH= 250; - protected static final int COMBO_HISTORY_LENGTH= 5; - - // dialog store id constants - private final static String PAGE_NAME= "PatchWizardPage1"; //$NON-NLS-1$ - private final static String STORE_PATCH_FILES_ID= PAGE_NAME + ".PATCH_FILES"; //$NON-NLS-1$ - private final static String STORE_USE_CLIPBOARD_ID= PAGE_NAME + ".USE_CLIPBOARD"; //$NON-NLS-1$ - - static final char SEPARATOR = System.getProperty ("file.separator").charAt (0); //$NON-NLS-1$ - - private boolean fShowError= false; - - // SWT widgets - private Button fUseClipboardButton; - private Combo fPatchFileNameField; - private Button fPatchFileBrowseButton; - private Button fUsePatchFileButton; - private Group fPatchFileGroup; - private CheckboxTreeViewer fPatchTargets; - private PatchWizard fPatchWizard; - - - InputPatchPage(PatchWizard pw) { - super("InputPatchPage", PatchMessages.getString("InputPatchPage.title"), null); //$NON-NLS-1$ //$NON-NLS-2$ - fPatchWizard= pw; - setMessage(PatchMessages.getString("InputPatchPage.message")); //$NON-NLS-1$ - } - - /* - * Get a path from the supplied text widget. - * @return org.eclipse.core.runtime.IPath - */ - protected IPath getPathFromText(Text textField) { - return (new Path(textField.getText())).makeAbsolute(); - } - - /* package */ String getPatchName() { - if (getUseClipboard()) - return PatchMessages.getString("InputPatchPage.Clipboard"); //$NON-NLS-1$ - return getPatchFilePath(); - } - - public void createControl(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - setControl(composite); - - Label l= new Label(composite, SWT.NONE); - l.setText(PatchMessages.getString("InputPatchPage.SelectInput")); //$NON-NLS-1$ - buildInputGroup(composite); - - new Label(composite, SWT.NONE); // a spacer - - buildPatchFileGroup(composite); - - restoreWidgetValues(); - - updateWidgetEnablements(); - - Dialog.applyDialogFont(composite); - WorkbenchHelp.setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE); - } - - /* (non-JavaDoc) - * Method declared in IWizardPage. - */ - public IWizardPage getNextPage() { - - Patcher patcher= ((PatchWizard) getWizard()).getPatcher(); - - String source; - // Create a reader for the input - Reader reader= null; - if (getUseClipboard()) { - Control c= getControl(); - if (c != null) { - Clipboard clipboard= new Clipboard(c.getDisplay()); - Object o= clipboard.getContents(TextTransfer.getInstance()); - clipboard.dispose(); - if (o instanceof String) - reader= new StringReader((String)o); - } - source= PatchMessages.getString("InputPatchPage.Clipboard.title"); //$NON-NLS-1$ - } else { - String patchFilePath= getPatchFilePath(); - if (patchFilePath != null) { - try { - reader= new FileReader(patchFilePath); - } catch (FileNotFoundException ex) { - MessageDialog.openError(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$ - PatchMessages.getString("InputPatchPage.PatchFileNotFound.message")); //$NON-NLS-1$ - } - } - source= PatchMessages.getString("InputPatchPage.PatchFile.title"); //$NON-NLS-1$ - } - - // parse the input - if (reader != null) { - try { - patcher.parse(new BufferedReader(reader)); - } catch (IOException ex) { - MessageDialog.openError(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$ - PatchMessages.getString("InputPatchPage.ParseError.message")); //$NON-NLS-1$ - } - - try { - reader.close(); - } catch (IOException x) { - // silently ignored - } - } - - Diff[] diffs= patcher.getDiffs(); - if (diffs == null || diffs.length == 0) { - String format= PatchMessages.getString("InputPatchPage.NoDiffsFound.format"); //$NON-NLS-1$ - String message= MessageFormat.format(format, new String[] { source }); - MessageDialog.openInformation(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), message); //$NON-NLS-1$ - return this; - } - - // if selected target is file ensure that patch file - // contains only a patch for a single file - IResource target= fPatchWizard.getTarget(); - if (target instanceof IFile && diffs.length > 1) { - String format= PatchMessages.getString("InputPatchPage.SingleFileError.format"); //$NON-NLS-1$ - String message= MessageFormat.format(format, new String[] { source }); - MessageDialog.openInformation(null, - PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), message); //$NON-NLS-1$ - return this; - } - - // guess prefix count - int guess= 0; // guessPrefix(diffs); - patcher.setStripPrefixSegments(guess); - - return super.getNextPage(); - } - - /* (non-JavaDoc) - * Method declared in IWizardPage. - */ - public boolean canFlipToNextPage() { - // we can't call getNextPage to determine if flipping is allowed since computing - // the next page is quite expensive. So we say yes if the page is complete. - return isPageComplete(); - } - - private void setEnablePatchFile(boolean enable) { - fPatchFileNameField.setEnabled(enable); - fPatchFileBrowseButton.setEnabled(enable); - } - - /* - * Create the group for selecting the patch file - */ - private void buildPatchFileGroup(Composite parent) { - - fPatchFileGroup= new Group(parent, SWT.NONE); - fPatchFileGroup.setText(PatchMessages.getString("InputPatchPage.SelectPatch.title")); //$NON-NLS-1$ - GridLayout layout= new GridLayout(); - layout.numColumns= 3; - fPatchFileGroup.setLayout(layout); - fPatchFileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // 1st row - fUsePatchFileButton= new Button(fPatchFileGroup, SWT.RADIO); - fUsePatchFileButton.setText(PatchMessages.getString("InputPatchPage.FileButton.text")); //$NON-NLS-1$ - - fPatchFileNameField= new Combo(fPatchFileGroup, SWT.BORDER); - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - //gd.horizontalIndent= 8; - gd.widthHint= SIZING_TEXT_FIELD_WIDTH; - fPatchFileNameField.setLayoutData(gd); - - fPatchFileBrowseButton= new Button(fPatchFileGroup, SWT.PUSH); - fPatchFileBrowseButton.setText(PatchMessages.getString("InputPatchPage.ChooseFileButton.text")); //$NON-NLS-1$ - fPatchFileBrowseButton.setLayoutData(new GridData()); - - // 2nd row - fUseClipboardButton= new Button(fPatchFileGroup, SWT.RADIO); - fUseClipboardButton.setText(PatchMessages.getString("InputPatchPage.UseClipboardButton.text")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalSpan= 2; - fUseClipboardButton.setLayoutData(gd); - - - // Add listeners - fUsePatchFileButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fShowError= true; - setEnablePatchFile(!getUseClipboard()); - updateWidgetEnablements(); - } - } - ); - fPatchFileNameField.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setSourceName(fPatchFileNameField.getText()); - updateWidgetEnablements(); - } - } - ); - fPatchFileNameField.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - fShowError= true; - updateWidgetEnablements(); - } - } - ); - fPatchFileBrowseButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handlePatchFileBrowseButtonPressed(); - updateWidgetEnablements(); - } - } - ); - - //fPatchFileNameField.setFocus(); - } - - private void buildInputGroup(Composite parent) { - - PatchWizard pw= (PatchWizard) getWizard(); - IResource target= pw.getTarget(); - IWorkspace workspace= target.getWorkspace(); - IWorkspaceRoot root= workspace.getRoot(); - - Tree tree= new Tree(parent, SWT.BORDER); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= 200; - tree.setLayoutData(gd); - - fPatchTargets= new CheckboxTreeViewer(tree); - fPatchTargets.setLabelProvider(new WorkbenchLabelProvider()); - fPatchTargets.setContentProvider(new WorkbenchContentProvider()); - fPatchTargets.setSorter(new WorkbenchViewerSorter()); - fPatchTargets.setInput(root); - if (target != null) { - fPatchTargets.expandToLevel(target, 0); - fPatchTargets.setSelection(new StructuredSelection(target)); - } - - // register listeners - fPatchTargets.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - fPatchWizard.setTargets(Utilities.getResources(event.getSelection())); - updateWidgetEnablements(); - } - } - ); - } - - /** - * Updates the enable state of this page's controls. - */ - private void updateWidgetEnablements() { - - String error= null; - - ISelection selection= fPatchTargets.getSelection(); - boolean anySelected= selection != null && !selection.isEmpty(); - if (!anySelected) - error= PatchMessages.getString("InputPatchPage.NothingSelected.message"); //$NON-NLS-1$ - - boolean gotPatch= false; - if (getUseClipboard()) { - Control c= getControl(); - if (c != null) { - Clipboard clipboard= new Clipboard(c.getDisplay()); - Object o= clipboard.getContents(TextTransfer.getInstance()); - clipboard.dispose(); - if (o instanceof String) { - String s= ((String) o).trim(); - if (s.length() > 0) - gotPatch= true; - else - error= PatchMessages.getString("InputPatchPage.ClipboardIsEmpty.message"); //$NON-NLS-1$ - } else - error= PatchMessages.getString("InputPatchPage.NoTextInClipboard.message"); //$NON-NLS-1$ - } else - error= PatchMessages.getString("InputPatchPage.CouldNotReadClipboard.message"); //$NON-NLS-1$ - } else { - String path= fPatchFileNameField.getText(); - if (path != null && path.length() > 0) { - File file= new File(path); - gotPatch= file.exists() && file.isFile() && file.length() > 0; - if (!gotPatch) - error= PatchMessages.getString("InputPatchPage.CannotLocatePatch.message") + path; //$NON-NLS-1$ - } else { - error= PatchMessages.getString("InputPatchPage.NoFileName.message"); //$NON-NLS-1$ - } - } - - setPageComplete(anySelected && gotPatch); - if (fShowError) - setErrorMessage(error); - } - - protected void handlePatchFileBrowseButtonPressed() { - FileDialog dialog= new FileDialog(getShell(), SWT.NONE); - dialog.setText(PatchMessages.getString("InputPatchPage.SelectPatchFileDialog.title")); //$NON-NLS-1$ - String patchFilePath= getPatchFilePath(); - if (patchFilePath != null) { - int lastSegment= patchFilePath.lastIndexOf(SEPARATOR); - if (lastSegment > 0) { - patchFilePath= patchFilePath.substring(0, lastSegment); - } - } - dialog.setFilterPath(patchFilePath); - String res= dialog.open(); - if (res == null) - return; - - patchFilePath= dialog.getFileName(); - IPath filterPath= new Path(dialog.getFilterPath()); - IPath path= filterPath.append(patchFilePath).makeAbsolute(); - patchFilePath= path.toOSString(); - //fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString()); - - fPatchFileNameField.setText(patchFilePath); - //setSourceName(patchFilePath); - } - - /** - * Sets the source name of the import to be the supplied path. - * Adds the name of the path to the list of items in the - * source combo and selects it. - * - * @param path the path to be added - */ - protected void setSourceName(String path) { - - if (path.length() > 0) { - - String[] currentItems= fPatchFileNameField.getItems(); - int selectionIndex= -1; - for (int i= 0; i < currentItems.length; i++) - if (currentItems[i].equals(path)) - selectionIndex= i; - - if (selectionIndex < 0) { // not found in history - int oldLength= currentItems.length; - String[] newItems= new String[oldLength + 1]; - System.arraycopy(currentItems, 0, newItems, 0, oldLength); - newItems[oldLength]= path; - fPatchFileNameField.setItems(newItems); - selectionIndex= oldLength; - } - fPatchFileNameField.select(selectionIndex); - - //resetSelection(); - } - } - - /** - * The Finish button was pressed. Try to do the required work now and answer - * a boolean indicating success. If false is returned then the wizard will - * not close. - * - * @return boolean - */ - public boolean finish() { -// if (!ensureSourceIsValid()) -// return false; - - saveWidgetValues(); - -// Iterator resourcesEnum = getSelectedResources().iterator(); -// List fileSystemObjects = new ArrayList(); -// while (resourcesEnum.hasNext()) { -// fileSystemObjects.add( -// ((FileSystemElement) resourcesEnum.next()).getFileSystemObject()); -// } -// -// if (fileSystemObjects.size() > 0) -// return importResources(fileSystemObjects); -// -// MessageDialog -// .openInformation( -// getContainer().getShell(), -// DataTransferMessages.getString("DataTransfer.information"), //$NON-NLS-1$ -// DataTransferMessages.getString("FileImport.noneSelected")); //$NON-NLS-1$ -// -// return false; - - return true; - } - - /** - * Use the dialog store to restore widget values to the values that they held - * last time this wizard was used to completion - */ - private void restoreWidgetValues() { - - boolean useClipboard= false; - - IDialogSettings settings= getDialogSettings(); - if (settings != null) { - - useClipboard= settings.getBoolean(STORE_USE_CLIPBOARD_ID); - - // set filenames history - String[] sourceNames= settings.getArray(STORE_PATCH_FILES_ID); - if (sourceNames != null) - for (int i= 0; i < sourceNames.length; i++) - if (sourceNames[i] != null && sourceNames[i].length() > 0) - fPatchFileNameField.add(sourceNames[i]); - - // set patch file path - String patchFilePath= settings.get(STORE_PATCH_FILES_ID); - if (patchFilePath != null) - setSourceName(patchFilePath); - } - - // set 'Use Clipboard' radio buttons - setUseClipboard(useClipboard); - } - - /** - * Since Finish was pressed, write widget values to the dialog store so that they - * will persist into the next invocation of this wizard page - */ - void saveWidgetValues() { - IDialogSettings settings= getDialogSettings(); - if (settings != null) { - - settings.put(STORE_USE_CLIPBOARD_ID, getUseClipboard()); - settings.put(STORE_PATCH_FILES_ID, getPatchFilePath()); - - // update source names history - String[] sourceNames= settings.getArray(STORE_PATCH_FILES_ID); - if (sourceNames == null) - sourceNames= new String[0]; - - sourceNames= addToHistory(sourceNames, getPatchFilePath()); - settings.put(STORE_PATCH_FILES_ID, sourceNames); - } - } - - // static helpers - - private void setUseClipboard(boolean useClipboard) { - if (useClipboard) - fUseClipboardButton.setSelection(true); - else - fUsePatchFileButton.setSelection(true); - setEnablePatchFile(!useClipboard); - } - - private boolean getUseClipboard() { - if (fUseClipboardButton != null) - return fUseClipboardButton.getSelection(); - return false; - } - - private String getPatchFilePath() { - if (fPatchFileNameField != null) - return fPatchFileNameField.getText(); - return ""; //$NON-NLS-1$ - } - - /* - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length COMBO_HISTORY_LENGTH. - * - * @param history the current history - * @param newEntry the entry to add to the history - */ - protected static String[] addToHistory(String[] history, String newEntry) { - java.util.ArrayList l= new java.util.ArrayList(java.util.Arrays.asList(history)); - - l.remove(newEntry); - l.add(0,newEntry); - - // since only one new item was added, we can be over the limit - // by at most one item - if (l.size() > COMBO_HISTORY_LENGTH) - l.remove(COMBO_HISTORY_LENGTH); - - return (String[]) l.toArray(new String[l.size()]); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java deleted file mode 100644 index f4ceeeb01..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.util.*; - -import org.eclipse.jface.util.Assert; - -/* package */ class LineReader { - - private boolean fHaveChar= false; - private int fLastChar; - private boolean fSawEOF= false; - private BufferedReader fReader; - private boolean fIgnoreSingleCR= false; - - - /* package */ LineReader(BufferedReader reader) { - fReader= reader; - Assert.isNotNull(reader); - } - - void ignoreSingleCR() { - fIgnoreSingleCR= true; - } - - /** - * Reads a line of text. A line is considered to be terminated by any one - * of a line feed ('\n'), a carriage return ('\r'), or a carriage return - * followed immediately by a linefeed. - * @return A string containing the contents of the line including - * the line-termination characters, or null if the end of the - * stream has been reached - * @exception IOException If an I/O error occurs - */ - /* package */ String readLine() throws IOException { - StringBuffer sb= null; - - while (!fSawEOF) { - int c= readChar(); - if (c == -1) { - fSawEOF= true; - break; - } - if (sb == null) - sb= new StringBuffer(); - sb.append((char)c); - if (c == '\n') - break; - if (c == '\r') { - c= readChar(); - if (c == -1) { - fSawEOF= true; - break; // EOF - } - if (c != '\n') { - if (fIgnoreSingleCR) { - sb.append((char)c); - continue; - } - fHaveChar= true; - fLastChar= c; - } else - sb.append((char)c); - break; - } - } - - if (sb != null) - return sb.toString(); - return null; - } - - /* package */ void close() { - try { - fReader.close(); - } catch (IOException ex) { - // silently ignored - } - } - - /* package */ List readLines() { - try { - List lines= new ArrayList(); - String line; - while ((line= readLine()) != null) - lines.add(line); - return lines; - } catch (IOException ex) { - // NeedWork - //System.out.println("error while reading file: " + fileName + "(" + ex + ")"); - } finally { - close(); - } - return null; - } - - /* - * Returns the number of characters in the given string without - * counting a trailing line separator. - */ - /* package */ int lineContentLength(String line) { - if (line == null) - return 0; - int length= line.length(); - for (int i= length-1; i >= 0; i--) { - char c= line.charAt(i); - if (c =='\n' || c == '\r') - length--; - else - break; - } - return length; - } - - //---- private - - private int readChar() throws IOException { - if (fHaveChar) { - fHaveChar= false; - return fLastChar; - } - return fReader.read(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java deleted file mode 100644 index 7b1b0a702..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -public class PatchErrorDialog { - - private PatchErrorDialog() { - // no instance. - } - -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java deleted file mode 100644 index eac554ccf..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class PatchMessages { - - private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.patch.PatchMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private PatchMessages() { - // nothing to do - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties deleted file mode 100644 index e0e37821e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties +++ /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 -############################################################################### - -# -# 'Compare with Patch' Action -# -PatchAction.ExceptionTitle=Saving Resources -PatchAction.Exception=Unexpected exception. See log for details -PatchAction.SavingDirtyEditorsTask=Saving dirty editors -PatchAction.AlwaysSaveQuestion=&Always save all modified resources automatically prior to patching -PatchAction.SaveAllQuestion=Save all modified resources -PatchAction.SaveAllDescription=All modified resources have to be saved before this operation.\nClick 'OK' to confirm or click 'Cancel'. - -# -# PatchWizard -# -PatchWizard.title=Apply Patch -PatchWizard.unexpectedException.message= Unexpected exception while applying the patch. See log for a detailed error description. - -# -# InputPatchPage -# -InputPatchPage.title= Patch Input Specification -InputPatchPage.message= Define the resource to patch and the patch to apply -InputPatchPage.Clipboard=Clipboard -InputPatchPage.SelectInput=Select a single file or folder to patch: -InputPatchPage.PatchErrorDialog.title=Patch Error -InputPatchPage.PatchErrorDialog=Patch Error -InputPatchPage.SelectPatch.title=Select Patch -InputPatchPage.FileButton.text=Fil&e -InputPatchPage.ChooseFileButton.text=&Browse... -InputPatchPage.UseClipboardButton.text=&Clipboard -InputPatchPage.NothingSelected.message=Select a file or folder to be patched -InputPatchPage.ClipboardIsEmpty.message=Clipboard is empty -InputPatchPage.NoTextInClipboard.message=Clipboard does not contain text -InputPatchPage.CouldNotReadClipboard.message=Cannot retrieve clipboard contents -InputPatchPage.CannotLocatePatch.message=Cannot locate patch file: -InputPatchPage.NoFileName.message=No file name -#SI - Select file name ? -InputPatchPage.SelectPatchFileDialog.title=Select Patch File -InputPatchPage.PatchFileNotFound.message=Patch file not found. -InputPatchPage.ParseError.message=Error while parsing patch -InputPatchPage.Clipboard.title=Clipboard -InputPatchPage.PatchFile.title=Patch file -InputPatchPage.NoDiffsFound.format={0} does not contain valid patch. -InputPatchPage.SingleFileError.format={0} contains multiple patches. You cannot apply them to a single file. - -# -# PreviewPatchPage -# -PreviewPatchPage.title= Verify Patch -PreviewPatchPage.message= The tree shows the contents of the patch.\nA checked item indicates that a patch can be applied successfully. To remove an item, clear its checkbox. -PreviewPatchPage.Left.title= Original -PreviewPatchPage.Right.title= Result -PreviewPatchPage.PatchOptions.title=Patch Options -PreviewPatchPage.IgnoreSegments.text=&Ignore leading path name segments: -PreviewPatchPage.ReversePatch.text=&Reverse patch -PreviewPatchPage.FuzzFactor.text=&Maximum fuzz factor: -PreviewPatchPage.FuzzFactor.tooltip=Allow Context to Shift This Number of Lines from the Original Location -PreviewPatchPage.IgnoreWhitespace.text=Ignore &white space -PreviewPatchPage.NoName.text=no name -PreviewPatchPage.FileExists.error=(file already exists) -PreviewPatchPage.FileDoesNotExist.error=(file does not exist) -PreviewPatchPage.NoMatch.error=(no match) -PreviewPatchPage.FileIsReadOnly.error=(file is read-only) -PreviewPatchPage.GuessFuzz.text= &Guess -PreviewPatchPage.GuessFuzzProgress.text= Guessing Fuzz Factor... -PreviewPatchPage.GuessFuzzProgress.format= {0} (hunk #{1}) - -# -# Patcher -# -Patcher.ErrorDialog.title=title -Patcher.DeleteError.message=Error while deleting resource -Patcher.UpdateError.message=Error while updating resource -Patcher.RefreshError.message=Error while refreshing from local -Patcher.Marker.message=Rejected patch -Patcher.Task.message=Patching - -# -# PatchCompareInput -# -PatchCompareInput.RightTitle.format= Patch: {0} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java deleted file mode 100644 index 6f7b1f5e5..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.Wizard; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.compare.internal.*; - - -/* package */ class PatchWizard extends Wizard { - - // dialog store id constants - private final static String DIALOG_SETTINGS_KEY= "PatchWizard"; //$NON-NLS-1$ - - private boolean fHasNewDialogSettings; - - private InputPatchPage fPatchWizardPage; - - private Patcher fPatcher; - private IResource fTarget; - - - /* - * Creates a wizard for applying a patch file to the workspace. - */ - /* package */ PatchWizard(ISelection selection) { - - setDefaultPageImageDescriptor(CompareUIPlugin.getImageDescriptor("wizban/applypatch_wizban.gif")); //$NON-NLS-1$ - setWindowTitle(PatchMessages.getString("PatchWizard.title")); //$NON-NLS-1$ - - setTargets(Utilities.getResources(selection)); - - fPatcher= new Patcher(); - - IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); //$NON-NLS-1$ - if (section == null) - fHasNewDialogSettings= true; - else { - fHasNewDialogSettings= false; - setDialogSettings(section); - } - } - - Patcher getPatcher() { - return fPatcher; - } - - IResource getTarget() { - return fTarget; - } - - void setTargets(IResource[] targets) { - if (targets != null && targets.length > 0) - fTarget= targets[0]; // right now we can only deal with a single selection - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public void addPages() { - super.addPages(); - - addPage(fPatchWizardPage= new InputPatchPage(this)); - addPage(new PreviewPatchPage(this)); - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public boolean needsProgressMonitor() { - return true; - } - - /* (non-Javadoc) - * Method declared on IWizard. - */ - public boolean performFinish() { - - fPatcher.setName(fPatchWizardPage.getPatchName()); - - try { - WorkspaceModifyOperation op= new WorkspaceModifyOperation(fTarget.getProject()) { - protected void execute(IProgressMonitor monitor) throws InvocationTargetException { - try { - fPatcher.applyAll(getTarget(), monitor, getShell(), PatchMessages.getString("PatchWizard.title")); //$NON-NLS-1$ - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }; - getContainer().run(true, false, op); - - } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, - PatchMessages.getString("PatchWizard.title"), //$NON-NLS-1$ - PatchMessages.getString("PatchWizard.unexpectedException.message")); //$NON-NLS-1$ - } catch (InterruptedException e) { - // cannot happen - // NeedWork: use assert! - } - - // Save the dialog settings - if (fHasNewDialogSettings) { - IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); - section= workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY); - setDialogSettings(section); - } - - fPatchWizardPage.saveWidgetValues(); - //fPreviewPatchPage.saveWidgetValues(); - - return true; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java deleted file mode 100644 index 29e3827d1..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java +++ /dev/null @@ -1,1081 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.text.*; -import java.util.*; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.resources.*; - -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.Differencer; - -/** - * A Patcher - * - knows how to parse various patch file formats into some in-memory structure, - * - holds onto the parsed data and the options to use when applying the patches, - * - knows how to apply the patches to files and folders. - */ -public class Patcher { - - private static final boolean DEBUG= false; - - private static final String DEV_NULL= "/dev/null"; //$NON-NLS-1$ - - private static final String REJECT_FILE_EXTENSION= ".rej"; //$NON-NLS-1$ - - private static final String MARKER_TYPE= "org.eclipse.compare.rejectedPatchMarker"; //$NON-NLS-1$ - - // diff formats -// private static final int CONTEXT= 0; -// private static final int ED= 1; -// private static final int NORMAL= 2; -// private static final int UNIFIED= 3; - - // we recognize the following date/time formats - private static DateFormat[] DATE_FORMATS= new DateFormat[] { - new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy"), //$NON-NLS-1$ - new SimpleDateFormat("yyyy/MM/dd kk:mm:ss"), //$NON-NLS-1$ - new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy", Locale.US) //$NON-NLS-1$ - }; - - private String fName; - private Diff[] fDiffs; - // patch options - private int fStripPrefixSegments; - private int fFuzz; - private boolean fIgnoreWhitespace= false; - private boolean fIgnoreLineDelimiter= true; - private boolean fPreserveLineDelimiters= false; - private boolean fReverse= false; - private boolean fAdjustShift= true; - - - Patcher() { - // nothing to do - } - - //---- options - - void setName(String name) { - fName= name; - } - - String getName() { - return fName; - } - - /* - * Returns an array of Diffs after a sucessfull call to parse. - * If parse hasn't been called returns null. - */ - Diff[] getDiffs() { - return fDiffs; - } - - IPath getPath(Diff diff) { - IPath path= diff.getPath(); - if (fStripPrefixSegments > 0 && fStripPrefixSegments < path.segmentCount()) - path= path.removeFirstSegments(fStripPrefixSegments); - return path; - } - - /* - * Returns true if new value differs from old. - */ - boolean setStripPrefixSegments(int strip) { - if (strip != fStripPrefixSegments) { - fStripPrefixSegments= strip; - return true; - } - return false; - } - - int getStripPrefixSegments() { - return fStripPrefixSegments; - } - - /* - * Returns true if new value differs from old. - */ - boolean setFuzz(int fuzz) { - if (fuzz != fFuzz) { - fFuzz= fuzz; - return true; - } - return false; - } - - /* - * Returns true if new value differs from old. - */ - boolean setReversed(boolean reverse) { - if (fReverse != reverse) { - fReverse= reverse; - - for (int i= 0; i < fDiffs.length; i++) - fDiffs[i].reverse(); - - return true; - } - return false; - } - - /* - * Returns true if new value differs from old. - */ - boolean setIgnoreWhitespace(boolean ignoreWhitespace) { - if (ignoreWhitespace != fIgnoreWhitespace) { - fIgnoreWhitespace= ignoreWhitespace; - return true; - } - return false; - } - - //---- parsing patch files - - /* package */ void parse(BufferedReader reader) throws IOException { - List diffs= new ArrayList(); - String line= null; - boolean reread= false; - String diffArgs= null; - String fileName= null; - - LineReader lr= new LineReader(reader); - if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ - lr.ignoreSingleCR(); - - // read leading garbage - while (true) { - if (!reread) - line= lr.readLine(); - reread= false; - if (line == null) - break; - if (line.length() < 4) - continue; // too short - - // remember some infos - if (line.startsWith("Index: ")) { //$NON-NLS-1$ - fileName= line.substring(7).trim(); - continue; - } - if (line.startsWith("diff")) { //$NON-NLS-1$ - diffArgs= line.substring(4).trim(); - continue; - } - - if (line.startsWith("--- ")) { //$NON-NLS-1$ - line= readUnifiedDiff(diffs, lr, line, diffArgs, fileName); - diffArgs= fileName= null; - reread= true; - } else if (line.startsWith("*** ")) { //$NON-NLS-1$ - line= readContextDiff(diffs, lr, line, diffArgs, fileName); - diffArgs= fileName= null; - reread= true; - } - } - - lr.close(); - - fDiffs= (Diff[]) diffs.toArray(new Diff[diffs.size()]); - } - - /* - * Returns the next line that does not belong to this diff - */ - private String readUnifiedDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException { - - String[] oldArgs= split(line.substring(4)); - - // read info about new file - line= reader.readLine(); - if (line == null || !line.startsWith("+++ ")) //$NON-NLS-1$ - return line; - - String[] newArgs= split(line.substring(4)); - - Diff diff= new Diff(extractPath(oldArgs, 0, fileName), extractDate(oldArgs, 1), - extractPath(newArgs, 0, fileName), extractDate(newArgs, 1)); - diffs.add(diff); - - int[] oldRange= new int[2]; - int[] newRange= new int[2]; - List lines= new ArrayList(); - - try { - // read lines of hunk - while (true) { - - line= reader.readLine(); - if (line == null) - return null; - - if (reader.lineContentLength(line) == 0) { - //System.out.println("Warning: found empty line in hunk; ignored"); - //lines.add(' ' + line); - continue; - } - - char c= line.charAt(0); - switch (c) { - case '@': - if (line.startsWith("@@ ")) { //$NON-NLS-1$ - // flush old hunk - if (lines.size() > 0) { - new Hunk(diff, oldRange, newRange, lines); - lines.clear(); - } - - // format: @@ -oldStart,oldLength +newStart,newLength @@ - extractPair(line, '-', oldRange); - extractPair(line, '+', newRange); - continue; - } - break; - case ' ': - case '+': - case '-': - lines.add(line); - continue; - case '\\': - if (line.startsWith("No newline at end of file", 2)) { //$NON-NLS-1$ - int lastIndex= lines.size(); - if (lastIndex > 0) { - line= (String) lines.get(lastIndex-1); - int end= line.length()-1; - char lc= line.charAt(end); - if (lc == '\n') { - end--; - if (end > 0 && line.charAt(end-1) == '\r') - end--; - } else if (lc == '\r') { - end--; - } - line= line.substring(0, end); - lines.set(lastIndex-1, line); - } - continue; - } - break; - default: - if (DEBUG) { - int a1= c, a2= 0; - if (line.length() > 1) - a2= line.charAt(1); - System.out.println("char: " + a1 + " " + a2); //$NON-NLS-1$ //$NON-NLS-2$ - } - break; - } - return line; - } - } finally { - if (lines.size() > 0) - new Hunk(diff, oldRange, newRange, lines); - diff.finish(); - } - } - - /* - * Returns the next line that does not belong to this diff - */ - private String readContextDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException { - - String[] oldArgs= split(line.substring(4)); - - // read info about new file - line= reader.readLine(); - if (line == null || !line.startsWith("--- ")) //$NON-NLS-1$ - return line; - - String[] newArgs= split(line.substring(4)); - - Diff diff= new Diff(extractPath(oldArgs, 0, fileName), extractDate(oldArgs, 1), - extractPath(newArgs, 0, fileName), extractDate(newArgs, 1)); - diffs.add(diff); - - int[] oldRange= new int[2]; - int[] newRange= new int[2]; - List oldLines= new ArrayList(); - List newLines= new ArrayList(); - List lines= oldLines; - - try { - // read lines of hunk - while (true) { - - line= reader.readLine(); - if (line == null) - return line; - - int l= line.length(); - if (l == 0) - continue; - if (l > 1) { - switch (line.charAt(0)) { - case '*': - if (line.startsWith("***************")) { // new hunk //$NON-NLS-1$ - // flush old hunk - if (oldLines.size() > 0 || newLines.size() > 0) { - new Hunk(diff, oldRange, newRange, unifyLines(oldLines, newLines)); - oldLines.clear(); - newLines.clear(); - } - continue; - } - if (line.startsWith("*** ")) { // old range //$NON-NLS-1$ - // format: *** oldStart,oldEnd *** - extractPair(line, ' ', oldRange); - oldRange[1]= oldRange[1]-oldRange[0]+1; - lines= oldLines; - continue; - } - break; - case ' ': // context line - case '+': // addition - case '!': // change - if (line.charAt(1) == ' ') { - lines.add(line); - continue; - } - break; - case '-': - if (line.charAt(1) == ' ') { // deletion - lines.add(line); - continue; - } - if (line.startsWith("--- ")) { // new range //$NON-NLS-1$ - // format: *** newStart,newEnd *** - extractPair(line, ' ', newRange); - newRange[1]= newRange[1]-newRange[0]+1; - lines= newLines; - continue; - } - break; - default: - break; - } - } - return line; - } - } finally { - // flush last hunk - if (oldLines.size() > 0 || newLines.size() > 0) - new Hunk(diff, oldRange, newRange, unifyLines(oldLines, newLines)); - diff.finish(); - } - } - - /* - * Creates a List of lines in the unified format from - * two Lists of lines in the 'classic' format. - */ - private List unifyLines(List oldLines, List newLines) { - List result= new ArrayList(); - - String[] ol= (String[]) oldLines.toArray(new String[oldLines.size()]); - String[] nl= (String[]) newLines.toArray(new String[newLines.size()]); - - int oi= 0, ni= 0; - - while (true) { - - char oc= 0; - String o= null; - if (oi < ol.length) { - o= ol[oi]; - oc= o.charAt(0); - } - - char nc= 0; - String n= null; - if (ni < nl.length) { - n= nl[ni]; - nc= n.charAt(0); - } - - // EOF - if (oc == 0 && nc == 0) - break; - - // deletion in old - if (oc == '-') { - do { - result.add('-' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == '-'); - continue; - } - - // addition in new - if (nc == '+') { - do { - result.add('+' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == '+'); - continue; - } - - // differing lines on both sides - if (oc == '!' && nc == '!') { - // remove old - do { - result.add('-' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == '!'); - - // add new - do { - result.add('+' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == '!'); - - continue; - } - - // context lines - if (oc == ' ' && nc == ' ') { - do { - Assert.isTrue(o.equals(n), "non matching context lines"); //$NON-NLS-1$ - result.add(' ' + o.substring(2)); - oi++; - ni++; - if (oi >= ol.length || ni >= nl.length) - break; - o= ol[oi]; - n= nl[ni]; - } while (o.charAt(0) == ' ' && n.charAt(0) == ' '); - continue; - } - - if (oc == ' ') { - do { - result.add(' ' + o.substring(2)); - oi++; - if (oi >= ol.length) - break; - o= ol[oi]; - } while (o.charAt(0) == ' '); - continue; - } - - if (nc == ' ') { - do { - result.add(' ' + n.substring(2)); - ni++; - if (ni >= nl.length) - break; - n= nl[ni]; - } while (n.charAt(0) == ' '); - continue; - } - - Assert.isTrue(false, "unexpected char <" + oc + "> <" + nc + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - return result; - } - - /* - * Breaks the given string into tab separated substrings. - * Leading and trailing whitespace is removed from each token. - */ - private String[] split(String line) { - List l= new ArrayList(); - StringTokenizer st= new StringTokenizer(line, "\t"); //$NON-NLS-1$ - while (st.hasMoreElements()) { - String token= st.nextToken().trim(); - if (token.length() > 0) - l.add(token); - } - return (String[]) l.toArray(new String[l.size()]); - } - - /* - * @return the parsed time/date in milliseconds or -1 on error - */ - private long extractDate(String[] args, int n) { - if (n < args.length) { - String line= args[n]; - for (int i= 0; i < DATE_FORMATS.length; i++) { - DATE_FORMATS[i].setLenient(true); - try { - Date date= DATE_FORMATS[i].parse(line); - return date.getTime(); - } catch (ParseException ex) { - // silently ignored - } - } - // System.err.println("can't parse date: <" + line + ">"); - } - return -1; - } - - /* - * Returns null if file name is "/dev/null". - */ - private IPath extractPath(String[] args, int n, String path2) { - if (n < args.length) { - String path= args[n]; - if (DEV_NULL.equals(path)) - return null; - int pos= path.lastIndexOf(':'); - if (pos >= 0) - path= path.substring(0, pos); - if (path2 != null && !path2.equals(path)) { - if (DEBUG) System.out.println("path mismatch: " + path2); //$NON-NLS-1$ - path= path2; - } - return new Path(path); - } - return null; - } - - /* - * Tries to extract two integers separated by a comma. - * The parsing of the line starts at the position after - * the first occurrence of the given character start an ends - * at the first blank (or the end of the line). - * If only a single number is found this is assumed to be the length of the range. - * In this case the start of the range is set to 1. - * If an error occurs the range -1,-1 is returned. - */ - private void extractPair(String line, char start, int[] pair) { - pair[0]= pair[1]= -1; - int startPos= line.indexOf(start); - if (startPos < 0) { - if (DEBUG) System.out.println("parsing error in extractPair: couldn't find \'" + start + "\'"); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - line= line.substring(startPos+1); - int endPos= line.indexOf(' '); - if (endPos < 0) { - if (DEBUG) System.out.println("parsing error in extractPair: couldn't find end blank"); //$NON-NLS-1$ - return; - } - line= line.substring(0, endPos); - int comma= line.indexOf(','); - if (comma >= 0) { - pair[0]= Integer.parseInt(line.substring(0, comma)); - pair[1]= Integer.parseInt(line.substring(comma+1)); - } else { - pair[0]= 1; - pair[1]= Integer.parseInt(line.substring(comma+1)); - } - } - - //---- applying a patch file - - /* - * Tries to patch the given lines with the specified Diff. - * Any hunk that couldn't be applied is returned in the list failedHunks. - */ - /* package */ void patch(Diff diff, List lines, List failedHunks) { - - int shift= 0; - Iterator iter= diff.fHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - hunk.fMatches= false; - shift= patch(hunk, lines, shift, failedHunks); - } - } - - /* - * Tries to apply the specified hunk to the given lines. - * If the hunk cannot be applied at the original position - * the methods tries Fuzz lines before and after. - * If this fails the Hunk is added to the given list of failed hunks. - */ - private int patch(Hunk hunk, List lines, int shift, List failedHunks) { - if (tryPatch(hunk, lines, shift)) { - if (hunk.isEnabled()) - shift+= doPatch(hunk, lines, shift); - } else { - boolean found= false; - int oldShift= shift; - - for (int i= 1; i <= fFuzz; i++) { - if (tryPatch(hunk, lines, shift-i)) { - if (fAdjustShift) - shift-= i; - found= true; - break; - } - } - - if (! found) { - for (int i= 1; i <= fFuzz; i++) { - if (tryPatch(hunk, lines, shift+i)) { - if (fAdjustShift) - shift+= i; - found= true; - break; - } - } - } - - if (found) { - if (DEBUG) System.out.println("patched hunk at offset: " + (shift-oldShift)); //$NON-NLS-1$ - shift+= doPatch(hunk, lines, shift); - } else { - if (failedHunks != null) { - if (DEBUG) System.out.println("failed hunk"); //$NON-NLS-1$ - failedHunks.add(hunk); - } - } - } - return shift; - } - - /* - * Tries to apply the given hunk on the specified lines. - * The parameter shift is added to the line numbers given - * in the hunk. - */ - private boolean tryPatch(Hunk hunk, List lines, int shift) { - int pos= hunk.fOldStart + shift; - int deleteMatches= 0; - for (int i= 0; i < hunk.fLines.length; i++) { - String s= hunk.fLines[i]; - Assert.isTrue(s.length() > 0); - String line= s.substring(1); - char controlChar= s.charAt(0); - if (controlChar == ' ') { // context lines - while (true) { - if (pos < 0 || pos >= lines.size()) - return false; - if (linesMatch(line, (String) lines.get(pos))) { - pos++; - break; - } - return false; - } - } else if (controlChar == '-') { - // deleted lines - while (true) { - if (pos < 0 || pos >= lines.size()) - return false; - if (linesMatch(line, (String) lines.get(pos))) { - deleteMatches++; - pos++; - break; - } - if (deleteMatches <= 0) - return false; - pos++; - } - } else if (controlChar == '+') { - // added lines - // we don't have to do anything for a 'try' - } else - Assert.isTrue(false, "tryPatch: unknown control character: " + controlChar); //$NON-NLS-1$ - } - return true; - } - - private int doPatch(Hunk hunk, List lines, int shift) { - int pos= hunk.fOldStart + shift; - for (int i= 0; i < hunk.fLines.length; i++) { - String s= hunk.fLines[i]; - Assert.isTrue(s.length() > 0); - String line= s.substring(1); - char controlChar= s.charAt(0); - if (controlChar == ' ') { // context lines - while (true) { - Assert.isTrue(pos < lines.size(), "doPatch: inconsistency in context"); //$NON-NLS-1$ - if (linesMatch(line, (String) lines.get(pos))) { - pos++; - break; - } - pos++; - } - } else if (controlChar == '-') { - // deleted lines - while (true) { - Assert.isTrue(pos < lines.size(), "doPatch: inconsistency in deleted lines"); //$NON-NLS-1$ - if (linesMatch(line, (String) lines.get(pos))) { - break; - } - pos++; - } - lines.remove(pos); - } else if (controlChar == '+') { - // added lines - lines.add(pos, line); - pos++; - } else - Assert.isTrue(false, "doPatch: unknown control character: " + controlChar); //$NON-NLS-1$ - } - hunk.fMatches= true; - return hunk.fNewLength - hunk.fOldLength; - } - - public void applyAll(IResource target, IProgressMonitor pm, Shell shell, String title) throws CoreException { - - final int WORK_UNIT= 10; - - int i; - - IFile singleFile= null; // file to be patched - IContainer container= null; - if (target instanceof IContainer) - container= (IContainer) target; - else if (target instanceof IFile) { - singleFile= (IFile) target; - container= singleFile.getParent(); - } else { - Assert.isTrue(false); - } - - // get all files to be modified in order to call validateEdit - List list= new ArrayList(); - if (singleFile != null) - list.add(singleFile); - else { - for (i= 0; i < fDiffs.length; i++) { - Diff diff= fDiffs[i]; - if (diff.isEnabled()) { - switch (diff.getType()) { - case Differencer.CHANGE: - list.add(createPath(container, getPath(diff))); - break; - } - } - } - } - if (! Utilities.validateResources(list, shell, title)) - return; - - if (pm != null) { - String message= PatchMessages.getString("Patcher.Task.message"); //$NON-NLS-1$ - pm.beginTask(message, fDiffs.length*WORK_UNIT); - } - - for (i= 0; i < fDiffs.length; i++) { - - int workTicks= WORK_UNIT; - - Diff diff= fDiffs[i]; - if (diff.isEnabled()) { - - IPath path= getPath(diff); - if (pm != null) - pm.subTask(path.toString()); - - IFile file= singleFile != null - ? singleFile - : createPath(container, path); - - List failed= new ArrayList(); - List result= null; - - int type= diff.getType(); - switch (type) { - case Differencer.ADDITION: - // patch it and collect rejected hunks - result= apply(diff, file, true, failed); - store(createString(result), file, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - case Differencer.DELETION: - file.delete(true, true, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - case Differencer.CHANGE: - // patch it and collect rejected hunks - result= apply(diff, file, false, failed); - store(createString(result), file, new SubProgressMonitor(pm, workTicks)); - workTicks-= WORK_UNIT; - break; - } - - if (failed.size() > 0) { - IPath pp= null; - if (path.segmentCount() > 1) { - pp= path.removeLastSegments(1); - pp= pp.append(path.lastSegment() + REJECT_FILE_EXTENSION); - } else - pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); - file= createPath(container, pp); - if (file != null) { - store(getRejected(failed), file, pm); - try { - IMarker marker= file.createMarker(MARKER_TYPE); - marker.setAttribute(IMarker.MESSAGE, PatchMessages.getString("Patcher.Marker.message")); //$NON-NLS-1$ - marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH); - } catch (CoreException ex) { - // NeedWork - } - } - } - } - - if (pm != null) { - if (pm.isCanceled()) - break; - if (workTicks > 0) - pm.worked(workTicks); - } - } - } - - /* - * Reads the contents from the given file and returns them as - * a List of lines. - */ - List load(IFile file, boolean create) { - List lines= null; - if (!create && file != null) { - // read current contents - InputStream is= null; - try { - is= file.getContents(); - - Reader streamReader= null; - try { - streamReader= new InputStreamReader(is, Utilities.getCharset(file)); - } catch (UnsupportedEncodingException x) { - // use default encoding - streamReader= new InputStreamReader(is); - } - - BufferedReader reader= new BufferedReader(streamReader); - LineReader lr= new LineReader(reader); - if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ - lr.ignoreSingleCR(); - lines= lr.readLines(); - } catch(CoreException ex) { - // NeedWork - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - - if (lines == null) - lines= new ArrayList(); - return lines; - } - - List apply(Diff diff, IFile file, boolean create, List failedHunks) { - List lines= load(file, create); - patch(diff, lines, failedHunks); - return lines; - } - - /* - * Converts the string into bytes and stores them in the given file. - */ - private void store(String contents, IFile file, IProgressMonitor pm) throws CoreException { - - byte[] bytes; - try { - bytes= contents.getBytes(Utilities.getCharset(file)); - } catch (UnsupportedEncodingException x) { - // uses default encoding - bytes= contents.getBytes(); - } - - InputStream is= new ByteArrayInputStream(bytes); - try { - if (file.exists()) { - file.setContents(is, false, true, pm); - } else { - file.create(is, false, pm); - } - } finally { - if (is != null) - try { - is.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - - /* - * Concatenates all strings found in the given List. - */ - private String createString(List lines) { - StringBuffer sb= new StringBuffer(); - Iterator iter= lines.iterator(); - if (fPreserveLineDelimiters) { - while (iter.hasNext()) - sb.append((String)iter.next()); - } else { - String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ - while (iter.hasNext()) { - String line= (String)iter.next(); - int l= length(line); - if (l < line.length()) { // line has delimiter - sb.append(line.substring(0, l)); - sb.append(lineSeparator); - } else { - sb.append(line); - } - } - } - return sb.toString(); - } - - String getRejected(List failedHunks) { - if (failedHunks.size() <= 0) - return null; - - String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ - StringBuffer sb= new StringBuffer(); - Iterator iter= failedHunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - sb.append(hunk.getRejectedDescription()); - sb.append(lineSeparator); - sb.append(hunk.getContent()); - } - return sb.toString(); - } - - /* - * Ensures that a file with the given path exists in - * the given container. Folder are created as necessary. - */ - private IFile createPath(IContainer container, IPath path) throws CoreException { - if (path.segmentCount() > 1) { - IFolder f= container.getFolder(path.uptoSegment(1)); - if (!f.exists()) - f.create(false, true, null); - return createPath(f, path.removeFirstSegments(1)); - } - // a leaf - return container.getFile(path); - } - - /* - * Returns the given string with all whitespace characters removed. - * Whitespace is defined by Character.isWhitespace(...). - */ - private static String stripWhiteSpace(String s) { - StringBuffer sb= new StringBuffer(); - int l= s.length(); - for (int i= 0; i < l; i++) { - char c= s.charAt(i); - if (!Character.isWhitespace(c)) - sb.append(c); - } - return sb.toString(); - } - - /* - * Compares two strings. - * If fIgnoreWhitespace is true whitespace is ignored. - */ - private boolean linesMatch(String line1, String line2) { - if (fIgnoreWhitespace) - return stripWhiteSpace(line1).equals(stripWhiteSpace(line2)); - if (fIgnoreLineDelimiter) { - int l1= length(line1); - int l2= length(line2); - if (l1 != l2) - return false; - return line1.regionMatches(0, line2, 0, l1); - } - return line1.equals(line2); - } - - /* - * Returns the length (exluding a line delimiter CR, LF, CR/LF) - * of the given string. - */ - /* package */ static int length(String s) { - int l= s.length(); - if (l > 0) { - char c= s.charAt(l-1); - if (c == '\r') - return l-1; - if (c == '\n') { - if (l > 1 && s.charAt(l-2) == '\r') - return l-2; - return l-1; - } - } - return l; - } - - int calculateFuzz(Hunk hunk, List lines, int shift, IProgressMonitor pm, int[] fuzz) { - - hunk.fMatches= false; - if (tryPatch(hunk, lines, shift)) { - shift+= doPatch(hunk, lines, shift); - fuzz[0]= 0; - } else { - boolean found= false; - int hugeFuzz= lines.size(); // the maximum we need for this file - fuzz[0]= -2; // not found - - for (int i= 1; i <= hugeFuzz; i++) { - if (pm.isCanceled()) { - fuzz[0]= -1; - return 0; - } - if (tryPatch(hunk, lines, shift-i)) { - fuzz[0]= i; - if (fAdjustShift) - shift-= i; - found= true; - break; - } - } - - if (! found) { - for (int i= 1; i <= hugeFuzz; i++) { - if (pm.isCanceled()) { - fuzz[0]= -1; - return 0; - } - if (tryPatch(hunk, lines, shift+i)) { - fuzz[0]= i; - if (fAdjustShift) - shift+= i; - found= true; - break; - } - } - } - - if (found) - shift+= doPatch(hunk, lines, shift); - } - return shift; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java deleted file mode 100644 index b4046f039..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java +++ /dev/null @@ -1,740 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.internal.patch; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.CompareUIPlugin; -import org.eclipse.compare.internal.DiffImage; -import org.eclipse.compare.internal.ICompareContextIds; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.structuremergeviewer.*; - - -/** - * Shows the parsed patch file and any mismatches - * between files, hunks and the currently selected - * resources. - */ -/* package */ class PreviewPatchPage extends WizardPage { - - /** - * Used with CompareInput - */ - static class HunkInput implements ITypedElement, IEncodedStreamContentAccessor { - static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - String fContent; - String fType; - - HunkInput(String type, String s) { - fType= type; - fContent= s; - } - public Image getImage() { - return null; - } - public String getName() { - return PatchMessages.getString("PreviewPatchPage.NoName.text"); //$NON-NLS-1$ - } - public String getType() { - return fType; - } - public InputStream getContents() { - return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); - } - public String getCharset() { - return UTF_16; - } - } - - private PatchWizard fPatchWizard; - - private Tree fTree; - private Combo fStripPrefixSegments; - private CompareViewerSwitchingPane fHunkViewer; - private Button fIgnoreWhitespaceButton; - private Button fReversePatchButton; - private Text fFuzzField; - - private Image[] fImages= new Image[6]; - private CompareConfiguration fCompareConfiguration; - - - /* package */ PreviewPatchPage(PatchWizard pw) { - super("PreviewPatchPage", //$NON-NLS-1$ - PatchMessages.getString("PreviewPatchPage.title"), null); //$NON-NLS-1$ - - setMessage(PatchMessages.getString("PreviewPatchPage.message")); //$NON-NLS-1$ - - fPatchWizard= pw; - //setPageComplete(false); - - int w= 16; - - ImageDescriptor addId= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$ - ImageDescriptor delId= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$ - - ImageDescriptor errId= CompareUIPlugin.getImageDescriptor("ovr16/error_ov.gif"); //$NON-NLS-1$ - Image errIm= errId.createImage(); - - fImages[0]= new DiffImage(null, null, w).createImage(); - fImages[1]= new DiffImage(null, addId, w).createImage(); - fImages[2]= new DiffImage(null, delId, w).createImage(); - - fImages[3]= new DiffImage(errIm, null, w).createImage(); - fImages[4]= new DiffImage(errIm, addId, w).createImage(); - fImages[5]= new DiffImage(errIm, delId, w).createImage(); - - fCompareConfiguration= new CompareConfiguration(); - - fCompareConfiguration.setLeftEditable(false); - fCompareConfiguration.setLeftLabel(PatchMessages.getString("PreviewPatchPage.Left.title")); //$NON-NLS-1$ - - fCompareConfiguration.setRightEditable(false); - fCompareConfiguration.setRightLabel(PatchMessages.getString("PreviewPatchPage.Right.title")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * Method declared in WizardPage - */ - public void setVisible(boolean visible) { - if (visible) - buildTree(); - super.setVisible(visible); - } - - Image getImage(Diff diff) { - if (diff.fMatches) { - switch (diff.getType()) { - case Differencer.ADDITION: - return fImages[1]; - case Differencer.DELETION: - return fImages[2]; - } - return fImages[0]; - } - switch (diff.getType()) { - case Differencer.ADDITION: - return fImages[4]; - case Differencer.DELETION: - return fImages[5]; - } - return fImages[3]; - } - - Image getImage(Hunk hunk) { - if (hunk.fMatches) - return fImages[0]; - return fImages[3]; - } - - public void createControl(Composite parent) { - - Composite composite= new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - - WorkbenchHelp.setHelp(composite, ICompareContextIds.PATCH_PREVIEW_WIZARD_PAGE); - - setControl(composite); - - buildPatchOptionsGroup(composite); - - Splitter splitter= new Splitter(composite, SWT.VERTICAL); - splitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - - - // top pane showing diffs and hunks in a check box tree - fTree= new Tree(splitter, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridData gd= new GridData(); - gd.verticalAlignment= GridData.FILL; - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.grabExcessVerticalSpace= true; - fTree.setLayoutData(gd); - - // bottom pane showing hunks in compare viewer - fHunkViewer= new CompareViewerSwitchingPane(splitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration); - } - }; - gd= new GridData(); - gd.verticalAlignment= GridData.FILL; - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.grabExcessVerticalSpace= true; - fHunkViewer.setLayoutData(gd); - - // register listeners - - fTree.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TreeItem ti= (TreeItem) e.item; - Object data= e.item.getData(); - if (e.detail == SWT.CHECK) { - boolean checked= ti.getChecked(); - if (data instanceof Hunk) { - Hunk hunk= (Hunk) data; - checked= checked && hunk.fMatches; - //hunk.setEnabled(checked); - ti.setChecked(checked); - updateGrayedState(ti); - } else if (data instanceof Diff) { - updateCheckedState(ti); - } - } else { - if (data instanceof Hunk) - PreviewPatchPage.this.fHunkViewer.setInput(createInput((Hunk)data)); - else - PreviewPatchPage.this.fHunkViewer.setInput(null); - } - } - } - ); - fTree.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (fImages != null) { - for (int i= 0; i < fImages.length; i++) { - if (fImages[i] == null) - fImages[i].dispose(); - } - fImages= null; - } - } - }); - // creating tree's content - buildTree(); - Dialog.applyDialogFont(composite); - } - - /* - * Create the group for setting various patch options - */ - private void buildPatchOptionsGroup(Composite parent) { - - GridLayout gl; - GridData gd; - Label l; - - final Patcher patcher= fPatchWizard.getPatcher(); - - Group group= new Group(parent, SWT.NONE); - group.setText(PatchMessages.getString("PreviewPatchPage.PatchOptions.title")); //$NON-NLS-1$ - gl= new GridLayout(); gl.numColumns= 4; gl.marginHeight= 0; - group.setLayout(gl); - group.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - - // 1st row - - Composite pair= new Composite(group, SWT.NONE); - gl= new GridLayout(); gl.numColumns= 2; gl.marginHeight= gl.marginWidth= 0; - pair.setLayout(gl); - gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - pair.setLayoutData(gd); - - l= new Label(pair, SWT.NONE); - l.setText(PatchMessages.getString("PreviewPatchPage.IgnoreSegments.text")); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL); - l.setLayoutData(gd); - - fStripPrefixSegments= new Combo(pair, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SIMPLE); - int prefixCnt= patcher.getStripPrefixSegments(); - String prefix= Integer.toString(prefixCnt); - fStripPrefixSegments.add(prefix); - fStripPrefixSegments.setText(prefix); - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END); - fStripPrefixSegments.setLayoutData(gd); - - addSpacer(group); - - fReversePatchButton= new Button(group, SWT.CHECK); - fReversePatchButton.setText(PatchMessages.getString("PreviewPatchPage.ReversePatch.text")); //$NON-NLS-1$ - - addSpacer(group); - - // 2nd row - pair= new Composite(group, SWT.NONE); - gl= new GridLayout(); gl.numColumns= 3; gl.marginHeight= gl.marginWidth= 0; - pair.setLayout(gl); - gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - pair.setLayoutData(gd); - - l= new Label(pair, SWT.NONE); - l.setText(PatchMessages.getString("PreviewPatchPage.FuzzFactor.text")); //$NON-NLS-1$ - l.setToolTipText(PatchMessages.getString("PreviewPatchPage.FuzzFactor.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL); - l.setLayoutData(gd); - - fFuzzField= new Text(pair, SWT.BORDER); - fFuzzField.setText("2"); //$NON-NLS-1$ - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END); gd.widthHint= 30; - fFuzzField.setLayoutData(gd); - - Button b= new Button(pair, SWT.PUSH); - b.setText(PatchMessages.getString("PreviewPatchPage.GuessFuzz.text")); //$NON-NLS-1$ - b.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int fuzz= guessFuzzFactor(patcher); - if (fuzz >= 0) - fFuzzField.setText(Integer.toString(fuzz)); - } - } - ); - gd= new GridData(GridData.VERTICAL_ALIGN_CENTER); - b.setLayoutData(gd); - - addSpacer(group); - - fIgnoreWhitespaceButton= new Button(group, SWT.CHECK); - fIgnoreWhitespaceButton.setText(PatchMessages.getString("PreviewPatchPage.IgnoreWhitespace.text")); //$NON-NLS-1$ - - addSpacer(group); - - // register listeners - - if (fStripPrefixSegments != null) - fStripPrefixSegments.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setStripPrefixSegments(getStripPrefixSegments())) - updateTree(); - } - } - ); - fReversePatchButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setReversed(fReversePatchButton.getSelection())) - updateTree(); - } - } - ); - fIgnoreWhitespaceButton.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (patcher.setIgnoreWhitespace(fIgnoreWhitespaceButton.getSelection())) - updateTree(); - } - } - ); - - fFuzzField.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (patcher.setFuzz(getFuzzFactor())) - updateTree(); - } - } - ); - } - - private int guessFuzzFactor(final Patcher patcher) { - final int strip= getStripPrefixSegments(); - final int[] result= new int[1]; - try { - PlatformUI.getWorkbench().getProgressService().run(true, true, - //TimeoutContext.run(true, GUESS_TIMEOUT, getControl().getShell(), - new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - result[0]= guess(patcher, monitor, strip); - } - } - ); - return result[0]; - } catch (InvocationTargetException ex) { - // NeedWork - } catch (InterruptedException ex) { - // NeedWork - } - return -1; - } - - private int guess(Patcher patcher, IProgressMonitor pm, int strip) { - - Diff[] diffs= patcher.getDiffs(); - if (diffs == null || diffs.length <= 0) - return -1; - - // now collect files and determine "work" - IFile[] files= new IFile[diffs.length]; - int work= 0; - for (int i= 0; i < diffs.length; i++) { - Diff diff= diffs[i]; - if (diff == null) - continue; - if (diff.getType() != Differencer.ADDITION) { - IPath p= diff.fOldPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - IFile file= existsInSelection(p); - if (file != null) { - files[i]= file; - work+= diff.fHunks.size(); - } - } - } - - // do the "work" - int[] fuzzRef= new int[1]; - String format= PatchMessages.getString("PreviewPatchPage.GuessFuzzProgress.format"); //$NON-NLS-1$ - pm.beginTask(PatchMessages.getString("PreviewPatchPage.GuessFuzzProgress.text"), work); //$NON-NLS-1$ - try { - int fuzz= 0; - for (int i= 0; i < diffs.length; i++) { - Diff d= diffs[i]; - IFile file= files[i]; - if (d != null && file != null) { - List lines= patcher.load(file, false); - String name= d.getPath().lastSegment(); - Iterator iter= d.fHunks.iterator(); - int shift= 0; - for (int hcnt= 1; iter.hasNext(); hcnt++) { - pm.subTask(MessageFormat.format(format, new String[] { name, Integer.toString(hcnt) } )); - Hunk h= (Hunk) iter.next(); - shift= patcher.calculateFuzz(h, lines, shift, pm, fuzzRef); - int f= fuzzRef[0]; - if (f == -1) // cancel - return -1; - if (f > fuzz) - fuzz= f; - pm.worked(1); - } - } - } - return fuzz; - } finally { - pm.done(); - } - } - - ICompareInput createInput(Hunk hunk) { - - String[] lines= hunk.fLines; - StringBuffer left= new StringBuffer(); - StringBuffer right= new StringBuffer(); - - for (int i= 0; i < lines.length; i++) { - String line= lines[i]; - String rest= line.substring(1); - switch (line.charAt(0)) { - case ' ': - left.append(rest); - right.append(rest); - break; - case '-': - left.append(rest); - break; - case '+': - right.append(rest); - break; - } - } - - Diff diff= hunk.fParent; - IPath path= diff.getPath(); - String type= path.getFileExtension(); - - return new DiffNode(new HunkInput(type, left.toString()), new HunkInput(type, right.toString())); - } - - /** - * Builds a tree from list of Diffs. - * As a side effect it calculates the maximum number of segments - * in all paths. - */ - private void buildTree() { - setPageComplete(true); - if (fTree != null && !fTree.isDisposed()) { - fTree.removeAll(); - fHunkViewer.setInput(null); - - int length= 99; - - Diff[] diffs= fPatchWizard.getPatcher().getDiffs(); - if (diffs != null) { - for (int i= 0; i < diffs.length; i++) { - Diff diff= diffs[i]; - TreeItem d= new TreeItem(fTree, SWT.NULL); - d.setData(diff); - d.setImage(getImage(diff)); - - if (diff.fOldPath != null) - length= Math.min(length, diff.fOldPath.segmentCount()); - if (diff.fNewPath != null) - length= Math.min(length, diff.fNewPath.segmentCount()); - - java.util.List hunks= diff.fHunks; - java.util.Iterator iter= hunks.iterator(); - while (iter.hasNext()) { - Hunk hunk= (Hunk) iter.next(); - TreeItem h= new TreeItem(d, SWT.NULL); - h.setData(hunk); - h.setText(hunk.getDescription()); - } - } - } - if (fStripPrefixSegments != null && length != 99) - for (int i= 1; i < length; i++) - fStripPrefixSegments.add(Integer.toString(i)); - } - - updateTree(); - } - - private IFile existsInSelection(IPath path) { - IResource target= fPatchWizard.getTarget(); - if (target instanceof IFile) { // special case - IFile file= (IFile) target; - if (matches(file.getFullPath(), path)) - return file; - } else if (target instanceof IContainer) { - IContainer c= (IContainer) target; - if (c.exists(path)) - return c.getFile(path); - } - return null; - } - - /* - * Returns true if path completely matches the end of fullpath - */ - private boolean matches(IPath fullpath, IPath path) { - - for (IPath p= fullpath; path.segmentCount() <= p.segmentCount(); p= p.removeFirstSegments(1)) { - if (p.equals(path)) - return true; - } - return false; - } - - /** - * Updates label and checked state of tree items. - */ - private void updateTree() { - if (fTree == null || fTree.isDisposed()) - return; - int strip= getStripPrefixSegments(); - TreeItem[] children= fTree.getItems(); - for (int i= 0; i < children.length; i++) { - TreeItem item= children[i]; - Diff diff= (Diff) item.getData(); - diff.fMatches= false; - String error= null; - - boolean create= false; - IFile file= null; - if (diff.getType() == Differencer.ADDITION) { - IPath p= diff.fNewPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - file= existsInSelection(p); - if (file == null) { - diff.fMatches= true; - } else { - // file already exists - error= PatchMessages.getString("PreviewPatchPage.FileExists.error"); //$NON-NLS-1$ - } - create= true; - } else { - IPath p= diff.fOldPath; - if (strip > 0 && strip < p.segmentCount()) - p= p.removeFirstSegments(strip); - file= existsInSelection(p); - diff.fMatches= false; - if (file != null) { - if (file.isReadOnly()) { - // file is readonly - error= PatchMessages.getString("PreviewPatchPage.FileIsReadOnly.error"); //$NON-NLS-1$ - file= null; - } else { - diff.fMatches= true; - } - } else { - // file doesn't exist - error= PatchMessages.getString("PreviewPatchPage.FileDoesNotExist.error"); //$NON-NLS-1$ - } - } - - ArrayList failedHunks= new ArrayList(); - Patcher patcher= fPatchWizard.getPatcher(); - patcher.setFuzz(getFuzzFactor()); - patcher.apply(diff, file, create, failedHunks); - - if (failedHunks.size() > 0) - diff.fRejected= fPatchWizard.getPatcher().getRejected(failedHunks); - - int checkedSubs= 0; // counts checked hunk items - TreeItem[] hunkItems= item.getItems(); - for (int h= 0; h < hunkItems.length; h++) { - Hunk hunk= (Hunk) hunkItems[h].getData(); - boolean failed= failedHunks.contains(hunk); - String hunkError= null; - if (failed) - hunkError= PatchMessages.getString("PreviewPatchPage.NoMatch.error"); //$NON-NLS-1$ - - boolean check= !failed; - hunkItems[h].setChecked(check); - if (check) - checkedSubs++; - - String hunkLabel= hunk.getDescription(); - if (hunkError != null) - hunkLabel+= " " + hunkError; //$NON-NLS-1$ - hunkItems[h].setText(hunkLabel); - hunkItems[h].setImage(getImage(hunk)); - } - - String label= diff.getDescription(strip); - if (error != null) - label+= " " + error; //$NON-NLS-1$ - item.setText(label); - item.setImage(getImage(diff)); - item.setChecked(checkedSubs > 0); - boolean gray= (checkedSubs > 0 && checkedSubs < hunkItems.length); - item.setGrayed(gray); - item.setExpanded(gray); - } - setPageComplete(updateModel()); - } - - /* - * Updates the gray state of the given diff and the checked state of its children. - */ - private void updateCheckedState(TreeItem diffItem) { - boolean checked= diffItem.getChecked(); - // check whether we can enable all hunks - TreeItem[] hunks= diffItem.getItems(); - int checkedCount= 0; - for (int i= 0; i < hunks.length; i++) { - Hunk hunk= (Hunk) hunks[i].getData(); - if (checked) { - if (hunk.fMatches) { - hunks[i].setChecked(true); - checkedCount++; - } - } else { - hunks[i].setChecked(false); - } - } - diffItem.setGrayed(checkedCount > 0 && checkedCount < hunks.length); - diffItem.setChecked(checkedCount > 0); - - setPageComplete(updateModel()); - } - - /* - * Updates the gray state of the given items parent. - */ - private void updateGrayedState(TreeItem hunk) { - TreeItem diff= hunk.getParentItem(); - TreeItem[] hunks= diff.getItems(); - int checked= 0; - for (int i= 0; i < hunks.length; i++) - if (hunks[i].getChecked()) - checked++; - diff.setChecked(checked > 0); - diff.setGrayed(checked > 0 && checked < hunks.length); - - setPageComplete(updateModel()); - } - - private void addSpacer(Composite parent) { - Label label= new Label(parent, SWT.NONE); - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint= 20; - label.setLayoutData(gd); - } - - private int getStripPrefixSegments() { - int stripPrefixSegments= 0; - if (fStripPrefixSegments != null) { - String s= fStripPrefixSegments.getText(); - try { - stripPrefixSegments= Integer.parseInt(s); - } catch(NumberFormatException ex) { - // silently ignored - } - } - return stripPrefixSegments; - } - - private int getFuzzFactor() { - int fuzzFactor= 0; - if (fFuzzField != null) { - String s= fFuzzField.getText(); - try { - fuzzFactor= Integer.parseInt(s); - } catch(NumberFormatException ex) { - // silently ignored - } - } - return fuzzFactor; - } - - public boolean updateModel() { - boolean atLeastOneIsEnabled= false; - if (fTree != null && !fTree.isDisposed()) { - TreeItem [] diffItems= fTree.getItems(); - for (int i= 0; i < diffItems.length; i++) { - TreeItem diffItem= diffItems[i]; - Object data= diffItem.getData(); - if (data instanceof Diff) { - Diff diff= (Diff) data; - boolean b= diffItem.getChecked(); - diff.setEnabled(b); - if (b) { - TreeItem [] hunkItems= diffItem.getItems(); - for (int j= 0; j < hunkItems.length; j++) { - TreeItem hunkItem= hunkItems[j]; - data= hunkItem.getData(); - if (data instanceof Hunk) { - Hunk hunk= (Hunk) data; - b= hunkItem.getChecked(); - hunk.setEnabled(b); - if (b) { - atLeastOneIsEnabled= true; - } - } - } - } - } - } - } - return atLeastOneIsEnabled; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/package.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/package.html deleted file mode 100644 index 96ffb6342..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/package.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for performing structural and textual -compare operations on arbitrary data and displaying the results. -

-Package Specification

- -The class CompareUI defines the entry point to initiate a configurable -compare operation on arbitrary resources. The result of the compare is -opened into a compare editor where the details can be browsed and edited -in dynamically selected structure and content viewers. -

- -A compare operation must be implemented as a subclass of CompareEditorInput. -A CompareEditorInput runs a (potentially lengthy) compare operation -under progress monitor control, creates a UI for drilling-down into the -compare results, tracks the dirty state of the result in case of merge, -and saves any changes that occured during a merge. -

- -The NavigationAction is used to navigate (step) through the individual -differences of a CompareEditorInput. -

- -An instance of CompareConfiguration configures various UI aspects -of compare/merge viewers like title labels and images, or whether a side -of a merge viewer is editable. It is passed to the CompareEditorInput -on creation. -

- -When implementing a hierarchical compare operation as a subclass of -CompareEditorInput clients have to provide a tree of objects where each -node implements the interface -org.eclipse.compare.structuremergeviewer.IStructureComparator. -This interface is used by the hierarchical differencing engine -(org.eclipse.compare.structuremergeviewer.Differencer) to walk the tree. -
-In addition every leaf of the tree must implement the IStreamContentAccessor -or IEncodedStreamContentAccessor -interfaces in order to give the differencing engine access to its stream content -and to its encoding (with IEncodedStreamContentAccessor). -

- -The abstract class BufferedContent provides a default implementation -for the IStreamContentAccessor and IContentChangeNotifier interfaces. -Its subclass ResourceNode adds an implementation for the -IStructureComparator and ITypedElement interfaces -based on Eclipse workbench resources (org.eclipse.core.resources.IResource). -It can be used without modification as the input to the differencing engine. -

- -The ZipFileStructureCreator is an implementation of the -org.eclipse.compare.structuremergeviewer.IStructureCreator interface -and makes the contents of a zip archive available as a -hierarchical structure of IStructureComparators which can be easily compared -by the differencing engine (org.eclipse.compare.structuremergeviewer.Differencer). -It is a good example for how to make structured files available to the hierarchical -compare functionality of the Compare plugin. -

- -The EditionSelectionDialog is a simple selection dialog where -one input element can be compared against a list of historic variants (editions) -of the same input element. The dialog can be used to implement functions -like "Replace with Version" or "Replace with Edition" on workbench resources. -

- -In addition it is possible to specify a subsection of the input element -(e.g. a method in a Java source file) by means of a path. In this -case the dialog compares only the subsection (as specified by the path) -with the corresponding subsection in the list of editions. This functionality -can be used to implement "Replace with Method Edition" for the Java -language. -

- -The EditionSelectionDialog requires that the editions implement -the IStreamContentAccessor and IModificationDate interfaces. -The HistoryItem is a convenience class that implements these interfaces -for IFileState objects. -

- - -The CompareViewerPane is a convenience class which provides -a label and local toolbar for a compare viewer (or any other subclass of a -JFace Viewer). -
-Its abstract subclass CompareViewerSwitchingPane supports dynamic -viewer switching, that is the viewer installed in the pane is dynamically -determined by the pane's input object. -Both classes are useful if you want to use compare viewers outside the context of -a compare editor, for example in a dialog or wizard. -

- -A Splitter is an extension of a SashForm that supports nesting, maximizing of panes, -and propagating the visibility state of panes. -

- -The interface IStreamMerger defines a single operation for performing a three-way merge on three -input streams. The merged result is written to an output stream. -
-Clients must implement this interface when contributing new mergers to the -org.eclipse.compare.streamMergers extension point. -New IStreamMergers can be created for registered types with the createStreamMerger methods of CompareUI. - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.java deleted file mode 100644 index 0ad70b4f4..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/DifferencesIterator.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.compare.rangedifferencer; - -import java.util.ArrayList; -import java.util.List; - -/** - * A custom iterator to iterate over a List of RangeDifferences. - * It is used internally by the RangeDifferencer. - */ -/* package */ class DifferencesIterator { - - List fRange; - int fIndex; - RangeDifference[] fArray; - RangeDifference fDifference; - - /* - * Creates a differences iterator on an array of RangeDifferences. - */ - 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 RangeDifference. - */ - 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 RangeDifferences - */ - void removeAll() { - fRange.clear(); - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java deleted file mode 100644 index 70bd1d5e0..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.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.compare.rangedifferencer; - -/** - * For breaking an object to compare into a sequence of comparable entities. - *

- * It is used by RangeDifferencer to find longest sequences of - * matching and non-matching ranges. - *

- * 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. getRangeCount would return the number of lines in the - * document, and rangesEqual would compare a specified line given - * with one in another IRangeComparator. - *

- *

- * Clients should implement this interface; there is no standard implementation. - *

- */ -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 IRangeComparator and index. - * - * @param thisIndex the index of the comparable entity within this IRangeComparator - * @param other the IRangeComparator to compare this with - * @param otherIndex the index of the comparable entity within the other IRangeComparator - * @return true 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 - * true or false - * @param maxLength another number on which to base the decision whether to return - * true or false - * @param other the other IRangeComparator to compare with - * @return true to avoid a too lengthy range comparison - */ - boolean skipRangeComparison(int length, int maxLength, IRangeComparator other); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.java deleted file mode 100644 index 0d06930bf..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/LinkedRangeDifference.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.compare.rangedifferencer; - -/* 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/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java deleted file mode 100644 index 8d75eae7e..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifference.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.rangedifferencer; - -/** - * Description of a change between two or three ranges of comparable entities. - *

- * RangeDifference objects are the elements of a compare result returned from - * the RangeDifferencer find* methods. - * Clients use these objects as they are returned from the differencer. - * This class is not intended to be instantiated or subclassed. - *

- * Note: A range in the RangeDifference 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. - *

- * - * @see RangeDifferencer - */ -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 RIGHT) */ - 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; - - /** - * Creates a new range difference with the given change kind. - * - * @param changeKind the kind of change - */ - /* package */ RangeDifference(int changeKind) { - fKind= changeKind; - } - - /** - * Creates a new RangeDifference 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 - */ - /* package */ RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength) { - fKind= kind; - fRightStart= rightStart; - fRightLength= rightLength; - fLeftStart= leftStart; - fLeftLength= leftLength; - } - - /** - * Creates a new RangeDifference 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 - */ - /* package */ 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 - * NOCHANGE, CHANGE, LEFT, RIGHT, - * ANCESTOR, CONFLICT, ERROR - */ - 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)); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java deleted file mode 100644 index 31cbc8214..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/RangeDifferencer.java +++ /dev/null @@ -1,536 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.rangedifferencer; - -import java.util.*; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A RangeDifferencer finds the differences between two or three IRangeComparators. - *

- * To use the differencer, clients provide an IRangeComparator - * that breaks their input data into a sequence of comparable entities. The differencer - * returns the differences among these sequences as an array of RangeDifference objects - * (findDifferences methods). - * Every RangeDifference represents a single kind of difference - * and the corresponding ranges of the underlying comparable entities in the - * left, right, and optionally ancestor sides. - *

- * Alternatively, the findRanges methods not only return objects for - * the differing ranges but for non-differing ranges too. - *

- * The algorithm used is an objectified version of one described in: - * A File Comparison Program, by Webb Miller and Eugene W. Myers, - * Software Practice and Experience, Vol. 15, Nov. 1985. - * - * @see IRangeComparator - * @see RangeDifference - */ -public final class RangeDifferencer { - - private static final RangeDifference[] EMPTY_RESULT= new RangeDifference[0]; - - /* (non Javadoc) - * Non instantiatiable! - */ - private RangeDifferencer() { - // nothing to do - } - - /** - * Finds the differences between two IRangeComparators. - * The differences are returned as an array of RangeDifferences. - * 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 - */ - public static RangeDifference[] findDifferences(IRangeComparator left, IRangeComparator right) { - return findDifferences((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences between two IRangeComparators. - * The differences are returned as an array of RangeDifferences. - * If no differences are detected an empty array is returned. - * - * @param pm if not null 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 - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) { - - // 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++; - - 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); - - // 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= new LinkedRangeDifference(script[k + 1], LinkedRangeDifference.DELETE); - } else { - // - // move right - // - row= lastDiagonal[k - 1]; - edit= new LinkedRangeDifference(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 IRangeComparators. - * The differences are returned as a list of RangeDifferences. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param ancestor the ancestor range comparator or null - * @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 - */ - public static RangeDifference[] findDifferences(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - return findDifferences(null, ancestor, left, right); - } - - /** - * Finds the differences among three IRangeComparators. - * The differences are returned as a list of RangeDifferences. - * If no differences are detected an empty list is returned. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param pm if not null used to report progress - * @param ancestor the ancestor range comparator or null - * @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 - * @since 2.0 - */ - public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - - 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 IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - */ - public static RangeDifference[] findRanges(IRangeComparator left, IRangeComparator right) { - return findRanges((IProgressMonitor)null, left, right); - } - - /** - * Finds the differences among two IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * - * @param pm if not null used to report progress - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @since 2.0 - */ - public static RangeDifference[] findRanges(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) { - 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 (RangeDifference[]) out.toArray(EMPTY_RESULT); - } - - /** - * Finds the differences among three IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param ancestor the ancestor range comparator or null - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - */ - public static RangeDifference[] findRanges(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - return findRanges(null, ancestor, left, right); - } - - /** - * Finds the differences among three IRangeComparators. - * In contrast to findDifferences, the result - * contains RangeDifference elements for non-differing ranges too. - * If the ancestor range comparator is null, a two-way - * comparison is performed. - * - * @param pm if not null used to report progress - * @param ancestor the ancestor range comparator or null - * @param left the left range comparator - * @param right the right range comparator - * @return an array of range differences - * @since 2.0 - */ - public static RangeDifference[] findRanges(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) { - - 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 (RangeDifference[]) out.toArray(EMPTY_RESULT); - } - - //---- 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 RangeDifference3 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 right and 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/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html deleted file mode 100644 index 368068b3b..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/package.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for finding the differences between -two or three sequences of comparable entities. -

-Package Specification

- -The class RangeDifferencer finds longest sequences of matching and -non-matching comparable entities. Its implementation is based on -an objectified version of the algorithm described in: -A File Comparison Program, by Webb Miller and Eugene W. Myers, -Software Practice and Experience, Vol. 15, Nov. 1985. -

- -Clients must supply the input to the differencer as an implementation -of the IRangeComparator interface. -An IRangeComparator breaks the input data into a sequence -of entities and provides a method for comparing -one entity with the entity in another IRangeComparator. -

- -For example, to compare two text documents and find longest common -sequences of matching and non-matching lines, -the implementation of IRangeComparator -must break the document into lines and provide a method for testing -whether two lines are considered equal. -See org.eclipse.compare.internal.DocLineComparator for how this can be done. -

- -The differencer returns the differences among these sequences as an -array of RangeDifference objects. -Every single RangeDifference describes the kind of difference -(no change, change, addition, deletion) and the corresponding ranges -of the underlying comparable entities in the two or three inputs. - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java deleted file mode 100644 index b74d36e1b..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.util.ArrayList; - -/** - * The standard implementation of a diff container element. - *

- * This class may be instantiated, or further subclassed. - *

- */ -public abstract class DiffContainer extends DiffElement implements IDiffContainer { - - private static IDiffElement[] fgEmptyArray= new IDiffElement[0]; - private ArrayList fChildren; - - /** - * Creates a new container with the specified kind under the given parent. - * - * @param parent under which the new container is added as a child or null. - * @param kind of difference (defined in Differencer). - */ - public DiffContainer(IDiffContainer parent, int kind) { - super(parent, kind); - } - - /** - * Tries to find the child with the given name. - * Returns null if no such child exists. - * - * @param name of the child to find - * @return the first element with a matching name - */ - public IDiffElement findChild(String name) { - Object[] children= getChildren(); - for (int i= 0; i < children.length; i++) { - IDiffElement child= (IDiffElement) children[i]; - if (name.equals(child.getName())) - return child; - } - return null; - } - - /* (non Javadoc) - * see IDiffContainer.add - */ - public void add(IDiffElement diff) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(diff); - diff.setParent(this); - } - - /* - * Removes the given child from this container. - * If the container becomes empty it is removed from its container. - */ - public void removeToRoot(IDiffElement child) { - if (fChildren != null) { - fChildren.remove(child); - child.setParent(null); - if (fChildren.size() == 0) { - IDiffContainer p= getParent(); - if (p != null) - p.removeToRoot(this); - } - } - } - - /** - * Removes the given child (non-recursively) from this container. - * - * @param child to remove - */ - public void remove(IDiffElement child) { - if (fChildren != null) { - fChildren.remove(child); - child.setParent(null); - } - } - - /* (non Javadoc) - * see IDiffContainer.hasChildren - */ - public boolean hasChildren() { - return fChildren != null && fChildren.size() > 0; - } - - /* (non Javadoc) - * see IDiffContainer.getChildren - */ - public IDiffElement[] getChildren() { - if (fChildren != null) - return (IDiffElement[]) fChildren.toArray(fgEmptyArray); - return fgEmptyArray; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java deleted file mode 100644 index ef1cf5f59..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.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.compare.structuremergeviewer; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.compare.ITypedElement; - -/** - * An abstract base implementation of the IDiffElement interface. - *

- * Subclasses may add behavior and state, and may override getImage - * and getType to suit. - *

- */ -public abstract class DiffElement implements IDiffElement { - - private int fKind; - private IDiffContainer fParent; - - /** - * Creates a new DiffElement as a child of the given parent. - * If parent is not null the new element is added to the parent. - * - * @param parent the parent of this child; if not null this element is automatically added as a child - * @param kind the kind of change - */ - public DiffElement(IDiffContainer parent, int kind) { - fParent= parent; - fKind= kind; - if (parent != null) - parent.add(this); - } - - /** - * The DiffElement implementation of this ITypedInput - * method returns null. Subclasses may re-implement to provide - * an image for this element. - * @return null. - */ - public Image getImage() { - return null; - } - - /** - * The DiffElement implementation of this ITypedElement - * method returns ITypedElement.UNKNOWN_TYPE. Subclasses may - * re-implement to provide a type for this element. - * @return ITypedElement.UNKNOWN_TYPE. - */ - public String getType() { - return ITypedElement.UNKNOWN_TYPE; - } - - /** - * Sets the kind of difference for this element. - * - * @param kind set the kind of difference this element represents - * @see Differencer - */ - public void setKind(int kind) { - fKind= kind; - } - - /* (non Javadoc) - * see IDiffElement.getKind - */ - public int getKind() { - return fKind; - } - - /* (non Javadoc) - * see IDiffElement.getParent - */ - public IDiffContainer getParent() { - return fParent; - } - - /* (non Javadoc) - * see IDiffElement.setParent - */ - public void setParent(IDiffContainer parent) { - fParent= parent; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java deleted file mode 100644 index 8e062d273..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.text.MessageFormat; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.jface.util.ListenerList; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; - -/** - * Diff node are used as the compare result of the differencing engine. - * Since it implements the ITypedElement and ICompareInput - * interfaces it can be used directly to display the - * compare result in a DiffTreeViewer and as the input to any other - * compare/merge viewer. - *

- * DiffNodes are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients typically use this class as is, but may subclass if required. - * - * @see DiffTreeViewer - * @see Differencer - */ -public class DiffNode extends DiffContainer implements ITypedElement, ICompareInput { - - private ITypedElement fAncestor; - private ITypedElement fLeft; - private ITypedElement fRight; - private boolean fDontExpand; - private ListenerList fListener; - private boolean fSwapSides; - - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param parent under which the new container is added as a child or null - * @param kind of difference (defined in Differencer) - * @param ancestor the common ancestor input to a compare - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - this(parent, kind); - fAncestor= ancestor; - fLeft= left; - fRight= right; - } - - /** - * Creates a new DiffNode with diff kind Differencer.CHANGE - * and initializes with the given values. - * - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(ITypedElement left, ITypedElement right) { - this(null, Differencer.CHANGE, null, left, right); - } - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param kind of difference (defined in Differencer) - * @param ancestor the common ancestor input to a compare - * @param left the left input to a compare - * @param right the right input to a compare - */ - public DiffNode(int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) { - this(null, kind, ancestor, left, right); - } - - /** - * Creates a new DiffNode with the given diff kind. - * - * @param kind of difference (defined in Differencer) - */ - public DiffNode(int kind) { - super(null, kind); - } - - /** - * Creates a new DiffNode and initializes with the given values. - * - * @param parent under which the new container is added as a child or null - * @param kind of difference (defined in Differencer) - */ - public DiffNode(IDiffContainer parent, int kind) { - super(parent, kind); - } - - /** - * Registers a listener for changes of this ICompareInput. - * Has no effect if an identical listener is already registered. - * - * @param listener the listener to add - */ - public void addCompareInputChangeListener(ICompareInputChangeListener listener) { - if (fListener == null) - fListener= new ListenerList(); - fListener.add(listener); - } - - /** - * Unregisters a ICompareInput listener. - * Has no effect if listener is not registered. - * - * @param listener the listener to remove - */ - public void removeCompareInputChangeListener(ICompareInputChangeListener listener) { - if (fListener != null) { - fListener.remove(listener); - if (fListener.isEmpty()) - fListener= null; - } - } - - /** - * Sends out notification that a change has occured on the ICompareInput. - */ - protected void fireChange() { - if (fListener != null) { - Object[] listeners= fListener.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((ICompareInputChangeListener) listeners[i]).compareInputChanged(this); - } - } - - //---- getters & setters - - /** - * Returns true if this node shouldn't automatically be expanded in - * a DiffTreeViewer. - * - * @return true if node shouldn't automatically be expanded - */ - public boolean dontExpand() { - return fDontExpand; - } - - /** - * Controls whether this node is not automatically expanded when displayed in - * a DiffTreeViewer. - * - * @param dontExpand if true this node is not automatically expanded in DiffTreeViewer - */ - public void setDontExpand(boolean dontExpand) { - fDontExpand= dontExpand; - } - - /** - * Returns the first not-null input of this node. - * Method checks the three inputs in the order: ancestor, right, left. - * - * @return the first not-null input of this node - */ - public ITypedElement getId() { - if (fAncestor != null) - return fAncestor; - if (fRight != null) - return fRight; - return fLeft; - } - - /** - * Returns the (non-null) name of the left or right side if they are identical. - * Otherwise both names are concatenated (separated with a slash ('/')). - *

- * Subclasses may re-implement to provide a different name for this node. - * @return the name of this node. - */ - public String getName() { - String right= null; - if (fRight != null) - right= fRight.getName(); - - String left= null; - if (fLeft != null) - left= fLeft.getName(); - - if (right == null && left == null) { - if (fAncestor != null) - return fAncestor.getName(); - return Utilities.getString("DiffNode.noName"); //$NON-NLS-1$ - } - - if (right == null) - return left; - if (left == null) - return right; - - if (right.equals(left)) - return right; - - String s1; - String s2; - - if (fSwapSides) { - s1= left; - s2= right; - } else { - s1= right; - s2= left; - } - - String fmt= Utilities.getString("DiffNode.nameFormat"); //$NON-NLS-1$ - return MessageFormat.format(fmt, new String[] { s1, s2 }); - } - - void swapSides(boolean swap) { - fSwapSides= swap; - } - - /* (non Javadoc) - * see ITypedElement.getImage - */ - public Image getImage() { - ITypedElement id= getId(); - if (id != null) - return id.getImage(); - return null; - } - - /* (non Javadoc) - * see ITypedElement.getType - */ - public String getType() { - ITypedElement id= getId(); - if (id != null) - return id.getType(); - return ITypedElement.UNKNOWN_TYPE; - } - - /** - * Sets the ancestor input to the given value. - * - * @param ancestor the new value for the ancestor input - * @since 3.0 - */ - public void setAncestor(ITypedElement ancestor) { - fAncestor= ancestor; - } - - /* (non Javadoc) - * see ICompareInput.getAncestor - */ - public ITypedElement getAncestor() { - return fAncestor; - } - - /** - * Sets the left input to the given value. - * - * @param left the new value for the left input - */ - public void setLeft(ITypedElement left) { - fLeft= left; - } - - /* (non Javadoc) - * see ICompareInput.getLeft - */ - public ITypedElement getLeft() { - return fLeft; - } - - /** - * Sets the right input to the given value. - * - * @param right the new value for the right input - */ - public void setRight(ITypedElement right) { - fRight= right; - } - - /* (non Javadoc) - * see ICompareInput.getRight - */ - public ITypedElement getRight() { - return fRight; - } - - /* (non Javadoc) - * see ICompareInput.copy - */ - public void copy(boolean leftToRight) { - //System.out.println("DiffNode.copy: " + leftToRight); - - IDiffContainer pa= getParent(); - if (pa instanceof ICompareInput) { - ICompareInput parent= (ICompareInput) pa; - Object dstParent= leftToRight ? parent.getRight() : parent.getLeft(); - - if (dstParent instanceof IEditableContent) { - ITypedElement dst= leftToRight ? getRight() : getLeft(); - ITypedElement src= leftToRight ? getLeft() : getRight(); - dst= ((IEditableContent)dstParent).replace(dst, src); - if (leftToRight) - setRight(dst); - else - setLeft(dst); - - //setKind(Differencer.NO_CHANGE); - - fireChange(); - } - } - } - - /* (non Javadoc) - * see Object.hashCode - */ - public int hashCode() { - String[] path= getPath(this, 0); - int hashCode= 1; - for (int i= 0; i < path.length; i++) { - String s= path[i]; - hashCode= (31*hashCode) + (s != null ? s.hashCode() : 0); - } - return hashCode; - } - - /* (non Javadoc) - * see Object.equals - */ - public boolean equals(Object other) { - if (other != null && getClass() == other.getClass()) { - String[] path1= getPath(this, 0); - String[] path2= getPath((DiffNode) other, 0); - if (path1.length != path2.length) - return false; - for (int i= 0; i < path1.length; i++) - if (! path1[i].equals(path2[i])) - return false; - return true; - } - return super.equals(other); - } - - private static String[] getPath(ITypedElement el, int level) { - String[] path= null; - if (el instanceof IDiffContainer) { - IDiffContainer parent= ((IDiffContainer)el).getParent(); - if (parent != null) - path= getPath(parent, level+1); - } - if (path == null) - path= new String[level+1]; - path[(path.length-1)-level]= el.getName(); - return path; - } -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java deleted file mode 100644 index 5b6b849f3..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java +++ /dev/null @@ -1,727 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.util.Iterator; -import java.util.ResourceBundle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jface.util.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; - -import org.eclipse.compare.internal.*; -import org.eclipse.compare.*; - -/** - * A tree viewer that works on objects implementing - * the IDiffContainer and IDiffElement interfaces. - *

- * This class may be instantiated; it is not intended to be subclassed outside - * this package. - *

- * - * @see IDiffContainer - * @see IDiffElement - */ -public class DiffTreeViewer extends TreeViewer { - - static class DiffViewerSorter extends ViewerSorter { - - public boolean isSorterProperty(Object element, Object property) { - return false; - } - - public int category(Object node) { - if (node instanceof DiffNode) { - Object o= ((DiffNode) node).getId(); - if (o instanceof DocumentRangeNode) - return ((DocumentRangeNode) o).getTypeCode(); - } - return 0; - } - } - - class DiffViewerContentProvider implements ITreeContentProvider { - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // empty implementation - } - - public boolean isDeleted(Object element) { - return false; - } - - public void dispose() { - inputChanged(DiffTreeViewer.this, getInput(), null); - } - - public Object getParent(Object element) { - if (element instanceof IDiffElement) - return ((IDiffElement)element).getParent(); - return null; - } - - public final boolean hasChildren(Object element) { - if (element instanceof IDiffContainer) - return ((IDiffContainer)element).hasChildren(); - return false; - } - - public final Object[] getChildren(Object element) { - if (element instanceof IDiffContainer) - return ((IDiffContainer)element).getChildren(); - return new Object[0]; - } - - public Object[] getElements(Object element) { - return getChildren(element); - } - } - - /* - * Takes care of swapping left and right if fLeftIsLocal - * is true. - */ - class DiffViewerLabelProvider extends LabelProvider { - - public String getText(Object element) { - - if (element instanceof IDiffElement) - return ((IDiffElement)element).getName(); - - return Utilities.getString(fBundle, "defaultLabel"); //$NON-NLS-1$ - } - - public Image getImage(Object element) { - if (element instanceof IDiffElement) { - IDiffElement input= (IDiffElement) element; - - int kind= input.getKind(); - if (fLeftIsLocal) { - switch (kind & Differencer.DIRECTION_MASK) { - case Differencer.LEFT: - kind= (kind &~ Differencer.LEFT) | Differencer.RIGHT; - break; - case Differencer.RIGHT: - kind= (kind &~ Differencer.RIGHT) | Differencer.LEFT; - break; - } - } - - return fCompareConfiguration.getImage(input.getImage(), kind); - } - return null; - } - } - - static class FilterSame extends ViewerFilter { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof IDiffElement) - return (((IDiffElement)element).getKind() & Differencer.PSEUDO_CONFLICT) == 0; - return true; - } - public boolean isFilterProperty(Object element, Object property) { - return false; - } - } - - private ResourceBundle fBundle; - private CompareConfiguration fCompareConfiguration; - /* package */ boolean fLeftIsLocal; - private IPropertyChangeListener fPropertyChangeListener; - - private Action fCopyLeftToRightAction; - private Action fCopyRightToLeftAction; - private Action fEmptyMenuAction; - private Action fExpandAllAction; - - /** - * Creates a new viewer for the given SWT tree control with the specified configuration. - * - * @param tree the tree control - * @param configuration the configuration for this viewer - */ - public DiffTreeViewer(Tree tree, CompareConfiguration configuration) { - super(tree); - initialize(configuration); - } - - /** - * Creates a new viewer under the given SWT parent and with the specified configuration. - * - * @param parent the SWT control under which to create the viewer - * @param configuration the configuration for this viewer - */ - public DiffTreeViewer(Composite parent, CompareConfiguration configuration) { - super(new Tree(parent, SWT.MULTI)); - initialize(configuration); - } - - private void initialize(CompareConfiguration configuration) { - - Control tree= getControl(); - - INavigatable nav= new INavigatable() { - public boolean gotoDifference(boolean next) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return internalNavigate(next, true); - } - }; - tree.setData(INavigatable.NAVIGATOR_PROPERTY, nav); - - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - IOpenable openable= new IOpenable() { - public void openSelected() { - internalOpen(); - } - }; - tree.setData(IOpenable.OPENABLE_PROPERTY, openable); - - fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ - - tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - - Composite parent= tree.getParent(); - - fBundle= ResourceBundle.getBundle("org.eclipse.compare.structuremergeviewer.DiffTreeViewerResources"); //$NON-NLS-1$ - - // register for notification with the CompareConfiguration - fCompareConfiguration= configuration; - if (fCompareConfiguration != null) { - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - DiffTreeViewer.this.propertyChange(event); - } - }; - fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); - } - - setContentProvider(new DiffViewerContentProvider()); - setLabelProvider(new DiffViewerLabelProvider()); - - addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent se) { - updateActions(); - } - } - ); - - setSorter(new DiffViewerSorter()); - - ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - - tbm.add(new Separator("merge")); //$NON-NLS-1$ - tbm.add(new Separator("modes")); //$NON-NLS-1$ - tbm.add(new Separator("navigation")); //$NON-NLS-1$ - - createToolItems(tbm); - updateActions(); - - tbm.update(true); - } - - MenuManager mm= new MenuManager(); - mm.setRemoveAllWhenShown(true); - mm.addMenuListener( - new IMenuListener() { - public void menuAboutToShow(IMenuManager mm2) { - fillContextMenu(mm2); - if (mm2.isEmpty()) { - if (fEmptyMenuAction == null) { - fEmptyMenuAction= new Action(Utilities.getString(fBundle, "emptyMenuItem")) { //$NON-NLS-1$ - // left empty - }; - fEmptyMenuAction.setEnabled(false); - } - mm2.add(fEmptyMenuAction); - } - } - } - ); - tree.setMenu(mm.createContextMenu(tree)); - } - - /** - * Returns the viewer's name. - * - * @return the viewer's name - */ - public String getTitle() { - String title= Utilities.getString(fBundle, "title", null); //$NON-NLS-1$ - if (title == null) - title= Utilities.getString("DiffTreeViewer.title"); //$NON-NLS-1$ - return title; - } - - /** - * Returns the resource bundle. - * - * @return the viewer's resource bundle - */ - protected ResourceBundle getBundle() { - return fBundle; - } - - /** - * Returns the compare configuration of this viewer. - * - * @return the compare configuration of this viewer - */ - public CompareConfiguration getCompareConfiguration() { - return fCompareConfiguration; - } - - /** - * Called on the viewer disposal. - * Unregisters from the compare configuration. - * Clients may extend if they have to do additional cleanup. - * @param event dispose event that triggered call to this method - */ - protected void handleDispose(DisposeEvent event) { - - if (fCompareConfiguration != null) { - if (fPropertyChangeListener != null) - fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener); - fCompareConfiguration= null; - } - fPropertyChangeListener= null; - - super.handleDispose(event); - } - - /** - * Tracks property changes of the configuration object. - * Clients may extend to track their own property changes. - * @param event property change event that triggered call to this method - */ - protected void propertyChange(PropertyChangeEvent event) { - // empty default implementation - } - - protected void inputChanged(Object in, Object oldInput) { - super.inputChanged(in, oldInput); - - if (in != oldInput) { - initialSelection(); - updateActions(); - } - } - - /** - * This hook method is called from within inputChanged - * after a new input has been set but before any controls are updated. - * This default implementation calls navigate(true) - * to select and expand the first leaf node. - * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * - * @since 2.0 - */ - protected void initialSelection() { - navigate(true); - } - - /** - * Overridden to avoid expanding DiffNodes that shouldn't expand. - * @param node the node to expand - * @param level non-negative level, or ALL_LEVELS to collapse all levels of the tree - */ - protected void internalExpandToLevel(Widget node, int level) { - - Object data= node.getData(); - - if (dontExpand(data)) - return; - - super.internalExpandToLevel(node, level); - } - - /** - * This hook method is called from within internalExpandToLevel - * to control whether a given model node should be expanded or not. - * This default implementation checks whether the object is a DiffNode and - * calls dontExpand() on it. - * Clients can override this method and are free to decide whether - * they want to call the inherited method. - * - * @param o the model object to be expanded - * @return false if a node should be expanded, true to prevent expanding - * @since 2.0 - */ - protected boolean dontExpand(Object o) { - return o instanceof DiffNode && ((DiffNode)o).dontExpand(); - } - - //---- merge action support - - /** - * This factory method is called after the viewer's controls have been created. - * It installs four actions in the given ToolBarManager. Two actions - * allow for copying one side of a DiffNode to the other side. - * Two other actions are for navigating from one node to the next (previous). - *

- * Clients can override this method and are free to decide whether they want to call - * the inherited method. - * - * @param toolbarManager the toolbar manager for which to add the actions - */ - protected void createToolItems(ToolBarManager toolbarManager) { - -// fCopyLeftToRightAction= new Action() { -// public void run() { -// copySelected(true); -// } -// }; -// Utilities.initAction(fCopyLeftToRightAction, fBundle, "action.TakeLeft."); -// toolbarManager.appendToGroup("merge", fCopyLeftToRightAction); - -// fCopyRightToLeftAction= new Action() { -// public void run() { -// copySelected(false); -// } -// }; -// Utilities.initAction(fCopyRightToLeftAction, fBundle, "action.TakeRight."); -// toolbarManager.appendToGroup("merge", fCopyRightToLeftAction); - -// fNextAction= new Action() { -// public void run() { -// navigate(true); -// } -// }; -// Utilities.initAction(fNextAction, fBundle, "action.NextDiff."); //$NON-NLS-1$ -// toolbarManager.appendToGroup("navigation", fNextAction); //$NON-NLS-1$ - -// fPreviousAction= new Action() { -// public void run() { -// navigate(false); -// } -// }; -// Utilities.initAction(fPreviousAction, fBundle, "action.PrevDiff."); //$NON-NLS-1$ -// toolbarManager.appendToGroup("navigation", fPreviousAction); //$NON-NLS-1$ - } - - /** - * This method is called to add actions to the viewer's context menu. - * It installs actions for expanding tree nodes, copying one side of a DiffNode to the other side. - * Clients can override this method and are free to decide whether they want to call - * the inherited method. - * - * @param manager the menu manager for which to add the actions - */ - protected void fillContextMenu(IMenuManager manager) { - if (fExpandAllAction == null) { - fExpandAllAction= new Action() { - public void run() { - expandSelection(); - } - }; - Utilities.initAction(fExpandAllAction, fBundle, "action.ExpandAll."); //$NON-NLS-1$ - } - - boolean enable= false; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator elements= ((IStructuredSelection)selection).iterator(); - while (elements.hasNext()) { - Object element= elements.next(); - if (element instanceof IDiffContainer) { - if (((IDiffContainer)element).hasChildren()) { - enable= true; - break; - } - } - } - } - fExpandAllAction.setEnabled(enable); - - manager.add(fExpandAllAction); - - if (fCopyLeftToRightAction != null) - manager.add(fCopyLeftToRightAction); - if (fCopyRightToLeftAction != null) - manager.add(fCopyRightToLeftAction); - } - - /** - * Expands to infinity all items in the selection. - * - * @since 2.0 - */ - protected void expandSelection() { - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator elements= ((IStructuredSelection)selection).iterator(); - while (elements.hasNext()) { - Object next= elements.next(); - expandToLevel(next, ALL_LEVELS); - } - } - } - - /** - * Copies one side of all DiffNodes in the current selection to the other side. - * Called from the (internal) actions for copying the sides of a DiffNode. - * Clients may override. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copySelected(boolean leftToRight) { - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator e= ((IStructuredSelection) selection).iterator(); - while (e.hasNext()) { - Object element= e.next(); - if (element instanceof ICompareInput) - copyOne((ICompareInput) element, leftToRight); - } - } - } - - /** - * Called to copy one side of the given node to the other. - * This default implementation delegates the call to ICompareInput.copy(...). - * Clients may override. - * @param node the node to copy - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copyOne(ICompareInput node, boolean leftToRight) { - - node.copy(leftToRight); - - // update node's image - update(new Object[] { node }, null); - } - - /** - * Selects the next (or previous) node of the current selection. - * If there is no current selection the first (last) node in the tree is selected. - * Wraps around at end or beginning. - * Clients may override. - * - * @param next if true the next node is selected, otherwise the previous node - */ - protected void navigate(boolean next) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - internalNavigate(next, false); - } - - //---- private - - /** - * Selects the next (or previous) node of the current selection. - * If there is no current selection the first (last) node in the tree is selected. - * Wraps around at end or beginning. - * Clients may override. - * - * @param next if true the next node is selected, otherwise the previous node - * @param fireOpen if true an open event is fired. - * @return true if at end (or beginning) - */ - private boolean internalNavigate(boolean next, boolean fireOpen) { - - Control c= getControl(); - if (!(c instanceof Tree)) - return false; - - Tree tree= (Tree) c; - TreeItem item= null; - TreeItem children[]= tree.getSelection(); - if (children != null && children.length > 0) - item= children[0]; - if (item == null) { - children= tree.getItems(); - if (children != null && children.length > 0) { - item= children[0]; - if (item != null && item.getItemCount() <= 0) { - internalSetSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - } - } - - while (true) { - item= findNextPrev(item, next); - if (item == null) - break; - if (item.getItemCount() <= 0) - break; - } - - if (item != null) { - internalSetSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - return true; - } - - private TreeItem findNextPrev(TreeItem item, boolean next) { - - if (item == null) - return null; - - TreeItem children[]= null; - - if (!next) { - - TreeItem parent= item.getParentItem(); - if (parent != null) - children= parent.getItems(); - else - children= item.getParent().getItems(); - - if (children != null && children.length > 0) { - // goto previous child - int index= 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - - if (index > 0) { - - item= children[index-1]; - - while (true) { - createChildren(item); - int n= item.getItemCount(); - if (n <= 0) - break; - - item.setExpanded(true); - item= item.getItems()[n-1]; - } - - // previous - return item; - } - } - - // go up - item= parent; - - } else { - item.setExpanded(true); - createChildren(item); - - if (item.getItemCount() > 0) { - // has children: go down - children= item.getItems(); - return children[0]; - } - - while (item != null) { - children= null; - TreeItem parent= item.getParentItem(); - if (parent != null) - children= parent.getItems(); - else - children= item.getParent().getItems(); - - if (children != null && children.length > 0) { - // goto next child - int index= 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - - if (index < children.length-1) { - // next - return children[index+1]; - } - } - - // go up - item= parent; - } - } - - return item; - } - - private void internalSetSelection(TreeItem ti, boolean fireOpen) { - if (ti != null) { - Object data= ti.getData(); - if (data != null) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - ISelection selection= new StructuredSelection(data); - setSelection(selection, true); - ISelection currentSelection= getSelection(); - if (fireOpen && currentSelection != null && selection.equals(currentSelection)) { - fireOpen(new OpenEvent(this, selection)); - } - } - } - } - - private final boolean isEditable(Object element, boolean left) { - if (element instanceof ICompareInput) { - ICompareInput diff= (ICompareInput) element; - Object side= left ? diff.getLeft() : diff.getRight(); - if (side == null && diff instanceof IDiffElement) { - IDiffContainer container= ((IDiffElement)diff).getParent(); - if (container instanceof ICompareInput) { - ICompareInput parent= (ICompareInput) container; - side= left ? parent.getLeft() : parent.getRight(); - } - } - if (side instanceof IEditableContent) - return ((IEditableContent) side).isEditable(); - } - return false; - } - - private void updateActions() { - int leftToRight= 0; - int rightToLeft= 0; - ISelection selection= getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - Iterator e= ss.iterator(); - while (e.hasNext()) { - Object element= e.next(); - if (element instanceof ICompareInput) { - if (isEditable(element, false)) - leftToRight++; - if (isEditable(element, true)) - rightToLeft++; - if (leftToRight > 0 && rightToLeft > 0) - break; - } - } - if (fExpandAllAction != null) - fExpandAllAction.setEnabled(selection.isEmpty()); - } - if (fCopyLeftToRightAction != null) - fCopyLeftToRightAction.setEnabled(leftToRight > 0); - if (fCopyRightToLeftAction != null) - fCopyRightToLeftAction.setEnabled(rightToLeft > 0); - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private void internalOpen() { - ISelection selection= getSelection(); - if (selection != null && !selection.isEmpty()) { - fireOpen(new OpenEvent(this, selection)); - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties deleted file mode 100644 index f737039be..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewerResources.properties +++ /dev/null @@ -1,53 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# @(#)DiffTreeViewerResources.properties -# -# Resource strings for DiffTreeViewer.java - -title= Structure Compare -defaultLabel= - -##################################################### -# Dummy menu item for empty context menu -##################################################### - -emptyMenuItem= - -##################################################### -# Actions -##################################################### - -action.Smart.label=Smart -action.Smart.tooltip=Guess Similar Elements -action.Smart.image=smartmode_co.gif - -action.ExpandAll.label=Expand All -action.ExpandAll.tooltip=Expand All Nodes - -action.CompareContents.label= Show Content Comparison -action.CompareContents.tooltip= Show Content Comparison - -action.NextDiff.label=Next -action.NextDiff.tooltip=Select Next Change -action.NextDiff.image=next_nav.gif - -action.PrevDiff.label=Previous -action.PrevDiff.tooltip=Select Previous Change -action.PrevDiff.image=prev_nav.gif - -action.TakeLeft.label=Copy Left to Right -action.TakeLeft.tooltip=Copy Selected Nodes from Left to Right -action.TakeLeft.image=copycont_r_co.gif - -action.TakeRight.label=Copy Right to Left -action.TakeRight.tooltip=Copy Selected Nodes from Right to Left -action.TakeRight.image=copycont_l_co.gif diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java deleted file mode 100644 index b90c3c0ef..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java +++ /dev/null @@ -1,529 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.io.*; -import java.util.*; -import java.text.MessageFormat; - -import org.eclipse.jface.util.Assert; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; - - -/** - * A generic two-way or three-way differencing engine. - *

- * The engine is used by calling one of the findDifferences methods and passing - * in the objects to compare. - * The engine calls the following methods on the input objects to perform the compare: - *

    - *
  • getChildren: for enumerating the children of an object (if any), - *
  • contentsEqual: for comparing the content of leaf objects, that is, objects without children, - *
  • visit: for every pair of compared object the compare result is passed in. - *
- * Clients may use as is, or subclass to provide a custom implementation for the three hooks. - * However the default implementation already deals with the typical case: - *
    - *
  • getChildren: tries to apply the IStructureComparator - * interface to enumerate the children, - *
  • contentsEqual: tries to apply the IStreamContentAccessor interface - * to perform a byte-wise content comparison, - *
  • visit: creates a DiffNode for any detected difference between the compared objects and - * links it under a parent node effectively creating a tree of differences. - *
- * The different kind of changes detected by the engine are decoded as follows: - * In the two-way case only NO_CHANGE, ADDITION, DELETION, and CHANGE are used. - * In the three-way case these constants are bitwise ORed with one of directional constants - * LEFT, RIGHT, and CONFLICTING. - */ -public class Differencer { - - // The kind of differences. - /** - * Difference constant (value 0) indicating no difference. - */ - public static final int NO_CHANGE= 0; - /** - * Difference constant (value 1) indicating one side was added. - */ - public static final int ADDITION= 1; - /** - * Difference constant (value 2) indicating one side was removed. - */ - public static final int DELETION= 2; - /** - * Difference constant (value 3) indicating side changed. - */ - public static final int CHANGE= 3; - - /** - * Bit mask (value 3) for extracting the kind of difference. - */ - public static final int CHANGE_TYPE_MASK= 3; - - // The direction of a three-way change. - /** - * Three-way change constant (value 4) indicating a change on left side. - */ - public static final int LEFT= 4; - - /** - * Three-way change constant (value 8) indicating a change on right side. - */ - public static final int RIGHT= 8; - - /** - * Three-way change constant (value 12) indicating a change on left and - * right sides. - */ - public static final int CONFLICTING= 12; - - /** - * Bit mask (value 12) for extracting the direction of a three-way change. - */ - public static final int DIRECTION_MASK= 12; - - /** - * Constant (value 16) indicating a change on left and - * right side (with respect to ancestor) but left and right are identical. - */ - public static final int PSEUDO_CONFLICT= 16; - - - static class Node { - List fChildren; - int fCode; - Object fAncestor; - Object fLeft; - Object fRight; - - Node() { - // nothing to do - } - Node(Node parent, Object ancestor, Object left, Object right) { - parent.add(this); - fAncestor= ancestor; - fLeft= left; - fRight= right; - } - void add(Node child) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(child); - } - Object visit(Differencer d, Object parent, int level) { - if (fCode == NO_CHANGE) - return null; - //dump(level); - Object data= d.visit(parent, fCode, fAncestor, fLeft, fRight); - if (fChildren != null) { - Iterator i= fChildren.iterator(); - while (i.hasNext()) { - Node n= (Node) i.next(); - n.visit(d, data, level+1); - } - } - return data; - } -// private void dump(int level) { -// String name= null; -// if (fAncestor instanceof ITypedElement) -// name= ((ITypedElement)fAncestor).getName(); -// if (name == null && fLeft instanceof ITypedElement) -// name= ((ITypedElement)fLeft).getName(); -// if (name == null && fRight instanceof ITypedElement) -// name= ((ITypedElement)fRight).getName(); -// if (name == null) -// name= "???"; //$NON-NLS-1$ -// -// for (int i= 0; i < level; i++) -// System.out.print(" "); //$NON-NLS-1$ -// -// System.out.println(getDiffType(fCode) + name); -// } - -// private String getDiffType(int code) { -// String dir= " "; //$NON-NLS-1$ -// switch (code & DIRECTION_MASK) { -// case LEFT: -// dir= ">"; //$NON-NLS-1$ -// break; -// case RIGHT: -// dir= "<"; //$NON-NLS-1$ -// break; -// case CONFLICTING: -// dir= "!"; //$NON-NLS-1$ -// break; -// } -// String change= "="; //$NON-NLS-1$ -// switch (code & CHANGE_TYPE_MASK) { -// case ADDITION: -// change= "+"; //$NON-NLS-1$ -// break; -// case DELETION: -// change= "-"; //$NON-NLS-1$ -// break; -// case CHANGE: -// change= "#"; //$NON-NLS-1$ -// break; -// } -// return dir + change + " "; //$NON-NLS-1$ -// } - } - - /** - * Creates a new differencing engine. - */ - public Differencer() { - // nothing to do - } - - /** - * Starts the differencing engine on the three input objects. If threeWay is true a - * three-way comparison is performed, otherwise a two-way compare (in the latter case the ancestor argument is ignored). - * The progress monitor is passed to the method updateProgress which is called for every node or - * leaf compare. The method returns the object that was returned from the top-most call to method visit. - * At most two of the ancestor, left, and right parameters are allowed to be null. - * - * @param threeWay if true a three-way comparison is performed, otherwise a two-way compare - * @param pm a progress monitor which is passed to method updateProgress - * @param data a client data that is passed to the top-level call to visit - * @param ancestor the ancestor object of the compare (may be null) - * @param left the left object of the compare - * @param right the right object of the compare - * @return the object returned from the top most call to method visit, - * possibly null - */ - public Object findDifferences(boolean threeWay, IProgressMonitor pm, Object data, Object ancestor, Object left, Object right) { - - Node root= new Node(); - - int code= traverse(threeWay, root, pm, threeWay ? ancestor : null, left, right); - - if (code != NO_CHANGE) { - List l= root.fChildren; - if (l.size() > 0) { - Node first= (Node)l.get(0); - return first.visit(this, data, 0); - } - } - return null; - } - - /* - * Traverse tree in postorder. - */ - private int traverse(boolean threeWay, Node parent, IProgressMonitor pm, Object ancestor, Object left, Object right) { - - Object[] ancestorChildren= getChildren(ancestor); - Object[] rightChildren= getChildren(right); - Object[] leftChildren= getChildren(left); - - int code= NO_CHANGE; - - Node node= new Node(parent, ancestor, left, right); - - boolean content= true; // we reset this if we have at least one child - - if (((threeWay && ancestorChildren != null) || !threeWay) - && rightChildren != null && leftChildren != null) { - // we only recurse down if no leg is null - // a node - - Set allSet= new HashSet(20); - Map ancestorSet= null; - Map rightSet= null; - Map leftSet= null; - - if (ancestorChildren != null) { - ancestorSet= new HashMap(10); - for (int i= 0; i < ancestorChildren.length; i++) { - Object ancestorChild= ancestorChildren[i]; - ancestorSet.put(ancestorChild, ancestorChild); - allSet.add(ancestorChild); - } - } - - if (rightChildren != null) { - rightSet= new HashMap(10); - for (int i= 0; i < rightChildren.length; i++) { - Object rightChild= rightChildren[i]; - rightSet.put(rightChild, rightChild); - allSet.add(rightChild); - } - } - - if (leftChildren != null) { - leftSet= new HashMap(10); - for (int i= 0; i < leftChildren.length; i++) { - Object leftChild= leftChildren[i]; - leftSet.put(leftChild, leftChild); - allSet.add(leftChild); - } - } - - Iterator e= allSet.iterator(); - while (e.hasNext()) { - Object keyChild= e.next(); - - content= false; - - if (pm != null) { - - if (pm.isCanceled()) - throw new OperationCanceledException(); - - updateProgress(pm, keyChild); - } - - Object ancestorChild= ancestorSet != null ? ancestorSet.get(keyChild) : null; - Object leftChild= leftSet != null ? leftSet.get(keyChild) : null; - Object rightChild= rightSet != null ? rightSet.get(keyChild) : null; - - int c= traverse(threeWay, node, pm, ancestorChild, leftChild, rightChild); - - if ((c & CHANGE_TYPE_MASK) != NO_CHANGE) { - code|= CHANGE; // deletions and additions of child result in a change of the container - code|= (c & DIRECTION_MASK); // incoming & outgoing are just ored - } - } - } - - if (content) // a leaf - code= compare(threeWay, ancestor, left, right); - - node.fCode= code; - - return code; - } - - /** - * Called for every node or leaf comparison. - * The differencing engine passes in the input objects of the compare and the result of the compare. - * The data object is the value returned from a call to the visit method on the parent input. - * It can be considered the "parent" reference and is useful when building a tree. - *

- * The Differencer implementation returns a new - * DiffNode which is initialized with the corresponding values. - * Subclasses may override. - * - * @param data object returned from parent call to visit, - * possibly null - * @param result the result of the compare operation performed on the three inputs - * @param ancestor the compare ancestor of the left and right inputs - * @param left the left input to the compare - * @param right the right input to the compare - * @return the result, possibly null - */ - protected Object visit(Object data, int result, Object ancestor, Object left, Object right) { - return new DiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); - } - - /* - * Performs a 2-way or 3-way compare of the given leaf elements and returns an integer - * describing the kind of difference. - */ - private int compare(boolean threeway, Object ancestor, Object left, Object right) { - - int description= NO_CHANGE; - - if (threeway) { - if (ancestor == null) { - if (left == null) { - if (right == null) { - Assert.isTrue(false); - // shouldn't happen - } else { - description= RIGHT | ADDITION; - } - } else { - if (right == null) { - description= LEFT | ADDITION; - } else { - description= CONFLICTING | ADDITION; - if (contentsEqual(left, right)) - description|= PSEUDO_CONFLICT; - } - } - } else { - if (left == null) { - if (right == null) { - description= CONFLICTING | DELETION | PSEUDO_CONFLICT; - } else { - if (contentsEqual(ancestor, right)) - description= LEFT | DELETION; - else - description= CONFLICTING | CHANGE; - } - } else { - if (right == null) { - if (contentsEqual(ancestor, left)) - description= RIGHT | DELETION; - else - description= CONFLICTING | CHANGE; - } else { - boolean ay= contentsEqual(ancestor, left); - boolean am= contentsEqual(ancestor, right); - - if (ay && am) { - // empty - } else if (ay && !am) { - description= RIGHT | CHANGE; - } else if (!ay && am) { - description= LEFT | CHANGE; - } else { - description= CONFLICTING | CHANGE; - if (contentsEqual(left, right)) - description|= PSEUDO_CONFLICT; - } - } - } - } - } else { // two way compare ignores ancestor - if (left == null) { - if (right == null) { - Assert.isTrue(false); - // shouldn't happen - } else { - description= ADDITION; - } - } else { - if (right == null) { - description= DELETION; - } else { - if (! contentsEqual(left, right)) - description= CHANGE; - } - } - } - - return description; - } - - /** - * Performs a content compare on the two given inputs. - *

- * The Differencer implementation - * returns true if both inputs implement IStreamContentAccessor - * and their byte contents is identical. Subclasses may override to implement - * a different content compare on the given inputs. - *

- * - * @param input1 first input to contents compare - * @param input2 second input to contents compare - * @return true if content is equal - */ - protected boolean contentsEqual(Object input1, Object input2) { - - if (input1 == input2) - return true; - - InputStream is1= getStream(input1); - InputStream is2= getStream(input2); - - if (is1 == null && is2 == null) // no byte contents - return true; - - try { - if (is1 == null || is2 == null) // only one has contents - return false; - - while (true) { - int c1= is1.read(); - int c2= is2.read(); - if (c1 == -1 && c2 == -1) - return true; - if (c1 != c2) - break; - - } - } catch (IOException ex) { - // NeedWork - } finally { - if (is1 != null) { - try { - is1.close(); - } catch(IOException ex) { - // silently ignored - } - } - if (is2 != null) { - try { - is2.close(); - } catch(IOException ex) { - // silently ignored - } - } - } - return false; - } - - /* - * Tries to return an InputStream for the given object. - * Returns null if the object not an IStreamContentAccessor - * or an error occured. - */ - private InputStream getStream(Object o) { - if (o instanceof IStreamContentAccessor) { - try { - return ((IStreamContentAccessor)o).getContents(); - } catch(CoreException ex) { - // NeedWork - } - } - return null; - } - - /** - * Returns the children of the given input or null if there are no children. - *

- * The Differencer implementation checks whether the input - * implements the IStructureComparator interface. If yes it is used - * to return an array containing all children. Otherwise null is returned. - * Subclasses may override to implement a different strategy to enumerate children. - *

- * - * @param input the object for which to return children - * @return the children of the given input or null if there are no children. - */ - protected Object[] getChildren(Object input) { - if (input instanceof IStructureComparator) - return ((IStructureComparator)input).getChildren(); - return null; - } - - /** - * Called for every leaf or node compare to update progress information. - *

- * The Differencer implementation shows the name of the input object - * as a subtask. Subclasses may override. - *

- * - * @param progressMonitor the progress monitor for reporting progress - * @param node the currently processed non-null node - */ - protected void updateProgress(IProgressMonitor progressMonitor, Object node) { - if (node instanceof ITypedElement) { - String name= ((ITypedElement)node).getName(); - String fmt= Utilities.getString("Differencer.progressFormat"); //$NON-NLS-1$ - String msg= MessageFormat.format(fmt, new String[] { name }); - progressMonitor.subTask(msg); - //progressMonitor.worked(1); - } - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java deleted file mode 100644 index d35bc457c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.ArrayList; - -import org.eclipse.jface.text.*; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.compare.*; -import org.eclipse.compare.internal.Utilities; -import org.eclipse.compare.contentmergeviewer.IDocumentRange; - - -/** - * A document range node represents a structural element - * when performing a structure compare of documents. - * DocumentRangeNodes are created while parsing the document and represent - * a semantic entity (e.g. a Java class or method). - * As a consequence of the parsing a DocumentRangeNode maps to a range - * of characters in the document. - *

- * Since a DocumentRangeNode implements the IStructureComparator - * and IStreamContentAccessor interfaces it can be used as input to the - * differencing engine. This makes it possible to perform - * a structural diff on a document and have the nodes and leaves of the compare easily map - * to character ranges within the document. - *

- * Subclasses may add additional state collected while parsing the document. - *

- * @see Differencer - */ -public class DocumentRangeNode - implements IDocumentRange, IStructureComparator, IEditableContent, IEncodedStreamContentAccessor { - - private static final boolean POS_UPDATE= true; - private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - - private IDocument fBaseDocument; - private Position fRange; // the range in the base document - private int fTypeCode; - private String fID; - private Position fAppendPosition; // a position where to insert a child textually - private ArrayList fChildren; - - /** - * Creates a new DocumentRangeNode for the given range within the specified - * document. The typeCode is uninterpreted client data. The ID is used when comparing - * two nodes with each other: i.e. the differencing engine performs a content compare - * on two nodes if their IDs are equal. - * - * @param typeCode a type code for this node - * @param id an identifier for this node - * @param document document on which this node is based on - * @param start start position of range within document - * @param length length of range - */ - public DocumentRangeNode(int typeCode, String id, IDocument document, int start, int length) { - - fTypeCode= typeCode; - fID= id; - - fBaseDocument= document; - fBaseDocument.addPositionCategory(RANGE_CATEGORY); - fRange= new Position(start, length); - - if (POS_UPDATE) { - try { - document.addPosition(RANGE_CATEGORY, fRange); - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } - } - - /* (non Javadoc) - * see IDocumentRange.getDocument - */ - public IDocument getDocument() { - return fBaseDocument; - } - - /* (non Javadoc) - * see IDocumentRange.getRange - */ - public Position getRange() { - return fRange; - } - - /** - * Returns the type code of this node. - * The type code is uninterpreted client data which can be set in the constructor. - * - * @return the type code of this node - */ - public int getTypeCode() { - return fTypeCode; - } - - /** - * Returns this node's id. - * It is used in equals and hashcode. - * - * @return the node's id - */ - public String getId() { - return fID; - } - - /** - * Sets this node's id. - * It is used in equals and hashcode. - * - * @param id the new id for this node - */ - public void setId(String id) { - fID= id; - } - - /** - * Adds the given node as a child. - * - * @param node the node to add as a child - */ - public void addChild(DocumentRangeNode node) { - if (fChildren == null) - fChildren= new ArrayList(); - fChildren.add(node); - } - - /* (non Javadoc) - * see IStructureComparator.getChildren - */ - public Object[] getChildren() { - if (fChildren != null) - return fChildren.toArray(); - return new Object[0]; - } - - /** - * Sets the length of the range of this node. - * - * @param length the length of the range - */ - public void setLength(int length) { - getRange().setLength(length); - } - - /** - * Sets a position within the document range that can be used to (legally) insert - * text without breaking the syntax of the document. - *

- * E.g. when parsing a Java document the "append position" of a DocumentRangeNode - * representating a Java class could be the character position just before the closing bracket. - * Inserting the text of a new method there would not disturb the syntax of the class. - * - * @param pos the character position within the underlying document where text can be legally inserted - */ - public void setAppendPosition(int pos) { - if (POS_UPDATE) { - fBaseDocument.removePosition(fAppendPosition); - try { - Position p= new Position(pos); - fBaseDocument.addPosition(RANGE_CATEGORY, p); - fAppendPosition= p; - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } else { - fAppendPosition= new Position(pos); - } - } - - /** - * Returns the position that has been set with setAppendPosition. - * If setAppendPosition hasn't been called, the position after the last character - * of this range is returned. - * - * @return a position where text can be legally inserted - */ - public Position getAppendPosition() { - if (fAppendPosition == null) { - if (POS_UPDATE) { - try { - Position p= new Position(fBaseDocument.getLength()); - fBaseDocument.addPosition(RANGE_CATEGORY, p); - fAppendPosition= p; - } catch (BadPositionCategoryException ex) { - // silently ignored - } catch (BadLocationException ex) { - // silently ignored - } - } else { - fAppendPosition= new Position(fBaseDocument.getLength()); - } - } - return fAppendPosition; - } - - /** - * Implementation based on getID. - * @param other the object to compare this DocumentRangeNode against. - * @return true if the DocumentRangeNodesare equal; false otherwise. - */ - public boolean equals(Object other) { - if (other != null && other.getClass() == getClass()) { - DocumentRangeNode tn= (DocumentRangeNode) other; - return fTypeCode == tn.fTypeCode && fID.equals(tn.fID); - } - return super.equals(other); - } - - /** - * Implementation based on getID. - * @return a hashcode for this object. - */ - public int hashCode() { - return fID.hashCode(); - } - - /* - * Find corresponding position - */ - private Position findCorrespondingPosition(DocumentRangeNode otherParent, DocumentRangeNode child) { - - // we try to find a predecessor of left Node which exists on the right side - - if (child != null && fChildren != null) { - int ix= otherParent.fChildren.indexOf(child); - if (ix >= 0) { - - for (int i= ix - 1; i >= 0; i--) { - DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i); - int i2= fChildren.indexOf(c1); - if (i2 >= 0) { - DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2); - //System.out.println(" found corresponding: " + i2 + " " + c); - Position p= c.fRange; - - //try { - Position po= new Position(p.getOffset() + p.getLength() + 1, 0); - //c.fBaseDocument.addPosition(RANGE_CATEGORY, po); - return po; - //} catch (BadLocationException ex) { - //} - //break; - } - } - - for (int i= ix; i < otherParent.fChildren.size(); i++) { - DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i); - int i2= fChildren.indexOf(c1); - if (i2 >= 0) { - DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2); - //System.out.println(" found corresponding: " + i2 + " " + c); - Position p= c.fRange; - //try { - Position po= new Position(p.getOffset(), 0); - //c.fBaseDocument.addPosition(RANGE_CATEGORY, po); - return po; - //} catch (BadLocationException ex) { - //} - //break; - } - } - - } - } - return getAppendPosition(); - } - - private void add(String s, DocumentRangeNode parent, DocumentRangeNode child) { - - Position p= findCorrespondingPosition(parent, child); - if (p != null) { - try { - fBaseDocument.replace(p.getOffset(), p.getLength(), s); - } catch (BadLocationException ex) { - // silently ignored - } - } - } - - /* (non Javadoc) - * see IStreamContentAccessor.getContents - */ - public InputStream getContents() { - String s; - try { - s= fBaseDocument.get(fRange.getOffset(), fRange.getLength()); - } catch (BadLocationException ex) { - s= ""; //$NON-NLS-1$ - } - return new ByteArrayInputStream(Utilities.getBytes(s, UTF_16)); - } - - /* (non Javadoc) - * see IEditableContent.isEditable - */ - public boolean isEditable() { - return true; - } - - /* (non Javadoc) - * see IEditableContent.replace - */ - public ITypedElement replace(ITypedElement child, ITypedElement other) { - - DocumentRangeNode src= null; - String srcContents= ""; //$NON-NLS-1$ - - if (other != null) { - src= (DocumentRangeNode) child; - - if (other instanceof IStreamContentAccessor) { - try { - srcContents= Utilities.readString((IStreamContentAccessor)other); - } catch(CoreException ex) { - // NeedWork - } - } - } - - if (child == null) // no destination: we have to add the contents into the parent - add(srcContents, null, src); - - return child; - } - - /* (non Javadoc) - * see IEditableContent.setContent - */ - public void setContent(byte[] content) { - // empty default implementation - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IStreamContentAccessor#getEncoding() - */ - public String getCharset() { - return UTF_16; - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java deleted file mode 100644 index 4d937937f..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import org.eclipse.compare.ITypedElement; -import org.eclipse.swt.graphics.Image; - -/** - * Interface for objects used as input to a two-way or three-way compare viewer. - * It defines API for accessing the three sides for the compare, - * and a name and image which is used when displaying the three way input - * in the UI, for example, in a title bar. - *

- * Note: at most two sides of an ICompareInput can be null, - * (as it is normal for additions or deletions) but not all three. - *

- * ICompareInput provides methods for registering - * ICompareInputChangeListeners - * that get informed if one (or more) - * of the three sides of an ICompareInput object changes its value. - *

- * For example when accepting an incoming addition - * the (non-null) left side of an ICompareInput - * is copied to the right side by means of method copy. - * This should trigger a call to compareInputChanged of registered - * ICompareInputChangeListeners. - *

- * Clients can implement this interface, or use the convenience implementation - * DiffNode. - *

- * - * @see StructureDiffViewer - * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer - * @see DiffNode - */ -public interface ICompareInput { - - /** - * Returns name of input. - * This name is displayed when this input is shown in a viewer. - * In many cases this name is the name of one of the non-null sides or a combination - * thereof. - * - * @return name of input - */ - String getName(); - - /** - * Returns an image representing this input. - * This image is typically displayed when this input is shown in a viewer. - * In many cases this image is the image of one of the non-null sides. - * - * @return image representing this input, or null if no icon should be shown - */ - Image getImage(); - - /** - * Returns the kind of difference between the - * three sides ancestor, left and right. - * This field is only meaningful if the ICompareInput - * is the result of another compare. In this case it is used - * together with getImage to compose a icon - * which reflects the kind of difference between the two or three elements. - * - * @return kind of difference (see Differencer) - */ - int getKind(); - - /** - * Returns the ancestor side of this input. - * Returns null if this input has no ancestor - * or in the two-way compare case. - * - * @return the ancestor of this input, or null - */ - ITypedElement getAncestor(); - - /** - * Returns the left side of this input. - * Returns null if there is no left side (deletion or addition). - * - * @return the left side of this input, or null - */ - ITypedElement getLeft(); - - /** - * Returns the right side of this input. - * Returns null if there is no right side (deletion or addition). - * - * @return the right side of this input, or null - */ - ITypedElement getRight(); - - /** - * Registers the given listener for notification. - * If the identical listener is already registered the method has no effect. - * - * @param listener the listener to register for changes of this input - */ - void addCompareInputChangeListener(ICompareInputChangeListener listener); - - /** - * Unregisters the given listener. - * If the identical listener is not registered the method has no effect. - * - * @param listener the listener to unregister - */ - void removeCompareInputChangeListener(ICompareInputChangeListener listener); - - /** - * Copy one side (source) to the other side (destination) depending on the - * value of leftToRight. This method is called from - * a merge viewer if a corresponding action ("take left" or "take right") - * has been pressed. - *

- * The implementation should handle the following cases: - *

    - *
  • - * if the source side is null the destination must be deleted, - *
  • - * if the destination is null the destination must be created - * and filled with the contents from the source, - *
  • - * if both sides are non-null the contents of source must be copied to destination. - *
- * In addition the implementation should send out notification to the registered - * ICompareInputChangeListener. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - void copy(boolean leftToRight); -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java deleted file mode 100644 index 461a94ab4..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.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.compare.structuremergeviewer; - -/** - * Listener that gets informed if one (or more) - * of the three sides of an ICompareInput object changes its value. - *

- * For example when accepting an incoming addition - * the (non-null) left side of an ICompareInput - * is copied to the right side (which was null). - * This triggers a call to compareInputChanged of registered - * ICompareInputChangeListener. - *

- * Note however, that listener are not informed if the content of one of the sides changes. - *

- * Clients may implement this interface. It is also implemented by viewers that take - * an ICompareInput as input. - *

- */ -public interface ICompareInputChangeListener { - - /** - * Called whenever the value (not the content) of one or more of the three sides - * of a ICompareInput has changed. - * - * @param source the ICompareInput that has changed - */ - void compareInputChanged(ICompareInput source); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.java deleted file mode 100644 index 598996bef..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffContainer.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.compare.structuremergeviewer; - -/** - * IDiffContainer is a IDiffElement with children. - *

- * IDiffContainer are the inner nodes displayed - * by the DiffTreeViewer. - * IDiffContainer are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients may implement this interface, or use one of the standard implementations, - * DiffContainer or DiffNode. - * - * @see Differencer - * @see DiffTreeViewer - */ -public interface IDiffContainer extends IDiffElement { - - /** - * Returns whether this container has at least one child. - * In some cases this methods avoids having to call the - * potential more costly getChildren method. - * - * @return true if this container has at least one child - */ - boolean hasChildren(); - - /** - * Returns the children of this container. - * If this container has no children an empty array is returned (not null). - * - * @return the children of this container as an array - */ - IDiffElement[] getChildren(); - - /** - * Adds the given child to this container. - * If the child is already contained in this container, this method has no effect. - * - * @param child the child to be added to this container - */ - void add(IDiffElement child); - - /** - * Removes the given child from this container. - * If the container becomes empty it is removed from its container. - * If the child is not contained in this container, this method has no effect. - * - * @param child the child to be removed from this container - */ - void removeToRoot(IDiffElement child); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.java deleted file mode 100644 index f09742a1d..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IDiffElement.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.compare.structuremergeviewer; - -import org.eclipse.compare.ITypedElement; - -/** - * An IDiffElement is used in the DiffTreeViewer - * to display the kind of change detected as the result of a two-way or three-way compare. - *

- * The base interface ITypedElement provides a name, a type, and an image. - * IDiffElement adds API for maintaining a parent relationship. - *

- * DiffTreeViewer works on a tree of IDiffElements. - * Leaf elements must implement the - * IDiffElement interface, inner nodes the IDiffContainer interface. - *

- * IDiffElements are typically created as the result of performing - * a compare with the Differencer. - *

- * Clients may implement this interface, or use one of the standard implementations, - * DiffElement, DiffContainer, or DiffNode. - * - * @see DiffTreeViewer - * @see DiffElement - * @see DiffContainer - * @see DiffNode - */ -public interface IDiffElement extends ITypedElement { - - /** - * Returns the kind of difference as defined in Differencer. - * - * @return the kind of difference as defined in Differencer - */ - int getKind(); - - /** - * Returns the parent of this element. - * If the object is the root of a hierarchy null is returned. - * - * @return the parent of this element, or null if the element has no parent - */ - IDiffContainer getParent(); - - /** - * Sets the parent of this element. - * - * @param parent the new parent of this element, or null if this - * element is to have no parent - */ - void setParent(IDiffContainer parent); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java deleted file mode 100644 index b4bb8e0d0..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -/** - * Interface used to compare hierarchical structures. - * It is used by the differencing engine. - *

- * Clients typically implement this interface in an adaptor class which - * wrappers the objects to be compared. - * - * @see org.eclipse.compare.ResourceNode - * @see Differencer - */ -public interface IStructureComparator { - - /** - * Returns an iterator for all children of this object or null - * if there are no children. - * - * @return an array with all children of this object, or an empty array if there are no children - */ - Object[] getChildren(); - - /** - * Returns whether some other object is "equal to" this one - * with respect to a structural comparison. For example, when comparing - * Java class methods, equals would return true - * if two methods have the same signature (the argument names and the - * method body might differ). - * - * @param other the reference object with which to compare - * @return true if this object is the same as the other argument; false otherwise - * @see java.lang.Object#equals - */ - boolean equals(Object other); -} diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.java deleted file mode 100644 index 2f2c3916a..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureCreator.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.compare.structuremergeviewer; - -/** - * Interface used to create a hierarchical structure of - * IStructureComparators for a given input object. - * In addition, it provides methods for locating a path in the hierarchical structure - * and to map a node of this structure back to the corresponding input object. - *

- * Structure creators are used in the following contexts: - *

    - *
  • - * the StructureDiffViewer uses an IStructureCreator to - * build two (or three) tree structures of its input elements (method getStructure). - * These trees are then compared with each other by means of the differencing engine and displayed - * with the DiffTreeViewer, - *
  • - *
  • - * the ReplaceWithEditionDialog uses an IStructureCreator - * to map a path back to a range of characters in the textual representation. - *
  • - *
- * A IStructureCreator provides methods for rewriting the tree produced by the differencing - * engine to support "smart" structural differencing. E.g. certain patterns of pairs of "addition" - * and "deletion" nodes can be detected as renames and merged into a single node. - *

- *

- * Clients may implement this interface; there is no standard implementation. - *

- * - * @see StructureDiffViewer - * @see org.eclipse.compare.EditionSelectionDialog - * @see Differencer - */ -public interface IStructureCreator { - - /** - * Returns a descriptive name which can be used in the UI of the StructureDiffViewer. - * - * @return a descriptive name for this IStructureCreator - */ - String getName(); - - /** - * Creates a tree structure consisting of IStructureComparators - * from the given object and returns its root object. - * Implementing this method typically involves parsing the input object. - * In case of an error (e.g. a parsing error) the value null is returned. - * - * @param input the object from which to create the tree of IStructureComparator - * @return the root node of the structure or null in case of error - */ - IStructureComparator getStructure(Object input); - - /** - * Creates the single node specified by path from the given input object. - * In case of an error (e.g. a parsing error) the value null is returned. - * This method is similar to getStructure but in - * contrast to getStructure only a single node without any children must be returned. - * This method is used in the ReplaceWithEditionDialog to locate a sub element - * (e.g. a method) within an input object (e.g. a file containing source code). - *

- * One (not optimized) approach to implement this method is calling getStructure(input) - * to build the full tree, and then finding that node within the tree that is specified - * by path. - *

- * The syntax of path is not specified, because it is treated by the compare subsystem - * as an opaque entity and is not further interpreted. Clients using this functionality - * will pass a value of path to the selectEdition - * method of ReplaceWithEditionDialog and will receive this value unchanged - * as an argument to locate. - * - * @param path specifies a sub object within the input object - * @param input the object from which to create the IStructureComparator - * @return the single node specified by path or null - * - * @see org.eclipse.compare.EditionSelectionDialog#selectEdition - */ - IStructureComparator locate(Object path, Object input); - - /** - * Returns the contents of the given node as a string for the purpose - * of performing a content comparison only (that is the string will not be visible in the UI). - * If ignoreWhitespace is true all character sequences considered - * whitespace should be removed from the returned string. - * - * @param node the node for which to return a string representation - * @param ignoreWhitespace if true the returned string should not contain whitespace - * @return the string contents of the given node - */ - String getContents(Object node, boolean ignoreWhitespace); - - /** - * Called whenever a copy operation has been performed on a tree node. - * - * @param node the node for which to save the new content - * @param input the object from which the structure tree was created in getStructure - */ - void save(IStructureComparator node, Object input); -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java deleted file mode 100644 index 9dd4f68f8..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.compare.structuremergeviewer; - -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.widgets.*; -import org.eclipse.jface.util.PropertyChangeEvent; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.*; - - -/** - * A diff tree viewer that can be configured with a IStructureCreator - * to retrieve a hierarchical structure from the input object (an ICompareInput) - * and perform a two-way or three-way compare on it. - *

- * This class may be instantiated; it is not intended to be subclassed outside - * this package. - *

- * - * @see IStructureCreator - * @see ICompareInput - */ -public class StructureDiffViewer extends DiffTreeViewer { - - private Differencer fDifferencer; - private boolean fThreeWay= false; - - private ITypedElement fAncestorInput; - private ITypedElement fLeftInput; - private ITypedElement fRightInput; - - private IStructureComparator fAncestorStructure; - private IStructureComparator fLeftStructure; - private IStructureComparator fRightStructure; - - private IStructureCreator fStructureCreator; - private IDiffContainer fRoot; - private IContentChangeListener fContentChangedListener; - private CompareViewerSwitchingPane fParent; - - /** - * Creates a new viewer for the given SWT tree control with the specified configuration. - * - * @param tree the tree control - * @param configuration the configuration for this viewer - */ - public StructureDiffViewer(Tree tree, CompareConfiguration configuration) { - super(tree, configuration); - Composite c= tree.getParent(); - if (c instanceof CompareViewerSwitchingPane) - fParent= (CompareViewerSwitchingPane) c; - initialize(); - } - - /** - * Creates a new viewer under the given SWT parent with the specified configuration. - * - * @param parent the SWT control under which to create the viewer - * @param configuration the configuration for this viewer - */ - public StructureDiffViewer(Composite parent, CompareConfiguration configuration) { - super(parent, configuration); - if (parent instanceof CompareViewerSwitchingPane) - fParent= (CompareViewerSwitchingPane) parent; - initialize(); - } - - private void initialize() { - - setAutoExpandLevel(3); - - fContentChangedListener= new IContentChangeListener() { - public void contentChanged(IContentChangeNotifier changed) { - StructureDiffViewer.this.contentChanged(changed); - } - }; - new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput input) { - StructureDiffViewer.this.compareInputChanged(input); - } - }; - } - - /** - * Configures the StructureDiffViewer with a structure creator. - * The structure creator is used to create a hierarchical structure - * for each side of the viewer's input element of type ICompareInput. - * - * @param structureCreator the new structure creator - */ - public void setStructureCreator(IStructureCreator structureCreator) { - if (fStructureCreator != structureCreator) { - fStructureCreator= structureCreator; - Control tree= getControl(); - if (tree != null && !tree.isDisposed()) - tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - } - } - - /** - * Returns the structure creator or null if no - * structure creator has been set with setStructureCreator. - * - * @return the structure creator or null - */ - public IStructureCreator getStructureCreator() { - return fStructureCreator; - } - - /** - * Reimplemented to get the descriptive title for this viewer from the IStructureCreator. - * @return the viewer's name - */ - public String getTitle() { - if (fStructureCreator != null) - return fStructureCreator.getName(); - return super.getTitle(); - } - - /** - * Overridden because the input of this viewer is not identical to the root of the tree. - * The tree's root is a IDiffContainer that was returned from the method diff. - * - * @return the root of the diff tree produced by method diff - */ - protected Object getRoot() { - return fRoot; - } - - /* - * (non-Javadoc) Method declared on StructuredViewer. - * Overridden to create the comparable structures from the input object - * and to feed them through the differencing engine. Note: for this viewer - * the value from getInput is not identical to getRoot. - */ - protected void inputChanged(Object input, Object oldInput) { - if (input instanceof ICompareInput) { - compareInputChanged((ICompareInput) input); - if (input != oldInput) - initialSelection(); - } - } - - protected void initialSelection() { - expandToLevel(2); - } - - /* (non Javadoc) - * Overridden to unregister all listeners. - */ - protected void handleDispose(DisposeEvent event) { - - compareInputChanged(null); - - fContentChangedListener= null; - - super.handleDispose(event); - } - - /** - * Recreates the comparable structures for the input sides. - * @param input this viewer's new input - */ - protected void compareInputChanged(ICompareInput input) { - ITypedElement t= null; - boolean changed= false; - - if (input != null) - t= input.getAncestor(); - - fThreeWay= (t != null); - - if (t != fAncestorInput) { - if (fAncestorInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fAncestorInput).removeContentChangeListener(fContentChangedListener); - fAncestorInput= t; - if (fAncestorInput != null) { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - changed= true; - } else - fAncestorStructure= null; - if (fAncestorInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fAncestorInput).addContentChangeListener(fContentChangedListener); - } - - if (input != null) - t= input.getLeft(); - if (t != fLeftInput) { - if (fLeftInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fLeftInput).removeContentChangeListener(fContentChangedListener); - fLeftInput= t; - if (fLeftInput != null) { - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - changed= true; - } else - fLeftStructure= null; - if (fLeftInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fLeftInput).addContentChangeListener(fContentChangedListener); - } - - if (input != null) - t= input.getRight(); - if (t != fRightInput) { - if (fRightInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fRightInput).removeContentChangeListener(fContentChangedListener); - fRightInput= t; - if (fRightInput != null) { - fRightStructure= fStructureCreator.getStructure(fRightInput); - changed= true; - } else - fRightStructure= null; - if (fRightInput instanceof IContentChangeNotifier) - ((IContentChangeNotifier)fRightInput).addContentChangeListener(fContentChangedListener); - } - - if (changed) - diff(); - } - - /** - * Calls diff whenever the byte contents changes. - * @param changed the object that sent out the notification - */ - protected void contentChanged(IContentChangeNotifier changed) { - - if (fStructureCreator == null) - return; - - if (changed != null) { - if (changed == fAncestorInput) { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - } else if (changed == fLeftInput) { - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - } else if (changed == fRightInput) { - fRightStructure= fStructureCreator.getStructure(fRightInput); - } else - return; - } else { - fAncestorStructure= fStructureCreator.getStructure(fAncestorInput); - fLeftStructure= fStructureCreator.getStructure(fLeftInput); - fRightStructure= fStructureCreator.getStructure(fRightInput); - } - - diff(); - } - - /** - * This method is called from within diff() before the difference - * tree is being built. - * Clients may override this method to perform their own pre-processing. - * This default implementation does nothing. - * @param ancestor the ancestor input to the differencing operation - * @param left the left input to the differencing operation - * @param right the right input to the differencing operation - * @since 2.0 - */ - protected void preDiffHook(IStructureComparator ancestor, IStructureComparator left, IStructureComparator right) { - // we do nothing here - } - - /** - * Runs the difference engine and refreshes the tree. - */ - protected void diff() { - - preDiffHook(fAncestorStructure, fLeftStructure, fRightStructure); - - String message= null; - - if ((fThreeWay && fAncestorStructure == null) || fLeftStructure == null || fRightStructure == null) { - // could not get structure of one (or more) of the legs - fRoot= null; - message= CompareMessages.getString("StructureDiffViewer.StructureError"); //$NON-NLS-1$ - - } else { // calculate difference of the two (or three) structures - - if (fDifferencer == null) - fDifferencer= new Differencer() { - protected boolean contentsEqual(Object o1, Object o2) { - return StructureDiffViewer.this.contentsEqual(o1, o2); - } - protected Object visit(Object data, int result, Object ancestor, Object left, Object right) { - Object o= super.visit(data, result, ancestor, left, right); - if (fLeftIsLocal && o instanceof DiffNode) - ((DiffNode)o).swapSides(fLeftIsLocal); - return o; - } - }; - - fRoot= (IDiffContainer) fDifferencer.findDifferences(fThreeWay, null, null, - fAncestorStructure, fLeftStructure, fRightStructure); - - if (fRoot == null || fRoot.getChildren().length == 0) { - message= CompareMessages.getString("StructureDiffViewer.NoStructuralDifferences"); //$NON-NLS-1$ - } else { - postDiffHook(fDifferencer, fRoot); - } - } - if (fParent != null) - fParent.setTitleArgument(message); - - refresh(getRoot()); - } - - /** - * This method is called from within diff() after the difference - * tree has been built. - * Clients may override this method to perform their own post-processing. - * This default implementation does nothing. - * @param differencer the differencer used to perform the differencing - * @param root the non-null root node of the difference tree - * @since 2.0 - */ - protected void postDiffHook(Differencer differencer, IDiffContainer root) { - // we do nothing here - } - - /* - * Performs a byte compare on the given objects. - * Called from the difference engine. - * Returns null if no structure creator has been set. - */ - private boolean contentsEqual(Object o1, Object o2) { - if (fStructureCreator != null) { - boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); - String s1= fStructureCreator.getContents(o1, ignoreWhiteSpace); - String s2= fStructureCreator.getContents(o2, ignoreWhiteSpace); - if (s1 == null || s2 == null) - return false; - return s1.equals(s2); - } - return false; - } - - /** - * Tracks property changes of the configuration object. - * Clients may override to track their own property changes. - * In this case they must call the inherited method. - * @param event the property changed event that triggered the call to this method - */ - protected void propertyChange(PropertyChangeEvent event) { - String key= event.getProperty(); - if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) - diff(); - else - super.propertyChange(event); - } - - /** - * Overridden to call the save method on the structure creator after - * nodes have been copied from one side to the other side of an input object. - * - * @param leftToRight if true the left side is copied to the right side. - * If false the right side is copied to the left side - */ - protected void copySelected(boolean leftToRight) { - super.copySelected(leftToRight); - - if (fStructureCreator != null) - fStructureCreator.save( - leftToRight ? fRightStructure : fLeftStructure, - leftToRight ? fRightInput : fLeftInput); - } -} - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html deleted file mode 100644 index 60257a4d8..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/package.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - Package-level Javadoc - - -Provides support for finding and displaying the differences -between hierarchically structured data. -

-Package Specification

- -The class Differencer is a differencing engine for hierarchically -structured data. It takes two or three inputs and performs a two-way or -three-way compare on them. -

- -If the input elements to the differencing engine implement the IStructureComparator -interface the engine recursively applies itself to the children of -the input element. Leaf elements must implement the org.eclipse.compare.IStreamContentAccessor -interface so that the differencer can perform a bytewise comparison on their contents. -

- -One good example for this is org.eclipse.compare.ResourceNode which implements both interfaces -(and more) for Eclipse workspace resources (org.eclipse.core.resources.IResource). -

- -Another example is the DocumentRangeNode which can be used to compare hierarchical structures -that are superimposed on a document, that is where nodes and leafs correspond to ranges in a document -(org.eclipse.compare.contentmergeviewer.IDocumentRange). -
-Typically DocumentRangeNodes are created while parsing a document and they represent -the semantic entities of the document (e.g. a Java class, method or field). -The two subclasses JavaNode (in org.eclipse.jdt.internal.ui.compare) -and PropertyNode (in org.eclipse.jdt.internal.ui.compare) are good examples for this. -

- -By default the differencing engine returns the result of the compare operation -as a tree of DiffNode objects. However, this can be changed by overriding -a single method of the engine. -

- -Every DiffNode describes the changes among the two or three inputs. -

- -A tree of DiffNodes can be displayed in a DiffTreeViewer. -The DiffTreeViewer requires that inner nodes of the tree implement -the IDiffContainer interface and leafs the IDiffElement interface. -

- -The typical steps to compare hierarchically structured data and to display -the differences would be to: -

    -
  • -map the input data into a tree of IStructureComparator and IStreamContentAccessors,
  • - -
  • -perform the compare operation by means of the Differencer, and
  • - -
  • -feed the differencing result into the DiffTreeViewer.
  • - -
- -The StructureDiffViewer is a specialized DiffTreeViewer -that automates the three steps from above. It takes a single input object -of type ICompareInput from which it retrieves the two or three -input elements to compare. Then it uses a IStructureCreator to -extract a tree of IStructureComparator and IStreamContentAccessor -from them. These trees are then compared with the differencing engine and -the result is displayed in the tree viewer. -

- - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif deleted file mode 100644 index a021812e0..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/ancestorpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif deleted file mode 100644 index 172e2a4ea..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif deleted file mode 100644 index 4cb42a1db..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copy_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif deleted file mode 100644 index 16539cd9f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif deleted file mode 100644 index 036abe05f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/copycont_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/next_nav.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/next_nav.gif deleted file mode 100644 index 8aacf959d..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/next_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif deleted file mode 100644 index 38841abe9..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/prev_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif deleted file mode 100644 index 0ddac91a1..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/smartmode_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif deleted file mode 100644 index 7da48249e..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/syncpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif deleted file mode 100644 index 8cdef204b..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dlcl16/twowaycompare_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif deleted file mode 100644 index 398c71927..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/conflict_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif deleted file mode 100644 index 702f0a83b..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/dtool16/ignorews_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif deleted file mode 100644 index ff06855e7..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/ancestorpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif deleted file mode 100644 index e029948cf..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif deleted file mode 100644 index 0659813a1..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copy_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif deleted file mode 100644 index db2b1e3d5..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_l_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif deleted file mode 100644 index 9ebd50a9f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/copycont_r_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/next_nav.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/next_nav.gif deleted file mode 100644 index 072b18445..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/next_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/prev_nav.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/prev_nav.gif deleted file mode 100644 index 091e88400..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/prev_nav.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif deleted file mode 100644 index 542dddca3..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/smartmode_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif deleted file mode 100644 index 2644c2ad6..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/syncpane_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif deleted file mode 100644 index 12788bafa..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/elcl16/twowaycompare_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/conflict_edit.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/conflict_edit.gif deleted file mode 100644 index 48a7d1d58..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/conflict_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif deleted file mode 100644 index 0b22e4a1a..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/etool16/ignorews_edit.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/eview16/compare_view.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/eview16/compare_view.gif deleted file mode 100644 index dc549bce8..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/eview16/compare_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/day_obj.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/day_obj.gif deleted file mode 100644 index 4fc84e4c3..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/day_obj.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/resource_obj.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/resource_obj.gif deleted file mode 100644 index 3bd4e3605..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/obj16/resource_obj.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/add_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/add_ov.gif deleted file mode 100644 index c123a2b13..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/add_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/chg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/chg_ov.gif deleted file mode 100644 index 2b1b8d677..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/chg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif deleted file mode 100644 index 65101e939..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif deleted file mode 100644 index ee805f9ed..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif deleted file mode 100644 index 980c0f84f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/confdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/del_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/del_ov.gif deleted file mode 100644 index ef0207c62..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/del_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/error_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/error_ov.gif deleted file mode 100644 index 3f43a29d9..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/error_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif deleted file mode 100644 index 05a9f5a68..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif deleted file mode 100644 index 12d4a9732..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/inchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/indel_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/indel_ov.gif deleted file mode 100644 index 373a68f14..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/indel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif deleted file mode 100644 index 63fb2967c..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif deleted file mode 100644 index 78321d74d..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif deleted file mode 100644 index 7182e5596..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/outdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif deleted file mode 100644 index 0ac0cea9e..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif deleted file mode 100644 index c330c0c9f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_inchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif deleted file mode 100644 index 5acab6778..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_indel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif deleted file mode 100644 index 69607651f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outadd_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif deleted file mode 100644 index 17ba1af4f..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outchg_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif deleted file mode 100644 index ef6b8b745..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/ovr16/r_outdel_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif deleted file mode 100644 index e7f0c5cdd..000000000 Binary files a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/icons/full/wizban/applypatch_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/old_buildnotes_compare_3_0.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/old_buildnotes_compare_3_0.html deleted file mode 100644 index 5bc43ccaa..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/old_buildnotes_compare_3_0.html +++ /dev/null @@ -1,1557 +0,0 @@ - - - - - - - Eclipse Platform Release Notes - Desktop - - - -

-Eclipse Platform Build Notes
-Compare

-Eclipse Build Input June 17th 2004 (RC3) - -

-Problem reports fixed

-37648: Exceptions after one of the compare viewer inputs got deleted
- -

-

-Eclipse Build Input June 11th 2004 (RC2) - -

-Problem reports fixed

-65460: Improve encoding fall back behavior for HistoryItems
-61998: bad idea to subclass Error for ordinary exceptions
-59232: DBCS: compare improperly in EUC-JP encoding project on workbench encoding MS932
-65515: Local History always says "Parsing Error; no structured Replace Available"
-55333: NPE in TextMergeViewer.interpolate
-55876: Viewer: Text not repainted when moving sash and then clicking on scroll bars
-65205: Compare editor doesn't update correctly while scrolling
-62545: binary compare text insertion cursor is very large
-56875: Resizing Apply Patch dialog doesn't resize tree
-47640: Move right to left misplaced the moved text
-66272: remove packages prefixes tag from plugin.xml
-64617: Not prompted to save dirty compare editor
- - -

-

-Eclipse Build Input May 28th 2004 (RC1) - -

-Problem reports fixed

-#62356: Use progress service when running compare input
-#64505: Remove unused class ColorEditor
-#63610: Colors and Fonts: Text Compare Appearance -> Text Compare
-#61996: bad idea to subclass Error for ordinary exceptions
-#63608: Migrate to improved modal progress support
- - -

-

-Eclipse Build Input May 11th 2004 - -

-Problem reports fixed

-added 3.0 tag to streamMergers schema file
-updated artwork
- -

-

-Eclipse Build Input May 4th 2004 - -

-Problem reports fixed

-#60383: Copy All non-conflicting changes from right-to-left erase left-to-right changes!!!
-#59273: target TextMergeViewerCreator not found
- -

-

-Eclipse Build Input April 27th 2004 - -

-Problem reports fixed

-#50914: Apply Patch dialog doesn't initialize file browse dialog
- -

-

-Eclipse Build Input April 20th 2004 - -

-Problem reports fixed

-#54091: Allow headless diff and merge
-#51791: Allow binding filenames to compare extensions
-#52261: DiffNode is missing setAncestor()
-#59204: NPE in CompareUIPlugin$CompareRegistry.search(...)
- -

-

-Eclipse Build Input April 13th 2004 - -

-Problem reports fixed

-new artwork - -

-

-Eclipse Build Input March 23rd 2004 (M8) - -

-Problem reports fixed

-#20914: Colorized Diff/compare output
-#55348: NPE in TextMergeViewer.interpolate
- -

-

-Eclipse Build Input March 9th 2004 - -

-Problem reports fixed

-#53754: Provide a resize affordance in the side by side compare part
- -

-

-Eclipse Build Input March 2th 2004 - -

-Problem reports fixed

-#42731: Synchronize horizontal scrolling in compare editor
-#2278: DCR: Would like coupled horizontal scrolling in compare browser (1GEJNHO)
-#53368: Layout problem with focus ring
- -

-

-Eclipse Build Input February 17th 2004 - -

-Problem reports fixed

-#51593: ArrayIndexOutOfBoundsException at org.eclipse.compare.internal.patch.PatchWizard.setTargets
-#52055: Method compare is broken
- -

-

-Eclipse Build Input February 10th 2004 (M7) - -

-API Additions

-Added new interface IEncodedStreamContentAccessor; deprecated IStreamContentAccessorExtension2
-Added first cut of outline view support. - -

-

-Eclipse Build Input January 27th 2004 - -

-Problem reports fixed

-#50565: [Preferences] Pref page Workbench/Compare/Patch; no mnemonic for "Filtered Members"
- -

-

-Eclipse Build Input January 13th 2004 - -

-Problem reports fixed

-#49695: Apply Patch wizard is leaking 7 Images
-#49803: Replace with local history leaks 2 images
- -

-

-Eclipse Build Input January 6th 2004 - -

-Problem reports fixed

-#32329: Support filters for compare
- -

-

-Eclipse Build Input December 18th (M6) 2003 - -

-Problem reports fixed

-#47866: Internal error in synchronize perspective
-#45239: Show ancestor for incoming and outgoing changes
-#41815: Internal error comparing with repository
-#46709: PatchWizard should use scheduling rule on project
- -

-

-Eclipse Build Input November 25th 2003 - -

-Problem reports fixed

-removed use of deprecated symbols - -

-

-Eclipse Build Input November 19th 2003 - -

-Problem reports fixed

-#46805: prepare Compare for encoding support
-#46877: Remove dependancies on Xerces
-#46977: Comparing/merging two local files screws up the content
- -

-

-Eclipse Build Input August 26th 2003 - -

-Problem reports fixed

-#40727: Allow navigation workflow control from other view
-#38770: CompareEditor should implement IReusableEditor
-#39757: Some compare operations fail on resources that do not exist
-#35380: Replace with Local History and read-only resources
- -

-

-Eclipse Build Input July 15th 2003 - -

-Problem reports fixed

-#38836: CompareEditorInput clears dirty state too quickly
-#38770: CompareEditor should implement IReusableEditor
- -

-

-Eclipse Build Input July 1st 2003 - -

-Problem reports fixed

-#38808: NPE in log file when restoring files from history.
-fixed minor error in schema files - -

-

-Eclipse Build Input June 24th 2003 - -

-Problem reports fixed

-#38770: CompareEditor should implement IReusableEditor
- -

-

-Eclipse Build Input June 10th 2003 - -

-Problem reports fixed

-#38713: Compare with -> Each other is not enabled
- -

-

-Eclipse Build Input June 3rd 2003 - -

-Problem reports fixed

-#37531: the javadoc of CompareViewerPane.setImage(Image)
-#38262: Apply patch applies unchecked changes
-#36399: Compare did retrieve entire remote ZIP contents on selection change
-#38198: TVT21: Strings are not externalized
- -

-

-Eclipse Build Input Mai 27th 2003 - -

-Problem reports fixed

-#37849: "Ignore whitespace" ignores also closing brackets?!?
- -Problem reports closed -#37582: Ignore whitespace option should be a button in the compare editor
- -

-

-Eclipse Build Input March 27th 2003 - -

-Problem reports fixed

-Fixed 5 Javadoc warnings - -

-

-Eclipse Build Input March 24th 2003 - -

-Problem reports fixed

-Updated schema copyright notices
-updated javadoc - -

-

-Eclipse Build Input March 19th 2003 - -

-Problem reports fixed

-Fixed wording in properties files
-#35130: Dialogs do not set the dialog font
- -

-

-Eclipse Build Input March 14th 2003 - -

-Problem reports fixed

-#34732: Compare/Patch preference page mnemonic
-#34696: Title casing issues
- - -

-

-Eclipse Build Input March 6th 2003 - -

-Problem reports fixed

-#27405: Should consider using the new font propogation support
-#24255: Internal error when invoking "Restore from Local History" in Outline view
-#32737: NegativeArraySizeException: Compare/patch preference page
- - -

-

-Eclipse Build Input March 4th 2003 - -

-Problem reports fixed

-#32769: Missing mneumonic in compare preference page
-#32798: No mnemonic for ComparePreferencePage.useSingleLine.label
-#32207: Wording: "Open with Compare Editor" action in sync view
-#28190: Middle area should act like sash
-added required IDs for compare viewers in plugin.xml
- - -

-

-Eclipse Build Input February 20th 2003 - -

-Problem reports fixed

-#20248: [Compare] Have to perform two actions to see diff
-#24165: Should have menu action for showing compare contents
-#13332: autosave before patching: can i undo?
-#24077: Comparing file named 'platformOption' does not use text editor
-#23958: NPE in compare with patch
-#28402: CompareConfiguration leaks Images
-#13844: TextMergeViewer should keep track of its posted runnables
-#14353: Cannot perform merge with keyboard accelerators/mnemonics
- -

-

-Eclipse Build Input February 18th 2003 - -

-Problem reports fixed

-#5323: Compare does not handle correctly conflicts at same location
-#26035: Local history uses wrong character encoding
-#15654: Can't maximize Compare with Local History window
- - -

-

-Eclipse Build Input February 13th 2003 - -

-Problem reports fixed

-#31136: Red icon too intrusive
-#31357: Compare View -- Compare-style option required.
-#31633: Cannot apply patch successfully
-#10754: Compare actions should target source window
- -

-

-Eclipse Build Input February 11th 2003 - -

-Problem reports fixed

-#25507: Compare view prevents Ctrl + F6 working
-#18571: patch: scary error dialog when no patch in clipboard
-#28840: Strange behavious applying patch
- -

-

-Eclipse Build Input February 6th 2003 (M5 aka RC0) - -

-API Additions

-Added new method EditionSelectionDialog.getSelection() - -

-Problem reports fixed

-#30525: "Team" menu item missing accelerator
-#28202: contentmergeviewers do not work with mixed-case extensions
-#19114: Restore Java Element from Local History should also provide check boxes [compare]
-#28436: Overview rule green only after focus change
-#29793: Automatically suggest a fuzz factor when applying a patch
- -

-

-Eclipse Build Input January 28th 2003 - -

-API Additions

-Added new method CompareUI.findContentViewer(..., Object input, ...) - -

-Problem reports fixed

-Remoced doc folder.
-#24597: Compare UI API issues
-#23883: CompareDialog.commitAction.label string resource name is wrong
-#29791: Rename 'Compare to Patch' to 'Apply Patch'
- -

-

-Eclipse Build Input January 14th 2003 - -

-Problem reports fixed

-Extension point schema files added.
-Resolve status indicator is only shown if there are incoming changes. - -

-

-Eclipse Build Input January 7th 2003 - -

-Problem reports fixed

-#28278: TextMergeViewer leaks Color objects
-#27864: Load of CompareUI fails when not triggered in UI thread
-#28388: Illegal Argument Exceptions in compare viewer
- -

-

-Eclipse Build Input December 17th 2002 - -

-Problem reports fixed

-#28388: Illegal Argument Exceptions in compare viewer
- -

-

-Eclipse Build Input December 16th 2002 - -

-Problem reports fixed

-Fixed a problem with trim in compare viewer on Mac OS X.
-#28278: TextMergeViewer leaks Color objects
- -
-Eclipse Build Input December 13th 2002 - -

-Problem reports fixed

-#28012: Double-click behaving strangely in Synchronize View
- -

-

-Eclipse Build Input December 10th 2002 - -

-What's new in this drop

-The Textmergeviewer sports a first cut of a new UI for left/right copying, -showing the 'resolved' status of a change, and uses smooth lines to -connect the differing ranges in the left and right panes. -The new UI options are off by default. You can turn them on -with the three 'experimental' options on the Compare preference page. - -

-Problem reports fixed

-#27993: Incorrect structure comparison
- -

-

-Eclipse Build Input December 3rd 2002 - -

-What's new in this drop

- -

-API Additions

-Made internal class Splitter public API. - -

-Problem reports fixed

-#24597: Compare UI API issues
- -

-

-Eclipse Build Input November 26th 2002 - -

-Problem reports fixed

-#20975: Compare preference page has no F1 help
- -

-

-Eclipse Build Input June 27th 2002 - -

-What's new in this drop

-Updated JavaDoc package.html files - -

-

-Eclipse Build Input June 25th 2002 - -

-What's new in this drop

-Updated JavaDoc - -

-

-Eclipse Build Input June 12th 2002 - -

-What's new in this drop

- -There were several complains that clicking on a zip file in the left pane (structure input pane) feeds all other -compare panes (see bug 13730). There are cases where this is expensive (for example a large zip file that has -to be read from a repository). To avoid those situations the left pane now honors single or double click mode as -set in Preferences->Workbench. So if this preference is set to double click the user has to double click on a file -in the left pane to actually feed all other compare panes. - -

-

-Eclipse Build Input June 8th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#18807: Compare with patch fails due to missing LF
-#13730: Entire zipfiles content sent prior when computing synchronization view content
- -

-Problem reports closed

- -

-

-Eclipse Build Input June 7th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13730: Entire zipfiles content sent prior when computing synchronization view content
-#14952: Diff Browser Opens Too Small / Not Easily Resizable
- - -

-Problem reports closed

- -

-

-Eclipse Build Input June 6th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-New constant CompareUI.PLUGIN_ID - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13949: DBCS: bogus at text compare
-#19013: backgronud color: is it honored?
-#19216: Accessibility in Workbench > Compare > Text Compare
-#19371: Java & Compare editor's Next/Previous toolbar buttons shouldn't be retargetable
- - -

-Problem reports closed

- -

-

-Eclipse Build Input June 1st 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-Made class NavigationAction public. - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8004: Ctrl+E beeps every time
-#14800: Compare View eats tabs
-#18200: Both sets of arrows say "Select Next Change"
-#18206: Casing, wording issue on "Last Resource reached" prompt
-#16285: Add from Local History needs a description label
-#17431: Accessibility issues
-#18148: Using combinations of No and Next file button break wrapping
-#18151: Next File button does not ding when on last file
-#16570: Compare refuses to show further differences if not ignoring whitespaces
-#10790: Patch does not apply if file not found locally
-#12643: Expand all does not disable when there is no selection
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 31st 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#18116: Compare view does not inherit Java editor background color
-#13190: Compare with Patch does not apply Patch, if single file selected
- - -

-Problem reports closed

- -

-

-Eclipse Build Input May 30th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#17699: Java Editor: Local Histroy menu entries are enabled for read-only files
-#16283: Add from Local History items are unsorted
-#16288: Add from Local History: list of available editions flashes
-#17664: Applying a patch with deleted package fails
- - -

-Problem reports closed

- -

-

-Eclipse Build Input May 29th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14040: Platform interoperability issue w.r.t. Compare With Patch
-#17790: Missing mnemonics in patch selection dialog
-#10917: Patch support does not use mnemonics
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 28th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#17889: Should not assume type of PropertyChangeEvent values
-#17678: Applying a patch does many compiles
-#17536: NPE in compare
-#17121: Casing of message when end of changes needs to be sentence style
-#17648: Can't apply patch w/o ignoring whitespace
-#16936: Compare with patch requires "Ignore Whitespace" to be turned off
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 18th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14371: TextMergeViewer.sameDoc() is broken
-#14378: CompareEditorInput never resets dirtyness flag (detailed)
-#14680: Compare unreadable in high contrast black
-#14952: Diff Browser Opens Too Small / Not Easily Resizable
-#14742: Ignore whitespace preference
-#14624: No visual cue when compared file wraps
-#13606: Support multiple selection in Add from local history
- -

-Problem reports closed

- -

-

-Eclipse Build Input May 16th 2002 - -

-What's new in this drop

-Bumped plugin version number to 2.0.0
-Adapted to new findEditor methods
- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8373: Compare With->Patch... missing mnemonic
-#12719: "Show Pseudo-Conflicts" setting is problematic
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 30th 2002 - -

-What's new in this drop

-All strings NLSed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#14515: java compare uses internal jcore scanner
-#14782: Add from Local History missing mnemonic
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 18th 2002 - -

-What's new in this drop

-All strings NLSed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#13152: Internal error in "Add from Local History..." on packages
- -

-Problem reports closed

- -

-

-Eclipse Build Input April 9th 2002 - -

-What's new in this drop

-New context menu action 'Add From Local History'. Just select any resource container and -'Add From Local History' presents all files that were deleted from the workspace but are -still in the local history. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

-The new 'Add From Local History' suffers from #12915. It works if the files were deleted -within the same session. However if you shut down and restart a workspace some deleted -files are nor listed. - -

-Problem reports fixed

-#11578: Patch: Missing resource on dialog
-#11579: Compare with Patch should be disabled on closed projects
-#11907: clicking in bird's eye view spots does nothing if panes not synched
-#11536: Option to turn off structured comparison
-#10682: Need better UI for recovering deletions from local history
-#11446: provide "add from local history" for compilation units
-#8615: Styled Text widget does not respond to system color change
-#9673: editor background color - no effect on other viewers
-#11642: Compare editors not using default background colors
-#10434: Compare browser fails silently and does not give result
- -

-Problem reports closed

- -

-

-Eclipse Build Input March 18th 2002 - -

-What's new in this drop

-First cut of a birdseyeview for the text compare viewer.
-'Compare which Each other' for Java elements. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#3641: DCR: Can't compare from outliner (1GDHJKK)
- -

-Problem reports closed

- -

-

-Eclipse Build Input March 14th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#11305: Can't compare a "C" file
- - -

-Problem reports closed

- -

-

-Eclipse Build Input March 12th 2002 - -

-What's new in this drop

-Structure Compare viewers are enabled by default.
- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#10379: Compare with Local History Dialog: lower pane is missing a bordeer
-#9768: (empty-menu) in compare view
-#9842: Expand All action needed in structure compare view
- - -

-Problem reports closed

- -

-

-Eclipse Build Input March 5th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9869: Need more support for creating/deleting resources
- - -

-Problem reports closed

- -

-

-Eclipse Build Input February 26th 2002 - -

-What's new in this drop

-Patch: for every rejected file a task marker is added
-Compare preference page shows options in a preview
-New preference option for additional compare status line information - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9540: Compare with patch: it should not be possible to check items that could not be applied
-#9532: Compare with patch: next disabled although clipboard specified
-#7681: Structured results expands import statements
-#9572: Debugging trace left in status bar
- - -

-Problem reports closed

- -

-

-Eclipse Build Input February 12th 2002 - -

-What's new in this drop

-The patch wizard no longer opens a Compare Editor but applies the -patch directly to the workspace. This will be the default. -In the future the old behavior of opening the Compare Editor will be -an additional option when finishing the wizard. -
-Patch wizard has a 'Reverse' option for applying a "reversed" patch. -This option can be used to 'undo' a patch. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#9153: NPE when closing synchronize view
-#9331: NPE during compare with stream version
-#6346: Problems with Patch
-#6727: Patch: *.rej file must be saved in workspace
-#7358: Internal Error in Compare with Patch with new files
- -

-Problem reports closed

- -

-

-Eclipse Build Input February 5th 2002 - -

-What's new in this drop

-The structure compare pane opens when a resource is selected. -In previous version a double click was required. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#5063: Should not have to double-click to open Structure Compare
-#2602: Compare FW accessibility issues (1GK79UB)
-#2707: Merge viewer should ask for save before releasing (1GI9JXS)
-#2772: DCR: Automatic structure compare (1GJ6EUY)
-#3829: Smart rename button enabled when no smartness is available (1GEUVHN)
-#9089: Local history - Selecting item in structured compare has no effect
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 29th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6271: Can't tell which file is which in Compare browser
-#2519: next/prev arrows active when only one difference in compare (1GFIQX3)
-#8363: NPE comparing two resources in the navigator.
-#2501: Empty menu in compare browser (1GFBQKE)
-#2854: Compare: Save code path problematic (1GJYGAX)
-#8574: Not structure compare in compare with local history
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 23th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#8089: Replace from local history: parse error
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 22th 2002 - -

-What's new in this drop

-Fixed an inconsistency in the binary compare viewer: -info message didn't match +/-icon in the resource compare pane. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#3859: replace from history does not work for elements with error (1GEYIZ6)
-#6177: Double click action dangerous in 'Restore from Local History'
-#7821: Team 2.0 CVS synchronze bug 'no-name' dirs..
-#2773: Java structure compare should give better indication when no changes (1GJ6ENE)
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 15th 2002 - -

-What's new in this drop

-Fixed a problem in DiffNode.getName()and the DiffTreeViewer's label provider -where the left and right half of a DiffNode label would be reversed because -the "leftIsLocal" property of a CompareConfiguration wasn't obeyed. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#1893: Compare Viewer doesn't scroll to last line (1GBB34N)
-#5839: Usability: Initial diff is sometimes not horizontally aligned
-#5325: Compare always scroll the text pane to the extreme limit
-#7048: First element not selected
-#2548: Project compare should open viewing selected file (1GFMRP6)
-#2938: Replace from local history should show busy cursor (1GKU0P3)
-#7594: Menu entry "Replace with Previous" shouldn't have a "..."
-Workaround added for:
-#7320: Next diff scrolls when going into current diff
- -

-Problem reports closed

- -

-

-Eclipse Build Input January 8th 2002 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

-Added methods to CompareUI plugin for adding and removing aliases -for the file extension to StructureCompareViewer mapping -(addStructureViewerAlias, removeStructureViewerAlias). - -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6828: Support with replace with previous
-#2396: Save in compare editors needs progress bar (1GEYF58)
-#5271: JARs compared as source in release browser
-#5121: Replace with Previous (from local history)
- -

-Problem reports closed

- -

-

-Eclipse Build Input December 11th 2001 - -

-What's new in this drop

-Keyboard shortcuts for 'Goto next Difference' and 'Goto previous Difference' -changed to Control-E and Control-Shift-E.
-Better NLS support.
-Updated file "about.html". - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

- -

-Problem reports closed

- -

-

-Eclipse Build Input December 4th 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#4381: Replace from local histroy - workspace element included
- -

-Problem reports closed

- -

-

-Eclipse Build Input November 27th 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#6298: Replace with Local History: Workbench -> Workspace
-#5238: Compare fails if takes more than 20 seconds
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 210, November 12th, 2001 - -

-What's new in this drop

-First cut for 'rejected hunk' support. - -

-API changes

- -

-API Additions

-new classes CompareViewerPane and CompareViewerSwitchingPane
- -

-Other highlights

-Improved Patch wizard.
- -

-Known deficiencies

- -

-Problem reports fixed

-#5723: Apply Patch dialog has no radio selection
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 207, November 1st, 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-#5334: Internal errors using patch tool
-#5150: Compare with patch cannot read VCM's CVS patch file
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 204, October 12th, 2001 - -

-What's new in this drop

-First cut of patch support. - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

- -

-Problem reports closed

- -

-

-Eclipse SDK Build 202, September 27th, 2001 - -

-What's new in this drop

- -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GKKUA5: ITPUI:WINNT - Severe: memory leak in sync view
-1GKKGGS: ITPJUI:WIN2000 - (136) compares zips as source
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 201, September 21st, 2001 - -

-What's new in this drop

-removed direction icon in TextMergeViewer for two-way compare - -

-API changes

- -

-API Additions

- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GJURWJ: ITPUI:WIN2000 - Hebrew + Japanese: compare view defaults to binary
-1GK0388: ITPJCORE:WIN2000 - replace with local history: selecting (workspace) deletes source
-1GITG2V: ITPUI:WIN2000 - Comparing html files uses binary compare
-1GJW2TP: ITPJUI:WIN2000 - java compare: why beep every time?
- -

-Problem reports closed

- -

-

-Eclipse SDK Build 200, September 13th, 2001 - -

-What's new in this drop

-If not specified otherwise Compare viewer font is taken from workbench text font
-The shortcut for "Goto Next/Previous Difference" is Ctrl-D/Ctrl-Shift-D -to avoid a clash with Ctrl-P of the Print command. - -

-API changes

- -

-API Additions

-new method EditionSelectionDialog.setHideIdenticalEntries(boolean)
-new method EditionSelectionDialog.setTargetIsRight(boolean)
-new method EditionSelectionDialog.setAddMode(boolean)
-new method CompareEditorInput.saveChanges(...)
-new method TextMergeViewer.createLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace)
- -

-Other highlights

- -

-Known deficiencies

- -

-Problem reports fixed

-1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty
-1GG0ELM: ITPVCM:ALL - Local history displayed some of Today's items as Yesterday
-1GGNKHN: ITPJUI:ALL - No progress during replace with local history
-1GF2JNI: ITPUI:ALL - (minor)Compare failed title should be title case
-1GHBPA1: ITPVCM:WINNT - Compare - next change arrow switches to wrong file
-1GGQQH3: ITPJUI:WINNT - Compare hightlights a non-change instead of the change
-1GI5DN9: ITPUI:WIN2000 - Conflicting token deletions don't show up in text compare viewer
-1GI3KUR: ITPJUI:WIN2000 - Compare: double-click in versions list closes view
-1GFFR4B: ITPUI:WIN98 - local history is misleading
-1GBM0IL: ITPUI:WINNT - CompareEditorInput#save should throw CoreException
-1GI99LE: ITPUI:ALL - Compare viewer does not show last line when horizontal scroll bar is present
-1GBB34N: ITPJUI:WIN2000 - Compare Viewer doesn't scroll to last line
-1GGZ8DO: ITPJUI:WIN - MergeViewer invalid selection range
-1GIIBHM: ITPUI:WIN2000 - Problems when comparing zip files
-1GIKKOZ: ITPUI:ALL - alt copyright text in html doc needs update
-1GIURNB: ITPUI:ALL - property file of EditionSelectionDialog contains configuration options
-1GIUS6L: ITPUI:ALL - TextMergeViewer uses deprecated Thread.stop()
-1GI3HDZ: ITPJUI:ALL - Compare: conflicts with no ancestor does not show differences
-1GEUX0D: ITPJUI:ALL - not state aware toolbar button in compare
- -

-Problem reports closed

-1GF9Y9C: ITPUI:WIN2000 - DCR: only get ancestor pane contents if pane is visible
- - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties deleted file mode 100644 index 264d30af9..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties +++ /dev/null @@ -1,216 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# -# Resource strings for Compare Plug-in -# -pluginName= Compare Support -providerName=Eclipse.org - -# -# Extension point names -# -streamMergers= Stream Merger -structureCreators= Structure Creator -structureMergeViewers= Structure Merge Viewer -contentMergeViewers= Content Merge Viewer -contentViewers= Content Viewer - -# -# CompareUIPlugin -# -CompareUIPlugin.dialogTitle=Compare -CompareUIPlugin.noActiveWorkbenchPage=Cannot find active workbench page -CompareUIPlugin.compareFailed=Compare Failed -CompareUIPlugin.openEditorError=Problems Opening Editor -CompareUIPlugin.noDifferences=There are no differences between the selected inputs. - -CompareUIPlugin.targetIdAttributeMissing=target id attribute ''{0}'' missing -CompareUIPlugin.contentTypeNotFound=content type ''{0}'' not found -CompareUIPlugin.targetNotFound=target ''{0}'' not found -CompareUIPlugin.unexpectedTag=expected tag ''{1}'', got ''{0}'' - -# -# Compare Editor -# -defaultCompareEditor.name= Default Compare Editor -CompareEditor.saveError.title= Save Error -CompareEditor.cantSaveError= Cannot save contents ({0}) -CompareEditor.invalidInput=Invalid input: not a CompareEditorInput -CompareEditor.error.setinput.title=Problem opening input -CompareEditor.error.setinput.message=Cannot open input: - -# -# Commands -# -compareCategory.name= Compare -compareCategory.description= Compare command category - -Command.copyRightToLeft.name= Copy from Right to Left -Command.copyRightToLeft.description= Copy Current Change from Right to Left - -Command.copyLeftToRight.name= Copy from Left to Right -Command.copyLeftToRight.description= Copy Current Change from Left to Right - -Command.copyAllRightToLeft.name= Copy All from Right to Left -Command.copyAllRightToLeft.description= Copy All Changes from Right to Left - -Command.copyAllLeftToRight.name= Copy All from Left to Right -Command.copyAllLeftToRight.description= Copy All Changes from Left to Right - -Command.selectNextChange.name= Select Next Change -Command.selectNextChange.description= Select Next Change - -Command.selectPreviousChange.name= Select Previous Change -Command.selectPreviousChange.description= Select Previous Change - - -# -# Context menu & actions -# -CompareWithMenu.label= Comp&are With - -CompareWithEachOtherAction.label= &Each Other -CompareWithEachOtherAction.tooltip= Compare the Selected Resources - -TeamMenu.label= T&eam - -CompareWithPatchAction.label= &Apply Patch... -CompareWithPatchAction.tooltip= Apply a Patch to the Selected Resources - -CompareWithHistoryAction.label= &Local History... -CompareWithHistoryAction.tooltip= Compare the Selected Resource with Local History - -ReplaceWithMenu.label= Rep&lace With - -ReplaceFromHistoryAction.label= &Local History... -ReplaceFromHistoryAction.tooltip= Replace the Selected Resource with Local History - -ReplaceWithPreviousFromHistoryAction.label= &Previous from Local History -ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with the Previous from Local History - -addFromHistoryAction.label= Restore from Local Histor&y... -addFromHistoryAction.tooltip= Restore Deleted Files from Local History - -# -# Preference Page -# -ComparePreferencePage.name= Compare/Patch - -ComparePreferencePage.generalTab.label= &General - -ComparePreferencePage.structureCompare.label= &Open structure compare automatically -ComparePreferencePage.showMoreInfo.label= &Show additional compare information in the status line -ComparePreferencePage.ignoreWhitespace.label= Ignore &white space -ComparePreferencePage.saveBeforePatching.label= A&utomatically save dirty editors before patching - -ComparePreferencePage.filter.description= Enter member names that should be excluded from 'Compare With Each Other'.\nList is comma separated (e.g. '*.class, .project, bin/') -ComparePreferencePage.filter.label= &Filtered Members: -ComparePreferencePage.filter.invalidsegment.error= Filter is invalid: {0} - -ComparePreferencePage.textCompareTab.label= &Text Compare - -ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor pane -ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts -ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers -ComparePreferencePage.useSingleLine.label= Connect &ranges with single line - -ComparePreferencePage.preview.label= Preview: -ComparePreferencePage.ancestor.label= Common Ancestor -ComparePreferencePage.left.label= Local -ComparePreferencePage.right.label= Remote -ComparePreferencePage.backgroundColor1.label= Bac&kground Color: -ComparePreferencePage.backgroundColor2.label= S&ystem Default -ComparePreferencePage.backgroundColor3.label= C&ustom - -# Compare editor contents for Compare preview page -ComparePreferencePage.previewAncestor= 1\n2\n3\nconflict\n4\n5 -ComparePreferencePage.previewLeft= 1\n2\noutgoing addition\n3\noutgoing change\n4\npseudo conflict\n5 -ComparePreferencePage.previewRight= 1\nincoming addition\nincoming addition\n2\n3\nincoming change\n4\npseudo conflict\n5 - -textCompareAppearance.label=Text Compare - -compareIncomingColor.label= Incoming change color -compareIncomingColor.description= The color used to indicate an incoming change in compare and merge tools. -compareOutgoingColor.label= Outgoing change color -compareOutgoingColor.description= The color used to indicate an outgoing change in compare and merge tools. -compareConflictColor.label= Conflicting change color -compareConflictColor.description= The color used to indicate a conflicting change in compare and merge tools. -compareResolvedColor.label= Resolved change color -compareResolvedColor.description= The color used to indicate a resolved change in merge tools. - -compareFontDefiniton.label= Compare text font -compareFontDefiniton.description= The compare text font is used by textual compare/merge tools. - -# New UI -#ComparePreferencePage.useSplines.label= Use splines in center panel -#ComparePreferencePage.useResolveUI.label= Use new resolve UI - -CompareEditorInput.defaultTitle= Compare - -# -# Toolbar actions -# -action.IgnoreWhiteSpace.label=Ignore White Space -action.IgnoreWhiteSpace.tooltip=Ignore White Space Where Applicable -action.IgnoreWhiteSpace.image=etool16/ignorews_edit.gif - -action.Next.label=Next Difference -action.Next.tooltip=Go to Next Difference -action.Next.image=elcl16/next_nav.gif - -action.Previous.label=Previous Difference -action.Previous.tooltip=Go to Previous Difference -action.Previous.image=elcl16/prev_nav.gif - -# -# Built in Structure Creators -# -ZipStructureCreator.name=Zip Archive Compare - -# -# Compare Dialog -# -CompareDialog.commitAction.label=Commit -CompareDialog.saveErrorTitle=Save Error -CompareDialog.saveErrorMessage=Cannot save - -# -# Compare With Each Other -# -ResourceCompare.taskName=Operation in Progress... -ResourceCompare.twoWay.title=Compare ({0}-{1}) -ResourceCompare.twoWay.tooltip=Two-way compare of {0} with {1} -ResourceCompare.threeWay.title=Compare ({0}-{1}-{2}) -ResourceCompare.threeWay.tooltip=Three-way compare of {1} and {2} relative to common ancestor {0} - -# -# DiffTreeViewer & DiffNodes -# -DiffTreeViewer.title= Structure Compare -DiffNode.noName= -DiffNode.nameFormat= {0} / {1} - -# -# Differencing engine -# -Differencer.progressFormat= Comparing {0} - -# -# Patch: rejected patch markers -# -rejectedPatchMarker.name= Rejected Patch - -# -# ValidateEdit -# -ValidateEdit.error.unable_to_perform= Operation cannot be performed. -ValidateEdit.error.fileModified= File ''{0}'' has been modified since the beginning of the operation. -ValidateEdit.error.stillReadonly= File ''{0}'' is read-only. diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml deleted file mode 100644 index ec7fac491..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %compareIncomingColor.description - - - - - %compareOutgoingColor.description - - - - - %compareConflictColor.description - - - - - %compareResolvedColor.description - - - - - %compareFontDefiniton.description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd deleted file mode 100644 index 961f643aa..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register compare/merge -viewers for specific content types. The viewer is expected to -extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However, since viewers don't have a default constructor, -the extension point must implement the factory interface -for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -content merge viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, gif" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a compare/merge viewer -for text files (extension "txt"): -<p> -<pre> -<extension point = "org.eclipse.compare.contentMergeViewers"> - <viewer - id="org.eclipse.compare.contentmergeviewer.TextMergeViewer" - class="org.eclipse.compare.internal.TextMergeViewerCreator" - extensions="txt" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines content viewers for text, binary contents, and images. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd deleted file mode 100644 index 203ed15f7..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register -viewers for specific content types. -These viewers are used in the <samp>EditionSelectionDialog</samp> when presenting an edition of a resource or a subsection thereof. The viewer is expected to extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However since viewers don't have a default constructor the extension point must implement the factory interface for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -content viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, gif" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a viewer for text -files (extension "txt"): -<p> -<pre> -<extension point = "org.eclipse.compare.contentViewers"> - <viewer - id="org.eclipse.compare.internal.TextViewer" - class="org.eclipse.compare.internal.TextViewerCreator" - extensions="txt" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines content viewers for -text and images. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd deleted file mode 100644 index a16ba63db..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register a stream merger -for specific content types. The stream merger is expected to perform a three-way merge -on three input streams and writes the result to an output stream. -The extension point must implement the interface <samp>org.eclipse.compare.IStreamMerger</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the stream merger - - - - - - - a fully qualified name of a class that implements <samp>org.eclipse.compare.IStreamMerger</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, properties" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.0 - - - - - - - - - The following is an example of a stream merger for property files (extension "properties"): -<p> -<pre> -<extension point = "org.eclipse.compare.streamMergers"> - <streamMerger - id="org.eclipse.compare.internal.merge.TextStreamMerger" - class="org.eclipse.compare.internal.merge.TextStreamMerger" - extensions="properties" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IStreamMerger</code> - - - - - - - - - The Compare UI plugin defines a stream merger for line oriented text files. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd deleted file mode 100644 index 24c6580bd..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register a structure creator -for specific content types. The structure creator is expected to create -a tree of <samp>IStructureComparator</samp>s for a given content. -This tree is used as the input for the structural compare. -The extension point must implement the interface <samp>org.eclipse.compare.structuremergeviewer.IStructureCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the structure creator - - - - - - - a fully qualified name of a class that implements <samp>org.eclipse.compare.structuremergeviewer.IStructureCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, properties" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a structure creator for -java files (extension "java"): -<p> -<pre> -<extension point = "org.eclipse.compare.structureCreators"> - <structureCreator - id="org.eclipse.compare.JavaStructureCreator" - class="org.eclipse.compare.JavaStructureCreator" - extensions="java" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.structuremergeviewer.IStructureCreator</code> - - - - - - - - - The Compare UI plugin defines a structure creator for zip archives. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd deleted file mode 100644 index 3e889f498..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register compare/merge -viewers for structural content types. The viewer is expected to -extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However, since viewers don't have a default constructor, -the extension point must implement the factory interface -for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -structure merge viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "zip, jar" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of compare/merge viewer -for zip files (extension "zip"): -<p> -<pre> -<extension point = "org.eclipse.compare.structureMergeViewers"> - <viewer - id="org.eclipse.compare.ZipCompareViewer" - class="org.eclipse.compare.ZipCompareViewerCreator" - extensions="zip" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines a structure compare -viewer for zip archives. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/scripts/exportplugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/scripts/exportplugin.xml deleted file mode 100644 index 3f309df2c..000000000 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/scripts/exportplugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd b/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd deleted file mode 100644 index 961f643aa..000000000 --- a/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register compare/merge -viewers for specific content types. The viewer is expected to -extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However, since viewers don't have a default constructor, -the extension point must implement the factory interface -for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -content merge viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, gif" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a compare/merge viewer -for text files (extension "txt"): -<p> -<pre> -<extension point = "org.eclipse.compare.contentMergeViewers"> - <viewer - id="org.eclipse.compare.contentmergeviewer.TextMergeViewer" - class="org.eclipse.compare.internal.TextMergeViewerCreator" - extensions="txt" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines content viewers for text, binary contents, and images. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/schema/contentViewers.exsd b/bundles/org.eclipse.compare/schema/contentViewers.exsd deleted file mode 100644 index 203ed15f7..000000000 --- a/bundles/org.eclipse.compare/schema/contentViewers.exsd +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register -viewers for specific content types. -These viewers are used in the <samp>EditionSelectionDialog</samp> when presenting an edition of a resource or a subsection thereof. The viewer is expected to extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However since viewers don't have a default constructor the extension point must implement the factory interface for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -content viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, gif" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a viewer for text -files (extension "txt"): -<p> -<pre> -<extension point = "org.eclipse.compare.contentViewers"> - <viewer - id="org.eclipse.compare.internal.TextViewer" - class="org.eclipse.compare.internal.TextViewerCreator" - extensions="txt" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines content viewers for -text and images. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/schema/streamMergers.exsd b/bundles/org.eclipse.compare/schema/streamMergers.exsd deleted file mode 100644 index a16ba63db..000000000 --- a/bundles/org.eclipse.compare/schema/streamMergers.exsd +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register a stream merger -for specific content types. The stream merger is expected to perform a three-way merge -on three input streams and writes the result to an output stream. -The extension point must implement the interface <samp>org.eclipse.compare.IStreamMerger</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the stream merger - - - - - - - a fully qualified name of a class that implements <samp>org.eclipse.compare.IStreamMerger</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, properties" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.0 - - - - - - - - - The following is an example of a stream merger for property files (extension "properties"): -<p> -<pre> -<extension point = "org.eclipse.compare.streamMergers"> - <streamMerger - id="org.eclipse.compare.internal.merge.TextStreamMerger" - class="org.eclipse.compare.internal.merge.TextStreamMerger" - extensions="properties" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IStreamMerger</code> - - - - - - - - - The Compare UI plugin defines a stream merger for line oriented text files. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/schema/structureCreators.exsd b/bundles/org.eclipse.compare/schema/structureCreators.exsd deleted file mode 100644 index 24c6580bd..000000000 --- a/bundles/org.eclipse.compare/schema/structureCreators.exsd +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register a structure creator -for specific content types. The structure creator is expected to create -a tree of <samp>IStructureComparator</samp>s for a given content. -This tree is used as the input for the structural compare. -The extension point must implement the interface <samp>org.eclipse.compare.structuremergeviewer.IStructureCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the structure creator - - - - - - - a fully qualified name of a class that implements <samp>org.eclipse.compare.structuremergeviewer.IStructureCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "java, properties" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of a structure creator for -java files (extension "java"): -<p> -<pre> -<extension point = "org.eclipse.compare.structureCreators"> - <structureCreator - id="org.eclipse.compare.JavaStructureCreator" - class="org.eclipse.compare.JavaStructureCreator" - extensions="java" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.structuremergeviewer.IStructureCreator</code> - - - - - - - - - The Compare UI plugin defines a structure creator for zip archives. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd b/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd deleted file mode 100644 index 3e889f498..000000000 --- a/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - This extension point allows a plug-in to register compare/merge -viewers for structural content types. The viewer is expected to -extend <samp>org.eclipse.jface.viewers.Viewer</samp>. -However, since viewers don't have a default constructor, -the extension point must implement the factory interface -for viewers <samp>org.eclipse.compare.IViewerCreator</samp>. - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique identifier that can be used to reference the viewer - - - - - - - a fully qualified name of a class that implements a factory for the -structure merge viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> - - - - - - - - - - a comma separated list of file extensions e.g. "zip, jar" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following is an example of compare/merge viewer -for zip files (extension "zip"): -<p> -<pre> -<extension point = "org.eclipse.compare.structureMergeViewers"> - <viewer - id="org.eclipse.compare.ZipCompareViewer" - class="org.eclipse.compare.ZipCompareViewerCreator" - extensions="zip" - /> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> - - - - - - - - - The Compare UI plugin defines a structure compare -viewer for zip archives. - - - - - - - - - Copyright (c) 2000, 2004 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.compare/scripts/exportplugin.xml b/bundles/org.eclipse.compare/scripts/exportplugin.xml deleted file mode 100644 index 3f309df2c..000000000 --- a/bundles/org.eclipse.compare/scripts/exportplugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.team.core/.classpath b/bundles/org.eclipse.team.core/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/bundles/org.eclipse.team.core/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.team.core/.cvsignore b/bundles/org.eclipse.team.core/.cvsignore deleted file mode 100644 index c5e82d745..000000000 --- a/bundles/org.eclipse.team.core/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin \ No newline at end of file diff --git a/bundles/org.eclipse.team.core/.options b/bundles/org.eclipse.team.core/.options deleted file mode 100644 index 0726f8d22..000000000 --- a/bundles/org.eclipse.team.core/.options +++ /dev/null @@ -1,10 +0,0 @@ -# Debugging options for the org.eclipse.team.core plugin. - -# Turn on debugging for the plugin. -org.eclipse.team.core/debug=false - -# Shows stream debugging information -org.eclipse.team.core/streams=false -org.eclipse.team.core/refreshjob=false -org.eclipse.team.core/backgroundevents=false -org.eclipse.team.core/threading=false \ No newline at end of file diff --git a/bundles/org.eclipse.team.core/.project b/bundles/org.eclipse.team.core/.project deleted file mode 100644 index 0fcc34fc1..000000000 --- a/bundles/org.eclipse.team.core/.project +++ /dev/null @@ -1,30 +0,0 @@ - - - org.eclipse.team.core - - - org.eclipse.core.resources - org.eclipse.core.runtime - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.team.core/about.html b/bundles/org.eclipse.team.core/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/bundles/org.eclipse.team.core/about.html +++ /dev/null @@ -1,30 +0,0 @@ - - - -About - - - -

About This Content

- -

20th June, 2002

-

License

-

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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

- -

Contributions

- -

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.

- -

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.

- - - \ No newline at end of file diff --git a/bundles/org.eclipse.team.core/build.properties b/bundles/org.eclipse.team.core/build.properties deleted file mode 100644 index 975c3f914..000000000 --- a/bundles/org.eclipse.team.core/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# Eclipse build contribution -bin.includes = about.html,plugin.xml,plugin.properties,*.jar,.options -source.team.jar=src/ -src.includes=about.html,schema/ diff --git a/bundles/org.eclipse.team.core/buildnotes_team.html b/bundles/org.eclipse.team.core/buildnotes_team.html deleted file mode 100644 index 877eb0d75..000000000 --- a/bundles/org.eclipse.team.core/buildnotes_team.html +++ /dev/null @@ -1,547 +0,0 @@ - - - -Eclipse Team Plugin - Build notes - - - - - - - - - - - -
Eclipse Team
build notes
- - - - - - - - - - - - - - - - - - - -
Here are the build notes for the Team Plugin - which includes changes to org.eclipse.team.core, - org.eclipse.team.ui, org.eclipse.team.ftp, org.eclipse.team.examples.filesystem, - org.eclipse.team.webdav. -
3.1 Builds
- -

September - 23rd 2004 - 3.1 M2

-

Interesting changes

-
    -
  • A Flat layout has been added to the Synchronize view. -
-

Breaking API changes

-

None

-

Fixed bugs

-

See this - bugzilla query to list all fixed bugs in this build.

-
3.0 Builds
- -

September - 23rd 2003 - 3.0 (I20030923)

-

Interesting changes

-
    -
  • More actions have been added to the view: copy/paste/rename/delete. -
  • The Synchronize View displays a Busy Pointer icon when performing - work in the background that affects the view. -
  • A status bar that shows the number of conflicting/incoming/outgoing - changes is located at the top of the Synchronize View. The numbers - reflect both the entire changes in the workspace or when a working - set is enabled, the changes in the working set versus those in the - workspace. This is a hint that changes in the workspace are being - filtered out by a working set. -
  • Conflicts are propagated to the parent folders in the Synchronize - View. This will make it harder to forget or miss important conflicting - changes. -
-

Breaking API changes

-

None

-

Fixed bugs

-

See this - bugzilla query to list all fixed bugs in this build.

-

September - 9th 2003 - 3.0 (I20030909)

-

Interesting changes

-
    -
  • The Synchronize View now supports stepping through all differences in step with the compare editor. You can use the - next/previous arrows to browse all changes. -
-

Breaking API changes

-

None

-

Fixed bugs

-

See this - bugzilla query to list all fixed bugs in this build.

- - -

- August 26th 2003 - 3.0 (I20030819)

-

Interesting changes

-
    -
  • The mode filters in the Synchronize View are saved as user preferences and the preference to use incoming/outgoing mode has been removed.
  • -
-

Breaking API changes

-

None

-

Fixed bugs (? fixed)

-

See this - bugzilla query to list all fixed bugs in this build.

- - -

- August 19th 2003 - 3.0 (I20030819)

-

Interesting changes

-
    -
  • We have received new Synchronize View action icons.
  • -
  • Cancellation support in the stream classes can be configured. This is to allow certain communications (e.g. logins) to not be interrupted.
  • -
  • Fixed a couple of bugs with SyncSets not being concurrent safe.
  • -
-

Breaking API changes

-

None

-

Fixed bugs (7 fixed)

-

See this - bugzilla query to list all fixed bugs in this build.

- - -

- August 6th 2003 - 3.0 (I20030806)

-

Interesting changes

-
    -
  • The new Synchronize View now calculates all changes in a separate - thread. This improves startup times and provides better responsiveness - when synchronizing resources.
  • -
  • The Synchronize View API is starting to take shape. For an advanced - preview look at the org.eclipse.team.core.subscribers - and org.eclipse.team.ui.sync packages.
  • -
  • A Team Synchronize perspective has been created and is the default - when synchronizing. This can be configured via the Synchronize View - preferences.
  • -
-

Breaking API changes

-

None

-

Fixed bugs (27 fixed)

-

See this - bugzilla query to list all fixed bugs in this build.

- -
-
-
-Archive for 2.0 and 2.1 Builds
- -

Eclipse Platform Build Notes – Team Support

-

Team build I20020909 – September 9, 2002

- -

Build submission for Integration Build 20020910

- -

What's new in this build

- -

The ability to export/import target sites has been added along -with properties pages for target sites and deployed projects.

- -

Eclipse Platform Build Notes – Team Support

-

Team build I20020517 – May 17 2002

- -

Build submission for Integration Build 20020517

- -

What's new in this build

- -

This build introduces Target Management support. Target -management consists of a set of core API, in combination with one or more -target providers. Initially, we are providing a WebDAV target provider in -the plug-in org.eclipse.team.webdav. Target management operations appear -in the navigator under the "Deploy" sub-menu.

- -

- -

- -

- -

- -

- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020430 – April 30 2002

- -

Build submission for Integration Build 20020430

- -

What's new in this build

- -

No major changes

- -

- -

- -

- -

- -

- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020423 – April 23 2002

- -

Build submission for Integration Build 20020423

- -

What's new in this build

- -

Initial release of team project set support. There is - now an import and export wizard that allows one to create a file containing - a list (and location) of team shared projects. This file may be imported -into another workspace, re-creating the entire set of projects.

- -

- -

- -

- -

- -

- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020418 – April 18 2002

- -

Build submission for Integration Build 20020418

- -

What's new in this build

- -

No significant changes to the core Team support in this - build.

- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020409 – April 9 2002

- -

Build submission for Integration Build 20020409

- -

What's new in this build

- -

No significant changes to the core Team support in this - build.

-
- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020402 – April 2 2002

- -

Build submission for Integration Build 20020402

- -

What's new in this build

- -

Team plug-ins are now turned on by default. The - old VCM plug-ins are still included in the build but are turned off.
- The global ignore and text/binary APIs have changed substantially. The - facilities are now provided as static methods on the class org.eclipse.team.core.Team. - See that class's Javadoc for more details.
-
-

- -


-

- -
-

Eclipse Platform Build Notes – Team Support

- -

Team build I20020312 – March 12 2002

- -

Build submission for Integration Build 20020312

- -

What's new in this build

- -

- -

Team plug-ins are now turned on by default. The - old VCM plug-ins are still included in the build but are turned off.

- -


- The Decorations extension point has been removed from org.eclipse.team.ui. - Please use the generic workbench decoration facility in the future.
-

- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020305 – March 5 2002

- -

Build submission for Integration Build 20020305

- -

What's new in this drop

- -

No changes to the core team support in this drop.

- -


- All Team plug-ins are turned off by default. If you wish to use Team - support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml 
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml 
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml 
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml 
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml 
  10. - -
- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020226 – February 26, 2002

- -

Build submission for Integration Build 20020226

- -

What's new in this drop

- -

- -

- -

- -

No changes in this drop.

- -


- All Team plug-ins are turned off by default. If you wish to use Team - support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml 
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml 
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml 
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml 
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml 
  10. - -
- -

Eclipse Platform Build Notes – Team Support

- -

Team build I20020214 – February 14, 2002

- -

Build submission for Integration Build 20020214

- -

What's new in this drop

- -

Bug fixes:

- -

Change in semantics to validateEdit (9802)

- -

 

- -

All Team plug-ins are turned off by default. If you -wish to use Team support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
  10. - -
- -

Eclipse Platform Build Notes – Team Support

- -

Team build V2_0_6 – February 12, 2002

- -

Build submission for Integration Build 20020212

- -

What's new in this drop

- -

48 bugs fixed.

- -

Global ignore facility added to the core team support.

- -

 

- -

All Team plug-ins are turned off by default. If you -wish to use Team support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
  10. - -
- -

-  

- -

Please report any problems to the VCM team, and use -the VCM component for bug tracking.

- -

Eclipse Platform Build Notes – Team Support

- -

Team build V2_0_5 – February 5, 2002

- -

Build submission for Integration Build 20020205

- -

What's new in this drop

- -

41 bugs fixed.

- -

CVS operations move from the CVS submenu to the Team - submenu.

- -

Proper plugin.xml files will be included with this build.

- -

 

- -

All Team plug-ins are turned off by default. If you -wish to use Team support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
  10. - -
- -

-  

- -

Please report any problems to the VCM team, and use -the VCM component for bug tracking.

- -

 

- -

Run - this query to determine which bugs have been fixed since January - 29 th. If you wish to narrow the search, edit the query and - change the dates.

- -

Eclipse Platform Build Notes – Team Support

- -

Team build V2_0_4 – January 29, 2002

- -

Build submission for Integration Build 20020129

- -

What's new in this drop

- -

Merge support has been added

- -

Numerous bug fixes

- -

 

- -

All Team plug-ins are turned off by default. If you -wish to use Team support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
  4. -
  5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
  6. -
  7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
  8. -
  9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
  10. - -
- -

-  

- -

Please report any problems to the VCM team, and use -the VCM component for bug tracking.

- -

 

- -

Run - this query to determine which bugs have been fixed since January - 15 th. If you wish to narrow the search, edit the query and - change the dates.

- -

Eclipse Platform Build Notes – Team Support

- -

Team build V2_0_2 – January 15, 2002

- -

Build submission for Integration Build 20020115

- -

What's new in this drop

- -

This is the initial release for the Team support plug-ins. - Team support is intended to be an eventual replacement for the VCM codebase.

- -

 

- -

The plug-ins are turned off by default. If you wish -to use Team support,

- -
    -
  1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
  2. -
  3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
  4. - -
- -

 

- -

Please report any problems to the VCM team, and use -the VCM component for bug tracking.

- -

 

- -

Run - this query to determine which bugs have been fixed since January - 7 th. If you wish to narrow the search, edit the query and - change the dates.

- -

 

-
- -
- - diff --git a/bundles/org.eclipse.team.core/plugin.properties b/bundles/org.eclipse.team.core/plugin.properties deleted file mode 100644 index ca690837f..000000000 --- a/bundles/org.eclipse.team.core/plugin.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.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=Team Support Core -providerName=Eclipse.org -FileTypesRegistry=File Types Registry -GlobalIgnoreRegistry=Global Ignore Registry -TeamProjectSets=Team Project Sets -Targets=Target Provider and Location Factories -Repository=Repository Providers diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml deleted file mode 100644 index 186681659..000000000 --- a/bundles/org.eclipse.team.core/plugin.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.team.core/schema/defaultFileModificationValidator.exsd b/bundles/org.eclipse.team.core/schema/defaultFileModificationValidator.exsd deleted file mode 100644 index 3da1b0b8a..000000000 --- a/bundles/org.eclipse.team.core/schema/defaultFileModificationValidator.exsd +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - This extension point is for external use only. It's purpose is to provide prompting for the overwriting of read-only resources using validateEdit on unshared projects. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.1 - - - - - - - - - Internal use only - - - - - - - - - Internal use only - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.core/schema/fileTypes.exsd b/bundles/org.eclipse.team.core/schema/fileTypes.exsd deleted file mode 100644 index 3dc2ec64a..000000000 --- a/bundles/org.eclipse.team.core/schema/fileTypes.exsd +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - This extension point is used to register information about whether particular file types should be considered to contain text or binary data. -This information is important to some repository providers as it affects how the data is stored, compared and transmitted. -<p> -Providers may provide an extension for this extension point. No code beyond the XML extension declaration is required. -</p> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - the file extension being identified by this contribution. - - - - - - - one of either "text" or "binary", identifying the contents of files matching the value of extension. - - - - - - - - - - - - Following is an example of a fileTypes extension: - -<p> -<pre> - <extension point="org.eclipse.team.core.fileTypes"> - <fileTypes extension="txt" type="text"/> - </extension> -</pre> -</p> - - - - - - - - - - - - - - - - - - 2.0 - - - - - - - - - - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.core/schema/ignore.exsd b/bundles/org.eclipse.team.core/schema/ignore.exsd deleted file mode 100644 index 2fc059014..000000000 --- a/bundles/org.eclipse.team.core/schema/ignore.exsd +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - This extension point is used to register information about whether particular resources should be ignored; -that is, excluded from version configuration management operations. -Providers may provide an extension for this extension point. No code beyond the XML extension declaration is required. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - the pattern against which resources will be compared. - - - - - - - one of "true" or "false", determines whether this ignore pattern is enabled. - - - - - - - - - - - - Following is an example of an ignore extension: - -<p> -<pre> - <extension point="org.eclipse.team.core.ignore"> - <ignore pattern="*.class" enabled="true"/> - </extension> -</pre> -</p> - - - - - - - - - - - - - - - - - - 2.0 - - - - - - - - - - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.core/schema/projectSets.exsd b/bundles/org.eclipse.team.core/schema/projectSets.exsd deleted file mode 100644 index 643933704..000000000 --- a/bundles/org.eclipse.team.core/schema/projectSets.exsd +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - This extension point is used to register a handler for creating and reading project sets. -Project sets are lightweight, portable method of sharing a particular lineup of team-shared projects in a workspace. -A project set file may be used to provide team memebers with a simple way of creating a workspace with a particular lineup of projects form one or more team providers. Providers may provide an extension for this extension point. -<p> -<i>deprecated: see RepositoryProvider#getProjectSetCapability.</i> -</p> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - the nature id of the provider for which this handler creates and reads project sets. - - - - - - - the fully qualified name of a class implementing <samp>org.eclipse.team.core.IProjectSerializer</samp>. - - - - - - - - - - - - - - - Following is an example of a projectSets extension: - -<p> -<pre> - <extension point="org.eclipse.team.core.projectSets"> - <projectSets - id="org.eclipse.team.cvs.core.cvsnature" - class="org.eclipse.team.cvs.core.CVSProjectSetSerializer"> - </projectSets> - </extension> -</pre> -</p> - - - - - - - - - - - - - - - - - - 2.0 - - - - - - - - - - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.core/schema/repository.exsd b/bundles/org.eclipse.team.core/schema/repository.exsd deleted file mode 100644 index d13aeea74..000000000 --- a/bundles/org.eclipse.team.core/schema/repository.exsd +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - The Team plugin contains the notion of Repositories. The job of a repository is to provide support for sharing resources between Team members. Repositories are configured on a per-project basis. Only one repository can be mapped to a project at a time. -<p> -Repositories that extend this extension point can provide implementations for common repository specific rules for resource modifications, moving and deleting. See the following interfaces for more details <code>IFileModificationValidator</code> and <code>MoveDeleteHook</code>. -</p> -<p> -A Repository type can also be specified in order to provide non-project specific funtionality such as a <samp>org.eclipse.team.core.ProjectSetCapability</samp>. -</p> -<p> -Optionaly, a repository provider type can designate that it can import projects from second provider, in the case where the second provider's plugin is not available in the current install. This is provided as a means to support the migration from one provider implementation to another where the resuse of the same id for the two providers was not possible. -</p> - - - - - - - - - - - - - - - - - - - - - - - - an optional identifier of the extension instance - - - - - - - the fully-qualified name of a subclass of - <samp>org.eclipse.team.core.RepositoryProvider</samp>. - - - - - - - - - - the fully-qualified name of a subclass of - <samp>org.eclipse.team.core.RepositoryProviderType</samp>. - - - - - - - - - - - - - - - - - - - - - - 2.0 - - - - - - - - - <pre> -<extension point="org.eclipse.team.core.repository"> - <repository - class="org.eclipse.myprovider.MyRepositoryProvider" - typeClass="org.eclipse.myprovider.MyRepositoryProvider" - id="org.eclipse.myprovider.myProviderID" - canImportId="org.eclipse.myprovider.myOldProviderID"> - </repository> -</extension> -</pre> - - - - - - - - - The value of the class attribute must represent a subclass of <samp>org.eclipse.team.core.RepositoryProvider</samp> and the value of the typeClass attribute must represent a subclass of <samp>org.eclipse.team.core.RepositoryProviderType</samp> - - - - - - - - - The provided implementation of RepositoryProvider provides helper methods and common code for mapping and unmapping providers to projects. -The optional RepositoryProviderType provides project set import and export through a ProjectSetCapability. - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java deleted file mode 100644 index 4fabc2bda..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/DefaultRepositoryProviderType.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -/* - */ -public final class DefaultRepositoryProviderType extends RepositoryProviderType { - - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileTypeInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileTypeInfo.java deleted file mode 100644 index eaab301ba..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileTypeInfo.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -/** - * A file type info specifies both the file extension and the - * corresponding file type. - * - * @since 2.0 - */ -public interface IFileTypeInfo { - /** - * Returns the string specifying the file extension - * - * @return the file extension - */ - public String getExtension(); - - /** - * Returns the file type for files ending with the corresponding - * extension. - * - * Valid values are: - * Team.UNKNOWN - * Team.TEXT - * Team.BINARY - * - * @return the file type - */ - public int getType(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IIgnoreInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IIgnoreInfo.java deleted file mode 100644 index 86bf1ba9a..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IIgnoreInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -/** - * An ignore info specifies both the pattern and the enabled state - * of a globally ignored pattern. - * - * @since 2.0 - */ -public interface IIgnoreInfo { - /** - * Return the string specifying the pattern of this ignore. The string - * may include the wildcard characters '*' and '?'. If you wish to - * include either of these characters verbatim (i.e. you do not wish - * them to expand to wildcards), you must escape them with a backslash '\'. - *

- * If you are using string literals in Java to represent the patterns, don't - * forget escape characters are represented by "\\". - * - * @return the pattern represented by this ignore info - */ - public String getPattern(); - /** - * Return whether or not this ignore info is enabled. A disabled ignore - * info remains in the global ignore list, but no attempt is made to match - * with it to determine resource ignore state. - * - * @return whether the ignore info is enabled - */ - public boolean getEnabled(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IProjectSetSerializer.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IProjectSetSerializer.java deleted file mode 100644 index 029bfcb45..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IProjectSetSerializer.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * IProjectSetSerializer manages the serializing and deserializing - * of references to projects. Given a project, it can produce a - * UTF-8 encoded String which can be stored in a file. - * Given this String, it can create in the workspace an IProject. - * - * @since 2.0 - * - * @deprecated - * Use {@link org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()} - * to obtain an instance of {@link org.eclipse.team.core.ProjectSetCapability} instead. - */ - -public interface IProjectSetSerializer { - - /** - * For every IProject in providerProjects, return an opaque - * UTF-8 encoded String to act as a reference to that project. - * The format of the String is specific to the provider. - * The format of the String must be such that - * IProjectSetSerializer.addToWorskpace() will be able to - * consume it and recreate a corresponding project. - * @see IProjectSetSerializer#addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) - * - * @param providerProjects an array of projects that the serializer should create - * text references for - * @param context a UI context object. This object will either be a - * com.ibm.swt.widgets.Shell or it will be null. - * @param monitor a progress monitor - * @return String[] an array of serialized reference strings uniquely identifying the projects - * @throws TeamException - */ - public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) throws TeamException; - - /** - * For every String in referenceStrings, create in the workspace a - * corresponding IProject. Return an Array of the resulting IProjects. - * Result is unspecified in the case where an IProject of that name - * already exists. In the case of failure, a TeamException must be thrown. - * The opaque strings in referenceStrings are guaranteed to have been previously - * produced by IProjectSetSerializer.asReference(). - * @see IProjectSetSerializer#asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) - * - * @param referenceStrings an array of referene strings uniquely identifying the projects - * @param filename the name of the file that the references were read from. This is included - * in case the provider needs to deduce relative paths - * @param context a UI context object. This object will either be a - * com.ibm.swt.widgets.Shell or it will be null. - * @param monitor a progress monitor - * @return IProject[] an array of projects that were created - * @throws TeamException - */ - public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) throws TeamException; -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ITeamStatus.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ITeamStatus.java deleted file mode 100644 index d0015a365..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ITeamStatus.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; - -/** - * Defines the status codes used in the status of exceptions and errors relating to Team. - * - * @since 3.0 - */ -public interface ITeamStatus extends IStatus { - - /** - * An error occurred trying to obtain the SyncInfo for a single resource. - * The error will be cleared when the set is reset or possibly when a sync info is added to - * the set for the resource for which the error occurred. - */ - public static final int RESOURCE_SYNC_INFO_ERROR = 1; - - /** - * An error occurred that may effect several resources in a SyncInfoSet. - * The error will be cleared when the set is reset. - */ - public static final int SYNC_INFO_SET_ERROR = 2; - - /** - * The collection of sync info for a sync info set has been cancelled so the - * contents fdo not reflect the state of the system. - * The error will be cleared when the set is reset. - */ - public static final int SYNC_INFO_SET_CANCELLATION = 3; - - /** - * Return the resource associated with this status. - * @return Returns the resource. - */ - public IResource getResource(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java deleted file mode 100644 index 2ca19589a..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Dan Rubel - project set serializer API - *******************************************************************************/ -package org.eclipse.team.core; - -import java.io.File; -import java.util.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.core.Policy; - -/** - * An object for serializing and deserializing - * references to projects. Given a project, it can produce a - * UTF-8 encoded String which can be stored in a file. - * Given this String, it can load a project into the workspace. - * It also provides a mechanism - * by which repository providers can be notified when a project set is created and exported. - * - * @see RepositoryProviderType - * - * @since 2.1 - */ -public abstract class ProjectSetCapability { - - /** - * Ensure that the provider type is backwards compatible by - * passing the project set serializer to the type if a serializer - * is registered. This is required for repository providers - * who implemented a project set capability in 2.1 (before the - * capability contained the serialization API) and have not - * released a 3.0 plugin yet. This method is - * called before project set export and import and can be used by - * other clients who work with project sets. - * - * @param type the provider type instance - * @param capability the capability that was obtained from the provider type - * - * @since 3.0 - */ - public static void ensureBackwardsCompatible(RepositoryProviderType type, ProjectSetCapability capability) { - if (capability != null) { - IProjectSetSerializer oldSerializer = Team.getProjectSetSerializer(type.getID()); - if (oldSerializer != null) { - capability.setSerializer(oldSerializer); - } - } - } - - /** - * The old serialization interface - */ - private IProjectSetSerializer serializer; - - /** - * Notify the provider that a project set has been created at path. Only - * providers identified as having projects in the project set will be - * notified. The project set may or may not be created in a workspace - * project (thus may not be a resource). - * - * @param file the project set file that was created - * @param context a UI context object. This object will either be a - * com.ibm.swt.widgets.Shell or it will be null. - * @param monitor a progress monitor - * - * @deprecated should use or override - * projectSetCreated(File, ProjectSetSerializationContext, IProgressMonitor) - * instead - */ - public void projectSetCreated(File file, Object context, IProgressMonitor monitor) { - //default is to do nothing - } - - /** - * Notify the provider that a project set has been created at path. Only - * providers identified as having projects in the project set will be - * notified. The project set may or may not be created in a workspace - * project (thus may not be a resource). - * - * @param file the project set file that was created - * @param context - * the context in which the references are created - * (not null) - * @param monitor a progress monitor - * - * @since 3.0 - */ - public void projectSetCreated(File file, ProjectSetSerializationContext context, IProgressMonitor monitor) { - // Invoke old method by default - projectSetCreated(file, context.getShell(), monitor); - } - - /** - * For every project in providerProjects, return an opaque - * UTF-8 encoded String to act as a reference to that project. - * The format of the String is specific to the provider. - * The format of the String must be such that - * {@link #addToWorkspace(String[], ProjectSetSerializationContext, IProgressMonitor)} - * will be able to consume it and load the corresponding project. - *

- * This default implementation simply throws an exception - * indicating that no references can be created unless there - * is an IProjectSetSerializer registered for the repository - * provider type in which case the operation is delegated to the - * serializer. - * Subclasses are expected to override. - * - * @since 3.0 - * - * @param providerProjects - * an array of projects for which references are needed - * (not null and contains no nulls) - * @param context - * the context in which the references are created - * (not null) - * @param monitor - * a progress monitor or null if none - * @return - * an array containing exactly the same number of elements - * as the providerProjects argument - * where each element is a serialized reference string - * uniquely identifying the corresponding the project in the providerProjects array - * (not null and contains no nulls) - * @throws TeamException - * thrown if there is a reference string cannot be created for a project - */ - public String[] asReference( - IProject[] providerProjects, - ProjectSetSerializationContext context, - IProgressMonitor monitor) - throws TeamException { - - if (serializer != null) { - return serializer.asReference(providerProjects, context.getShell(), monitor); - } - throw new TeamException(Policy.bind("ProjectSetCapability.0")); //$NON-NLS-1$ - } - - /** - * For every String in referenceStrings, load the corresponding project into the workspace. - * The opaque strings in referenceStrings are guaranteed to have been previously - * produced by {@link #asReference(IProject[], ProjectSetSerializationContext, IProgressMonitor)}. - * The confirmOverwrite method is called with an array of projects - * for which projects of the same name already exists in the workspace. - *

- * Callers from within a UI context should wrapper a call to this method - * inside a WorkspaceModifyOperation so that events generated as a result - * of this operation are deferred until the outermost operation - * has successfully completed. - *

- * This default implementation simply throws an exception - * indicating that no projects can be loaded unless there - * is an IProjectSetSerializer registered for the repository - * provider type in which case the operation is delegated to the - * serializer. - * Subclasses are expected to override. - * - * @since 3.0 - * - * @param referenceStrings - * an array of referene strings uniquely identifying the projects - * (not null and contains no nulls) - * @param context - * the context in which the projects are loaded - * (not null) - * @param monitor - * a progress monitor or null if none - * @return IProject[] - * an array of projects that were loaded - * excluding those projects already existing and not overwritten - * (not null, contains no nulls) - * @throws TeamException - * thrown if there is a problem loading a project into the workspace. - * If an exception is thrown, then the workspace is left in an unspecified state - * where some of the referenced projects may be loaded or partially loaded, and others may not. - */ - public IProject[] addToWorkspace( - String[] referenceStrings, - ProjectSetSerializationContext context, - IProgressMonitor monitor) - throws TeamException { - - if (serializer != null) { - return serializer.addToWorkspace(referenceStrings, context.getFilename(), context.getShell(), monitor); - } - throw new TeamException(Policy.bind("ProjectSetCapability.1")); //$NON-NLS-1$ - } - - //////////////////////////////////////////////////////////////////////////// - // - // Internal utility methods for subclasses - // - //////////////////////////////////////////////////////////////////////////// - - /** - * Determine if any of the projects already exist - * and confirm which of those projects are to be overwritten. - * - * @since 3.0 - * - * @param context - * the context in which the projects are loaded - * (not null) - * @param projects - * an array of proposed projects to be loaded - * (not null, contains no nulls) - * @return - * an array of confirmed projects to be loaded - * or null if the operation is to be canceled. - * @throws TeamException - */ - protected IProject[] confirmOverwrite( - ProjectSetSerializationContext context, - IProject[] projects) - throws TeamException { - - // Build a collection of existing projects - - final Collection existingProjects = new ArrayList(); - for (int i = 0; i < projects.length; i++) { - IProject eachProj = projects[i]; - if (eachProj.exists()) - existingProjects.add(eachProj); - } - if (existingProjects.size() == 0) - return projects; - - // Confirm the overwrite - - IProject[] confirmed = - context.confirmOverwrite( - (IProject[]) existingProjects.toArray( - new IProject[existingProjects.size()])); - if (confirmed == null) - return null; - if (existingProjects.size() == confirmed.length) - return projects; - - // Return the amended list of projects to be loaded - - Collection result = new ArrayList(projects.length); - result.addAll(Arrays.asList(projects)); - result.removeAll(existingProjects); - for (int i = 0; i < confirmed.length; i++) { - IProject eachProj = confirmed[i]; - if (existingProjects.contains(eachProj)) - result.add(eachProj); - } - return (IProject[]) result.toArray(new IProject[result.size()]); - } - - /* - * Set the serializer to the one registered. The serializer - * will be used if subclasses do not override asReference - * and addToWorkspace - */ - void setSerializer(IProjectSetSerializer serializer) { - this.serializer = serializer; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetSerializationContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetSerializationContext.java deleted file mode 100644 index aba7d2a2e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetSerializationContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/********************************************************************** - Copyright (c) 2004 Dan Rubel and others. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Common Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/cpl-v10.html - - Contributors: - - Dan Rubel - initial API and implementation - - **********************************************************************/ - -package org.eclipse.team.core; - -import org.eclipse.core.resources.IProject; - -/** - * The context in which project serialization occurs. - * The class may be subclassed to represent different serialization contexts. - * - * @since 3.0 - */ -public class ProjectSetSerializationContext { - - private final String filename; - - /** - * Create a serialization context with no filename - */ - public ProjectSetSerializationContext() { - this(null); - } - - /** - * Create a serialization context and set the filename of the file - * that does or is to contain the project set. - * @param filename a filename or null - */ - public ProjectSetSerializationContext(String filename) { - this.filename = filename; - } - - /** - * Given an array of projects that currently exist in the workspace - * determine which of those projects should be overwritten. - *

- * This default implementation always returns an empty array - * indicating that no existing projects should be overwritten. - * Subclasses may override this as appropriate. - * - * @param projects - * an array of projects currently existing in the workspace - * that are desired to be overwritten. - * (not null, contains no nulls) - * @return - * an array of zero or more projects that should be overwritten - * or null if the operation is to be canceled - */ - public IProject[] confirmOverwrite(IProject[] projects) throws TeamException { - return new IProject[0]; - } - - /** - * Return a org.eclipse.swt.Shell if there is a UI context - * or null if executing headless. - * - * @return the shell or null - */ - public Object getShell() { - return null; - } - - /** - * Return the name of the file to or from which teh project set is being loaded or saved. - * This may be null. - * @return the filename or null - */ - public String getFilename() { - return filename; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java deleted file mode 100644 index 52f22b412..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java +++ /dev/null @@ -1,666 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import java.util.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.team.internal.core.*; - -/** - * A concrete subclass of RepositoryProvider is created for each - * project that is associated with a repository provider. The lifecycle of these - * instances is is similar to that of the platform's 'nature' mechanism. - *

- * To create a repository provider and have it registered with the platform, a client - * must minimally: - *

    - *
  1. extend RepositoryProvider - *
  2. define a repository extension in plugin.xml. - * Here is an example extension point definition: - * - * - *
    <extension point="org.eclipse.team.core.repository"> - *
     <repository - *
      class="org.eclipse.myprovider.MyRepositoryProvider" - *
      id="org.eclipse.myprovider.myProviderID"> - *
     </repository> - *
    </extension> - *
    - *

- *

- * Once a repository provider is registered with Team, then you - * can associate a repository provider with a project by invoking RepositoryProvider.map(). - *

- * @see RepositoryProvider#map(IProject, String) - * - * @since 2.0 - */ -public abstract class RepositoryProvider implements IProjectNature, IAdaptable { - - private final static String TEAM_SETID = "org.eclipse.team.repository-provider"; //$NON-NLS-1$ - - private final static QualifiedName PROVIDER_PROP_KEY = - new QualifiedName("org.eclipse.team.core", "repository"); //$NON-NLS-1$ //$NON-NLS-2$ - - private final static List AllProviderTypeIds = initializeAllProviderTypes(); - - // the project instance that this nature is assigned to - private IProject project; - - // lock to ensure that map/unmap and getProvider support concurrency - private static final ILock mappingLock = Platform.getJobManager().newLock(); - - /** - * Instantiate a new RepositoryProvider with concrete class by given providerID - * and associate it with project. - * - * @param project the project to be mapped - * @param id the ID of the provider to be mapped to the project - * @throws TeamException if - *
    - *
  • There is no provider by that ID.
  • - *
  • The project is already associated with a repository provider and that provider - * prevented its unmapping.
  • - *
- * @see RepositoryProvider#unmap(IProject) - */ - public static void map(IProject project, String id) throws TeamException { - ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project); - try { - // Obtain a scheduling rule on the project before obtaining the - // mappingLock. This is required because a caller of getProvider - // may hold a scheduling rule before getProvider is invoked but - // getProvider itself does not (and can not) obtain a scheduling rule. - // Thus, the locking order is always scheduling rule followed by - // mappingLock. - Platform.getJobManager().beginRule(rule, null); - try { - mappingLock.acquire(); - RepositoryProvider existingProvider = null; - - if(project.getPersistentProperty(PROVIDER_PROP_KEY) != null) - existingProvider = getProvider(project); // get the real one, not the nature one - - //if we already have a provider, and its the same ID, we're ok - //if the ID's differ, unmap the existing. - if(existingProvider != null) { - if(existingProvider.getID().equals(id)) - return; //nothing to do - else - unmap(project); - } - - // Create the provider as a session property before adding the persistant - // property to ensure that the provider can be instantiated - RepositoryProvider provider = mapNewProvider(project, id); - - //mark it with the persistent ID for filtering - try { - project.setPersistentProperty(PROVIDER_PROP_KEY, id); - } catch (CoreException outer) { - // couldn't set the persistant property so clear the session property - try { - project.setSessionProperty(PROVIDER_PROP_KEY, null); - } catch (CoreException inner) { - // something is seriously wrong - TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoryProvider.couldNotClearAfterError", project.getName(), id), inner);//$NON-NLS-1$ - } - throw outer; - } - - provider.configure(); //xxx not sure if needed since they control with wiz page and can configure all they want - - //adding the nature would've caused project description delta, so trigger one - project.touch(null); - - // Set the rule factory for the provider after the touch - // so the touch does not fail due to incomptible modify rules - TeamHookDispatcher.setProviderRuleFactory(project, provider.getRuleFactory()); - } finally { - mappingLock.release(); - } - } catch (CoreException e) { - throw TeamPlugin.wrapException(e); - } finally { - Platform.getJobManager().endRule(rule); - } - } - - /* - * Instantiate the provider denoted by ID and store it in the session property. - * Return the new provider instance. If a TeamException is thrown, it is - * guaranteed that the session property will not be set. - * - * @param project - * @param id - * @return RepositoryProvider - * @throws TeamException we can't instantiate the provider, or if the set - * session property fails from core - */ - private static RepositoryProvider mapNewProvider(IProject project, String id) throws TeamException { - RepositoryProvider provider = newProvider(id); // instantiate via extension point - - if(provider == null) - throw new TeamException(Policy.bind("RepositoryProvider.couldNotInstantiateProvider", project.getName(), id)); //$NON-NLS-1$ - - // validate that either the provider supports linked resources or the project has no linked resources - if (!provider.canHandleLinkedResources()) { - try { - IResource[] members = project.members(); - for (int i = 0; i < members.length; i++) { - IResource resource = members[i]; - if (resource.isLinked()) { - throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.LINKING_NOT_ALLOWED, Policy.bind("RepositoryProvider.linkedResourcesExist", project.getName(), id), null)); //$NON-NLS-1$ - } - } - } catch (CoreException e) { - throw TeamPlugin.wrapException(e); - } - } - - //store provider instance as session property - try { - project.setSessionProperty(PROVIDER_PROP_KEY, provider); - provider.setProject(project); - } catch (CoreException e) { - throw TeamPlugin.wrapException(e); - } - return provider; - } - - private static RepositoryProvider mapExistingProvider(IProject project, String id) throws TeamException { - try { - // Obtain the mapping lock before creating the instance so we can make sure - // that a disconnect is not happening at the same time - mappingLock.acquire(); - try { - // Ensure that the persistant property is still set - // (i.e. an unmap may have come in since we checked it last - String currentId = project.getPersistentProperty(PROVIDER_PROP_KEY); - if (currentId == null) { - // The provider has been unmapped - return null; - } - if (!currentId.equals(id)) { - // A provider has been disconnected and another connected - // Since mapping creates the session property, we - // can just return it - return lookupProviderProp(project); - } - } catch (CoreException e) { - throw TeamPlugin.wrapException(e); - } - return mapNewProvider(project, id); - } finally { - mappingLock.release(); - } - } - /** - * Disassoociates project with the repository provider its currently mapped to. - * @param project - * @throws TeamException The project isn't associated with any repository provider. - */ - public static void unmap(IProject project) throws TeamException { - ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project); - try{ - // See the map(IProject, String) method for a description of lock ordering - Platform.getJobManager().beginRule(rule, null); - try { - mappingLock.acquire(); - String id = project.getPersistentProperty(PROVIDER_PROP_KEY); - - //If you tried to remove a non-existant nature it would fail, so we need to as well with the persistent prop - if(id == null) { - throw new TeamException(Policy.bind("RepositoryProvider.No_Provider_Registered", project.getName())); //$NON-NLS-1$ - } - - //This will instantiate one if it didn't already exist, - //which is ok since we need to call deconfigure() on it for proper lifecycle - RepositoryProvider provider = getProvider(project); - if (provider == null) { - // There is a persistant property but the provider cannot be obtained. - // The reason could be that the provider's plugin is no longer available. - // Better log it just in case this is unexpected. - TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoryProvider.couldNotInstantiateProvider", project.getName(), id), null); //$NON-NLS-1$ - } - - if (provider != null) provider.deconfigure(); - - project.setSessionProperty(PROVIDER_PROP_KEY, null); - project.setPersistentProperty(PROVIDER_PROP_KEY, null); - - if (provider != null) provider.deconfigured(); - - //removing the nature would've caused project description delta, so trigger one - project.touch(null); - - // Change the rule factory after the touch in order to - // avoid rule incompatibility - TeamHookDispatcher.setProviderRuleFactory(project, null); - } finally { - mappingLock.release(); - } - } catch (CoreException e) { - throw TeamPlugin.wrapException(e); - } finally { - Platform.getJobManager().endRule(rule); - } - } - - /* - * Return the provider mapped to project, or null if none; - */ - private static RepositoryProvider lookupProviderProp(IProject project) throws CoreException { - return (RepositoryProvider) project.getSessionProperty(PROVIDER_PROP_KEY); - } - - - /** - * Default constructor required for the resources plugin to instantiate this class from - * the nature extension definition. - */ - public RepositoryProvider() { - } - - /** - * Configures the provider for the given project. This method is called after setProject. - * If an exception is generated during configuration - * of the project, the provider will not be assigned to the project. - * - * @throws CoreException if the configuration fails. - */ - abstract public void configureProject() throws CoreException; - - /** - * Configures the nature for the given project. This is called by RepositoryProvider.map() - * the first time a provider is mapped to a project. It is not intended to be called by clients. - * - * @throws CoreException if this method fails. If the configuration fails the provider will not be - * associated with the project. - * - * @see RepositoryProvider#configureProject() - */ - final public void configure() throws CoreException { - try { - configureProject(); - } catch(CoreException e) { - try { - RepositoryProvider.unmap(getProject()); - } catch(TeamException e2) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, 0, Policy.bind("RepositoryProvider_Error_removing_nature_from_project___1") + getID(), e2)); //$NON-NLS-1$ - } - throw e; - } - } - - /** - * Method deconfigured is invoked after a provider has been unmaped. The - * project will no longer have the provider associated with it when this - * method is invoked. It is a last chance for the provider to clean up. - */ - protected void deconfigured() { - } - - /** - * Answer the id of this provider instance. The id should be the repository provider's - * id as defined in the provider plugin's plugin.xml. - * - * @return the nature id of this provider - */ - abstract public String getID(); - - /** - * Returns an IFileModificationValidator for pre-checking operations - * that modify the contents of files. - * Returns null if the provider does not wish to participate in - * file modification validation. - * - * @see org.eclipse.core.resources.IFileModificationValidator - */ - - public IFileModificationValidator getFileModificationValidator() { - return null; - } - - /** - * Returns an IMoveDeleteHook for handling moves and deletes - * that occur withing projects managed by the provider. This allows providers - * to control how moves and deletes occur and includes the ability to prevent them. - *

- * Returning null signals that the default move and delete behavior is desired. - * - * @see org.eclipse.core.resources.team.IMoveDeleteHook - */ - public IMoveDeleteHook getMoveDeleteHook() { - return null; - } - - /** - * Returns a brief description of this provider. The exact details of the - * representation are unspecified and subject to change, but the following - * may be regarded as typical: - * - * "SampleProject:org.eclipse.team.cvs.provider" - * - * @return a string description of this provider - */ - public String toString() { - return Policy.bind("RepositoryProvider.toString", getProject().getName(), getID()); //$NON-NLS-1$ - } - - /** - * Returns all known (registered) RepositoryProvider ids. - * - * @return an array of registered repository provider ids. - */ - final public static String[] getAllProviderTypeIds() { - IProjectNatureDescriptor[] desc = ResourcesPlugin.getWorkspace().getNatureDescriptors(); - Set teamSet = new HashSet(); - - teamSet.addAll(AllProviderTypeIds); // add in all the ones we know via extension point - - //fall back to old method of nature ID to find any for backwards compatibility - for (int i = 0; i < desc.length; i++) { - String[] setIds = desc[i].getNatureSetIds(); - for (int j = 0; j < setIds.length; j++) { - if(setIds[j].equals(TEAM_SETID)) { - teamSet.add(desc[i].getNatureId()); - } - } - } - return (String[]) teamSet.toArray(new String[teamSet.size()]); - } - - /** - * Returns the provider for a given IProject or null if a provider is not associated with - * the project or if the project is closed or does not exist. This method should be called if the caller - * is looking for any repository provider. Otherwise call getProvider(project, id) - * to look for a specific repository provider type. - *

- * @param project the project to query for a provider - * @return the repository provider associated with the project - */ - final public static RepositoryProvider getProvider(IProject project) { - try { - if(project.isAccessible()) { - - //----------------------------- - //First, look for the session property - RepositoryProvider provider = lookupProviderProp(project); - if(provider != null) - return provider; - - // ----------------------------- - //Next, check if it has the ID as a persistent property, if yes then instantiate provider - String id = project.getPersistentProperty(PROVIDER_PROP_KEY); - if(id != null) - return mapExistingProvider(project, id); - - //Couldn't find using new method, fall back to lookup using natures for backwards compatibility - //----------------------------- - IProjectDescription projectDesc = project.getDescription(); - String[] natureIds = projectDesc.getNatureIds(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - // for every nature id on this project, find it's natures sets and check if it is - // in the team set. - for (int i = 0; i < natureIds.length; i++) { - IProjectNatureDescriptor desc = workspace.getNatureDescriptor(natureIds[i]); - // The descriptor can be null if the nature doesn't exist - if (desc != null) { - String[] setIds = desc.getNatureSetIds(); - for (int j = 0; j < setIds.length; j++) { - if(setIds[j].equals(TEAM_SETID)) { - return getProvider(project, natureIds[i]); - } - } - } - } - } - } catch(CoreException e) { - if (!isAcceptableException(e)) { - TeamPlugin.log(e); - } - } - return null; - } - - /* - * Return whether the given exception is acceptable during a getProvider(). - * If the exception is acceptable, it is assumed that there is no provider - * on the project. - */ - private static boolean isAcceptableException(CoreException e) { - return e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND; - } - - /** - * Returns a provider of type with the given id if associated with the given project - * or null if the project is not associated with a provider of that type - * or the nature id is that of a non-team repository provider nature. - * - * @param project the project to query for a provider - * @param id the repository provider id - * @return the repository provider - */ - final public static RepositoryProvider getProvider(IProject project, String id) { - try { - if(project.isAccessible()) { - // Look for an existing provider first to avoid accessing persistant properties - RepositoryProvider provider = lookupProviderProp(project); //throws core, we will reuse the catching already here - if(provider != null) { - if (provider.getID().equals(id)) { - return provider; - } else { - return null; - } - } - // There isn't one so check the persistant property - String existingID = project.getPersistentProperty(PROVIDER_PROP_KEY); - if(id.equals(existingID)) { - // The ids are equal so instantiate and return - RepositoryProvider newProvider = mapExistingProvider(project, id); - if (newProvider!= null && newProvider.getID().equals(id)) { - return newProvider; - } else { - // The id changed before we could create the desired provider - return null; - } - } - - //couldn't find using new method, fall back to lookup using natures for backwards compatibility - //----------------------------- - - // if the nature id given is not in the team set then return - // null. - IProjectNatureDescriptor desc = ResourcesPlugin.getWorkspace().getNatureDescriptor(id); - if(desc == null) //for backwards compat., may not have any nature by that ID - return null; - - String[] setIds = desc.getNatureSetIds(); - for (int i = 0; i < setIds.length; i++) { - if(setIds[i].equals(TEAM_SETID)) { - return (RepositoryProvider)project.getNature(id); - } - } - } - } catch(CoreException e) { - if (!isAcceptableException(e)) { - TeamPlugin.log(e); - } - } - return null; - } - - /** - * Returns whether the given project is shared or not. This is a lightweight - * method in that it will not instantiate a provider instance (as - * getProvider would) if one is not already instantiated. - * - * Note that IProject.touch() generates a project description delta. This, in combination - * with isShared() can be used to be notified of sharing/unsharing of projects. - * - * @param project the project being tested. - * @return boolean - * - * @see #getProvider(IProject) - * - * @since 2.1 - */ - public static boolean isShared(IProject project) { - if (!project.isAccessible()) return false; - try { - if (lookupProviderProp(project) != null) return true; - return project.getPersistentProperty(PROVIDER_PROP_KEY) != null; - } catch (CoreException e) { - TeamPlugin.log(e); - return false; - } - } - - /* - * @see IProjectNature#getProject() - */ - public IProject getProject() { - return project; - } - - /* - * @see IProjectNature#setProject(IProject) - */ - public void setProject(IProject project) { - this.project = project; - } - - private static List initializeAllProviderTypes() { - List allIDs = new ArrayList(); - - TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin != null) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - allIDs.add(extensionId); - } - } - } - } - return allIDs; - } - - private static RepositoryProvider newProvider(String id) { - TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin != null) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - if (extensionId != null && extensionId.equals(id)) { - try { - return (RepositoryProvider) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ - } catch (CoreException e) { - TeamPlugin.log(e); - } catch (ClassCastException e) { - String className = configElements[j].getAttribute("class"); //$NON-NLS-1$ - TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoryProvider.invalidClass", id, className), e); //$NON-NLS-1$ - } - return null; - } - } - } - } - } - return null; - } - - /** - * Method validateCreateLink is invoked by the Platform Core TeamHook when a - * linked resource is about to be added to the provider's project. It should - * not be called by other clients and it should not need to be overridden by - * subclasses (although it is possible to do so in special cases). - * Subclasses can indicate that they support linked resources by overridding - * the canHandleLinkedResources() method. - * - * @param resource see org.eclipse.core.resources.team.TeamHook - * @param updateFlags see org.eclipse.core.resources.team.TeamHook - * @param location see org.eclipse.core.resources.team.TeamHook - * @return IStatus see org.eclipse.core.resources.team.TeamHook - * - * @see RepositoryProvider#canHandleLinkedResources() - * - * @since 2.1 - */ - public IStatus validateCreateLink(IResource resource, int updateFlags, IPath location) { - if (canHandleLinkedResources()) { - return Team.OK_STATUS; - } else { - return new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.LINKING_NOT_ALLOWED, Policy.bind("RepositoryProvider.linkedResourcesNotSupported", getProject().getName(), getID()), null); //$NON-NLS-1$ - } - } - - /** - * Method canHandleLinkedResources should be overridden by subclasses who - * support linked resources. At a minimum, supporting linked resources - * requires changes to the move/delete hook - * (see org.eclipe.core.resources.team.IMoveDeleteHook). This method is - * called after the RepositoryProvider is instantiated but before - * setProject() is invoked so it will not have access to any - * state determined from the setProject() method. - * @return boolean - * - * @see org.eclipse.core.resources.team.IMoveDeleteHook - * - * @since 2.1 - */ - public boolean canHandleLinkedResources() { - return false; - } - - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /** - * Return the resource rule factory for this provider. This factory - * will be used to determine the scheduling rules that are to be obtained - * when performing various resource operations (e.g. move, copy, delete, etc.) - * on the resources in the project the provider is mapped to. - *

- * By default, the factory returned by this method is pessimistic and - * obtains the workspace lock for all operations that could result in a - * callback to the provider (either through the IMoveDeleteHook - * or IFileModificationValidator). This is done to ensure that - * older providers are not broken. However, providers should override this - * method and provide a subclass of {@link org.eclipse.core.resources.team.ResourceRuleFactory} - * that provides rules of a more optimistic granularity (e.g. project - * or lower). - * @return the rule factory for this provider - * @since 3.0 - * @see org.eclipse.core.resources.team.ResourceRuleFactory - */ - public IResourceRuleFactory getRuleFactory() { - return new PessimisticResourceRuleFactory(); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java deleted file mode 100644 index 2856ca521..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.internal.core.DefaultProjectSetCapability; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * This class represents provisional API. A provider is not required to implement this API. - * Implementers, and those who reference it, do so with the awareness that this class may be - * removed or substantially changed at future times without warning. - *

- * This class represents things you can ask/do with a type of provider. This - * is in the absence of a project, as opposed to RepositoryProvider which - * requires a concrete project in order to be instantiated. - *

- * A repository provider type class is asscoaited with it's provider ID along with it's - * corresponding repository provider class. To add a - * repository provider type and have it registered with the platform, a client - * must minimally: - *

    - *
  1. extend RepositoryProviderType - *
  2. add the typeClass field to the repository extension in plugin.xml. - * Here is an example extension point definition: - * - * - *
    <extension point="org.eclipse.team.core.repository"> - *
     <repository - *
      class="org.eclipse.myprovider.MyRepositoryProvider" - *
      typeClass="org.eclipse.myprovider.MyRepositoryProviderType" - *
      id="org.eclipse.myprovider.myProviderID"> - *
     </repository> - *
    </extension> - *
    - *

- * - *

- * Once a repository provider type is registered with Team, then you - * can access the singleton instance of the class by invoking RepositoryProviderType.getProviderType(). - *

- * - * @see RepositoryProviderType#getProviderType(String) - * - * @since 2.1 - */ - -public abstract class RepositoryProviderType { - private static Map allProviderTypes = new HashMap(); - - private String id; - - public RepositoryProviderType() { - } - - /** - * Return the RepositoryProviderType for the given provider ID. - * - * @param id the ID of the provider - * @return RepositoryProviderType - * - * @see #getID() - */ - public static RepositoryProviderType getProviderType(String id) { - RepositoryProviderType type = (RepositoryProviderType) allProviderTypes.get(id); - - if(type != null) - return type; - - //If there isn't one in the table, we'll try to create one from the extension point - //Its possible that newProviderType() will return null, but in that case it will have also logged the error so just return the result - return newProviderType(id); - } - - private void setID(String id) { - this.id = id; - } - - private static RepositoryProviderType newProviderType(String id) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - - if (extensionId != null && extensionId.equals(id)) { - try { - RepositoryProviderType providerType; - //Its ok not to have a typeClass extension. In this case, a default instance will be created. - if(configElements[j].getAttribute("typeClass") == null) { //$NON-NLS-1$ - providerType = new DefaultRepositoryProviderType(); - } else { - providerType = (RepositoryProviderType) configElements[j].createExecutableExtension("typeClass"); //$NON-NLS-1$ - } - - providerType.setID(id); - allProviderTypes.put(id, providerType); - return providerType; - } catch (CoreException e) { - TeamPlugin.log(e); - } catch (ClassCastException e) { - String className = configElements[j].getAttribute("typeClass"); //$NON-NLS-1$ - TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoryProviderType.invalidClass", id, className), e); //$NON-NLS-1$ - } - return null; - } - } - } - } - return null; - } - - /** - * Answer the id of this provider type. The id will be the repository - * provider type's id as defined in the provider plugin's plugin.xml. - * - * @return the id of this provider type - */ - public final String getID() { - return this.id; - } - - /** - * Answers an object for serializing and deserializing - * of references to projects. Given a project, it can produce a - * UTF-8 encoded String which can be stored in a file. - * Given this String, it can load a project into the workspace. - * It also provides a mechanism - * by which repository providers can be notified when a project set is created and exported. - * If the provider doesn't wish to provide this - * feature, return null. - *

- * Subclasses should override this method to return the appropriate - * serializer for the associated repository type. - * It is recommended that serializers not have any references to UI classes - * so that they can be used in a headless environment. - *

- * At this time, the default implementation wrappers the IProjectSetSerializer - * interface if one exists, providing backward compatibility with existing code. - * At some time in the future, the IProjectSetSerializer interface will be removed - * and the default implementation will revert to having limited functionality. - * - * @return the project set serializer (or null) - */ - public ProjectSetCapability getProjectSetCapability() { - // Provide backward compatibility with the old IProjectSetSerializer interface - IProjectSetSerializer oldSerializer = Team.getProjectSetSerializer(getID()); - if (oldSerializer != null) { - ProjectSetCapability capability = new DefaultProjectSetCapability(); - capability.setSerializer(oldSerializer); - return capability; - } - return null; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java deleted file mode 100644 index 74af21766..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ /dev/null @@ -1,601 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import java.io.*; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; -import org.eclipse.team.internal.core.*; - -/** - * The Team class provides a global point of reference for the global ignore set - * and the text/binary registry. - * - * @since 2.0 - */ -public final class Team { - - private static final String PREF_TEAM_IGNORES = "ignore_files"; //$NON-NLS-1$ - private static final String PREF_TEAM_TYPES = "file_types"; //$NON-NLS-1$ - private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ - public static final Status OK_STATUS = new Status(Status.OK, TeamPlugin.ID, Status.OK, Policy.bind("ok"), null); //$NON-NLS-1$ - - // File type constants - public static final int UNKNOWN = 0; - public static final int TEXT = 1; - public static final int BINARY = 2; - - // Keys: file extensions. Values: Integers - private static SortedMap globalTypes, pluginTypes; - - // The ignore list that is read at startup from the persisted file - private static SortedMap globalIgnore, pluginIgnore; - private static StringMatcher[] ignoreMatchers; - - private static class FileTypeInfo implements IFileTypeInfo { - private String extension; - private int type; - - public FileTypeInfo(String extension, int type) { - this.extension = extension; - this.type = type; - } - public String getExtension() { - return extension; - } - public int getType() { - return type; - } - } - - /** - * Return the type of the given IStorage. - * - * Valid return values are: - * Team.TEXT - * Team.BINARY - * Team.UNKNOWN - * - * @param storage the IStorage - * @return whether the given IStorage is TEXT, BINARY, or UNKNOWN - */ - public static int getType(IStorage storage) { - String extension = getFileExtension(storage.getName()); - if (extension == null) return UNKNOWN; - SortedMap table = getFileTypeTable(); - Integer integer = (Integer)table.get(extension); - if (integer == null) return UNKNOWN; - return integer.intValue(); - } - - /** - * Returns whether the given file should be ignored. - * - * This method answers true if the file matches one of the global ignore - * patterns, or if the file is marked as derived. - * - * @param file the file - * @return whether the file should be ignored - */ - public static boolean isIgnoredHint(IResource resource) { - if (resource.isDerived()) return true; - return matchesEnabledIgnore(resource); - } - - /** - * Returns whether the given file should be ignored. - * @deprecated use isIgnoredHint(IResource) instead - */ - public static boolean isIgnoredHint(IFile file) { - if (file.isDerived()) return true; - return matchesEnabledIgnore(file); - } - - private static boolean matchesEnabledIgnore(IResource resource) { - StringMatcher[] matchers = getStringMatchers(); - for (int i = 0; i < matchers.length; i++) { - if (matchers[i].match(resource.getName())) return true; - } - return false; - } - - /** - * Returns whether the given file should be ignored. - * @deprecated use isIgnoredHint instead - */ - public static boolean isIgnored(IFile file) { - return matchesEnabledIgnore(file); - } - - private static IFileTypeInfo[] getFileTypeInfo(SortedMap map) { - List result = new ArrayList(); - Iterator e = map.keySet().iterator(); - while (e.hasNext()) { - String string = (String)e.next(); - int type = ((Integer)map.get(string)).intValue(); - result.add(new FileTypeInfo(string, type)); - } - return (IFileTypeInfo[])result.toArray(new IFileTypeInfo[result.size()]); - } - - /** - * Return all known file types. - * - * @return all known file types - */ - public static IFileTypeInfo[] getAllTypes() { - return getFileTypeInfo(getFileTypeTable()); - } - - /** - * Returns the list of global ignores. - */ - public synchronized static IIgnoreInfo[] getAllIgnores() { - // The ignores are cached and when the preferences change the - // cache is cleared. This makes it faster to lookup without having - // to re-parse the preferences. - if (globalIgnore == null) { - globalIgnore = new TreeMap(); - pluginIgnore = new TreeMap(); - ignoreMatchers = null; - try { - readIgnoreState(); - } catch (TeamException e) { - TeamPlugin.log(IStatus.ERROR, Policy.bind("Team.Error_loading_ignore_state_from_disk_1"), e); //$NON-NLS-1$ - } - initializePluginIgnores(pluginIgnore, globalIgnore); - } - IIgnoreInfo[] result = getIgnoreInfo(globalIgnore); - return result; - } - - private static IIgnoreInfo[] getIgnoreInfo(Map gIgnore) { - IIgnoreInfo[] result = new IIgnoreInfo[gIgnore.size()]; - Iterator e = gIgnore.keySet().iterator(); - int i = 0; - while (e.hasNext() ) { - final String pattern = (String)e.next(); - final boolean enabled = ((Boolean)gIgnore.get(pattern)).booleanValue(); - result[i++] = new IIgnoreInfo() { - private String p = pattern; - private boolean e = enabled; - public String getPattern() { - return p; - } - public boolean getEnabled() { - return e; - } - }; - } - return result; - } - - private synchronized static StringMatcher[] getStringMatchers() { - if (ignoreMatchers==null) { - IIgnoreInfo[] ignorePatterns = getAllIgnores(); - Vector matchers = new Vector(ignorePatterns.length); - for (int i = 0; i < ignorePatterns.length; i++) { - if (ignorePatterns[i].getEnabled()) { - matchers.add(new StringMatcher(ignorePatterns[i].getPattern(), true, false)); - } - } - ignoreMatchers = new StringMatcher[matchers.size()]; - matchers.copyInto(ignoreMatchers); - } - return ignoreMatchers; - } - - private synchronized static SortedMap getFileTypeTable() { - // The types are cached and when the preferences change the - // cache is cleared. This makes it faster to lookup without having - // to re-parse the preferences. - if (globalTypes == null) loadTextState(); - return globalTypes; - } - - /** - * Set the file type for the give extension to the given type. - * - * Valid types are: - * Team.TEXT - * Team.BINARY - * Team.UNKNOWN - * - * @param extension the file extension - * @param type the file type - */ - public static void setAllTypes(String[] extensions, int[] types) { - if (pluginTypes == null) { - loadTextState(); - } - globalTypes = new TreeMap(); - for (int i = 0; i < extensions.length; i++) { - globalTypes.put(extensions[i], new Integer(types[i])); - } - // Now set into preferences - StringBuffer buf = new StringBuffer(); - Iterator e = globalTypes.keySet().iterator(); - while (e.hasNext()) { - String extension = (String)e.next(); - boolean isCustom = (!pluginTypes.containsKey(extension)) || - !((Integer)pluginTypes.get(extension)).equals(globalTypes.get(extension)); - if (isCustom) { - buf.append(extension); - buf.append(PREF_TEAM_SEPARATOR); - Integer type = (Integer)globalTypes.get(extension); - buf.append(type); - buf.append(PREF_TEAM_SEPARATOR); - } - - } - TeamPlugin.getPlugin().getPluginPreferences().setValue(PREF_TEAM_TYPES, buf.toString()); - } - - /** - * Add patterns to the list of global ignores. - */ - public static void setAllIgnores(String[] patterns, boolean[] enabled) { - globalIgnore = new TreeMap(); - ignoreMatchers = null; - for (int i = 0; i < patterns.length; i++) { - globalIgnore.put(patterns[i], new Boolean(enabled[i])); - } - // Now set into preferences - StringBuffer buf = new StringBuffer(); - Iterator e = globalIgnore.keySet().iterator(); - while (e.hasNext()) { - String pattern = (String)e.next(); - boolean isCustom = (!pluginIgnore.containsKey(pattern)) || - !((Boolean)pluginIgnore.get(pattern)).equals(globalIgnore.get(pattern)); - if (isCustom) { - buf.append(pattern); - buf.append(PREF_TEAM_SEPARATOR); - boolean en = ((Boolean)globalIgnore.get(pattern)).booleanValue(); - buf.append(en); - buf.append(PREF_TEAM_SEPARATOR); - } - - } - TeamPlugin.getPlugin().getPluginPreferences().setValue(PREF_TEAM_IGNORES, buf.toString()); - } - - /* - * TEXT - * - * Reads the text patterns currently defined by extensions. - */ - private static void initializePluginPatterns(Map pTypes, Map fTypes) { - TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin != null) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.FILE_TYPES_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String ext = configElements[j].getAttribute("extension"); //$NON-NLS-1$ - if (ext != null) { - String type = configElements[j].getAttribute("type"); //$NON-NLS-1$ - // If the extension doesn't already exist, add it. - if (!fTypes.containsKey(ext)) { - if (type.equals("text")) { //$NON-NLS-1$ - pTypes.put(ext, new Integer(TEXT)); - fTypes.put(ext, new Integer(TEXT)); - } else if (type.equals("binary")) { //$NON-NLS-1$ - fTypes.put(ext, new Integer(BINARY)); - pTypes.put(ext, new Integer(BINARY)); - } - } - } - } - } - } - } - } - - /* - * TEXT - * - * Read the saved file type state from the given input stream. - * - * @param dis the input stream to read the saved state from - * @throws IOException if an I/O problem occurs - */ - private static void readTextState(DataInputStream dis) throws IOException { - int extensionCount = 0; - try { - extensionCount = dis.readInt(); - } catch (EOFException e) { - // Ignore the exception, it will occur if there are no - // patterns stored in the state file. - return; - } - for (int i = 0; i < extensionCount; i++) { - String extension = dis.readUTF(); - int type = dis.readInt(); - globalTypes.put(extension, new Integer(type)); - } - } - - /* - * TEXT - * - * Load the file type registry saved state. This loads the previously saved - * contents, as well as discovering any values contributed by plug-ins. - */ - private static void loadTextState() { - globalTypes = new TreeMap(); - boolean old = loadBackwardCompatibleTextState(); - if (!old) loadTextPreferences(); - pluginTypes = new TreeMap(); - initializePluginPatterns(pluginTypes, globalTypes); - if (old) TeamPlugin.getPlugin().savePluginPreferences(); - } - - private static void loadTextPreferences() { - Preferences pref = TeamPlugin.getPlugin().getPluginPreferences(); - if (!pref.contains(PREF_TEAM_TYPES)) return; - pref.addPropertyChangeListener(new Preferences.IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - // when a property is changed, invalidate our cache so that - // properties will be recalculated. - if(event.getProperty().equals(PREF_TEAM_TYPES)) - globalTypes = null; - } - }); - String prefTypes = pref.getString(PREF_TEAM_TYPES); - StringTokenizer tok = new StringTokenizer(prefTypes, PREF_TEAM_SEPARATOR); - String extension, integer; - try { - while (true) { - extension = tok.nextToken(); - if (extension.length()==0) return; - integer = tok.nextToken(); - globalTypes.put(extension, Integer.valueOf(integer)); - } - } catch (NoSuchElementException e) { - return; - } - - } - /* - * If the workspace is an old 2.0 one, read the old file and delete it - */ - private static boolean loadBackwardCompatibleTextState() { - // File name of the persisted file type information - String STATE_FILE = ".fileTypes"; //$NON-NLS-1$ - IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(STATE_FILE); - File f = pluginStateLocation.toFile(); - if (!f.exists()) return false; - try { - DataInputStream dis = new DataInputStream(new FileInputStream(f)); - try { - readTextState(dis); - } finally { - dis.close(); - } - } catch (IOException ex) { - TeamPlugin.log(Status.ERROR, ex.getMessage(), ex); - return false; - } - f.delete(); - return true; - } - - /* - * IGNORE - * - * Reads the ignores currently defined by extensions. - */ - private static void initializePluginIgnores(SortedMap pIgnore, SortedMap gIgnore) { - TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin != null) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.IGNORE_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String pattern = configElements[j].getAttribute("pattern"); //$NON-NLS-1$ - if (pattern != null) { - String selected = configElements[j].getAttribute("enabled"); //$NON-NLS-1$ - if (selected == null) { - // Check for selected because this used to be the field name - selected = configElements[j].getAttribute("selected"); //$NON-NLS-1$ - } - boolean enabled = selected != null && selected.equalsIgnoreCase("true"); //$NON-NLS-1$ - // if this ignore doesn't already exist, add it to the global list - pIgnore.put(pattern, new Boolean(enabled)); - if (!gIgnore.containsKey(pattern)) { - gIgnore.put(pattern, new Boolean(enabled)); - } - } - } - } - } - } - } - - /* - * IGNORE - * - * Reads global ignore preferences and populates globalIgnore - */ - private static void readIgnoreState() throws TeamException { - if (readBackwardCompatibleIgnoreState()) return; - Preferences pref = TeamPlugin.getPlugin().getPluginPreferences(); - if (!pref.contains(PREF_TEAM_IGNORES)) return; - pref.addPropertyChangeListener(new Preferences.IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - // when a property is changed, invalidate our cache so that - // properties will be recalculated. - if(event.getProperty().equals(PREF_TEAM_IGNORES)) - globalIgnore = null; - } - }); - String prefIgnores = pref.getString(PREF_TEAM_IGNORES); - StringTokenizer tok = new StringTokenizer(prefIgnores, PREF_TEAM_SEPARATOR); - String pattern, enabled; - try { - while (true) { - pattern = tok.nextToken(); - if (pattern.length()==0) return; - enabled = tok.nextToken(); - globalIgnore.put(pattern, new Boolean(enabled)); - } - } catch (NoSuchElementException e) { - return; - } - } - - /* - * For backward compatibility, we still look at if we have .globalIgnores - */ - private static boolean readBackwardCompatibleIgnoreState() throws TeamException { - String GLOBALIGNORE_FILE = ".globalIgnores"; //$NON-NLS-1$ - IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(GLOBALIGNORE_FILE); - File f = pluginStateLocation.toFile(); - if (!f.exists()) return false; - try { - DataInputStream dis = new DataInputStream(new FileInputStream(f)); - try { - int ignoreCount = 0; - try { - ignoreCount = dis.readInt(); - } catch (EOFException e) { - // Ignore the exception, it will occur if there are no ignore - // patterns stored in the provider state file. - return false; - } - for (int i = 0; i < ignoreCount; i++) { - String pattern = dis.readUTF(); - boolean enabled = dis.readBoolean(); - globalIgnore.put(pattern, new Boolean(enabled)); - } - } finally { - dis.close(); - } - f.delete(); - } catch (FileNotFoundException e) { - // not a fatal error, there just happens not to be any state to read - } catch (IOException ex) { - throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, 0, Policy.bind("Team.readError"), ex)); //$NON-NLS-1$ - } - return true; - } - /** - * Initialize the registry, restoring its state. - * - * This method is called by the plug-in upon startup, clients should not call this method - */ - public static void startup() { - // Register a delta listener that will tell the provider about a project move - ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta[] projectDeltas = event.getDelta().getAffectedChildren(); - for (int i = 0; i < projectDeltas.length; i++) { - IResourceDelta delta = projectDeltas[i]; - IResource resource = delta.getResource(); - // Only consider project additions that are moves - if (delta.getKind() != IResourceDelta.ADDED) continue; - if ((delta.getFlags() & IResourceDelta.MOVED_FROM) == 0) continue; - // Only consider projects that have a provider - if (!RepositoryProvider.isShared(resource.getProject())) continue; - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject()); - if (provider == null) continue; - // Only consider providers whose project is not mapped properly already - if (provider.getProject().equals(resource.getProject())) continue; - // Tell the provider about it's new project - provider.setProject(resource.getProject()); - } - } - }, IResourceChangeEvent.POST_CHANGE); - } - - /** - * Shut down the registry, persisting its state. - * - * This method is called by the plug-in upon shutdown, clients should not call this method - */ - public static void shutdown() { - TeamPlugin.getPlugin().savePluginPreferences(); - } - /** - * @deprecated - * Use {@link org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()} - * to obtain an instance of {@link ProjectSetCapability} instead. - */ - public static IProjectSetSerializer getProjectSetSerializer(String id) { - TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin != null) { - IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(TeamPlugin.PROJECT_SET_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - if (extensionId != null && extensionId.equals(id)) { - try { - return (IProjectSetSerializer)configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ - } catch (CoreException e) { - TeamPlugin.log(e); - return null; - } - } - } - } - } - } - return null; - } - - private static String getFileExtension(String name) { - if (name == null) return null; - int index = name.lastIndexOf('.'); - if (index == -1) - return null; - if (index == (name.length() - 1)) - return ""; //$NON-NLS-1$ - return name.substring(index + 1); - } - - /** - * Return the default ignore infos - * (i.e. those that are specified in - * plugin manifests). - * @return the default ignore infos. - * @since 3.0 - */ - public static IIgnoreInfo[] getDefaultIgnores() { - SortedMap gIgnore = new TreeMap(); - SortedMap pIgnore = new TreeMap(); - initializePluginIgnores(pIgnore, gIgnore); - return getIgnoreInfo(gIgnore); - } - - /** - * Return the default file type bindings - * (i.e. those that are specified in - * plugin manifests). - * @return the default file type bindings - * @since 3.0 - */ - public static IFileTypeInfo[] getDefaultTypes() { - SortedMap gTypes = new TreeMap(); - SortedMap pTypes = new TreeMap(); - initializePluginPatterns(pTypes, gTypes); - return getFileTypeInfo(gTypes); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java deleted file mode 100644 index 60f40b197..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * This exception is thrown by the team provider API. It represents a failure in an API call. - * Since some API calls take multiple arguments, the exception is capable of returning multiple - * statuses. The API definition determinies if the exception represents a single or multiple status - * response; this can also be tested on the exception instance itself. - *

- * To determine the exact cause of the failure the caller should look at each status in detail. - *

- * @since 2.0 - */ -public class TeamException extends CoreException { - - // Field required to avoid compiler warning - private static final long serialVersionUID = 1L; - - // The operation completed successfully. - public static final int OK = 0; - - // The operation failed because the resource is not checked-in. - public static final int NOT_CHECKED_IN = -1; - - // The operation failed because the resource is not checked-out. - public static final int NOT_CHECKED_OUT = -2; - - // The corresponding remote resource no longer exists or was never created. - public static final int NO_REMOTE_RESOURCE = -3; - - // The provider suffered an IO failure, the operation may be retried. - public static final int IO_FAILED = -4; - - // The user is not authorized to execute the attempted operation. - public static final int NOT_AUTHORIZED = -5; - - // The provider was unable to complete the operation for an unspecified reason. - public static final int UNABLE = -6; - - // The operation cannot be performed due to a conflict with other work. - public static final int CONFLICT = -7; - - /** - * Create a TeamException which contains the given status object. - * @param status the status for this exception - */ - public TeamException(IStatus status) { - super(status); - } - - /** - * Create a TeamException with an - * error status that contains the given message and - * throwable. - * @param message the message for the exception - * @param e an associated exception - * @since 3.0 - */ - public TeamException(String message, Throwable e) { - super(new Status(IStatus.ERROR, TeamPlugin.ID, 0, message, e)); - } - - /** - * Create a TeamException with an - * error status that contains the given message. - * @param message the message for the exception - */ - public TeamException(String message) { - this(message, null); - } - - /** - * Create a TeamException that wraps the given CoreException - * @param e a CoreException - * @since 3.0 - */ - protected TeamException(CoreException e) { - super(asStatus(e)); - } - - private static Status asStatus(CoreException e) { - IStatus status = e.getStatus(); - return new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), e); - } - - /** - * Return a TeamException for the given exception. - * @param e an exception - * @return a TeamException for the given exception - * @since 3.0 - */ - public static TeamException asTeamException(CoreException e) { - if (e instanceof TeamException) { - return (TeamException)e; - } - return new TeamException(e); - } - - /** - * Return a TeamException for the given exception. - * @param e an exception - * @return a TeamException for the given exception - * @since 3.0 - */ - public static TeamException asTeamException(InvocationTargetException e) { - Throwable target = e.getTargetException(); - if (target instanceof TeamException) { - return (TeamException) target; - } - return new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, UNABLE, target.getMessage() != null ? target.getMessage() : "", target)); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamStatus.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamStatus.java deleted file mode 100644 index fe03d189b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamStatus.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.team.core; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Status; - -/** - * Status that is returned from some Team operations or is the payload of - * some TeamExceptions. - * - * @since 3.0 - */ -public class TeamStatus extends Status implements ITeamStatus { - - private IResource resource; - - /** - * Create a new status object. - * @param severity the severity; one of OK, - * ERROR, INFO, or WARNING - * @param pluginId the unique identifier of the relevant plug-in - * @param code the plug-in-specific status code, or OK - * @param message a human-readable message, localized to the - * current locale - * @param exception a low-level exception, or null if not - * applicable - * @param resource the resource asociated with the exception - */ - public TeamStatus(int severity, String pluginId, int code, String message, Throwable exception, IResource resource) { - super(severity, pluginId, code, message, exception); - if (resource == null) { - this.resource = ResourcesPlugin.getWorkspace().getRoot(); - } else { - this.resource = resource; - } - } - - /** - * Return the resource associated with this status. - * @return Returns the resource. - */ - public IResource getResource() { - return resource; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/package.html b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/package.html deleted file mode 100644 index 998490f0d..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - Package-level Javadoc - - -Application programming interfaces for defining and working with repository providers. -

-Package Specification

-This package specifies the API for defining repository providers. A repository -provider supports the sharing of projects in the local Eclipse workspace -with remote locations managed by a particular type of repository system. -Additional facilites included in this API exist for the mapping and unmapping of a -repository provider to a project, the deifnition of a project set serializer for -sharing workspace setup, and the management of global ignore patterns and content type -determination for files. - - \ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ActiveChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ActiveChangeSet.java deleted file mode 100644 index 6c44c292f..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ActiveChangeSet.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.core.TeamPlugin; -import org.osgi.service.prefs.Preferences; - -/** - * An active change set represents a set of local resource changes - * that are grouped together as a single logical change. - * @since 3.1 - */ -public class ActiveChangeSet extends ChangeSet { - - private static final String CTX_TITLE = "title"; //$NON-NLS-1$ - private static final String CTX_COMMENT = "comment"; //$NON-NLS-1$ - private static final String CTX_RESOURCES = "resources"; //$NON-NLS-1$ - - private String comment; - private final SubscriberChangeSetCollector manager; - - /** - * Create a change set with the given title - * @param manager the manager that owns this set - * @param title the title of the set - */ - public ActiveChangeSet(SubscriberChangeSetCollector manager, String title) { - super(title); - this.manager = manager; - } - - /** - * Get the title of the change set. The title is used - * as the comment when the set is checking in if no comment - * has been explicitly set using setComment. - * @return the title of the set - */ - public String getTitle() { - return getName(); - } - - /** - * Set the title of the set. The title is used - * as the comment when the set is committed if no comment - * has been explicitly set using setComment. - * @param title the title of the set - */ - public void setTitle(String title) { - setName(title); - getManager().fireNameChangedEvent(this); - } - - /** - * Get the comment of this change set. If the comment - * as never been set, the title is returned as the comment - * @return the comment to be used when the set is committed - */ - public String getComment() { - if (comment == null) { - return getTitle(); - } - return comment; - } - - /** - * Set the comment to be used when the change set is committed. - * If null is passed, the title of the set - * will be used as the comment. - * @param comment the comment for the set or null - * if the title should be the comment - */ - public void setComment(String comment) { - if (comment != null && comment.equals(getTitle())) { - this.comment = null; - } else { - this.comment = comment; - } - } - - /* - * Override inherited method to only include outgoing changes - */ - protected boolean isValidChange(SyncInfo info) { - return getManager().isModified(info); - } - - private void addResource(IResource resource) throws TeamException { - Subscriber subscriber = getManager().getSubscriber(); - SyncInfo info = subscriber.getSyncInfo(resource); - if (info != null) { - add(info); - } - } - - private SubscriberChangeSetCollector getManager() { - return manager; - } - - /** - * Return whether the set has a comment that differs from the title. - * @return whether the set has a comment that differs from the title - */ - public boolean hasComment() { - return comment != null; - } - - public void save(Preferences prefs) { - prefs.put(CTX_TITLE, getTitle()); - if (comment != null) { - prefs.put(CTX_COMMENT, comment); - } - if (!isEmpty()) { - StringBuffer buffer = new StringBuffer(); - IResource[] resources = getResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - buffer.append(resource.getFullPath().toString()); - buffer.append('\n'); - } - prefs.put(CTX_RESOURCES, buffer.toString()); - } - } - - public void init(Preferences prefs) { - setName(prefs.get(CTX_TITLE, "")); //$NON-NLS-1$ - comment = prefs.get(CTX_COMMENT, null); - String resourcePaths = prefs.get(CTX_RESOURCES, null); - if (resourcePaths != null) { - SyncInfoTree syncInfoSet = getSyncInfoSet(); - try { - syncInfoSet.beginInput(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - StringTokenizer tokenizer = new StringTokenizer(resourcePaths, "\n"); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String next = tokenizer.nextToken(); - if (next.trim().length() > 0) { - IResource resource = getResource(root, next); - try { - // Only include the resource if it is out-of-sync - if (resource != null && manager.getSubscriber().getSyncInfo(resource) != null) { - try { - addResource(resource); - } catch (TeamException e) { - TeamPlugin.log(e); - } - } - } catch (TeamException e) { - // Log and continue - TeamPlugin.log(e); - } - } - } - } finally { - syncInfoSet.endInput(null); - } - } - } - - private IResource getResource(IWorkspaceRoot root, String next) { - IResource resource = root.findMember(next); - if (resource == null) { - // May be an outgoing deletion - Path path = new Path(null, next); - if (next.charAt(next.length()-1) == Path.SEPARATOR) { - if (path.segmentCount() == 1) { - // resource is a project - resource = root.getProject(path.lastSegment()); - } else { - // resource is a folder - resource = root.getFolder(path); - } - } else { - // resource is a file - resource = root.getFile(path); - } - } - return resource; - } - - /** - * Add the resources to the change set if they are outgoing changes. - * @param resources the resouces to add. - * @throws TeamException - */ - public void add(IResource[] resources) throws TeamException { - List toAdd = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - SyncInfo info = manager.getSyncInfo(resource); - if (info != null) { - toAdd.add(info); - } - } - if (!toAdd.isEmpty()) { - add((SyncInfo[]) toAdd.toArray(new SyncInfo[toAdd.size()])); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSet.java deleted file mode 100644 index a5dbb4ebf..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSet.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoTree; - -/** - * A change set represents a set of changes that are logically - * grouped together as a single change. The changes are - * represented usign a set of SyncInfo. - * - * @since 3.1 - */ -public abstract class ChangeSet { - - private String name; - - private final SyncInfoTree set = new SyncInfoTree(); - - /** - * Create a change set with no name. Subclasses - * that create a change set in this manner should - * provide a name before the set is used by other clients. - */ - protected ChangeSet() { - super(); - } - - /** - * Create a change set with the given name. - */ - public ChangeSet(String name) { - this.name = name; - } - - /** - * Return the SyncInfoSet that contains the resources that belong to this change set. - * @return the SyncInfoSet that contains the resources that belong to this change set - */ - public SyncInfoTree getSyncInfoSet() { - return set; - } - - /** - * Return the resources that are contained in this set. - * @return the resources that are contained in this set - */ - public IResource[] getResources() { - return set.getResources(); - } - - /** - * Return whether the set contains any files. - * @return whether the set contains any files - */ - public boolean isEmpty() { - return set.isEmpty(); - } - - /** - * Return true if the given file is included in this set. - * @param local a ocal file - * @return true if the given file is included in this set - */ - public boolean contains(IResource local) { - return set.getSyncInfo(local) != null; - } - - /** - * Add the resource to this set if it is modified - * w.r.t. the subscriber. - * @param resource - * @throws TeamException - */ - public void add(SyncInfo info) { - if (isValidChange(info)) { - set.add(info); - } - } - - /** - * Return whether the given sync info is a valid change - * and can be included in this set. This method is used - * by the add method to filter set additions. - * @param info a sync info - * @return whether the sync info is a valid member of this set - */ - protected boolean isValidChange(SyncInfo info) { - return (info != null); - } - - /** - * Add the resources to this set if they are modified - * w.r.t. the subscriber. - * @param resources the resources to be added. - * @throws TeamException - */ - public void add(SyncInfo[] infos) { - try { - set.beginInput(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - add(info); - } - } finally { - set.endInput(null); - } - } - - /** - * Remove the resource from the set. - * @param resource the resource to be removed - */ - public void remove(IResource resource) { - if (contains(resource)) { - set.remove(resource); - } - } - - /** - * Remove the resources from the set. - * @param resources the resources to be removed - */ - public void remove(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - remove(resource); - } - } - - /** - * Remove the resource and it's descendants to the given depth. - * @param resource the resource to be removed - * @param depth the depth of the removal (one of - * IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE) - */ - public void rootRemoved(IResource resource, int depth) { - SyncInfo[] infos = set.getSyncInfos(resource, depth); - if (infos.length > 0) { - IResource[] resources = new IResource[infos.length]; - for (int i = 0; i < resources.length; i++) { - resources[i] = infos[i].getLocal(); - } - set.removeAll(resources); - } - } - - /** - * Return a comment describing the change. - * @return a comment describing the change - */ - public abstract String getComment(); - - /** - * Return the name assigned to this set. The name should be - * unique. - * @return the name assigned to this set - */ - public String getName() { - return name; - } - - /** - * Set the name of the change set. The name of a change - * set can be changed but it is up to subclass to notify - * any interested partied of the name change. - * @param name the new name for the set - */ - protected void setName(String name) { - this.name = name; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSetCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSetCollector.java deleted file mode 100644 index aeeaef4d8..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ChangeSetCollector.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; - -import java.util.*; - -import org.eclipse.core.internal.runtime.ListenerList; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; -import org.eclipse.team.core.synchronize.SyncInfoSet; - -/** - * This class defines the common aspects of collecting a set of change - * sets, including event notification. - * - * @since 3.1 - */ -public abstract class ChangeSetCollector { - - private ListenerList listeners = new ListenerList(); - private Set sets = new HashSet(); - - private Object[] getListeners() { - return listeners.getListeners(); - } - - /** - * Method that can be invoked by subclasses when the name of - * a managed change set changes. - * @param set the set whose title has changed - */ - protected void fireNameChangedEvent(final ChangeSet set) { - if (contains(set)) { - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - public void run() throws Exception { - listener.nameChanged(set); - } - }); - } - } - } - - /** - * Method which allows subclasses to notify listeners that the default - * set has changed. - * @param oldSet the previous default - * @param defaultSet the new default - */ - protected void fireDefaultChangedEvent(final ChangeSet oldSet, final ChangeSet defaultSet) { - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - public void run() throws Exception { - listener.defaultSetChanged(oldSet, defaultSet); - } - }); - } - } - - /** - * Add the set to the list of active sets. - * @param set the set to be added - */ - public void add(final ChangeSet set) { - if (!contains(set)) { - sets.add(set); - set.getSyncInfoSet().addSyncSetChangedListener(getChangeSetChangeListener()); - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - public void run() throws Exception { - listener.setAdded(set); - } - }); - } - } - } - - /** - * Remove the set from the list of active sets. - * @param set the set to be removed - */ - public void remove(final ChangeSet set) { - if (contains(set)) { - set.getSyncInfoSet().removeSyncSetChangedListener(getChangeSetChangeListener()); - sets.remove(set); - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - public void run() throws Exception { - listener.setRemoved(set); - } - }); - } - } - } - - /** - * Return the change listener that will be registered with each - * SyncInfoSet associated with the ChangeSets - * added to this collector. - * @return the change listener that will be registered with each - * SyncInfoSet associated with the ChangeSets - * added to this collector - */ - protected abstract ISyncInfoSetChangeListener getChangeSetChangeListener(); - - /** - * Return whether the manager contains the given commit set - * @param set the commit set being tested - * @return whether the set is contained in the manager's list of active sets - */ - public boolean contains(ChangeSet set) { - return sets.contains(set); - } - - /** - * Add the listener to the set of registered listeners. - * @param listener the listener to be added - */ - public void addListener(IChangeSetChangeListener listener) { - listeners.add(listener); - } - - /** - * Remove the listener from the set of registered listeners. - * @param listener the listener to remove - */ - public void removeListener(IChangeSetChangeListener listener) { - listeners.remove(listener); - } - - /** - * Return the list of active commit sets. - * @return the list of active commit sets - */ - public ChangeSet[] getSets() { - return (ChangeSet[]) sets.toArray(new ChangeSet[sets.size()]); - } - - /** - * Dispose of any resources maintained by the manager - */ - public void dispose() { - // Nothing to do - } - - /** - * @param changeSet - * @param allAffectedResources - */ - protected void fireResourcesChangedEvent(final ChangeSet changeSet, final IResource[] allAffectedResources) { - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - public void run() throws Exception { - listener.resourcesChanged(changeSet, allAffectedResources); - } - }); - } - } - - /** - * Return the Change Set whose sync info set is the - * one given. - * @param set a sync info set - * @return the change set for the given sync info set - */ - protected ChangeSet getChangeSet(SyncInfoSet set) { - for (Iterator iter = sets.iterator(); iter.hasNext();) { - ChangeSet changeSet = (ChangeSet) iter.next(); - if (changeSet.getSyncInfoSet() == set) { - return changeSet; - } - } - return null; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/CheckedInChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/CheckedInChangeSet.java deleted file mode 100644 index dc59a4f03..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/CheckedInChangeSet.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.team.core.subscribers; - -import java.util.Date; - -/** - * A checked-in change set represents a group of resource - * changes that were previously checked into a repository - * as a single logical change. - *

- * A previously checked-in set of changes may not apply directly - * to the local versions of the resources involved. However, - * a SyncInfo is still used to reprsent each change. - * The base and remote slots of the SyncInfo identify - * the state before and after the resources were checked-in. - * @since 3.1 - */ -public abstract class CheckedInChangeSet extends ChangeSet { - - public abstract String getAuthor(); - - public abstract Date getDate(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/IChangeSetChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/IChangeSetChangeListener.java deleted file mode 100644 index 090fc84ea..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/IChangeSetChangeListener.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.team.core.subscribers; - -import org.eclipse.core.resources.IResource; - - -/** - * Interface for registering change set change listeners with - * the change set manager. - */ -public interface IChangeSetChangeListener { - - /** - * The given set has been added to the set manager. - * @param set the added set - */ - void setAdded(ChangeSet set); - - /** - * The default change set has change to be the given set. - * All new modifications will be placed in the default - * set. - * @param set the default set - */ - void defaultSetChanged(ChangeSet previousDefault, ChangeSet set); - - /** - * The given set has been removed from the set manager. - * @param set the removed set - */ - void setRemoved(ChangeSet set); - - /** - * The title of the given set has changed. - * @param set the set whose title changed - */ - void nameChanged(ChangeSet set); - - /** - * The state of the given resources have change with respect to the - * given set. This means that the resource have either been added - * or removed from the set. Callers can use the resources contained - * in the set to determine if each resource is an addition or removal. - * @param set the set that has changed - * @param resources the resources whose containment state has changed w.r.t the set - */ - void resourcesChanged(ChangeSet set, IResource[] resources); - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeEvent.java deleted file mode 100644 index 1961991c7..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; -import org.eclipse.core.resources.IResource; - -/** - * A change event that describes a change in a resource - * that is or was supervised by a subscriber. - *

- * Clients are not intented to implement. Instead subclass {@link SubscriberChangeEvent}. - *

- * @see ISubscriberChangeListener - * @since 3.0 - */ -public interface ISubscriberChangeEvent { - /*==================================================================== - * Constants defining the kinds of team changes to resources: - *====================================================================*/ - /** - * Delta kind constant indicating that the resource has not been changed in any way - * @see IResourceDelta#getKind - */ - public static final int NO_CHANGE = 0; - /** - * Delta kind constant (bit mask) indicating that the synchronization state of a resource has changed. - * @see #getFlags - */ - public static final int SYNC_CHANGED = 0x1; - /** - * Delta kind constant (bit mask) indicating that a team provider has been configured on the resource. - * @see #getFlags - */ - public static final int ROOT_ADDED = 0x2; - /** - * Delta kind constant (bit mask) indicating that a team provider has been de-configured on the resource. - * @see #getFlags - */ - public static final int ROOT_REMOVED = 0x4; - - /** - * Return the flags that describe the type of change. - * The returned value should be ANDed with the change type - * flags to determine whether the change event is of - * a particular type. For exampe, - *
-	 *   if (event.getFlags() & ISubscriberChangeEvent.SYNC_CHANGED) {
-	 *      // the sync info for the resource has changed
-	 *   }
-	 * 
- * @return the flags that describe the type of change - */ - public abstract int getFlags(); - - /** - * Return the resource whose state with - * respect to the subscriber has changed. - * @return the resource whose state with - * respect to the subscriber has changed - */ - public abstract IResource getResource(); - - /** - * Return the subscriber to which this change event applies. - * @return the subscriber to which this change event applies - */ - public abstract Subscriber getSubscriber(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeListener.java deleted file mode 100644 index ca73c6914..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ISubscriberChangeListener.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.team.core.subscribers; - -import java.util.EventListener; - -/** - * A subscriber change listener is notified of changes to resources - * regarding their subscriber synchronization state. - *

- * Clients may implement this interface. - *

- * @see Subscriber#addListener(ISubscriberChangeListener) - * @since 3.0 - */ -public interface ISubscriberChangeListener extends EventListener{ - - /** - * Notifies this listener that some resources' subscriber properties have - * changed. The changes have already happened. For example, a resource's - * base revision may have changed. The resource tree may or may not be open for modification - * when this method is invoked. - * - * @param deltas detailing the kinds of changes - */ - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas); -} - diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java deleted file mode 100644 index ba54254b2..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java +++ /dev/null @@ -1,334 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.variants.IResourceVariantComparator; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * A Subscriber provides synchronization between local resources and a - * remote location that is used to share those resources. - *

- * When queried for the SyncInfo corresponding to a local resource using - * getSyncInfo(IResource), the subscriber should not contact the server. - * Server round trips should only occur within the refresh - * method of the subscriber. Consequently, - * the implementation of a subscriber must cache enough state information for a remote resource to calculate the - * synchronization state without contacting the server. During a refresh, the latest remote resource state - * information should be fetched and cached. For - * a subscriber that supports three-way compare, the refresh should also fetch the latest base state unless this is - * available by some other means (e.g. for some repository tools, the base state is persisted on disk with the - * local resources). - *

- *

- * After a refresh, the subscriber must notify any listeners of local resources whose corresponding remote resource - * or base resource changed. The subscriber does not need to notify listeners when the state changes due to a local - * modification since local changes are available through the IResource delta mechanism. However, - * the subscriber must - * cache enough information (e.g. the local timestamp of when the file was in-sync with its corresponding remote - * resource) - * to determine if the file represents an outgoing change so that SyncInfo obtained - * after a delta will indicate that the file has an outgoing change. The subscriber must also notify listeners - * when roots and added - * or removed. For example, a subscriber for a repository provider would fire a root added event when a project - * was shared - * with a repository. No event is required when a root is deleted as this is available through the - * IResource delta mechanism. It is up to clients to requery the subscriber - * when the state of a resource changes locally by listening to IResource deltas. - *

- * The remote and base states can also include the state for resources that do not exist locally (i.e outgoing deletions - * or incoming additions). When queried for the members of a local resource, the subscriber should include any children - * for which a remote exists even if the local does not. - *

- * @since 3.0 - */ -abstract public class Subscriber { - - private List listeners = new ArrayList(1); - - /** - * Return the name of this subscription, in a format that is - * suitable for display to an end user. - * - * @return String representing the name of this subscription. - */ - abstract public String getName(); - - /** - * Returns true if this resource is supervised by this - * subscriber. A supervised resource is one for which this subscriber - * maintains the synchronization state. Supervised resources are the only - * resources returned when members(IResource) was invoked with the parent - * of the resource. Returns false in all - * other cases. - * - * @return true if this resource is supervised, and false - * otherwise - */ - abstract public boolean isSupervised(IResource resource) throws TeamException; - - /** - * Returns all non-transient member resources of the given resource. The - * result will include entries for resources that exist either in the - * workspace or are implicated in an incoming change. Returns an empty list - * if the given resource exists neither in the workspace nor in the - * corresponding subscriber location, or if the given resource is transient. - *

- * This is a fast operation; the repository is not contacted. - *

- * @param resource the resource - * @return a list of member resources - */ - abstract public IResource[] members(IResource resource) throws TeamException; - - /** - * Returns the list of root resources this subscriber considers for - * synchronization. A client should call this method first then can safely - * call members to navigate the resources managed by this - * subscriber. - * - * @return a list of resources - */ - abstract public IResource[] roots(); - - /** - * Returns synchronization info for the given resource, or null - * if there is no synchronization info because the subscriber does not apply - * to this resource. - *

- * Note that sync info may be returned for non-existing or for resources - * which have no corresponding remote resource. - *

- * This method will be quick. If synchronization calculation requires content from - * the server it must be cached when the subscriber is refreshed. A client should - * call refresh before calling this method to ensure that the latest information - * is available for computing the sync state. - *

- * @param resource the resource of interest - * @return sync info - */ - abstract public SyncInfo getSyncInfo(IResource resource) throws TeamException; - - /** - * Returns the comparison criteria that will be used by the sync info - * created by this subscriber. - * - * @return the comparator to use when computing sync states for this - * subscriber. - */ - abstract public IResourceVariantComparator getResourceComparator(); - - /** - * Refreshes the resource hierarchy from the given resources and their - * children (to the specified depth) from the corresponding resources in the - * remote location. Resources are ignored in the following cases: - *
    - *
  • if they do not exist either in the workspace or in the corresponding - * remote location
  • - *
  • if the given resource is not supervised by this subscriber
  • - *
  • if the given resource is a closed project (they are ineligible for - * synchronization)
  • - *

    - * Typical synchronization operations use the statuses computed by this - * method as the basis for determining what to do. It is possible for the - * actual sync status of the resource to have changed since the current - * local sync status was refreshed. Operations typically skip resources with - * stale sync information. The chances of stale information being used can - * be reduced by running this method (where feasible) before doing other - * operations. Note that this will of course affect performance. - *

    - *

    - * The depth parameter controls whether refreshing is performed on just the - * given resource (depth= DEPTH_ZERO), the resource and its - * children (depth= DEPTH_ONE), or recursively to the - * resource and all its descendents (depth= DEPTH_INFINITE). - * Use depth DEPTH_ONE, rather than depth - * DEPTH_ZERO, to ensure that new members of a project or - * folder are detected. - *

    - *

    - * This method might change resources; any changes will be reported in a - * subsequent subscriber resource change event indicating changes to server - * sync status. - *

    - *

    - * This method contacts the server and is therefore long-running; progress - * and cancellation are provided by the given progress monitor. - *

    - * @param resources the resources - * @param depth valid values are DEPTH_ZERO, - * DEPTH_ONE, or DEPTH_INFINITE - * @param monitor progress monitor, or null if progress - * reporting and cancellation are not desired - * @return status with code OK if there were no problems; - * otherwise a description (possibly a multi-status) consisting of - * low-severity warnings or informational messages. - * @exception TeamException if this method fails. Reasons include: - *
      - *
    • The server could not be contacted.
    • - *
    - */ - abstract public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException; - - /** - * Adds a listener to this team subscriber. Has no effect if an identical - * listener is already registered. - *

    - * Team resource change listeners are informed about state changes that - * affect the resources supervised by this subscriber. - *

    - * @param listener a team resource change listener - */ - public void addListener(ISubscriberChangeListener listener) { - synchronized (listeners) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - } - - /** - * Removes a listener previously registered with this team subscriber. Has - * no affect if an identical listener is not registered. - * - * @param listener a team resource change listener - */ - public void removeListener(ISubscriberChangeListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - /** - * Adds all out-of-sync resources (getKind() != IN_SYNC) that occur - * under the given resources to the specified depth. The purpose of this - * method is to provide subscribers a means of optimizing the determination - * of all out-of-sync out-of-sync descendants of a set of resources. - *

    - * If any of the directly provided resources are not supervised by the subscriber, then - * they should be removed from the set. - * If errors occur while determining the sync info for the resources, they should - * be added to the set using addError. - *

    - * @param resources the root of the resource subtrees from which out-of-sync sync info should be collected - * @param depth the depth to which sync info should be collected - * (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param set the sync info set to which out-of-sync resources should be added (or removed). Any errors - * should be added to the set as well. - * @param monitor a progress monitor - */ - public void collectOutOfSync(IResource[] resources, int depth, SyncInfoSet set, IProgressMonitor monitor) { - try { - monitor.beginTask(null, 100 * resources.length); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 100); - subMonitor.beginTask(null, IProgressMonitor.UNKNOWN); - collect(resource, depth, set, subMonitor); - subMonitor.done(); - } - } finally { - monitor.done(); - } - } - - /** - * Fires a team resource change event to all registered listeners Only - * listeners registered at the time this method is called are notified. - * Listener notification makes use of an ISafeRunnable to ensure that - * client exceptions do not effect the notification to other clients. - */ - protected void fireTeamResourceChange(final ISubscriberChangeEvent[] deltas) { - ISubscriberChangeListener[] allListeners; - // Copy the listener list so we're not calling client code while synchronized - synchronized (listeners) { - allListeners = (ISubscriberChangeListener[]) listeners.toArray(new ISubscriberChangeListener[listeners.size()]); - } - // Notify the listeners safely so all will receive notification - for (int i = 0; i < allListeners.length; i++) { - final ISubscriberChangeListener listener = allListeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in - // Platform#run - } - public void run() throws Exception { - listener.subscriberResourceChanged(deltas); - } - }); - } - } - - /* - * Collect the calculated synchronization information for the given resource at the given depth. The - * results are added to the provided list. - */ - private void collect( - IResource resource, - int depth, - SyncInfoSet set, - IProgressMonitor monitor) { - - Policy.checkCanceled(monitor); - - if (resource.getType() != IResource.FILE - && depth != IResource.DEPTH_ZERO) { - try { - IResource[] members = members(resource); - for (int i = 0; i < members.length; i++) { - collect( - members[i], - depth == IResource.DEPTH_INFINITE - ? IResource.DEPTH_INFINITE - : IResource.DEPTH_ZERO, - set, - monitor); - } - } catch (TeamException e) { - set.addError(new TeamStatus(IStatus.ERROR, TeamPlugin.ID, ITeamStatus.SYNC_INFO_SET_ERROR, Policy.bind("SubscriberEventHandler.8", resource.getFullPath().toString(), e.getMessage()), e, resource)); //$NON-NLS-1$ - } - } - - monitor.subTask(Policy.bind("SubscriberEventHandler.2", resource.getFullPath().toString())); //$NON-NLS-1$ - try { - SyncInfo info = getSyncInfo(resource); - if (info == null || info.getKind() == SyncInfo.IN_SYNC) { - // Resource is no longer under the subscriber control. - // This can occur for the resources past as arguments to collectOutOfSync - set.remove(resource); - } else { - set.add(info); - } - } catch (TeamException e) { - set.addError(new TeamStatus( - IStatus.ERROR, TeamPlugin.ID, ITeamStatus.RESOURCE_SYNC_INFO_ERROR, - Policy.bind("SubscriberEventHandler.9", resource.getFullPath().toString(), e.getMessage()), //$NON-NLS-1$ - e, resource)); - } - // Tick the monitor to give the owner a chance to do something - monitor.worked(1); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java deleted file mode 100644 index 2152f7192..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.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.team.core.subscribers; - -import org.eclipse.core.resources.IResource; - -/** - * A concrete implementation of ISubscriberChangeEvent that can - * be used by clients. - * - * @see ISubscriberChangeEvent - * @see Subscriber - * - * @since 3.0 - */ -public class SubscriberChangeEvent implements ISubscriberChangeEvent { - - private Subscriber subscriber; - private int flags; - private IResource resource; - - /** - * Create a cahnge event with the given flags for the given subscriber and resource. - * @param subscriber the subscriber to which the state change applies - * @param flags the flags that describe the change - * @param resource the resource whose state has change - */ - public SubscriberChangeEvent(Subscriber subscriber, int flags, IResource resource) { - this.subscriber = subscriber; - this.flags = flags; - this.resource = resource; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getFlags() - */ - public int getFlags() { - return flags; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getResource() - */ - public IResource getResource() { - return resource; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getSubscriber() - */ - public Subscriber getSubscriber() { - return subscriber; - } - - /** - * Returns an array of deltas for the resources with ISubscriberChangeEvent.SYNC_CHANGED - * as the flag. - * @param resources the resources whose sync info has changed - * @return an array of change events - */ - public static SubscriberChangeEvent[] asSyncChangedDeltas(Subscriber subscriber, IResource[] resources) { - SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[resources.length]; - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - deltas[i] = new SubscriberChangeEvent(subscriber, ISubscriberChangeEvent.SYNC_CHANGED, resource); - } - return deltas; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java deleted file mode 100644 index 8d065bb8c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.subscribers; - -import java.util.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.*; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.*; -import org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -/** - * This class manages the active change sets associated with a subscriber. - */ -public class SubscriberChangeSetCollector extends ChangeSetCollector implements ISyncInfoSetChangeListener { - - private static final String PREF_CHANGE_SETS = "changeSets"; //$NON-NLS-1$ - private static final String CTX_DEFAULT_SET = "defaultSet"; //$NON-NLS-1$ - - private static final int RESOURCE_REMOVAL = 1; - private static final int RESOURCE_CHANGE = 2; - - private ActiveChangeSet defaultSet; - private EventHandler handler; - private ResourceCollector collector; - - /* - * Background event handler for serializing and batching change set changes - */ - private class EventHandler extends BackgroundEventHandler { - - private List dispatchEvents = new ArrayList(); - - protected EventHandler(String jobName, String errorTitle) { - super(jobName, errorTitle); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#processEvent(org.eclipse.team.internal.core.BackgroundEventHandler.Event, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void processEvent(Event event, IProgressMonitor monitor) throws CoreException { - // Handle everything in the dispatch - dispatchEvents.add(event); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#doDispatchEvents(org.eclipse.core.runtime.IProgressMonitor) - */ - protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { - if (dispatchEvents.isEmpty()) { - return false; - } - SyncInfoTree[] locked = null; - try { - locked = beginDispath(); - for (Iterator iter = dispatchEvents.iterator(); iter.hasNext();) { - Event event = (Event) iter.next(); - switch (event.getType()) { - case RESOURCE_REMOVAL: - handleRemove(event.getResource()); - break; - case RESOURCE_CHANGE: - handleChange(event.getResource(), ((ResourceEvent)event).getDepth()); - break; - default: - break; - } - } - } finally { - try { - endDispatch(locked, monitor); - } finally { - dispatchEvents.clear(); - } - } - return true; - } - - /* - * Begin input on all the sets and return the sync sets that were - * locked. If this method throws an exception then the client - * can assume that no sets were locked - */ - private SyncInfoTree[] beginDispath() { - ChangeSet[] sets = getSets(); - List lockedSets = new ArrayList(); - try { - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - SyncInfoTree syncInfoSet = set.getSyncInfoSet(); - lockedSets.add(syncInfoSet); - syncInfoSet.beginInput(); - } - return (SyncInfoTree[]) lockedSets.toArray(new SyncInfoTree[lockedSets.size()]); - } catch (RuntimeException e) { - try { - for (Iterator iter = lockedSets.iterator(); iter.hasNext();) { - SyncInfoTree tree = (SyncInfoTree) iter.next(); - try { - tree.endInput(null); - } catch (Throwable e1) { - // Ignore so that original exception is not masked - } - } - } catch (Throwable e1) { - // Ignore so that original exception is not masked - } - throw e; - } - } - - private void endDispatch(SyncInfoTree[] locked, IProgressMonitor monitor) { - if (locked == null) { - // The begin failed so there's nothing to unlock - return; - } - monitor.beginTask(null, 100 * locked.length); - for (int i = 0; i < locked.length; i++) { - SyncInfoTree tree = locked[i]; - try { - tree.endInput(Policy.subMonitorFor(monitor, 100)); - } catch (RuntimeException e) { - // Don't worry about ending every set if an error occurs. - // Instead, log the error and suggest a restart. - TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.0"), e); //$NON-NLS-1$ - throw e; - } - } - monitor.done(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#queueEvent(org.eclipse.team.internal.core.BackgroundEventHandler.Event, boolean) - */ - protected synchronized void queueEvent(Event event, boolean front) { - // Override to allow access from enclosing class - super.queueEvent(event, front); - } - - /* - * Handle the removal - */ - private void handleRemove(IResource resource) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - // This will remove any descendants from the set and callback to - // resourcesChanged which will batch changes - if (!set.isEmpty()) { - set.rootRemoved(resource, IResource.DEPTH_INFINITE); - if (set.isEmpty()) { - remove(set); - } - } - } - } - - /* - * Handle the change - */ - private void handleChange(IResource resource, int depth) throws TeamException { - SyncInfo syncInfo = getSyncInfo(resource); - if (isModified(syncInfo)) { - ActiveChangeSet[] containingSets = getContainingSets(resource); - if (containingSets.length == 0) { - // Consider for inclusion in the default set - // if the resource is not already a memebr of another set - if (defaultSet != null) { - defaultSet.add(syncInfo); - } - } else { - for (int i = 0; i < containingSets.length; i++) { - ActiveChangeSet set = containingSets[i]; - // Update the sync info in the set - set.getSyncInfoSet().add(syncInfo); - } - } - } else { - removeFromAllSets(resource); - } - if (depth != IResource.DEPTH_ZERO) { - IResource[] members = getSubscriber().members(resource); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - handleChange(member, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE); - } - } - } - - private void removeFromAllSets(IResource resource) { - List toRemove = new ArrayList(); - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.contains(resource)) { - set.remove(resource); - if (set.isEmpty()) { - toRemove.add(set); - } - } - } - for (Iterator iter = toRemove.iterator(); iter.hasNext();) { - ActiveChangeSet set = (ActiveChangeSet) iter.next(); - remove(set); - } - } - - private ActiveChangeSet[] getContainingSets(IResource resource) { - Set result = new HashSet(); - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.contains(resource)) { - result.add(set); - } - } - return (ActiveChangeSet[]) result.toArray(new ActiveChangeSet[result.size()]); - } - } - - private class ResourceCollector extends SubscriberResourceCollector { - - public ResourceCollector(Subscriber subscriber) { - super(subscriber); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#remove(org.eclipse.core.resources.IResource) - */ - protected void remove(IResource resource) { - handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_REMOVAL, IResource.DEPTH_INFINITE), false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#change(org.eclipse.core.resources.IResource, int) - */ - protected void change(IResource resource, int depth) { - handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_CHANGE, depth), false); - } - - } - - public SubscriberChangeSetCollector(Subscriber subscriber) { - collector = new ResourceCollector(subscriber); - load(); - handler = new EventHandler(Policy.bind("SubscriberChangeSetCollector.1", subscriber.getName()), Policy.bind("SubscriberChangeSetCollector.2", subscriber.getName())); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Add the active change set to this collector. - * @param set the active change set being added - */ - public void add(ChangeSet set) { - Assert.isTrue(set instanceof ActiveChangeSet); - if (!contains(set)) { - super.add(set); - handleAddedResources(set, set.getSyncInfoSet().getSyncInfos()); - } - } - - /** - * Return whether the manager allows a resource to - * be in mulitple sets. By default, a resource - * may only be in one set. - * @return whether the manager allows a resource to - * be in mulitple sets. - */ - protected boolean isSingleSetPerResource() { - return true; - } - - /** - * Create a commit set with the given title and files. The created - * set is not added to the control of the commit set manager - * so no events are fired. The set can be added using the - * add method. - * @param title the title of the commit set - * @param files the files contained in the set - * @return the created set - * @throws CVSException - */ - public ActiveChangeSet createSet(String title, SyncInfo[] infos) { - ActiveChangeSet commitSet = new ActiveChangeSet(this, title); - if (infos != null && infos.length > 0) { - commitSet.add(infos); - } - return commitSet; - } - - /** - * Create a change set containing the given files if - * they have been modified locally. - * @param title the title of the commit set - * @param files the files contained in the set - * @return the created set - * @throws TeamException - */ - public ActiveChangeSet createSet(String title, IFile[] files) throws TeamException { - List infos = new ArrayList(); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - SyncInfo info = getSyncInfo(file); - if (info != null) { - infos.add(info); - } - } - return createSet(title, (SyncInfo[]) infos.toArray(new SyncInfo[infos.size()])); - } - - /** - * Make the given set the default set into which all new modifications - * that ae not already in another set go. - * @param set the set which is to become the default set - */ - public void makeDefault(ActiveChangeSet set) { - // The default set must be an active set - if (!contains(set)) { - add(set); - } - ActiveChangeSet oldSet = defaultSet; - defaultSet = set; - fireDefaultChangedEvent(oldSet, defaultSet); - } - - /** - * Retrn the set which is currently the default or - * null if there is no default set. - * @return - */ - public ActiveChangeSet getDefaultSet() { - return defaultSet; - } - /** - * Return whether the given set is the default set into which all - * new modifications will be placed. - * @param set the set to test - * @return whether the set is the default set - */ - public boolean isDefault(ActiveChangeSet set) { - return set == defaultSet; - } - - /** - * Return the sync info for the given resource obtained - * from the subscriber. - * @param resource the resource - * @return the sync info for the resource - * @throws TeamException - */ - protected SyncInfo getSyncInfo(IResource resource) throws TeamException { - Subscriber subscriber = getSubscriber(); - SyncInfo info = subscriber.getSyncInfo(resource); - return info; - } - - /** - * Return the subscriber associated with this collector. - * @return the subscriber associated with this collector - */ - public Subscriber getSubscriber() { - return collector.getSubscriber(); - } - - protected boolean isModified(SyncInfo info) { - if (info != null) { - if (info.getComparator().isThreeWay()) { - int dir = (info.getKind() & SyncInfo.DIRECTION_MASK); - return dir == SyncInfo.OUTGOING || dir == SyncInfo.CONFLICTING; - } else { - return (info.getKind() & SyncInfo.CHANGE_MASK) == SyncInfo.CHANGE; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#dispose() - */ - public void dispose() { - handler.shutdown(); - collector.dispose(); - super.dispose(); - save(); - } - - private void save() { - Preferences prefs = getPreferences(); - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set instanceof ActiveChangeSet && !set.isEmpty()) { - Preferences child = prefs.node(((ActiveChangeSet)set).getTitle()); - ((ActiveChangeSet)set).save(child); - } - } - if (defaultSet != null) { - prefs.put(CTX_DEFAULT_SET, defaultSet.getTitle()); - } - try { - prefs.flush(); - } catch (BackingStoreException e) { - TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.3", getSubscriber().getName()), e); //$NON-NLS-1$ - } - } - - private void load() { - Preferences prefs = getPreferences(); - String defaultSetTitle = prefs.get(CTX_DEFAULT_SET, null); - try { - String[] childNames = prefs.childrenNames(); - for (int i = 0; i < childNames.length; i++) { - String string = childNames[i]; - Preferences childPrefs = prefs.node(string); - ActiveChangeSet set = createSet(string, childPrefs); - if (!set.isEmpty()) { - if (defaultSet == null && defaultSetTitle != null && set.getTitle().equals(defaultSetTitle)) { - defaultSet = set; - } - add(set); - } - } - } catch (BackingStoreException e) { - TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.4", getSubscriber().getName()), e); //$NON-NLS-1$ - } - } - - /** - * Create a change set from the given preferences that were - * previously saved. - * @param childPrefs the previously saved preferences - * @return the created change set - */ - protected ActiveChangeSet createSet(String title, Preferences childPrefs) { - ActiveChangeSet changeSet = new ActiveChangeSet(this, title); - changeSet.init(childPrefs); - return changeSet; - } - - private Preferences getPreferences() { - return getParentPreferences().node(getSubscriberIdentifier()); - } - - private static Preferences getParentPreferences() { - return getTeamPreferences().node(PREF_CHANGE_SETS); - } - - private static Preferences getTeamPreferences() { - IPreferencesService service = Platform.getPreferencesService(); - IEclipsePreferences root = service.getRootNode(); - return root.node(InstanceScope.SCOPE).node(TeamPlugin.getPlugin().getBundle().getSymbolicName()); - } - - /** - * Return the id that will uniquely identify the subscriber accross - * restarts. - * @return - */ - protected String getSubscriberIdentifier() { - return getSubscriber().getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - handleSyncSetChange(set, set.getSyncInfos(), set.getResources()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoChanged(org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - SyncInfoSet set = event.getSet(); - handleSyncSetChange(set, event.getAddedResources(), getAllResources(event)); - } - - private IResource[] getAllResources(ISyncInfoSetChangeEvent event) { - Set allResources = new HashSet(); - SyncInfo[] addedResources = event.getAddedResources(); - for (int i = 0; i < addedResources.length; i++) { - SyncInfo info = addedResources[i]; - allResources.add(info.getLocal()); - } - SyncInfo[] changedResources = event.getChangedResources(); - for (int i = 0; i < changedResources.length; i++) { - SyncInfo info = changedResources[i]; - allResources.add(info.getLocal()); - } - allResources.addAll(Arrays.asList(event.getRemovedResources())); - return (IResource[]) allResources.toArray(new IResource[allResources.size()]); - } - - private void handleAddedResources(ChangeSet set, SyncInfo[] infos) { - if (isSingleSetPerResource()) { - IResource[] resources = new IResource[infos.length]; - for (int i = 0; i < infos.length; i++) { - resources[i] = infos[i].getLocal(); - } - // Remove the added files from any other set that contains them - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet otherSet = sets[i]; - if (otherSet != set) { - otherSet.remove(resources); - } - } - } - } - - private void handleSyncSetChange(SyncInfoSet set, SyncInfo[] addedInfos, IResource[] allAffectedResources) { - ChangeSet changeSet = getChangeSet(set); - if (set.isEmpty() && changeSet != null) { - remove(changeSet); - } - fireResourcesChangedEvent(changeSet, allAffectedResources); - handleAddedResources(changeSet, addedInfos); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetErrors(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - // Nothing to do - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ChangeSetCollector#getChangeSetSyncSetChangeListener() - */ - protected ISyncInfoSetChangeListener getChangeSetChangeListener() { - return this; - } - - /** - * Wait until the collector is done processing any events. - * This method is for testing purposes only. - */ - public void waitUntilDone(IProgressMonitor monitor) { - monitor.worked(1); - // wait for the event handler to process changes. - while(handler.getEventHandlerJob().getState() != Job.NONE) { - monitor.worked(1); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } - Policy.checkCanceled(monitor); - } - monitor.worked(1); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/package.html b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/package.html deleted file mode 100644 index 9066327bb..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/package.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - Package-level Javadoc - - -Application programming interfaces for generating and refreshing -synchronization state. -

    Package Specification

    -

    This package specifies the API for Team subscribers. A Subscriber -provides access to the synchronization state between the local -workspace resources and a set of variants of those resources, whether -it be a code repository or some other type of server (e.g. FTP). A -subscriber is typically associated with only a subset of the resources -in the local workspace, referred to as the set of resources the -subscriber supervises. The supervised local resources have a -corresponding variant state which describes the state of the remote -resources that correspond to the local resources.

    -

    A Subscriber provides:

    -
      -
    • a set of root resources that define the subset of resources in -the workspace that the subscriber supervises (some children of the -roots may not be supervised, as indicated by the isSupervised method).
    • -
    • access to the synchronization state (using SyncInfo) between the -resources it supervises and their corresponding variant resources.
    • -
    • the ability to refresh the the remote state
    • -
    • change notification to registered listeners (of type -ISubscriberChangeListener) when the variant state changes or when roots -are added or removed.
    • -
    -

    Implementing a Subscriber

    -

    An implementation of a subscriber must provide: -

    -
      -
    • a subclass of Subcriber which maintains the synchronization state -between its local resources and their corresponding variants.
    • -
    • an implemenation of org.eclipse.team.core.variants.IResourceVariant which provides access to the -contents and other state of a variant resource that corresponds to a -local resource
    • -
    • an implementation of org.eclipse.team.core.variants.IResourceVariantComparator which is used by -org.eclipse.team.core.synchronize.SyncInfo to determine the synchronization state of a resource.
    • -
    -Optionally, a subscriber may provide a subclass of org.eclipse.team.core.synchronize.SyncInfo in order to -customize the algorithm used to -determine the synchronization state of a resource. - - diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/FastSyncInfoFilter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/FastSyncInfoFilter.java deleted file mode 100644 index 51663c96a..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/FastSyncInfoFilter.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A specialized SyncInfoFilter that does not require a progress monitor. - * This enables these filters to be used when determining menu enablement or other - * operations that must be short running. - * - * @see SyncInfo - * @see SyncInfoSet - * @see SyncInfoFilter - * @since 3.0 - */ -public class FastSyncInfoFilter extends SyncInfoFilter { - - /** - * Selects SyncInfo that match the given change type and direction. - * - * @param direction the change direction (SyncInfo.OUTGOING, - * SyncInfo.INCOMING and SyncInfo.CONFLICTING) that this filter matches - * @param change the change type (SyncInfo.ADDITION, - * SyncInfo.DELETION and SyncInfo.CHANGE) that this filter matches - * @return a FastSyncInfoFilter that selects SyncInfo that match the given - * change type and direction. - */ - public static FastSyncInfoFilter getDirectionAndChangeFilter(int direction, int change) { - return new AndSyncInfoFilter(new FastSyncInfoFilter[]{new SyncInfoDirectionFilter(direction), new SyncInfoChangeTypeFilter(change)}); - } - - /** - * An abstract class which contains a set of FastSyncInfoFilter instances. - * Subclasses must provide the select(SyncInfo) method for determining - * matches. - */ - public static abstract class CompoundSyncInfoFilter extends FastSyncInfoFilter { - /** - * Instance variable which contains all the child filters for ths compound filter. - */ - protected FastSyncInfoFilter[] filters; - /** - * Create a compund filter that contains the provided filters. - * @param filters the child filters - */ - protected CompoundSyncInfoFilter(FastSyncInfoFilter[] filters) { - this.filters = filters; - } - } - - /** - * Selects SyncInfo which match all child filters. - */ - public static class AndSyncInfoFilter extends CompoundSyncInfoFilter { - /** - * Create an AND filter from the given filters - * @param filters the filters to be ANDed - */ - public AndSyncInfoFilter(FastSyncInfoFilter[] filters) { - super(filters); - } - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - for (int i = 0; i < filters.length; i++) { - FastSyncInfoFilter filter = filters[i]; - if (!filter.select(info)) { - return false; - } - } - return true; - } - } - - /** - * Selects SyncInfo instances that are auto-mergable. - */ - public static class AutomergableFilter extends FastSyncInfoFilter { - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - return (info.getKind() & SyncInfo.AUTOMERGE_CONFLICT) != 0; - } - } - - /** - * Selects SyncInfo instances that are pseudo-conflicts. - */ - public static class PseudoConflictFilter extends FastSyncInfoFilter { - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - return info.getKind() != 0 && (info.getKind() & SyncInfo.PSEUDO_CONFLICT) == 0; - } - } - - /** - * Selects SyncInfo that match any of the child filters. - */ - public static class OrSyncInfoFilter extends CompoundSyncInfoFilter { - /** - * Create an OR filter from the given filters - * @param filters the filters to be ORed - */ - public OrSyncInfoFilter(FastSyncInfoFilter[] filters) { - super(filters); - } - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - for (int i = 0; i < filters.length; i++) { - FastSyncInfoFilter filter = filters[i]; - if (filter.select(info)) { - return true; - } - } - return false; - } - } - - /** - * Selects SyncInfo whose change type match those of the filter. - */ - public static class SyncInfoChangeTypeFilter extends FastSyncInfoFilter { - private int[] changeFilters = new int[]{SyncInfo.ADDITION, SyncInfo.DELETION, SyncInfo.CHANGE}; - /** - * Create a filter that will match SyncInfo whose change type - * match those passed as arguments to this constructor. - * @param changeFilters the array of change types (SyncInfo.ADDITION, - * SyncInfo.DELETION and SyncInfo.CHANGE) that this filter match - */ - public SyncInfoChangeTypeFilter(int[] changeFilters) { - this.changeFilters = changeFilters; - } - /** - * Create a filter that will match SyncInfo whose change type - * match that passed as an argument to this constructor. - * @param change the change type (SyncInfo.ADDITION, - * SyncInfo.DELETION and SyncInfo.CHANGE) that this filter matches - */ - public SyncInfoChangeTypeFilter(int change) { - this(new int[]{change}); - } - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - int syncKind = info.getKind(); - for (int i = 0; i < changeFilters.length; i++) { - int filter = changeFilters[i]; - if ((syncKind & SyncInfo.CHANGE_MASK) == filter) - return true; - } - return false; - } - } - - /** - * Selects SyncInfo whose change direction match those of the filter. - */ - public static class SyncInfoDirectionFilter extends FastSyncInfoFilter { - int[] directionFilters = new int[] {SyncInfo.OUTGOING, SyncInfo.INCOMING, SyncInfo.CONFLICTING}; - /** - * Create a filter that will match SyncInfo whose change direction - * match those passed as arguments to this constructor. - * @param directionFilters the array of change directions (SyncInfo.OUTGOING, - * SyncInfo.INCOMING and SyncInfo.CONFLICTING) that this filter match - */ - public SyncInfoDirectionFilter(int[] directionFilters) { - this.directionFilters = directionFilters; - } - /** - * Create a filter that will match SyncInfo whose change direction - * match that passed as arguments to this constructor. - * @param direction the change direction (SyncInfo.OUTGOING, - * SyncInfo.INCOMING and SyncInfo.CONFLICTING) that this filter matches - */ - public SyncInfoDirectionFilter(int direction) { - this(new int[] { direction }); - } - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.FastSyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo) - */ - public boolean select(SyncInfo info) { - int syncKind = info.getKind(); - for (int i = 0; i < directionFilters.length; i++) { - int filter = directionFilters[i]; - if ((syncKind & SyncInfo.DIRECTION_MASK) == filter) - return true; - } - return false; - } - } - - /** - * Return whether the provided SyncInfo matches the filter. The default - * behavior it to include resources whose syncKind is non-zero. - * - * @param info the SyncInfo being tested - * @return true if the SyncInfo matches the filter - */ - public boolean select(SyncInfo info) { - return info.getKind() != 0; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.SyncInfoFilter#select(org.eclipse.team.core.subscribers.SyncInfo, org.eclipse.core.runtime.IProgressMonitor) - */ - public final boolean select(SyncInfo info, IProgressMonitor monitor) { - return select(info); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeEvent.java deleted file mode 100644 index 7e8ac987f..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import org.eclipse.core.resources.IResource; - -/** - * An event generated when a {@link SyncInfoSet} collection is changed. The event contains - * a description of the changes which include added, changed and removed resources. - * In some cases, (e.g. when the change is too complicated to be efficiently described - * using the mechanisms provided by this interface) the event will be a reset. In these - * cases, the client should ignore any other contents of the event and reclaculate - * from scratch any state that is derived from the SyncInfoSet from - * which the event originated. - *

    - * The mix of return types, SyncInfo and IResourceis required as a result of an optimization - * included in {@link SyncInfoSet} collections that doesn't maintain SyncInfo objects - * for in-sync resources. - *

    - * @see SyncInfoSet#addSyncSetChangedListener(ISyncInfoSetChangeListener) - * @see ISyncInfoSetChangeListener - * @since 3.0 - */ -public interface ISyncInfoSetChangeEvent { - - /** - * Returns newly added out-of-sync SyncInfo elements. - * - * @return newly added SyncInfo elements or an empty list if this event - * doesn't contain added resources. - */ - public SyncInfo[] getAddedResources(); - - /** - * Returns changed SyncInfo elements. The returned elements - * are still out-of-sync. - * - * @return changed SyncInfo elements or an empty list if this event - * doesn't contain changes resources. - */ - public SyncInfo[] getChangedResources(); - - /** - * Returns the removed IResource elements for which the set no longer - * contains on out-of-sync SyncInfo. The returned elements - * are all in-sync resources. - * - * @return removed SyncInfo elements or an empty list if this event - * doesn't contain removed resources. - */ - public IResource[] getRemovedResources(); - - /** - * Returns the {@link SyncInfoSet} that generated these events. - * - * @return the {@link SyncInfoSet} that generated these events. - */ - public SyncInfoSet getSet(); - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeListener.java deleted file mode 100644 index 3da2277a1..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoSetChangeListener.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.team.core.synchronize; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.ITeamStatus; - -/** - * Classes which implement this interface provide methods that deal with the - * change events that are generated by a {@link SyncInfoSet}. - *

    - * Implementors of this interface it can - * be added to a sync info set using the addSyncSetChangedListener - * method and removed using the removeSyncSetChangedListener - * method. - *

    - * The originating sync set holds modification locks on the sync info set to ensure - * that no more changes occur until after the current change event is processed. - * The implementors of this interface must not modify the set within the scope of - * the listener's methods. If modiciations are attempted a runtime exception will occur. - *

    - * @see ISyncInfoSetChangeEvent - * @since 3.0 - */ -public interface ISyncInfoSetChangeListener { - - /** - * Sent when the contents of a {@link SyncInfoSet} have been reset or the - * listener has been connected to the set for the first time using - * SyncInfoSet#connect(ISyncInfoSetChangeListener, IProgressMonitor). Listeners - * should discard any state they have accumulated from the originating sync info set - * and re-obtain their state from the set. The originating sync set will be - * locked for modification when this method is called. - *

    - * Clients should not modify the set within this method and other threads that try to - * modify the set will be blocked until the reset is processed. - *

    - * @param set the originating {@link SyncInfoSet} - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor); - - /** - * Sent when a {@link SyncInfoSet} changes. For example, when a resource's - * synchronization state changes. The originating sync set will be - * locked for modification when this method is called. - * Clients should not modify the set within this method and other threads that try to - * modify the set will be blocked until the change is processed. - *

    - * If the originating set is an instance of SyncInfoTree then - * the event will be an instance of ISyncInfoTreeChangeEvent. - * Clients can determine this using an instancof check. - *

    - * @param event an event containing information about the change. - */ - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor); - - /** - * This method is called when errors have occurred calculating the SyncInfo - * for a resource. The resource associated with the error is available from the - * ITeamStatus. This event only provides the latest errors that occurred. - * An array of all errors can be retrieved directly from the set. - * - * @param set the originating {@link SyncInfoSet} - * @param errors the errors that occurred during the latest set modifications - * @param monitor a progress monitor - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor); - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoTreeChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoTreeChangeEvent.java deleted file mode 100644 index 3c24fa48c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/ISyncInfoTreeChangeEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import org.eclipse.core.resources.IResource; - -/** - * This is a change event that provides access to changes in subtrees - * that contain the out-of-sync resources. It is the event type - * provided by {@link SyncInfoTree} when it notifies listeners - * of changes. - * @since 3.0 - */ -public interface ISyncInfoTreeChangeEvent extends ISyncInfoSetChangeEvent { - - /** - * Returns the highest parent resources of all newly added elements available in this event - * by calling getAddedResources(). In other words, it returns the set of all - * parent containers that did not previously have descendants in the sync set but are direct - * children of containers that did previously have descescendants in the set. - *

    - * These roots are provided in order - * to allow listeners to optimize the reconciliation of hierachical views of - * the SyncInfoSet contents. - * - * @return parents of all newly added elements or an empty list if this event - * doesn't contain added resources. - */ - public IResource[] getAddedSubtreeRoots(); - - /** - * Returns the highest parent resources of all newly removed elements available in this event - * by calling getRemovedResources(). In other words, it returns the set of all - * parent containers that previously had descendants in the sync set but are direct - * children of containers that still have descescendants in the set. - *

    - * These roots are provided in order - * to allow listeners to optimize the reconciliation of hierachical views of - * the SyncInfoSet contents. - * - * @return parents of all newly removed elements. or an empty list if this event - * doesn't contain added resources. - */ - public IResource[] getRemovedSubtreeRoots(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java deleted file mode 100644 index 7d4dc7b64..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java +++ /dev/null @@ -1,474 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.*; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.Policy; - -/** - * Describes the synchronization of a local resource - * relative to a remote resource variant. There are two - * types of comparison: two-way and three-way. - * The {@link IResourceVariantComparator} is used to decide which - * comparison type to use. - *

    - *

    - * For two-way comparisons, a SyncInfo node has a change - * type. This will be one of IN-SYNC, ADDITION, DELETION or CHANGE determined - * in the following manner. - *

      - *
    • A resource is considered an ADDITION if it exists locally and there is no remote. - *
    • A resource is considered an DELETION if it does not exists locally and there is remote. - *
    • A resource is considered a CHANGE if both the local and remote exist but the - * comparator indicates that they differ. The comparator may be comparing contents or - * timestamps or some other resource state. - *
    • A resource is considered IN_SYNC in all other cases. - *
    - *

    - * For three-way comparisons, the sync info node has a direction as well as a change - * type. The direction is one of INCOMING, OUTGOING or CONFLICTING. The comparison - * of the local and remote resources with a base resource is used to determine - * the direction of the change. - *

      - *
    • Differences between the base and local resources - * are classified as outgoing changes; if there is - * a difference, the local resource is considered the - * outgoing resource. - *
    • Differences between the base and remote resources - * are classified as incoming changes; if there is - * a difference, the remote resource is considered the - * incoming resource. - *
    • If there are both incoming and outgoing changes, the resource - * is considered a conflicting change. - * Again, the comparison of resources is done using the variant comparator provided - * when the sync info was created. - *

      - * @since 3.0 - */ -public class SyncInfo implements IAdaptable { - - /*==================================================================== - * Constants defining synchronization types: - *====================================================================*/ - - /** - * Sync constant (value 0) indicating element is in sync. - */ - public static final int IN_SYNC = 0; - - /** - * Sync constant (value 1) indicating that one side was added. - */ - public static final int ADDITION = 1; - - /** - * Sync constant (value 2) indicating that one side was deleted. - */ - public static final int DELETION = 2; - - /** - * Sync constant (value 3) indicating that one side was changed. - */ - public static final int CHANGE = 3; - - /** - * Bit mask for extracting the change type. - */ - public static final int CHANGE_MASK = CHANGE; - - /*==================================================================== - * Constants defining synchronization direction: - *====================================================================*/ - - /** - * Sync constant (value 4) indicating a change to the local resource. - */ - public static final int OUTGOING = 4; - - /** - * Sync constant (value 8) indicating a change to the remote resource. - */ - public static final int INCOMING = 8; - - /** - * Sync constant (value 12) indicating a change to both the remote and local resources. - */ - public static final int CONFLICTING = 12; - - /** - * Bit mask for extracting the synchronization direction. - */ - public static final int DIRECTION_MASK = CONFLICTING; - - /*==================================================================== - * Constants defining synchronization conflict types: - *====================================================================*/ - - /** - * Sync constant (value 16) indication that both the local and remote resources have changed - * relative to the base but their contents are the same. - */ - public static final int PSEUDO_CONFLICT = 16; - - /** - * Sync constant (value 32) indicating that both the local and remote resources have changed - * relative to the base but their content changes do not conflict (e.g. source file changes on different - * lines). These conflicts could be merged automatically. - */ - public static final int AUTOMERGE_CONFLICT = 32; - - /** - * Sync constant (value 64) indicating that both the local and remote resources have changed relative - * to the base and their content changes conflict (e.g. local and remote resource have changes on - * same lines). These conflicts can only be correctly resolved by the user. - */ - public static final int MANUAL_CONFLICT = 64; - - /*==================================================================== - * Members: - *====================================================================*/ - private IResource local; - private IResourceVariant base; - private IResourceVariant remote; - private IResourceVariantComparator comparator; - - private int syncKind; - - /** - * Construct a sync info object. - * @param local the local resource. Must be non-null but may not exist. - * @param base the base resource variant or null - * @param remote the remote resource variant or null - * @param comparator the comparator used to determine if resources differ - */ - public SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) { - Assert.isNotNull(local); - Assert.isNotNull(comparator); - this.local = local; - this.base = base; - this.remote = remote; - this.comparator = comparator; - } - - /** - * Returns the state of the local resource. Note that the - * resource may or may not exist. - * - * @return a resource - */ - public IResource getLocal() { - return local; - } - - /** - * Returns the content identifier for the local resource or null if - * it doesn't have one. For example, in CVS this would be the revision number. - * - * @return String that could be displayed to the user to identify this resource. - */ - public String getLocalContentIdentifier() { - return null; - } - - /** - * Returns the remote resource handle for the base resource, - * or null if the base resource does not exist. - *

      - * [Note: The type of the common resource may be different from the types - * of the local and remote resources. - * ] - *

      - * @return a remote resource handle, or null - */ - public IResourceVariant getBase() { - return base; - } - - /** - * Returns the handle for the remote resource, - * or null if the remote resource does not exist. - *

      - * [Note: The type of the remote resource may be different from the types - * of the local and common resources. - * ] - *

      - * @return a remote resource handle, or null - */ - public IResourceVariant getRemote() { - return remote; - } - - /** - * Returns the comparator that is used to determine the - * kind of this sync node. - * - * @return the comparator that is used to determine the - * kind of this sync node. - */ - public IResourceVariantComparator getComparator() { - return comparator; - } - - /** - * Returns the kind of synchronization for this node. - * - * @return the kind of synchronization for this node. - */ - public int getKind() { - return syncKind; - } - - /** - * Helper method that returns whether the given kind represents - * an in-sync resource. - * - * @param kind the kind of a SyncInfo - * @return whether the kind is IN_SYNC. - */ - static public boolean isInSync(int kind) { - return kind == IN_SYNC; - } - - /** - * Helper method to return the direction portion - * of the given kind. The resulting value - * can be compared directly with the direction constants. - * - * @param kind the kind of a SyncInfo - * @return the direction portion of the kind - */ - static public int getDirection(int kind) { - return kind & DIRECTION_MASK; - } - - /** - * Helper method to return the change portion - * of the given kind. The resulting value - * can be compared directly with the change - * type constants. - * - * @param kind the kind of a SyncInfo - * @return the change portion of the kind - */ - static public int getChange(int kind) { - return kind & CHANGE_MASK; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - if(other == this) return true; - if(other instanceof SyncInfo) { - return equalNodes(this, (SyncInfo)other); - } - return false; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return getLocal().hashCode(); - } - - private boolean equalNodes(SyncInfo node1, SyncInfo node2) { - if(node1 == null || node2 == null) { - return false; - } - - // First, ensure the local resources are equals - IResource local1 = null; - if (node1.getLocal() != null) - local1 = node1.getLocal(); - IResource local2 = null; - if (node2.getLocal() != null) - local2 = node2.getLocal(); - if (!equalObjects(local1, local2)) return false; - - // Next, ensure the base resources are equal - IResourceVariant base1 = null; - if (node1.getBase() != null) - base1 = node1.getBase(); - IResourceVariant base2 = null; - if (node2.getBase() != null) - base2 = node2.getBase(); - if (!equalObjects(base1, base2)) return false; - - // Finally, ensure the remote resources are equal - IResourceVariant remote1 = null; - if (node1.getRemote() != null) - remote1 = node1.getRemote(); - IResourceVariant remote2 = null; - if (node2.getRemote() != null) - remote2 = node2.getRemote(); - if (!equalObjects(remote1, remote2)) return false; - - return true; - } - - private boolean equalObjects(Object o1, Object o2) { - if (o1 == null && o2 == null) return true; - if (o1 == null || o2 == null) return false; - return o1.equals(o2); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IResource.class) { - return getLocal(); - } - return null; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - return getLocal().getName() + " " + kindToString(getKind()); //$NON-NLS-1$ - } - - /** - * A helper method that returns a displayable (i.e. externalized) - * string describing the provided sync kind. - * - * @param kind the sync kind obtained from a SyncInfo - * @return a displayable string that descibes the kind - */ - public static String kindToString(int kind) { - String label = ""; //$NON-NLS-1$ - if(kind==IN_SYNC) { - label = Policy.bind("RemoteSyncElement.insync"); //$NON-NLS-1$ - } else { - switch(kind & DIRECTION_MASK) { - case CONFLICTING: label = Policy.bind("RemoteSyncElement.conflicting"); break; //$NON-NLS-1$ - case OUTGOING: label = Policy.bind("RemoteSyncElement.outgoing"); break; //$NON-NLS-1$ - case INCOMING: label = Policy.bind("RemoteSyncElement.incoming"); break; //$NON-NLS-1$ - } - switch(kind & CHANGE_MASK) { - case CHANGE: label = Policy.bind("concatStrings", label, Policy.bind("RemoteSyncElement.change")); break; //$NON-NLS-1$ //$NON-NLS-2$ - case ADDITION: label = Policy.bind("concatStrings", label, Policy.bind("RemoteSyncElement.addition")); break; //$NON-NLS-1$ //$NON-NLS-2$ - case DELETION: label = Policy.bind("concatStrings", label, Policy.bind("RemoteSyncElement.deletion")); break; //$NON-NLS-1$ //$NON-NLS-2$ - } - if((kind & MANUAL_CONFLICT) != 0) { - label = Policy.bind("concatStrings", label, Policy.bind("RemoteSyncElement.manual")); //$NON-NLS-1$ //$NON-NLS-2$ - } - if((kind & AUTOMERGE_CONFLICT) != 0) { - label = Policy.bind("concatStrings", label, Policy.bind("RemoteSyncElement.auto")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return Policy.bind("RemoteSyncElement.delimit", label); //$NON-NLS-1$ - } - - /** - * Method that is invoked after instance creation to initialize the sync kind. - * This method should only be invoked by the creator of the SyncInfo - * instance. It is not done from the constructor in order to allow subclasses - * to calculate the sync kind from any additional state variables they may have. - * - * @throws TeamException if there were problems calculating the sync state. - */ - public final void init() throws TeamException { - syncKind = calculateKind(); - } - - /** - * Method that is invoked from the init() method to calculate - * the sync kind for this instance of SyncInfo. The result is - * assigned to an instance variable and is available using getKind(). - * Subclasses should not invoke this method but may override it in order to customize - * the sync kind calculation algorithm. - * - * @return the sync kind of this SyncInfo - * @throws TeamException if there were problems calculating the sync state. - */ - protected int calculateKind() throws TeamException { - int description = IN_SYNC; - - boolean localExists = local.exists(); - - if (comparator.isThreeWay()) { - if (base == null) { - if (remote == null) { - if (!localExists) { - description = IN_SYNC; - } else { - description = OUTGOING | ADDITION; - } - } else { - if (!localExists) { - description = INCOMING | ADDITION; - } else { - description = CONFLICTING | ADDITION; - if (comparator.compare(local, remote)) { - description |= PSEUDO_CONFLICT; - } - } - } - } else { - if (!localExists) { - if (remote == null) { - description = CONFLICTING | DELETION | PSEUDO_CONFLICT; - } else { - if (comparator.compare(base, remote)) - description = OUTGOING | DELETION; - else - description = CONFLICTING | CHANGE; - } - } else { - if (remote == null) { - if (comparator.compare(local, base)) - description = INCOMING | DELETION; - else - description = CONFLICTING | CHANGE; - } else { - boolean ay = comparator.compare(local, base); - boolean am = comparator.compare(base, remote); - if (ay && am) { - // in-sync - } else if (ay && !am) { - description = INCOMING | CHANGE; - } else if (!ay && am) { - description = OUTGOING | CHANGE; - } else { - if(! comparator.compare(local, remote)) { - description = CONFLICTING | CHANGE; - } - } - } - } - } - } else { // two compare without access to base contents - if (remote == null) { - if (!localExists) { - Assert.isTrue(false); - // shouldn't happen - } else { - description= DELETION; - } - } else { - if (!localExists) { - description= ADDITION; - } else { - if (! comparator.compare(local, remote)) - description= CHANGE; - } - } - } - return description; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoFilter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoFilter.java deleted file mode 100644 index 1d2b15095..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoFilter.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.subscribers.ContentComparator; - -/** - * A SyncInfoFilter tests a SyncInfo for inclusion, - * typically in a SyncInfoSet. - * - * @see SyncInfo - * @see SyncInfoSet - * - * @since 3.0 - */ -public abstract class SyncInfoFilter { - - /** - * Selects SyncInfo whose local and remote contents match. - * This filter makes use of the IStorage provided by - * an IResourceVariant to obtain the remote contents. - * This means that the comparison may contact the server unless the contents - * were cached locally by a previous operation. The caching of remote - * contents is subscriber specific. - *

      - * For folders, the comparison always returns true. - */ - public static class ContentComparisonSyncInfoFilter extends SyncInfoFilter { - ContentComparator criteria = new ContentComparator(false); - /** - * Create a filter that does not ignore whitespace. - */ - public ContentComparisonSyncInfoFilter() { - this(false); - } - /** - * Create a filter and configure how whitspace is handled. - * @param ignoreWhitespace whether whitespace should be ignored - */ - public ContentComparisonSyncInfoFilter(boolean ignoreWhitespace) { - criteria = new ContentComparator(ignoreWhitespace); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.SyncInfoFilter#select(org.eclipse.team.core.synchronize.SyncInfo, org.eclipse.core.runtime.IProgressMonitor) - */ - public boolean select(SyncInfo info, IProgressMonitor monitor) { - IResourceVariant remote = info.getRemote(); - IResource local = info.getLocal(); - if (local.getType() != IResource.FILE) return true; - if (remote == null) return !local.exists(); - if (!local.exists()) return false; - return compareContents((IFile)local, remote, monitor); - } - - /** - * Compare the contents of the local file and its variant. - * This is used by the select method to compare the - * contents of two non-null files. - * @param local a local file - * @param remote a resource variant of the file - * @param monitor a progress monitor - * @return whether the contents of the two files are equal - */ - public boolean compareContents(IFile local, IResourceVariant remote, IProgressMonitor monitor) { - Assert.isNotNull(local); - Assert.isNotNull(remote); - return criteria.compare(local, remote, monitor); - } - } - - /** - * Return true if the provided SyncInfo matches the filter. - * - * @param info the SyncInfo to be tested - * @param monitor a progress monitor - * @return true if the SyncInfo matches the filter - */ - public abstract boolean select(SyncInfo info, IProgressMonitor monitor); - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java deleted file mode 100644 index 6658ee042..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java +++ /dev/null @@ -1,650 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.synchronize; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.internal.core.*; -import org.eclipse.team.internal.core.subscribers.SyncInfoStatistics; -import org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent; - -/** - * A dynamic collection of {@link SyncInfo} objects that provides - * change notification to registered listeners. Batching of change notifications - * can be accomplished using the beginInput/endInput methods. - * - * @see SyncInfoTree - * @see SyncInfo - * @see ISyncInfoSetChangeListener - * @since 3.0 - */ -public class SyncInfoSet { - // fields used to hold resources of interest - // {IPath -> SyncInfo} - private Map resources = Collections.synchronizedMap(new HashMap()); - - // keep track of number of sync kinds in the set - private SyncInfoStatistics statistics = new SyncInfoStatistics(); - - // keep track of errors that occurred while trying to populate the set - private Map errors = new HashMap(); - - private boolean lockedForModification; - - /** - * Create an empty set. - */ - public SyncInfoSet() { - } - - /** - * Create a SyncInfoSet containing the given SyncInfo - * instances. - * - * @param infos the SyncInfo instances to be contained by this set - */ - public SyncInfoSet(SyncInfo[] infos) { - this(); - // use the internal add since we can't have listeners at this point anyway - for (int i = 0; i < infos.length; i++) { - internalAdd(infos[i]); - } - } - - /** - * Return an array of SyncInfo for all out-of-sync resources that are contained by the set. - * - * @return an array of SyncInfo - */ - public synchronized SyncInfo[] getSyncInfos() { - return (SyncInfo[]) resources.values().toArray(new SyncInfo[resources.size()]); - } - - /** - * Return all out-of-sync resources contained in this set. The default implementation - * uses getSyncInfos() to determine the resources contained in the set. - * Subclasses may override to optimize. - * - * @return all out-of-sync resources contained in the set - */ - public IResource[] getResources() { - SyncInfo[] infos = getSyncInfos(); - List resources = new ArrayList(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - resources.add(info.getLocal()); - } - return (IResource[]) resources.toArray(new IResource[resources.size()]); - } - - /** - * Return the SyncInfo for the given resource or null - * if the resource is not contained in the set. - * - * @param resource the resource - * @return the SyncInfo for the resource or null if - * the resource is in-sync or doesn't have synchronization information in this set. - */ - public synchronized SyncInfo getSyncInfo(IResource resource) { - return (SyncInfo)resources.get(resource.getFullPath()); - } - - /** - * Return the number of out-of-sync resources contained in this set. - * - * @return the size of the set. - * @see #countFor(int, int) - */ - public synchronized int size() { - return resources.size(); - } - - /** - * Return the number of out-of-sync resources in the given set whose sync kind - * matches the given kind and mask (e.g. (SyncInfo#getKind() & mask) == kind). - *

      - * For example, this will return the number of outgoing changes in the set: - *

      -	 *  long outgoing =  countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
      -	 * 
      - *

      - * @param kind the sync kind - * @param mask the sync kind mask - * @return the number of matching resources in the set. - */ - public long countFor(int kind, int mask) { - return statistics.countFor(kind, mask); - } - - /** - * Returns true if there are any conflicting nodes in the set, and - * false otherwise. - * - * @return true if there are any conflicting nodes in the set, and - * false otherwise. - */ - public boolean hasConflicts() { - return countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK) > 0; - } - - /** - * Return whether the set is empty. - * - * @return true if the set is empty - */ - public synchronized boolean isEmpty() { - return resources.isEmpty(); - } - - /** - * Add the SyncInfo to the set, replacing any previously existing one. - * - * @param info the new SyncInfo - */ - protected synchronized void internalAdd(SyncInfo info) { - Assert.isTrue(!lockedForModification); - IResource local = info.getLocal(); - IPath path = local.getFullPath(); - SyncInfo oldSyncInfo = (SyncInfo)resources.put(path, info); - if(oldSyncInfo == null) { - statistics.add(info); - } else { - statistics.remove(oldSyncInfo); - statistics.add(info); - } - } - - /** - * Remove the resource from the set, updating all internal data structures. - * - * @param resource the resource to be removed - * @return the SyncInfo that was just removed - */ - protected synchronized SyncInfo internalRemove(IResource resource) { - Assert.isTrue(!lockedForModification); - IPath path = resource.getFullPath(); - SyncInfo info = (SyncInfo)resources.remove(path); - if (info != null) { - statistics.remove(info); - } - return info; - } - - /** - * Registers the given listener for sync info set notifications. Has - * no effect if an identical listener is already registered. - * - * @param listener listener to register - */ - public void addSyncSetChangedListener(ISyncInfoSetChangeListener listener) { - synchronized(listeners) { - listeners.add(listener); - } - } - - /** - * Deregisters the given listener for participant notifications. Has - * no effect if listener is not already registered. - * - * @param listener listener to deregister - */ - public void removeSyncSetChangedListener(ISyncInfoSetChangeListener listener) { - synchronized(listeners) { - listeners.remove(listener); - } - } - - /** - * Reset the sync set so it is empty. Listeners are notified of the change. - */ - public void clear() { - try { - beginInput(); - errors.clear(); - resources.clear(); - statistics.clear(); - getChangeEvent().reset(); - } finally { - endInput(null); - } - } - - /* - * Run the given runnable. This operation - * will block other threads from modifying the - * set and postpone any change notifications until after the runnable - * has been executed. Mutable subclasses must override. - *

      - * The given runnable may be run in the same thread as the caller or - * more be run asynchronously in another thread at the discretion of the - * subclass implementation. However, it is gaurenteed that two invocations - * of run performed in the same thread will be executed in the - * same order even if run in different threads. - *

      - * @param runnable a runnable - * @param progress a progress monitor or null - */ - private void run(IWorkspaceRunnable runnable, IProgressMonitor monitor) { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - try { - beginInput(); - runnable.run(Policy.subMonitorFor(monitor, 80)); - } catch (CoreException e) { - addError(new TeamStatus(IStatus.ERROR, TeamPlugin.ID, ITeamStatus.SYNC_INFO_SET_ERROR, e.getMessage(), e, null)); - } finally { - endInput(Policy.subMonitorFor(monitor, 20)); - } - } - - /** - * Connect the listener to the sync set in such a fashion that the listener will - * be connected the the sync set using addChangeListener - * and issued a reset event. This is done to provide a means of connecting to the - * sync set and initializing a model based on the sync set without worrying about - * missing events. - *

      - * The reset event may be done in the context of this method invocation or may be - * done in another thread at the discretion of the SyncInfoSet - * implementation. - *

      - * Disconnecting is done by calling removeChangeListener. Once disconnected, - * a listener can reconnect to be reinitialized. - *

      - * @param listener the listener that should be connected to this set - * @param monitor a progress monitor - */ - public void connect(final ISyncInfoSetChangeListener listener, IProgressMonitor monitor) { - run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) { - try { - monitor.beginTask(null, 100); - addSyncSetChangedListener(listener); - listener.syncInfoSetReset(SyncInfoSet.this, Policy.subMonitorFor(monitor, 95)); - } finally { - monitor.done(); - } - } - }, monitor); - } - - private ILock lock = Platform.getJobManager().newLock(); - - private Set listeners = Collections.synchronizedSet(new HashSet()); - - private SyncSetChangedEvent changes = createEmptyChangeEvent(); - - /** - * Add the given SyncInfo to the set. A change event will - * be generated unless the call to this method is nested in between calls - * to beginInput() and endInput(IProgressMonitor) - * in which case the event for this addition and any other sync set - * change will be fired in a batched event when endInput - * is invoked. - *

      - * Invoking this method outside of the above mentioned block will result - * in the endInput(IProgressMonitor) being invoked with a null - * progress monitor. If responsiveness is required, the client should always - * nest sync set modifications within beginInput/endInput. - *

      - * @param info the sync info to be added to this set. - */ - public void add(SyncInfo info) { - try { - beginInput(); - boolean alreadyExists = getSyncInfo(info.getLocal()) != null; - internalAdd(info); - if (alreadyExists) { - getChangeEvent().changed(info); - } else { - getChangeEvent().added(info); - } - } finally { - endInput(null); - } - } - - /** - * Add all the syncinfo from the given set to this set. - * - * @param set the set whose sync info should be added to this set - */ - public void addAll(SyncInfoSet set) { - try { - beginInput(); - SyncInfo[] infos = set.getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - add(infos[i]); - } - } finally { - endInput(null); - } - } - - /** - * Remove the given local resource from the set. - * - * @param resource the local resource to remove - */ - public synchronized void remove(IResource resource) { - try { - beginInput(); - SyncInfo info = internalRemove(resource); - getChangeEvent().removed(resource, info); - } finally { - endInput(null); - } - } - - /** - * Remove all the given resources from the set. - * - * @param resources the resources to be removed - */ - public void removeAll(IResource[] resources) { - try { - beginInput(); - for (int i = 0; i < resources.length; i++) { - remove(resources[i]); - } - } finally { - endInput(null); - } - } - - /** - * Removes all conflicting nodes from this set. - */ - public void removeConflictingNodes() { - rejectNodes(new SyncInfoDirectionFilter(SyncInfo.CONFLICTING)); - } - - /** - * Removes all outgoing nodes from this set. - */ - public void removeOutgoingNodes() { - rejectNodes(new SyncInfoDirectionFilter(SyncInfo.OUTGOING)); - } - - /** - * Removes all incoming nodes from this set. - */ - public void removeIncomingNodes() { - rejectNodes(new SyncInfoDirectionFilter(SyncInfo.INCOMING)); - } - - /** - * Indicate whether the set has nodes matching the given filter. - * - * @param filter a sync info filter - */ - public boolean hasNodes(FastSyncInfoFilter filter) { - SyncInfo[] infos = getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - if (info != null && filter.select(info)) { - return true; - } - } - return false; - } - - /** - * Removes all nodes from this set that do not match the given filter - * leaving only those that do match the filter. - * - * @param filter a sync info filter - */ - public void selectNodes(FastSyncInfoFilter filter) { - try { - beginInput(); - SyncInfo[] infos = getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - if (info == null || !filter.select(info)) { - remove(info.getLocal()); - } - } - } finally { - endInput(null); - } - } - - /** - * Removes all nodes from this set that match the given filter - * leaving those that do not match the filter. - * - * @param filter a sync info filter - */ - public void rejectNodes(FastSyncInfoFilter filter) { - try { - beginInput(); - SyncInfo[] infos = getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - if (info != null && filter.select(info)) { - remove(info.getLocal()); - } - } - } finally { - endInput(null); - } - } - - /** - * Return all nodes in this set that match the given filter. - * - * @param filter a sync info filter - */ - public SyncInfo[] getNodes(FastSyncInfoFilter filter) { - List result = new ArrayList(); - SyncInfo[] infos = getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - if (info != null && filter.select(info)) { - result.add(info); - } - } - return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]); - } - - /** - * Returns true if this sync set has incoming changes. - * Note that conflicts are not considered to be incoming changes. - * - * @return true if this sync set has incoming changes. - */ - public boolean hasIncomingChanges() { - return countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK) > 0; - } - - /** - * Returns true if this sync set has outgoing changes. - * Note that conflicts are not considered to be outgoing changes. - * - * @return true if this sync set has outgoing changes. - */ - public boolean hasOutgoingChanges() { - return countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK) > 0; - } - - /** - * This method is used to obtain a lock on the set which ensures thread safety - * and batches change notification. If the set is locked by another thread, - * the calling thread will block until the lock - * becomes available. This method uses an org.eclipse.core.runtime.jobs.ILock. - *

      - * It is important that the lock is released after it is obtained. Calls to endInput - * should be done in a finally block as illustrated in the following code snippet. - *

      -	 *   try {
      -	 *       set.beginInput();
      -	 *       // do stuff
      -	 *   } finally {
      -	 *      set.endInput(progress);
      -	 *   }
      -	 * 
      - *

      - * Calls to beginInput and endInput can be nested and must be matched. - *

      - */ - public void beginInput() { - lock.acquire(); - } - - /** - * This method is used to release the lock on this set. The prgress monitor is needed to allow - * listeners to perform long-running operations is reponse to the set change. The lock is held - * while the listeners are notified so listeners must be cautious in order to avoid deadlock. - */ - public void endInput(IProgressMonitor monitor) { - try { - if (lock.getDepth() == 1) { - // Remain locked while firing the events so the handlers - // can expect the set to remain constant while they process the events - fireChanges(Policy.monitorFor(monitor)); - } - } finally { - lock.release(); - } - } - - /** - * Reset the changes accumulated so far by this set. This method is not - * intended to be invoked or implemented by clients. - */ - protected void resetChanges() { - changes = createEmptyChangeEvent(); - } - - /** - * Create an empty change event. Subclass may override to provided specialized event types - * - * @return an empty change event - */ - protected SyncSetChangedEvent createEmptyChangeEvent() { - return new SyncSetChangedEvent(this); - } - - private void fireChanges(final IProgressMonitor monitor) { - // Use a synchronized block to ensure that the event we send is static - final SyncSetChangedEvent event; - synchronized(this) { - event = getChangeEvent(); - resetChanges(); - } - // Ensure that the list of listeners is not changed while events are fired. - // Copy the listeners so that addition/removal is not blocked by event listeners - if(event.isEmpty() && ! event.isReset()) return; - ISyncInfoSetChangeListener[] allListeners = getListeners(); - // Fire the events using an ISafeRunnable - final ITeamStatus[] newErrors = event.getErrors(); - monitor.beginTask(null, 100 + (newErrors.length > 0 ? 50 : 0) * allListeners.length); - for (int i = 0; i < allListeners.length; i++) { - final ISyncInfoSetChangeListener listener = allListeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in Platform#run - } - public void run() throws Exception { - try { - lockedForModification = true; - if (event.isReset()) { - listener.syncInfoSetReset(SyncInfoSet.this, Policy.subMonitorFor(monitor, 100)); - } else { - listener.syncInfoChanged(event, Policy.subMonitorFor(monitor, 100)); - } - if (newErrors.length > 0) { - listener.syncInfoSetErrors(SyncInfoSet.this, newErrors, Policy.subMonitorFor(monitor, 50)); - } - } finally { - lockedForModification = false; - } - } - }); - } - monitor.done(); - } - - /** - * Return a copy of all the listeners registered with this set - * @return the listeners - */ - protected ISyncInfoSetChangeListener[] getListeners() { - ISyncInfoSetChangeListener[] allListeners; - synchronized(listeners) { - allListeners = (ISyncInfoSetChangeListener[]) listeners.toArray(new ISyncInfoSetChangeListener[listeners.size()]); - } - return allListeners; - } - - /** - * Return the change event that is accumulating the changes to the set. - * This can be called by sublasses to access the event. - * @return Returns the changes. - */ - protected SyncSetChangedEvent getChangeEvent() { - return changes; - } - - /** - * Add the error to the set. Errors should be added to the set when the client - * populating the set cannot determine the SyncInfo for one - * or more resources due to an exception or some other problem. Listeners - * will be notified that an error occurred and can react accordingly. - *

      - * Only one error can be associated with a resource (which is obtained from - * the ITeamStatus). It is up to the - * client populating the set to ensure that the error associated with a - * resource contains all relevent information. - * The error will remain in the set until the set is reset. - *

      - * @param resource the resource associated with the error or the workspace root - * @param status the status that describes the error that occurred. - */ - public void addError(ITeamStatus status) { - try { - beginInput(); - errors.put(status.getResource(), status); - getChangeEvent().errorOccurred(status); - } finally { - endInput(null); - } - } - - /** - * Return an array of the errors the occurred while populating this set. - * The errors will remain with the set until it is reset. - * - * @return the errors - */ - public ITeamStatus[] getErrors() { - return (ITeamStatus[]) errors.values().toArray(new ITeamStatus[errors.size()]); - } - - /** - * Return an interator over all SyncInfo - * contained in this set. - * @return an interator over all SyncInfo - * contained in this set. - * @since 3.1 - */ - public Iterator iterator() { - return resources.values().iterator(); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoTree.java deleted file mode 100644 index 94005804c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoTree.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.team.core.synchronize; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.core.TeamPlugin; -import org.eclipse.team.internal.core.subscribers.SyncInfoTreeChangeEvent; -import org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent; -import org.eclipse.team.internal.core.Policy; - -/** - * Provides addition API for accessing the SyncInfo in the set through - * their resource's hierarchical relationships. - *

      - * Events fired from a SyncInfoTree will be instances of ISyncInfoTreeChangeEvent. - *

      - * @see SyncInfoSet - * @since 3.0 - */ -public class SyncInfoTree extends SyncInfoSet { - - protected Map parents = Collections.synchronizedMap(new HashMap()); - - /** - * Create an empty sync info tree. - */ - public SyncInfoTree() { - super(); - } - - /** - * Create a sync info tree containing the given sync info elements. - * - * @param infos the sync info elements - */ - public SyncInfoTree(SyncInfo[] infos) { - super(infos); - } - - /** - * Return wether the given resource has any children in the sync set. The children - * could be either out-of-sync resources that are contained by the set or containers - * that are ancestors of out-of-sync resources contained by the set. - * - * @param resource the resource to check for children. - * @return true if the resource has children in the set. - */ - public synchronized boolean hasMembers(IResource resource) { - if (resource.getType() == IResource.FILE) return false; - IContainer parent = (IContainer)resource; - if (parent.getType() == IResource.ROOT) return !isEmpty(); - IPath path = parent.getFullPath(); - Set allDescendants = (Set)parents.get(path); - return (allDescendants != null && !allDescendants.isEmpty()); - } - - /** - * Return the SyncInfo for each out-of-sync resource in the subtree rooted at the given resource - * to the depth specified. The depth is one of: - *
        - *
      • IResource.DEPTH_ZERO: the resource only, - *
      • IResource.DEPTH_ONE: the resource or its direct children, - *
      • IResource.DEPTH_INFINITE: the resource and all of it's descendants. - *
          - * If the given resource is out of sync, it will be included in the result. - *

          - * The default implementation makes use of getSyncInfo(IResource), - * members(IResource) and getSyncInfos() - * to provide the varying depths. Subclasses may override to optimize. - *

          - * @param resource the root of the resource subtree - * @param depth the depth of the subtree - * @return the SyncInfo for any out-of-sync resources - */ - public synchronized SyncInfo[] getSyncInfos(IResource resource, int depth) { - if (depth == IResource.DEPTH_ZERO || resource.getType() == IResource.FILE) { - SyncInfo info = getSyncInfo(resource); - if (info == null) { - return new SyncInfo[0]; - } else { - return new SyncInfo[] { info }; - } - } - if (depth == IResource.DEPTH_ONE) { - List result = new ArrayList(); - SyncInfo info = getSyncInfo(resource); - if (info != null) { - result.add(info); - } - IResource[] members = members(resource); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - info = getSyncInfo(member); - if (info != null) { - result.add(info); - } - } - return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]); - } - // if it's the root then return all out of sync resources. - if(resource.getType() == IResource.ROOT) { - return getSyncInfos(); - } - // for folders return all children deep. - return internalGetDeepSyncInfo((IContainer)resource); - } - - /* - * Return the SyncInfo for all out-of-sync resources in the - * set that are at or below the given resource in the resource hierarchy. - * @param resource the root resource - * @return the SyncInfo for all out-of-sync resources at or below the given resource - */ - private synchronized SyncInfo[] internalGetDeepSyncInfo(IContainer resource) { - List infos = new ArrayList(); - IResource[] children = internalGetOutOfSyncDescendants(resource); - for (int i = 0; i < children.length; i++) { - IResource child = children[i]; - SyncInfo info = getSyncInfo(child); - if(info != null) { - infos.add(info); - } else { - TeamPlugin.log(IStatus.INFO, Policy.bind("SyncInfoTree.0") + child.getFullPath(), null); //$NON-NLS-1$ - } - } - return (SyncInfo[]) infos.toArray(new SyncInfo[infos.size()]); - } - - /** - * Overrides inherited method to provide an instance of - * ISyncInfoTreeChangeEvent. - */ - protected SyncSetChangedEvent createEmptyChangeEvent() { - return new SyncInfoTreeChangeEvent(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.SyncInfoSet#add(org.eclipse.team.core.synchronize.SyncInfo) - */ - public void add(SyncInfo info) { - try { - beginInput(); - boolean alreadyExists = getSyncInfo(info.getLocal()) != null; - super.add(info); - if(! alreadyExists) { - IResource local = info.getLocal(); - addToParents(local, local); - } - } finally { - endInput(null); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.SyncInfoSet#remove(org.eclipse.core.resources.IResource) - */ - public void remove(IResource resource) { - try { - beginInput(); - super.remove(resource); - removeFromParents(resource, resource); - } finally { - endInput(null); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.SyncInfoSet#clear() - */ - public void clear() { - try { - beginInput(); - super.clear(); - synchronized(this) { - parents.clear(); - } - } finally { - endInput(null); - } - } - - private synchronized boolean addToParents(IResource resource, IResource parent) { - if (parent.getType() == IResource.ROOT) { - return false; - } - // this flag is used to indicate if the parent was previosuly in the set - boolean addedParent = false; - if (parent.getType() == IResource.FILE) { - // the file is new - addedParent = true; - } else { - Set children = (Set)parents.get(parent.getFullPath()); - if (children == null) { - children = new HashSet(); - parents.put(parent.getFullPath(), children); - // this is a new folder in the sync set - addedParent = true; - } - children.add(resource); - } - // if the parent already existed and the resource is new, record it - if (!addToParents(resource, parent.getParent()) && addedParent) { - internalAddedSubtreeRoot(parent); - } - return addedParent; - } - - private synchronized boolean removeFromParents(IResource resource, IResource parent) { - if (parent.getType() == IResource.ROOT) { - return false; - } - // this flag is used to indicate if the parent was removed from the set - boolean removedParent = false; - if (parent.getType() == IResource.FILE) { - // the file will be removed - removedParent = true; - } else { - Set children = (Set)parents.get(parent.getFullPath()); - if (children != null) { - children.remove(resource); - if (children.isEmpty()) { - parents.remove(parent.getFullPath()); - removedParent = true; - } - } - } - // if the parent wasn't removed and the resource was, record it - if (!removeFromParents(resource, parent.getParent()) && removedParent) { - internalRemovedSubtreeRoot(parent); - } - return removedParent; - } - - private void internalAddedSubtreeRoot(IResource parent) { - ((SyncInfoTreeChangeEvent)getChangeEvent()).addedSubtreeRoot(parent); - } - - private void internalRemovedSubtreeRoot(IResource parent) { - ((SyncInfoTreeChangeEvent)getChangeEvent()).removedSubtreeRoot(parent); - } - - /** - * Remove from this set the SyncInfo for the given resource and any of its descendants - * within the specified depth. The depth is one of: - *
            - *
          • IResource.DEPTH_ZERO: the resource only, - *
          • IResource.DEPTH_ONE: the resource or its direct children, - *
          • IResource.DEPTH_INFINITE: the resource and all of it's descendants. - *
              - * @param resource the root of the resource subtree - * @param depth the depth of the subtree - */ - public void remove(IResource resource, int depth) { - try { - beginInput(); - if (getSyncInfo(resource) != null) { - remove(resource); - } - if (depth == IResource.DEPTH_ZERO || resource.getType() == IResource.FILE) return; - if (depth == IResource.DEPTH_ONE) { - IResource[] members = members(resource); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - if (getSyncInfo(member) != null) { - remove(member); - } - } - } else if (depth == IResource.DEPTH_INFINITE) { - IResource [] toRemove = internalGetOutOfSyncDescendants((IContainer)resource); - for (int i = 0; i < toRemove.length; i++) { - remove(toRemove[i]); - } - } - } finally { - endInput(null); - } - } - - /** - * This is an internal method and is not intended to be invoked or - * overriden by clients. - */ - protected synchronized IResource[] internalGetOutOfSyncDescendants(IContainer resource) { - // The parent map contains a set of all out-of-sync children - Set allChildren = (Set)parents.get(resource.getFullPath()); - if (allChildren == null) return new IResource[0]; - return (IResource[]) allChildren.toArray(new IResource[allChildren.size()]); - } - - private synchronized IResource[] internalMembers(IWorkspaceRoot root) { - Set possibleChildren = parents.keySet(); - Set children = new HashSet(); - for (Iterator it = possibleChildren.iterator(); it.hasNext();) { - Object next = it.next(); - IResource element = root.findMember((IPath)next); - if (element != null) { - children.add(element.getProject()); - } - } - return (IResource[]) children.toArray(new IResource[children.size()]); - } - - /** - * Return the immediate children of the given resource who are either out-of-sync - * or contain out-of-sync resources. - * - * @param resource the parent resource - * @return the children of the resource that are either out-of-sync or are ancestors of - * out-of-sync resources contained in the set - */ - public synchronized IResource[] members(IResource resource) { - if (resource.getType() == IResource.FILE) return new IResource[0]; - IContainer parent = (IContainer)resource; - if (parent.getType() == IResource.ROOT) return internalMembers((IWorkspaceRoot)parent); - // OPTIMIZE: could be optimized so that we don't traverse all the deep - // children to find the immediate ones. - Set children = new HashSet(); - IPath path = parent.getFullPath(); - Set possibleChildren = (Set)parents.get(path); - if(possibleChildren != null) { - for (Iterator it = possibleChildren.iterator(); it.hasNext();) { - Object next = it.next(); - IResource element = (IResource)next; - IPath childPath = element.getFullPath(); - IResource modelObject = null; - if(childPath.segmentCount() == (path.segmentCount() + 1)) { - modelObject = element; - - } else if (childPath.segmentCount() > path.segmentCount()) { - IContainer childFolder = parent.getFolder(new Path(null, childPath.segment(path.segmentCount()))); - modelObject = childFolder; - } - if (modelObject != null) { - children.add(modelObject); - } - } - } - return (IResource[]) children.toArray(new IResource[children.size()]); - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/package.html b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/package.html deleted file mode 100644 index 25d39ad6b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/package.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - Package-level Javadoc - - -Application programming interfaces for managing synchronization state. -

              Package Specification

              -

              This package specifies the API for managing the synchronization state between - the local workspace resources and a corresponding variants of those resources. - The classes in this package can be used by Subscribers (see the org.eclipse.team.core.subscribers - package) or others. The classes are roughly divided into three categories:

              -
                -
              • describing the synchronization state of a one or more resources,
              • -
              • notifying interested parties of changes in the synchronization state.
              • -
              • filtering a set of resource based on a sync state criteria
              • -
              -

              Describing the synchronization state of resources

              -

              The following classes are provided to accumulate (and possibly filter) the - synchronization state of one or more resources.

              -
                -
              • SyncInfo: node which maps a local resource to a corresponding variant resource - (and a base resource for three-way compare) and descibes the synchronization - state of those resources (e.g. in-sync or incoming-change).
              • -
              • SyncInfoSet: a set which contains the out-of-sync SyncInfo for multiple - local resources.
              • -
              • SyncInfoTree: a specialized set optimized for hierarchical resource based - access (e.g. to obtain all out-of-sync children of a particular local resource).
              • -
              -

              Notifying interested parties of sync info set changes

              -

              Interested parties can register with a SyncInfoSet in order to -receive notification when a set changes.

              -
                -
              • ISyncInfoSetChangeListener: implementors of this interface can be -registered with a SyncInfoSet in order to recieve notification when the -contents of the set change.
              • -
              • ISyncInfoSetChangeEvent: the type of the events generated by a -SyncInfoSet
              • -
              • ISyncInfoTreeChangeEvent: specialized ISyncInfoSetChangeEvent -generated by SyncInfoTree which includes notification of resource -subtree aditions and removals.
              • -
              -

              Sync info filtering

              -

              There are also some additional classes provided to help manage -SyncInfoSets

              -
                -
              • SyncInfoFilter: a filter that can be used to test SyncInfo. Long -running tests are supported via an IProgressMonitor. SyncInfoSet has -API for selecting and rejecting SyncInfo based on a provided filter.
              • -
              • FastSyncInfoFilter: a specialized filter that does not support -the ue of a progress monitor
              • -
              -

              Several common filters are provided as inner classes of the two -filter classes for doing synchronization state tests and filter -compounding (and, or, not).

              -

               

              - - diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java deleted file mode 100644 index 3bda82ad3..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.Policy; - -/** - * An implemenation of IResourceVariantTree that provides the logic for - * refreshing the tree and collecting the results so they can be cached locally. - * This class does not perform the caching but relies on subclasses to do that by - * overriding the setVariant method. The subclass - * {@link ResourceVariantTree} does provide caching. - * - * @see IResourceVariantTree - * @see ResourceVariantTree - * - * @since 3.0 - */ -public abstract class AbstractResourceVariantTree implements IResourceVariantTree { - - /** - * Refreshes the resource variant tree for the specified resources and possibly their descendants, - * depending on the depth. The default implementation of this method invokes - * refresh(IResource, int, IProgressMonitor) for each resource. - * Subclasses may override but should either invoke the above mentioned refresh or - * collectChanges in order to reconcile the resource variant tree. - * @param resources the resources whose variants should be refreshed - * @param depth the depth of the refresh (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param monitor a progress monitor - * @return the array of resources whose corresponding varianst have changed - * @throws TeamException - */ - public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - List changedResources = new ArrayList(); - monitor.beginTask(null, 100 * resources.length); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IResource[] changed = refresh(resource, depth, Policy.subMonitorFor(monitor, 100)); - changedResources.addAll(Arrays.asList(changed)); - } - monitor.done(); - if (changedResources == null) return new IResource[0]; - return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]); - } - - /** - * Helper method invoked from refresh(IResource[], int, IProgressMonitor monitor) - * for each resource. The default implementation performs the following steps: - *
                - *
              1. get the resource variant handle corresponding to the local resource by calling - * getRemoteTree. - *
              2. pass the local resource and the resource variant handle to collectChanges - *
              - * Subclasses may override but should perform roughly the same steps. - * @param resource the resoure being refreshed - * @param depth the depth of the refresh (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param monitor a progress monitor - * @return the resource's whose variants have changed - * @throws TeamException - */ - protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - IResource[] changedResources = null; - monitor.beginTask(null, 100); - try { - monitor.setTaskName(Policy.bind("SynchronizationCacheRefreshOperation.0", resource.getFullPath().makeRelative().toString())); //$NON-NLS-1$ - - // build the remote tree only if an initial tree hasn't been provided - IResourceVariant tree = fetchVariant(resource, depth, Policy.subMonitorFor(monitor, 70)); - - // update the known remote handles - IProgressMonitor sub = Policy.infiniteSubMonitorFor(monitor, 30); - try { - sub.beginTask(null, 64); - changedResources = collectChanges(resource, tree, depth, Policy.subMonitorFor(sub, 64)); - } finally { - sub.done(); - } - } finally { - monitor.done(); - } - if (changedResources == null) return new IResource[0]; - return changedResources; - } - - /** - * Collect the changes in the remote tree to the specified depth. - * @param local the local resource being refreshed - * @param remote the corresponding resource variant - * @param depth the depth of the refresh (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param monitor a progress monitor - * @return the resource's whose variants have changed - * @throws TeamException - */ - protected IResource[] collectChanges(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor) throws TeamException { - List changedResources = new ArrayList(); - collectChanges(local, remote, changedResources, depth, monitor); - return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]); - } - - /** - * Fetch the members of the given resource variant handle. This method may - * return members that were fetched when fetchVariant was called or - * may fetch the children directly (i.e. this method may contact the server). - * @param variant the resource variant - * @param progress a progress monitor - * @return the members of the resource variant. - */ - protected abstract IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException; - - /** - * Fetch the resource variant corresponding to the given resource. The depth - * parameter indicates the depth of the refresh operation and also indicates the - * depth to which the resource variant's desendants will be traversed. - * This method may prefetch the descendants to the provided depth - * or may just return the variant handle corresponding to the given - * local resource, in which case - * the descendant variants will be fetched by fetchMembers(IResourceVariant, IProgressMonitor). - * @param resource the local resource - * @param depth the depth of the refresh (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param monitor a progress monitor - * @return the resource variant corresponding to the given local resource - */ - protected abstract IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException; - - /** - * Method that is invoked during collection to let subclasses know which members - * were collected for the given resource. Implementors should purge any cached - * state for children of the local resource that are no longer members. Any such resources - * should be returned to allow clients to clear any state they maintain for those resources. - * @param local the local resource - * @param members the collected members - * @return any resources that were previously collected whose state has been flushed - */ - protected IResource[] collectedMembers(IResource local, IResource[] members) throws TeamException { - return new IResource[0]; - } - - /** - * Set the variant associated with the local resource to the newly fetched resource - * variant. This method is invoked during change collection and should return whether - * the variant associated with the local resource has changed - * @param local the local resource - * @param remote the newly fetched resoure variant - * @return true if the resource variant changed - * @throws TeamException - */ - protected abstract boolean setVariant(IResource local, IResourceVariant remote) throws TeamException; - - private void collectChanges(IResource local, IResourceVariant remote, Collection changedResources, int depth, IProgressMonitor monitor) throws TeamException { - boolean changed = setVariant(local, remote); - if (changed) { - changedResources.add(local); - } - if (depth == IResource.DEPTH_ZERO) return; - Map children = mergedMembers(local, remote, monitor); - for (Iterator it = children.keySet().iterator(); it.hasNext();) { - IResource localChild = (IResource) it.next(); - IResourceVariant remoteChild = (IResourceVariant)children.get(localChild); - collectChanges(localChild, remoteChild, changedResources, - depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, - monitor); - } - - IResource[] cleared = collectedMembers(local, (IResource[]) children.keySet().toArray(new IResource[children.keySet().size()])); - changedResources.addAll(Arrays.asList(cleared)); - monitor.worked(1); - } - - private Map mergedMembers(IResource local, IResourceVariant remote, IProgressMonitor progress) throws TeamException { - - // {IResource -> IResourceVariant} - Map mergedResources = new HashMap(); - - IResourceVariant[] remoteChildren; - if (remote == null) { - remoteChildren = new IResourceVariant[0]; - } else { - remoteChildren = fetchMembers(remote, progress); - } - - - IResource[] localChildren = members(local); - - if (remoteChildren.length > 0 || localChildren.length > 0) { - Set allSet = new HashSet(20); - Map localSet = null; - Map remoteSet = null; - - if (localChildren.length > 0) { - localSet = new HashMap(10); - for (int i = 0; i < localChildren.length; i++) { - IResource localChild = localChildren[i]; - String name = localChild.getName(); - localSet.put(name, localChild); - allSet.add(name); - } - } - - if (remoteChildren.length > 0) { - remoteSet = new HashMap(10); - for (int i = 0; i < remoteChildren.length; i++) { - IResourceVariant remoteChild = remoteChildren[i]; - String name = remoteChild.getName(); - remoteSet.put(name, remoteChild); - allSet.add(name); - } - } - - Iterator e = allSet.iterator(); - while (e.hasNext()) { - String keyChildName = (String) e.next(); - - Policy.checkCanceled(progress); - - IResource localChild = - localSet != null ? (IResource) localSet.get(keyChildName) : null; - - IResourceVariant remoteChild = - remoteSet != null ? (IResourceVariant) remoteSet.get(keyChildName) : null; - - if (localChild == null) { - // there has to be a remote resource available if we got this far - Assert.isTrue(remoteChild != null); - boolean isContainer = remoteChild.isContainer(); - localChild = getResourceChild(local /* parent */, keyChildName, isContainer); - } - mergedResources.put(localChild, remoteChild); - } - } - return mergedResources; - } - - private IResource getResourceChild(IResource parent, String childName, boolean isContainer) { - if (parent.getType() == IResource.FILE) { - return null; - } - if (isContainer) { - return ((IContainer) parent).getFolder(new Path(null, childName)); - } else { - return ((IContainer) parent).getFile(new Path(null, childName)); - } - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java deleted file mode 100644 index 86c3583f6..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.*; - -/** - * A resource variant is a partial implementation of a remote resource - * whose contents and handle are cached locally. It is assumed that a - * resource variant is an immutable version or revision of a resource. - * Therefore, once the contents are cached they cannot be replaced. - * However, the cached handle can be replaced to allow clients to - * cache addition state or properties for a resource variant. - *

              - * Overriding subclasses need to provide a cache Id for all their resource variants - * and a cache path for each resource variant that uniquely identifies it. In addition, - * they must implement fetchContents to retrieve the contents of the - * resource variant and then call setContents to place these contents in the cache. - * Subclasses may also call cacheHandle in order to place the handle in the - * cache so that it can be retrieved later by calling getCachedHandle on any - * resource variant whose cache path is the same as the cached handle. This allows subclasses to - * cache additional resource variant properties such as author, comment, etc. - *

              - *

              - * The IStorage instance returned by this class will be - * an {@link org.eclipse.core.resources.IEncodedStorage}. - *

              - * The cache in which the resource variants reside will occasionally clear - * cached entries if they have not been accessed for a certain amount of time. - *

              - * - * @since 3.0 - */ -public abstract class CachedResourceVariant extends PlatformObject implements IResourceVariant { - - // holds the storage instance for this resource variant - private IStorage storage; - - /* - * Internal class which provides access to the cached contents - * of this resource variant - */ - class ResourceVariantStorage implements IEncodedStorage { - public InputStream getContents() throws CoreException { - if (!isContentsCached()) { - // The cache may have been cleared if someone held - // on to the storage too long - throw new TeamException(Policy.bind("CachedResourceVariant.0", getCachePath())); //$NON-NLS-1$ - } - return getCachedContents(); - } - public IPath getFullPath() { - return getDisplayPath(); - } - public String getName() { - return CachedResourceVariant.this.getName(); - } - public boolean isReadOnly() { - return true; - } - public Object getAdapter(Class adapter) { - return CachedResourceVariant.this.getAdapter(adapter); - } - public String getCharset() throws CoreException { - InputStream contents = getContents(); - try { - String charSet = TeamPlugin.getCharset(getName(), contents); - return charSet; - } catch (IOException e) { - throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, Policy.bind("CachedResourceVariant.1", getFullPath().toString()), e)); //$NON-NLS-1$ - } finally { - try { - contents.close(); - } catch (IOException e1) { - // Ignore - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#getStorage(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStorage getStorage(IProgressMonitor monitor) throws TeamException { - if (isContainer()) return null; - ensureContentsCached(monitor); - if (storage == null) { - storage = new ResourceVariantStorage(); - } - return storage; - } - - private void ensureContentsCached(IProgressMonitor monitor) throws TeamException { - // Ensure that the contents are cached from the server - if (!isContentsCached()) { - fetchContents(monitor); - } - } - - /** - * Method that is invoked when the contents of the resource variant need to - * be fetched. This method will only be invoked for files (i.e. - * isContainer() returns false. - * Subclasses should override this method and invoke setContents - * with a stream containing the fetched contents. - * @param monitor a progress monitor - */ - protected abstract void fetchContents(IProgressMonitor monitor) throws TeamException; - - /** - * This method should be invoked by subclasses from within their fetchContents - * method in order to cache the contents for this resource variant. - *

              - * This method is not intended to be overridden by clients. - * @param stream the stream containing the contents of the resource variant - * @param monitor a progress monitor - * @throws TeamException - */ - protected void setContents(InputStream stream, IProgressMonitor monitor) throws TeamException { - // Ensure that there is a cache entry to receive the contents - Assert.isTrue(!isContainer()); - if (!isHandleCached()) cacheHandle(); - getCacheEntry().setContents(stream, monitor); - } - - private ResourceVariantCacheEntry getCacheEntry() { - return getCache().getCacheEntry(this.getCachePath()); - } - - /** - * Return whether there are already contents cached for this resource variant. - * This method will return false even if the contents are currently - * being cached by another thread. The consequence of this is that the contents - * may be fetched twice in the rare case where two threads request the same contents - * concurrently. For containers, this method will always return false. - *

              - * This method is not intended to be overridden by clients. - */ - protected boolean isContentsCached() { - if (isContainer() || !isHandleCached()) { - return false; - } - ResourceVariantCacheEntry entry = getCache().getCacheEntry(getCachePath()); - return entry.getState() == ResourceVariantCacheEntry.READY; - } - - /** - * Return the cached contents for this resource variant or null - * if the contents have not been cached. - * For containers, this method will always return null. - *

              - * This method is not intended to be overridden by clients. - * @return the cached contents or null - * @throws TeamException - */ - protected InputStream getCachedContents() throws TeamException { - if (isContainer() || !isContentsCached()) return null; - return getCache().getCacheEntry(getCachePath()).getContents(); - } - - /** - * Return true if the cache contains an entry for this resource - * variant. It is possible that another instance of this variant is cached. - * To get the cached instance, call getCachedHandle(). Note that - * cached contents can be retrieved from any handle to a resource variant whose - * cache path (as returned by getCachePath()) match but other - * state information may only be accessible from the cached copy. - *

              - * This method is not intended to be overridden by clients. - * @return whether the variant is cached - */ - protected boolean isHandleCached() { - return (getCache().hasEntry(getCachePath())); - } - - /** - * Get the path that uniquely identifies the remote resource - * variant. This path descibes the remote location where - * the remote resource is stored and also uniquely identifies - * each resource variant. It is used to uniquely identify this - * resource variant when it is stored in the resource variant cache. - * This path is also returned as the full path of the IStorage - * returned from this variant so the path could be converted to an - * IPath and displayed to the user. - * @return the full path of the remote resource variant - */ - protected abstract String getCachePath(); - - /** - * Return the size (in bytes) of the contents of this resource variant. - * The method will return 0 if the contents have not yet been cached - * locally. - * For containers, this method will always return 0. - */ - public long getSize() { - if (isContainer() || !isContentsCached()) return 0; - ResourceVariantCacheEntry entry = getCacheEntry(); - if (entry == null || entry.getState() != ResourceVariantCacheEntry.READY) { - return 0; - } - return entry.getSize(); - } - - /* - * Return the cache that is used to cache this resource variant and its contents. - * @return Returns the cache. - */ - private ResourceVariantCache getCache() { - ResourceVariantCache.enableCaching(getCacheId()); - return ResourceVariantCache.getCache(getCacheId()); - } - - /** - * Return the ID that uniquely identifies the cache in which this resource variant - * is to be cache. The ID of the plugin that provides the resource variant subclass - * is a good candidate for this ID. The creation, management and disposal of the cache - * is managed by Team. - * @return the cache ID - */ - protected abstract String getCacheId(); - - /** - * Return the cached handle for this resource variant if there is - * one. If there isn't one, then null is returned. - * If there is no cached handle and one is desired, then cacheHandle() - * should be called. - *

              - * This method is not intended to be overridden by clients. - * @return a cached copy of this resource variant or null - */ - protected CachedResourceVariant getCachedHandle() { - ResourceVariantCacheEntry entry = getCacheEntry(); - if (entry == null) return null; - return entry.getResourceVariant(); - } - - /** - * Cache this handle in the cache, replacing any previously cached handle. - * Note that caching this handle will replace any state associated with a - * previously cached handle, if there is one, but the contents will remain. - * The reason for this is the assumption that the cache path for a resource - * variant (as returned by getCachePath() identifies an immutable - * resource version (or revision). The ability to replace the handle itself - * is provided so that additional state may be cached before or after the contents - * are fetched. - *

              - * This method is not intended to be overridden by clients. - */ - protected void cacheHandle() { - getCache().add(getCachePath(), this); - } - - /** - * Return the full path of this resource that should be displayed to the - * user. This path is used by the instabce of IStorage that - * is returned by this instance. By default, the path return by getCachePath() - * is used to create a Path object which is returned by this method. - * Subclasses may override. - * @return the full path of this resource that should be displayed to the - * user - * - * @since 3.1 - */ - public IPath getDisplayPath() { - return new Path(null, getCachePath()); - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java deleted file mode 100644 index d2ac3043c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/** - * This interface is used by SyncInfo instances - * to provide access to the base and remote resources that correspond to - * a local resource. - * - * @see org.eclipse.team.core.synchronize.SyncInfo - * @since 3.0 - */ -public interface IResourceVariant { - - /** - * Answers the name of the remote resource. The name may be - * displayed to the user. - * - * @return name of the resource variant. - */ - public String getName(); - - /** - * Answers if the remote resource may have children. - * - * @return true if the remote resource may have children and - * false otherwise. - */ - public boolean isContainer(); - - /** - * Return an instance of IStorage or null if the remote resource - * does not have contents (i.e. is a folder). Since the ISorage#getContents() - * method does not accept an IProgressMonitor, this method must ensure that the contents - * access by the resulting IStorage is cached locally (hence the IProgressMonitor - * argument to this method). Implementations of this method should - * ensure that the resulting IStorage is accessing locally cached contents and is not - * contacting the server. - *

              - * The returned storage object may be an instance of (@link org.eclipse.core.resources.IEncodedStorage} - * in which case clients can determine the character encoding of the contents. - * - * @return an IStorage that provides access to the contents of - * the remote resource or null if the remote resource is a container. - */ - public IStorage getStorage(IProgressMonitor monitor) throws TeamException; - - /** - * Return a content identifier that is used to differentiate versions - * or revisions of the same resource. - * - * @return a String that identifies the version of the subscriber resource - * @throws TeamException - */ - public String getContentIdentifier(); - - /** - * Return an array of bytes that can be used to uniquely identify this - * resource variant when compared to other resource variants and could - * also potentially be used to recreate a resource variant handle. - * @return the bytes that uniquely identify this resource variant - */ - public byte[] asBytes(); - - /** - * Returns whether the remote resource is equal to the provided object. - * @param object the object to be compared - * @return whether the object is equal to the remote resource - */ - public boolean equals(Object object); - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java deleted file mode 100644 index c39483995..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.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.team.core.variants; - -import org.eclipse.core.resources.IResource; - -/** - * An IResourceVariantComparator is provided by a Subscriber - * and used by a SyncInfo to calculate the sync - * state of the workspace resources. Subscribers should provide a criteria - * best suited for their environment. For example, an FTP subscriber could choose to use file - * size or file timestamps as comparison criterias whereas a CVS workspace subscriber would - * use file revision numbers. - * - * @see org.eclipse.team.core.synchronize.SyncInfo - * @see org.eclipse.team.core.subscribers.Subscriber - * @since 3.0 - */ -public interface IResourceVariantComparator { - - /** - * Returns true if the local resource - * matches the remote resource based on this criteria and false - * otherwise. Comparing should be fast and based on cached information. - * - * @param resource the local resource to be compared - * @param remote the remote resources to be compared - * @return true if local and remote are equal based on this criteria and false - * otherwise. - */ - public boolean compare(IResource local, IResourceVariant remote); - - /** - * Returns true if the base resource - * matches the remote resource based on this criteria and false - * otherwise. Comparing should be fast and based on cached information. - * - * @param base the base resource to be compared - * @param remote the remote resources to be compared - * @return true if base and remote are equal based on this criteria and false - * otherwise. - */ - public boolean compare(IResourceVariant base, IResourceVariant remote); - - /** - * Answers true if the base tree is maintained by this comparator's - * subscriber. If the base tree is not considered than the subscriber can - * be considered as not supported three-way comparisons. Instead - * comparisons are made between the local and remote only without - * consideration for the base. - */ - public boolean isThreeWay(); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java deleted file mode 100644 index f74886e36..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java +++ /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 - *******************************************************************************/ -package org.eclipse.team.core.variants; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/** - * A handle that provides access to locally cached resource variants that - * represent a resource line-up such as a project version or branch. - *

              - * This interface is not intended to be implemented by clients. However, - * clients may subclass {@link AbstractResourceVariantTree} or {@link ResourceVariantTree}. - *

              - * - * @see AbstractResourceVariantTree - * @see ResourceVariantTree - * @since 3.0 - */ -public interface IResourceVariantTree { - - /** - * Returns the list of root resources for which this tree may have resource - * variants. - * @return the list of root resources. - */ - public abstract IResource[] roots(); - - /** - * Returns the members of the local resource that have resource variants in this tree. - * The members may or may not exist locally. The resource variants corresponding to the - * members can be retrieved using getResourceVariant(IResource). - * @param resource the local resource - * @return the members of the local resource for which this tree contains resource variants - * @throws TeamException - */ - public abstract IResource[] members(IResource resource) throws TeamException; - - /** - * Return the resource variant corresponding to the local resource. Return - * null if there is no variant for the resource. - * @param resource the local resource - * @return the resource's variant in this tree - * @throws TeamException - */ - public abstract IResourceVariant getResourceVariant(IResource resource) throws TeamException; - - /** - * Return whether the local resource has a variant in this tree. - * @param resource the local resource - * @return true if the tree contains a variant for the resource - * @throws TeamException - */ - public boolean hasResourceVariant(IResource resource) throws TeamException; - - /** - * Refreshes the resource variant tree for the specified resources and possibly - * their descendants, depending on the depth. - * @param resources the resources whose variants should be refreshed - * @param depth the depth of the refresh (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @param monitor a progress monitor - * @return the array of resources whose corresponding variants have changed - * as a result of the refresh - * @throws TeamException - */ - public IResource[] refresh( - IResource[] resources, - int depth, - IProgressMonitor monitor) throws TeamException; - - /** - * Flush any variants in the tree for the given resource to the depth - * specified. - * @param resource the resource - * @param depth the flush depth (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - */ - public void flushVariants(IResource resource, int depth) throws TeamException; -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java deleted file mode 100644 index ed29b0825..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.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.team.core.variants; - -import org.eclipse.core.resources.IResource; - -/** - * Listener that can receive notification from a ThreeWaySynchronizer - * when the synchronization state of one or more resources has changed. - * @see ThreeWaySynchronizer - * @since 3.0 - */ -public interface ISynchronizerChangeListener { - - /** - * Notification of synchronization state changes for the given resources. - * Clients must query the ThreeWaySynchronizer that generated - * this event to determine the new synchronization state. - * @param resources the resources whose synchronization state has changed - */ - public void syncStateChanged(IResource[] resources); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java deleted file mode 100644 index 681e419c0..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.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.team.core.variants; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Assert; - -/** - * A ResourceVariantByteStore that caches the variant bytes using - * the org.eclipse.core.resources.ISynchronizer so that - * the tree is cached accross workbench invocations. - *

              - * This class is not intended to be subclassed by clients. - * - * @since 3.0 - */ -public class PersistantResourceVariantByteStore extends ResourceVariantByteStore { - - private static final byte[] NO_REMOTE = new byte[0]; - - private QualifiedName syncName; - - /** - * Create a persistant tree that uses the given qualified name - * as the key in the org.eclipse.core.resources.ISynchronizer. - * It must be unique and should use the plugin as the local name - * and a unique id within the plugin as the qualifier name. - * @param name the key used in the Core synchronizer - */ - public PersistantResourceVariantByteStore(QualifiedName name) { - syncName = name; - getSynchronizer().add(syncName); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose() - */ - public void dispose() { - getSynchronizer().remove(getSyncName()); - } - - /** - * Return the qualified name that uniquely identifies this tree. - * @return the qwualified name that uniquely identifies this tree. - */ - public QualifiedName getSyncName() { - return syncName; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#getBytes(org.eclipse.core.resources.IResource) - */ - public byte[] getBytes(IResource resource) throws TeamException { - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes != null && equals(syncBytes, NO_REMOTE)) { - // If it is known that there is no remote, return null - return null; - } - return syncBytes; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#setBytes(org.eclipse.core.resources.IResource, byte[]) - */ - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - Assert.isNotNull(bytes); - byte[] oldBytes = internalGetSyncBytes(resource); - if (oldBytes != null && equals(oldBytes, bytes)) return false; - try { - getSynchronizer().setSyncInfo(getSyncName(), resource, bytes); - return true; - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#flushBytes(org.eclipse.core.resources.IResource, int) - */ - public boolean flushBytes(IResource resource, int depth) throws TeamException { - if (resource.exists() || resource.isPhantom()) { - try { - if (depth != IResource.DEPTH_ZERO || internalGetSyncBytes(resource) != null) { - getSynchronizer().flushSyncInfo(getSyncName(), resource, depth); - return true; - } - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - return false; - } - - /** - * Return whether the resource variant state for this resource is known. - * This is used to differentiate the case where a resource variant has never been fetched - * from the case where the resource variant is known to not exist. In the later - * case, this method returns true while getBytes returns null - * @param resource the local resource - * @return whether the resource variant state for this resource is known - * @throws TeamException - */ - public boolean isVariantKnown(IResource resource) throws TeamException { - return internalGetSyncBytes(resource) != null; - } - - /** - * This method should be invoked by a client to indicate that it is known that - * there is no remote resource associated with the local resource. After this method - * is invoked, isVariantKnown(resource) will return true and - * getBytes(resource) will return null. - * @return true if this changes the remote sync bytes - */ - public boolean deleteBytes(IResource resource) throws TeamException { - return setBytes(resource, NO_REMOTE); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) throws TeamException { - if(resource.getType() == IResource.FILE) { - return new IResource[0]; - } - try { - // Filter and return only resources that have sync bytes in the cache. - IResource[] members = ((IContainer)resource).members(true /* include phantoms */); - List filteredMembers = new ArrayList(members.length); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - if(getBytes(member) != null) { - filteredMembers.add(member); - } - } - return (IResource[]) filteredMembers.toArray(new IResource[filteredMembers.size()]); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - - private ISynchronizer getSynchronizer() { - return ResourcesPlugin.getWorkspace().getSynchronizer(); - } - - private byte[] internalGetSyncBytes(IResource resource) throws TeamException { - try { - return getSynchronizer().getSyncInfo(getSyncName(), resource); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) - throws TeamException { - try { - ResourcesPlugin.getWorkspace().run(runnable, root, 0, monitor); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java deleted file mode 100644 index 82ebe51e5..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.team.core.TeamException; - -/** - * The purpose of a ResourceVariantByteStore is to support the caching of - * the synchronization bytes for the resource variants that represent - * a resource line-up of interest such as a version, baseline or branch. The - * cache stores bytes in order to minimize the memory footprint of the tree. It is the - * reponsibility of the client of this API to cache enough bytes to meaningfully identify - * a resource variant (and possibly create an {@link IResourceVariant} handle from them). - *

              - * The bytes for a resource variant are accessed using the local IResource handle - * that corresponds to the resource variant (using the getBytes method). - * The potential children of a resource variant are also accessed - * by using the local handle that corresponds to the resource variant - * (using the members method). - * - * @since 3.0 - */ -public abstract class ResourceVariantByteStore { - - /** - * Dispose of any cached sync bytes when this cache is no longer needed. - */ - public abstract void dispose(); - - /** - * Return the bytes for the variant corresponding the given local resource. - * A return value of null means that no bytes have been stored - * for the resource variant. It is up to the client to determine whether - * this means that the resource variant does not exist or that it has not been - * fetched or otherwise determined yet. - * @param resource the local resource - * @return the bytes that represent the resource's variant - * @throws TeamException - */ - public abstract byte[] getBytes(IResource resource) throws TeamException; - - /** - * Set the bytes for the variant corresponding the given local resource. - * The bytes should never be null. If it is known that the remote - * does not exist, deleteBytes(IResource) should be used instead. - * If the sync bytes for the remote are stale and should be removed, - * flushBytes(IResouce, int) should be called. - * @param resource the local resource - * @param bytes the bytes that represent the resource's variant - * @return true if the bytes changed - * @throws TeamException - */ - public abstract boolean setBytes(IResource resource, byte[] bytes) throws TeamException; - - /** - * Remove the bytes from the tree for the resource variants corresponding to the - * given local resource and its descendants to the given depth. - * After the bytes are removed, getBytes(resource) will - * return null for the affected resources. - * @param resource the local resource - * @param depth the depth of the operation (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @return true if there were bytes present which were removed - * @throws TeamException - */ - public abstract boolean flushBytes(IResource resource, int depth) throws TeamException; - - /** - * Method called to indicate that it is known that there is no variant associated - * with the local resource. Subclasses may handle this information in different ways. - * The flush(IResource, int) method should be used in the cases - * where a client wishes to remove bytes for other reason. - * @param resource the local resource - * @return true if this changes the bytes for the variant - */ - public abstract boolean deleteBytes(IResource resource) throws TeamException; - - /** - * Return the children of the given resource that have resource variants in this tree. - * @param resource the parent resource - * @return the members who have resource variants in this tree. - */ - public abstract IResource[] members(IResource resource) throws TeamException; - - /** - * Helper method to compare two byte arrays for equality - * @param syncBytes1 the first byte array or null - * @param syncBytes2 the second byte array or null - * @return whetehr the two arrays are equal (i.e. same content) - */ - protected boolean equals(byte[] syncBytes1, byte[] syncBytes2) { - if (syncBytes1 == null) { - return syncBytes2 == null; - } else if (syncBytes2 == null) { - return false; - } - if (syncBytes1.length != syncBytes2.length) return false; - for (int i = 0; i < syncBytes1.length; i++) { - if (syncBytes1[i] != syncBytes2[i]) return false; - } - return true; - } - - /** - * Run the given action which may contain multiple modfications - * to the byte store. By default, the action is run. Subclasses - * may override to obtain scheduling rules or batch deltas (if - * the byte store modifies workspace resources). - * @param root the root resource for all modifications - * @param action the action to perform - * @param monitor a progress monitor. - * @exception CoreException if the operation failed. - * @exception OperationCanceledException if the operation is canceled. - */ - public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { - try { - runnable.run(monitor); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java deleted file mode 100644 index afde6ead2..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/** - * Provides caching for a {@link AbstractResourceVariantTree} using a - * {@link ResourceVariantByteStore}. - * - * @see IResourceVariantTree - * @see AbstractResourceVariantTree - * @see ResourceVariantByteStore - * @since 3.0 - */ -public abstract class ResourceVariantTree extends AbstractResourceVariantTree { - - private ResourceVariantByteStore store; - - /** - * Create a resource variant tree that uses the provided byte store to - * cache the resource variant bytes. - * @param store the resource variant byte store used to cahe resource variants - */ - protected ResourceVariantTree(ResourceVariantByteStore store) { - this.store = store; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantTree#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) throws TeamException { - return getByteStore().members(resource); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantTree#hasResourceVariant(org.eclipse.core.resources.IResource) - */ - public boolean hasResourceVariant(IResource resource) throws TeamException { - return getByteStore().getBytes(resource) != null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantTree#flushVariants(org.eclipse.core.resources.IResource, int) - */ - public void flushVariants(IResource resource, int depth) throws TeamException { - getByteStore().flushBytes(resource, depth); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#setVariant(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant) - */ - protected boolean setVariant(IResource local, IResourceVariant remote) throws TeamException { - ResourceVariantByteStore cache = getByteStore(); - byte[] newRemoteBytes = getBytes(local, remote); - boolean changed; - if (newRemoteBytes == null) { - changed = cache.deleteBytes(local); - } else { - changed = cache.setBytes(local, newRemoteBytes); - } - return changed; - } - - /** - * Get the byte store that is used to cache the serialization bytes - * for the resource variants of this tree. A byte store is used - * to reduce the memory footprint of the tree. - *

              - * This method is not intended to be overriden by subclasses. - * - * @return the resource variant tree that is being refreshed. - */ - protected ResourceVariantByteStore getByteStore() { - return store; - } - - /** - * Get the bytes to be stored in the ResourceVariantByteStore - * from the given resource variant. By default, the IResourceVariant#asBytes() - * method is used to get the bytes. - * @param local the local resource - * @param remote the corresponding resource variant handle - * @return the bytes for the resource variant. - */ - protected byte[] getBytes(IResource local, IResourceVariant remote) throws TeamException { - if (remote == null) return null; - return remote.asBytes(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResource[] collectChanges(final IResource local, - final IResourceVariant remote, final int depth, IProgressMonitor monitor) - throws TeamException { - final IResource[][] resources = new IResource[][] { null }; - getByteStore().run(local, new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - resources[0] = ResourceVariantTree.super.collectChanges(local, remote, depth, monitor); - } - }, monitor); - return resources[0]; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java deleted file mode 100644 index 9fc328115..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.subscribers.SubscriberChangeEvent; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * A specialization of Subscriber that uses IResourceVariantTree objects - * to manage the base (for three-way) and remote trees. Refreshing and obtaining the subscriber - * members and resource variants is delegated to the resource variant trees. - * - * @since 3.0 - */ -public abstract class ResourceVariantTreeSubscriber extends Subscriber { - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#getSyncInfo(org.eclipse.core.resources.IResource) - */ - public SyncInfo getSyncInfo(IResource resource) throws TeamException { - if (!isSupervised(resource)) return null; - IResourceVariant remoteResource = getRemoteTree().getResourceVariant(resource); - IResourceVariant baseResource; - if (getResourceComparator().isThreeWay()) { - baseResource= getBaseTree().getResourceVariant(resource); - } else { - baseResource = null; - } - return getSyncInfo(resource, baseResource, remoteResource); - } - - /** - * Method that creates an instance of SyncInfo for the provided local, base and remote - * resource variants. - * Can be overiden by subclasses. - * @param local the local resource - * @param base the base resource variant or null - * @param remote the remote resource variant or null - * @return the SyncInfo containing the provided resources - */ - protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException { - SyncInfo info = new SyncInfo(local, base, remote, this.getResourceComparator()); - info.init(); - return info; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) throws TeamException { - if(resource.getType() == IResource.FILE) { - return new IResource[0]; - } - try { - Set allMembers = new HashSet(); - try { - allMembers.addAll(Arrays.asList(((IContainer)resource).members())); - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - // The resource is no longer exists so ignore the exception - } else { - throw e; - } - } - allMembers.addAll(Arrays.asList(internalMembers(getRemoteTree(), resource))); - if (getResourceComparator().isThreeWay()) { - allMembers.addAll(Arrays.asList(internalMembers(getBaseTree(), resource))); - } - for (Iterator iterator = allMembers.iterator(); iterator.hasNext();) { - IResource member = (IResource) iterator.next(); - if(!member.exists() && !getRemoteTree().hasResourceVariant(member)) { - // Remove deletion conflicts - iterator.remove(); - } else if (!isSupervised(resource)) { - // Remove unsupervised resources - iterator.remove(); - } - } - return (IResource[]) allMembers.toArray(new IResource[allMembers.size()]); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - monitor = Policy.monitorFor(monitor); - List errors = new ArrayList(); - try { - monitor.beginTask(null, 1000 * resources.length); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IStatus status = refresh(resource, depth, Policy.subMonitorFor(monitor, 1000)); - if (!status.isOK()) { - errors.add(status); - } - } - } finally { - monitor.done(); - } - if (!errors.isEmpty()) { - int numSuccess = resources.length - errors.size(); - throw new TeamException(new MultiStatus(TeamPlugin.ID, 0, - (IStatus[]) errors.toArray(new IStatus[errors.size()]), - Policy.bind("ResourceVariantTreeSubscriber.1", new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)}), null)); //$NON-NLS-1$ - } - } - - /** - * Return the base resource variant tree. - */ - protected abstract IResourceVariantTree getBaseTree(); - - /** - * Return the remote resource variant tree. - */ - protected abstract IResourceVariantTree getRemoteTree(); - - private IStatus refresh(IResource resource, int depth, IProgressMonitor monitor) { - monitor = Policy.monitorFor(monitor); - try { - monitor.beginTask(null, 100); - Set allChanges = new HashSet(); - if (getResourceComparator().isThreeWay()) { - IResource[] baseChanges = getBaseTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 25)); - allChanges.addAll(Arrays.asList(baseChanges)); - } - IResource[] remoteChanges = getRemoteTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 75)); - allChanges.addAll(Arrays.asList(remoteChanges)); - IResource[] changedResources = (IResource[]) allChanges.toArray(new IResource[allChanges.size()]); - fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); - return Status.OK_STATUS; - } catch (TeamException e) { - return new TeamStatus(IStatus.ERROR, TeamPlugin.ID, 0, Policy.bind("ResourceVariantTreeSubscriber.2", resource.getFullPath().toString(), e.getMessage()), e, resource); //$NON-NLS-1$ - } finally { - monitor.done(); - } - } - - private IResource[] internalMembers(IResourceVariantTree tree, IResource resource) throws TeamException, CoreException { - // Filter and return only phantoms associated with the remote synchronizer. - IResource[] members; - try { - members = tree.members(resource); - } catch (CoreException e) { - if (!isSupervised(resource) || e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - // The resource is no longer supervised or doesn't exist in any form - // so ignore the exception and return that there are no members - return new IResource[0]; - } - throw e; - } - return members; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java deleted file mode 100644 index dfffe949c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import java.util.*; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Assert; - -/** - * A ResourceVariantByteStore that caches the variant bytes in memory - * and does not persist them over workbench invocations. - *

              - * This class is not intended to be subclassed by clients. - * - * @since 3.0 - */ -public class SessionResourceVariantByteStore extends ResourceVariantByteStore { - - private static final byte[] NO_REMOTE = new byte[0]; - private Map membersCache = new HashMap(); - - private Map syncBytesCache = new HashMap(); - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#deleteBytes(org.eclipse.core.resources.IResource) - */ - public boolean deleteBytes(IResource resource) throws TeamException { - return flushBytes(resource, IResource.DEPTH_ZERO); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose() - */ - public void dispose() { - syncBytesCache.clear(); - membersCache.clear(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#flushBytes(org.eclipse.core.resources.IResource, int) - */ - public boolean flushBytes(IResource resource, int depth) throws TeamException { - if (getSyncBytesCache().containsKey(resource)) { - if (depth != IResource.DEPTH_ZERO) { - IResource[] members = members(resource); - for (int i = 0; i < members.length; i++) { - IResource child = members[i]; - flushBytes(child, (depth == IResource.DEPTH_INFINITE) ? IResource.DEPTH_INFINITE: IResource.DEPTH_ZERO); - } - } - getSyncBytesCache().remove(resource); - internalRemoveFromParent(resource); - return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#getBytes(org.eclipse.core.resources.IResource) - */ - public byte[] getBytes(IResource resource) throws TeamException { - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes != null && equals(syncBytes, NO_REMOTE)) { - // If it is known that there is no remote, return null - return null; - } - return syncBytes; - } - - /** - * Return true if no bytes are contained in this tree. - * @return true if no bytes are contained in this tree. - */ - public boolean isEmpty() { - return syncBytesCache.isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) { - List members = (List)membersCache.get(resource); - if (members == null) { - return new IResource[0]; - } - return (IResource[]) members.toArray(new IResource[members.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#setBytes(org.eclipse.core.resources.IResource, byte[]) - */ - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - Assert.isNotNull(bytes); - byte[] oldBytes = internalGetSyncBytes(resource); - if (oldBytes != null && equals(oldBytes, bytes)) return false; - internalSetSyncInfo(resource, bytes); - return true; - } - - private Map getSyncBytesCache() { - return syncBytesCache; - } - - private void internalAddToParent(IResource resource) { - IContainer parent = resource.getParent(); - if (parent == null) return; - List members = (List)membersCache.get(parent); - if (members == null) { - members = new ArrayList(); - membersCache.put(parent, members); - } - members.add(resource); - } - - private byte[] internalGetSyncBytes(IResource resource) { - return (byte[])getSyncBytesCache().get(resource); - } - - private void internalRemoveFromParent(IResource resource) { - IContainer parent = resource.getParent(); - List members = (List)membersCache.get(parent); - if (members != null) { - members.remove(resource); - if (members.isEmpty()) { - membersCache.remove(parent); - } - } - } - - private void internalSetSyncInfo(IResource resource, byte[] bytes) { - getSyncBytesCache().put(resource, bytes); - internalAddToParent(resource); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java deleted file mode 100644 index bd84b1903..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/** - * A resource variant tree that caches and obtains its bytes from the remote slot - * in a three-way synchronizer. Clients must subclass to provide remote resource - * variant refresh functionality. - * - * @see ThreeWaySubscriber - * - * @since 3.0 - */ -public abstract class ThreeWayRemoteTree extends ResourceVariantTree { - - private ThreeWaySubscriber subscriber; - - /* - * A resource variant byte store that accesses the remote bytes - * from a three-way synchronizer. Both access and modification - * are supported. - */ - static class RemoteResourceVariantByteStore extends ResourceVariantByteStore { - private ThreeWaySynchronizer synchronizer; - public RemoteResourceVariantByteStore(ThreeWaySynchronizer synchronizer) { - this.synchronizer = synchronizer; - } - public void dispose() { - // Nothing to do as contents are owned by the TargetSynchronizer - } - public byte[] getBytes(IResource resource) throws TeamException { - return getSynchronizer().getRemoteBytes(resource); - } - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - return getSynchronizer().setRemoteBytes(resource, bytes); - } - public boolean flushBytes(IResource resource, int depth) throws TeamException { - // This method is invoked when the remote bytes are stale and should be removed - // This is handled by the ThreeWaySynchronizer so nothing needs to be done here. - return false; - } - public boolean isVariantKnown(IResource resource) throws TeamException { - return getSynchronizer().hasSyncBytes(resource); - } - public boolean deleteBytes(IResource resource) throws TeamException { - return getSynchronizer().removeRemoteBytes(resource); - } - public IResource[] members(IResource resource) throws TeamException { - return synchronizer.members(resource); - } - private ThreeWaySynchronizer getSynchronizer() { - return synchronizer; - } - } - - /** - * Create a remote resource variant tree that stores and obtains - * it's bytes from the remote slot of the synchronizer of the - * given subscriber - * @param subscriber a three-way subscriber - */ - public ThreeWayRemoteTree(ThreeWaySubscriber subscriber) { - super(new RemoteResourceVariantByteStore(subscriber.getSynchronizer())); - this.subscriber = subscriber; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#roots() - */ - public IResource[] roots() { - return getSubscriber().roots(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#getResourceVariant(org.eclipse.core.resources.IResource) - */ - public IResourceVariant getResourceVariant(IResource resource) throws TeamException { - return getSubscriber().getResourceVariant(resource, getByteStore().getBytes(resource)); - } - - /** - * Return the subscriber associated with this resource variant tree. - * @return the subscriber associated with this resource variant tree - */ - protected ThreeWaySubscriber getSubscriber() { - return subscriber; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResource[] collectChanges(final IResource local, - final IResourceVariant remote, final int depth, IProgressMonitor monitor) - throws TeamException { - final IResource[][] resources = new IResource[][] { null }; - getSubscriber().getSynchronizer().run(local, new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - resources[0] = ThreeWayRemoteTree.super.collectChanges(local, remote, depth, monitor); - } - }, monitor); - return resources[0]; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java deleted file mode 100644 index bc8955118..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.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.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * A resource comparator that uses the ThreeWaySynchronizer - * to compare local resources to their resource variants. The local state - * is determined using the local modification state and the remote state - * is determined by comparing the base bytes to the remote bytes obtained - * from the synchronizer. - * - * @since 3.0 - */ -public class ThreeWayResourceComparator implements IResourceVariantComparator { - - private ThreeWaySynchronizer synchronizer; - - /** - * Create a three-way resource comparator that uses the ThreeWaySynchronizer - * to compare a local resource to a resource variant. - * @param synchronizer - */ - public ThreeWayResourceComparator(ThreeWaySynchronizer synchronizer) { - this.synchronizer = synchronizer; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant) - */ - public boolean compare(IResource local, IResourceVariant remote) { - // First, ensure the resources are the same gender - if ((local.getType() == IResource.FILE) == remote.isContainer()) { - return false; - } - try { - // If the file is locally modified, it cannot be in sync - if (local.getType() == IResource.FILE && getSynchronizer().isLocallyModified(local)) { - return false; - } - // If there is no base, the local cannopt match the remote - if (getSynchronizer().getBaseBytes(local) == null) return false; - // Otherwise, assume they are the same if the remote equals the base - return equals(getSynchronizer().getBaseBytes(local), getBytes(remote)); - } catch (TeamException e) { - TeamPlugin.log(e); - return false; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.team.core.variants.IResourceVariant, org.eclipse.team.core.variants.IResourceVariant) - */ - public boolean compare(IResourceVariant base, IResourceVariant remote) { - byte[] bytes1 = getBytes(base); - byte[] bytes2 = getBytes(remote); - return equals(bytes1, bytes2); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#isThreeWay() - */ - public boolean isThreeWay() { - return true; - } - - private ThreeWaySynchronizer getSynchronizer() { - return synchronizer; - } - - private byte[] getBytes(IResourceVariant remote) { - return remote.asBytes(); - } - - private boolean equals(byte[] syncBytes, byte[] oldBytes) { - if (syncBytes.length != oldBytes.length) return false; - for (int i = 0; i < oldBytes.length; i++) { - if (oldBytes[i] != syncBytes[i]) return false; - } - return true; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java deleted file mode 100644 index 7e026a342..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.team.core.Team; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ISubscriberChangeEvent; -import org.eclipse.team.core.subscribers.SubscriberChangeEvent; -import org.eclipse.team.internal.core.TeamPlugin; -import org.eclipse.team.internal.core.subscribers.ThreeWayBaseTree; - -/** - * A resource variant tree subscriber whose trees use an underlying - * ThreeWaySycnrhonizer to store and manage the - * synchronization state for the local workspace. Subclasses need to - * provide a subclass of ThreeWayRemoteTree and a method - * to create resource variant handles from the bytes cached in the - * ThreeWaySynchronizer. - * - * @see ThreeWaySynchronizer - * @see ThreeWayRemoteTree - * @see CachedResourceVariant - * - * @since 3.0 - */ -public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber implements ISynchronizerChangeListener { - - private ThreeWayResourceComparator comparator; - private ThreeWayBaseTree baseTree; - private ThreeWayRemoteTree remoteTree; - private ThreeWaySynchronizer synchronizer; - - /** - * Create a three-way subscriber that uses the given synchronizer - * to manage the synchronization state of local resoures - * and their variants - * @param synchronizer the three-way synchronizer for this subscriber - */ - protected ThreeWaySubscriber(ThreeWaySynchronizer synchronizer) { - this.synchronizer = synchronizer; - baseTree = new ThreeWayBaseTree(this); - getSynchronizer().addListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getBaseTree() - */ - protected final IResourceVariantTree getBaseTree() { - return baseTree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getRemoteTree() - */ - protected final IResourceVariantTree getRemoteTree() { - if (remoteTree == null) { - remoteTree = createRemoteTree(); - } - return remoteTree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#getResourceComparator() - */ - public final IResourceVariantComparator getResourceComparator() { - if (comparator == null) { - comparator = new ThreeWayResourceComparator(this.getSynchronizer()); - } - return comparator; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ISynchronizerChangeListener#syncStateChanged(org.eclipse.core.resources.IResource[]) - */ - public void syncStateChanged(IResource[] resources) { - fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources)); - } - - /** - * Returns false for resources that are not children - * of a subscriber root, are ignored by the subscriber's synchronizer - * or are ignored by the Team.ignoreHist(IResource). Returns - * true otherwise. - * @see org.eclipse.team.core.subscribers.Subscriber#isSupervised(IResource) - */ - public boolean isSupervised(IResource resource) throws TeamException { - if (!isChildOfRoot(resource)) return false; - if (getSynchronizer().isIgnored(resource)) return false; - if (Team.isIgnoredHint(resource)) return false; - return true; - } - - /** - * Return the three-way sychronizer of this subscriber. - * @return the three-way sychronizer of this subscriber. - */ - public ThreeWaySynchronizer getSynchronizer() { - return synchronizer; - } - - /** - * Create the resource variant for the given local resource from the - * given bytes. The bytes are those that were previously returned - * from a call to IResourceVariant#asBytes(). - * @param resource the local resource - * @param bytes the bytes that identify a variant of the resource - * @return the resouce variant handle recreated from the bytes - * @throws TeamException - */ - public abstract IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException; - - /** - * Create the three-way remote tree which provides access to the - * remote bytes in the three-way synchronizer. This method is invoked - * once when the remote tree is first accessed. The returned object is - * cached and reused on subsequent accesses. - * @return the remote tree - */ - protected abstract ThreeWayRemoteTree createRemoteTree(); - - /** - * Convenience method that can be used by subclasses to notify listeners - * when a root is added or removed from the subscriber. The added - * parameter should be true if the root was added and false - * if it was removed. - * @param resource the added or removed root - * @param added true if the root was added and false - * if it was removed. - */ - protected void handleRootChanged(IResource resource, boolean added) { - if (added) { - rootAdded(resource); - } else { - rootRemoved(resource); - } - } - - private void rootAdded(IResource resource) { - SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_ADDED, resource); - fireTeamResourceChange(new SubscriberChangeEvent[] { delta }); - } - - private void rootRemoved(IResource resource) { - try { - getSynchronizer().flush(resource, IResource.DEPTH_INFINITE); - } catch (TeamException e) { - TeamPlugin.log(e); - } - SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, resource); - fireTeamResourceChange(new SubscriberChangeEvent[] { delta }); - } - - private boolean isChildOfRoot(IResource resource) { - IResource[] roots = roots(); - IPath fullPath = resource.getFullPath(); - for (int i = 0; i < roots.length; i++) { - IResource root = roots[i]; - if (root.getFullPath().isPrefixOf(fullPath)) { - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java deleted file mode 100644 index 0e05c9019..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java +++ /dev/null @@ -1,519 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.subscribers.BatchingLock; -import org.eclipse.team.internal.core.subscribers.SyncByteConverter; -import org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation; -import org.eclipse.team.internal.core.subscribers.BatchingLock.ThreadInfo; - -/** - * This class manages the synchronization between local resources and their - * corresponding resource variants. It provides the following: - *

                - *
              • Three way synchronization (set base, set remote, ignored) - *
              • Resource traversal (members) - *
              • Change events and event batching (run) - *
              • Thread-safety - *
              - * - * @since 3.0 - */ -public class ThreeWaySynchronizer implements IFlushOperation { - - private static final byte[] IGNORED_BYTES = "i".getBytes(); //$NON-NLS-1$ - - private ILock lock = Platform.getJobManager().newLock(); - private BatchingLock batchingLock = new BatchingLock(); - private ResourceVariantByteStore cache; - private Set listeners = new HashSet(); - - /** - * Create a three-way synchronizer that uses a persistant - * byte store with the given qualified name as its unique - * identifier. - * @param name the unique identifier for the persistant store - */ - public ThreeWaySynchronizer(QualifiedName name) { - this(new PersistantResourceVariantByteStore(name)); - } - - /** - * Create a three-way synchronizer that uses the given byte store - * as its underlying byte cache. - * @param store the byte store this synchronizer uses to cache its bytes - */ - public ThreeWaySynchronizer(ResourceVariantByteStore store) { - cache = store; - } - - /** - * Adds a listener to this synchronizer. Listeners will be notified - * when the synchronization state of a resource changes. Listeners - * are not notified when files are modified locally. Clients can - * make use of the IResource delta mechanism if they - * need to know about local modifications. - * Has no effect if an identical listener is already registered. - *

              - * Team resource change listeners are informed about state changes - * that affect the resources supervised by this subscriber.

              - * - * @param listener a synchronizer change listener - */ - public void addListener(ISynchronizerChangeListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - /** - * Removes a listener previously registered with this synchronizer. - * Has no affect if an identical listener is not registered. - * - * @param listener a synchronizer change listener - */ - public void removeListener(ISynchronizerChangeListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - /** - * Return the base bytes that are cached for the given resource - * or null if no base is cached. The returned bytes - * should uniquely identify the resource variant that is the base - * for the given local resource. - * - * @param resource the resource - * @return the base bytes cached with the resource or null - * @throws TeamException - */ - public byte[] getBaseBytes(IResource resource) throws TeamException { - try { - beginOperation(); - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes == null) return null; - byte[] baseBytes = getSlot(syncBytes, 1); - if (baseBytes == null || baseBytes.length == 0) return null; - return baseBytes; - } finally { - endOperation(); - } - } - - /** - * Set the base bytes for the given resource. The provided bytes - * should encode enough information to uniquely identify - * (and possibly recreate) the resource variant that is the base - * for the given local resource. In essence, setting the base - * bytes is equivalent to marking the file as in-sync. As such, - * setting the base bytes will also set the remote bytes and mark - * the file as clean (i.e. having no outgoing changes). - * - * @param resource the resource - * @param baseBytes the base bytes that identify the base resource variant - * @throws TeamException - */ - public void setBaseBytes(IResource resource, byte[] baseBytes) throws TeamException { - Assert.isNotNull(baseBytes); - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - String base = new String(baseBytes); - String[] slots = new String[] { - new Long(resource.getModificationStamp()).toString(), - base, - base - }; - byte[] syncBytes = toBytes(slots); - internalSetSyncBytes(resource, syncBytes); - batchingLock.resourceChanged(resource); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Return whether the local resource has been modified since the last time - * the base bytes were set. This method will return false - * for ignored resources and true for non-existant resources - * that have base bytes cached. - * @param resource the resource - * @return true if the resource has been modified since the - * last time the base bytes were set. - * @throws TeamException - */ - public boolean isLocallyModified(IResource resource) throws TeamException { - return ((internalGetSyncBytes(resource) == null && ! isIgnored(resource)) || - (getLocalTimestamp(resource) != resource.getModificationStamp()) || - (getBaseBytes(resource) != null && !resource.exists())); - } - - /** - * Return the remote bytes that are cached for the given resource - * or null if no remote is cached. The returned bytes - * should uniquely identify the resource variant that is the remote - * for the given local resource. - * - * @param resource the resource - * @return the remote bytes cached with the resource or null - * @throws TeamException - */ - public byte[] getRemoteBytes(IResource resource) throws TeamException { - try { - beginOperation(); - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes == null) return null; - byte[] remoteBytes = getSlot(syncBytes, 2); - if (remoteBytes == null || remoteBytes.length == 0) return null; - return remoteBytes; - } finally { - endOperation(); - } - } - - /** - * Set the remote bytes for the given resource. The provided bytes - * should encode enough information to uniquely identify - * (and possibly recreate) the resource variant that is the remote - * for the given local resource. If the remote for a resource - * no longer exists, removeRemoteBytes(IResource) - * should be called. - * - * @param resource the resource - * @param remoteBytes the base bytes that identify the remote resource variant - * @return true if the remote bytes changed as a result of the set - * @throws TeamException - */ - public boolean setRemoteBytes(IResource resource, byte[] remoteBytes) throws TeamException { - Assert.isNotNull(remoteBytes); - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes == null) { - String[] slots = new String[] { - "", //$NON-NLS-1$ - "", //$NON-NLS-1$ - new String(remoteBytes) - }; - syncBytes = toBytes(slots); - } else { - byte[] currentRemote = getSlot(syncBytes, 2); - if (equals(remoteBytes, currentRemote)) return false; - syncBytes = setSlot(syncBytes, 2, remoteBytes); - } - internalSetSyncBytes(resource, syncBytes); - batchingLock.resourceChanged(resource); - return true; - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Remove the remote bytes associated with the resource. This is typically - * done when the corresponding remote resource variant no longer exists. - * @param resource the resource - * @return true if the remote bytes changed as a result of the removal - * @throws TeamException - */ - public boolean removeRemoteBytes(IResource resource) throws TeamException { - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes != null) { - String currentRemote = new String(getSlot(syncBytes, 2)); - if (currentRemote.length() == 0) return false; - syncBytes = setSlot(syncBytes, 2, new byte[0]); - internalSetSyncBytes(resource, syncBytes); - batchingLock.resourceChanged(resource); - return true; - } - return false; - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Return whether the given resource has sync bytes in the synchronizer. - * @param resource the local resource - * @return whether there are sync bytes cached for the local resources. - */ - public boolean hasSyncBytes(IResource resource) throws TeamException { - return internalGetSyncBytes(resource) != null; - } - - /** - * Returns whether the resource has been marked as ignored - * using setIgnored(IResource). - * @param resource the resource - * @return true if the resource is ignored. - * @throws TeamException - */ - public boolean isIgnored(IResource resource) throws TeamException { - byte[] bytes = cache.getBytes(resource); - return (bytes != null && equals(bytes, IGNORED_BYTES)); - } - - /** - * Mark the resource as being ignored. Ignored resources - * are not returned by the members method, - * are never dirty (see isLocallyModified) and - * do not have base or remote bytes cahced for them. - * @param resource the resource to be ignored - * @throws TeamException - */ - public void setIgnored(IResource resource) throws TeamException { - internalSetSyncBytes(resource, IGNORED_BYTES); - } - - /** - * Return the members of the local resource that either have sync bytes - * or exist locally and are not ignored. - * @param resource the local resource - * @return the children of the local resource that have cached sync bytes - * or are not ignored - * @throws TeamException - */ - public IResource[] members(IResource resource) throws TeamException { - if (resource.getType() == IResource.FILE) { - return new IResource[0]; - } - try { - Set potentialChildren = new HashSet(); - IContainer container = (IContainer)resource; - if (container.exists()) { - potentialChildren.addAll(Arrays.asList(container.members())); - } - potentialChildren.addAll(Arrays.asList(cache.members(resource))); - List result = new ArrayList(); - for (Iterator iter = potentialChildren.iterator(); iter.hasNext();) { - IResource child = (IResource) iter.next(); - if (child.exists() || hasSyncBytes(child)) { - result.add(child); - } - } - return (IResource[]) result.toArray(new IResource[result.size()]); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } - - /** - * Flush any cached bytes for the given resource to the depth specified. - * @param resource the resource - * @param depth the depth of the flush (one of IResource.DEPTH_ZERO, - * IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE) - * @throws TeamException - */ - public void flush(IResource resource, int depth) throws TeamException { - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - if (cache.flushBytes(resource, depth)) { - batchingLock.resourceChanged(resource); - } - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Perform multiple sync state modifications and fire only a single change notification - * at the end. - * @param resourceRule the scheduling rule that encompasses all modifications - * @param runnable the runnable that performs the sync state modifications - * @param monitor a progress monitor - * @throws TeamException - */ - public void run(IResource resourceRule, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ISchedulingRule rule = beginBatching(resourceRule, Policy.subMonitorFor(monitor, 10)); - try { - cache.run(resourceRule, runnable, Policy.subMonitorFor(monitor, 80)); - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - } - - /* (non-Javadoc) - * - * Callback which is invoked when the batching resource lock is released - * or when a flush is requested (see beginBatching(IResource)). - * - * @see org.eclipse.team.internal.ftp.deployment.BatchingLock.IFlushOperation#flush(org.eclipse.team.internal.ftp.deployment.BatchingLock.ThreadInfo, org.eclipse.core.runtime.IProgressMonitor) - */ - public void flush(ThreadInfo info, IProgressMonitor monitor) throws TeamException { - if (info != null && !info.isEmpty()) { - broadcastSyncChanges(info.getChangedResources()); - } - } - - private void broadcastSyncChanges(final IResource[] resources) { - ISynchronizerChangeListener[] allListeners; - // Copy the listener list so we're not calling client code while synchronized - synchronized(listeners) { - allListeners = (ISynchronizerChangeListener[]) listeners.toArray(new ISynchronizerChangeListener[listeners.size()]); - } - // Notify the listeners safely so all will receive notification - for (int i = 0; i < allListeners.length; i++) { - final ISynchronizerChangeListener listener = allListeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in Platform#run - } - public void run() throws Exception { - listener.syncStateChanged(resources); - - } - }); - } - } - - /* - * Return the cached sync bytes for the given resource. - * The value null is returned if there is no - * cached bytes or if the resource is ignored. - */ - private byte[] internalGetSyncBytes(IResource resource) throws TeamException { - byte[] bytes = cache.getBytes(resource); - if (bytes != null && equals(bytes, IGNORED_BYTES)) return null; - return bytes; - } - - /* - * Set the cached sync bytes - */ - private boolean internalSetSyncBytes(IResource resource, byte[] syncBytes) throws TeamException { - return cache.setBytes(resource, syncBytes); - } - - private byte[] getSlot(byte[] syncBytes, int i) { - return SyncByteConverter.getSlot(syncBytes, i, false); - } - - private byte[] setSlot(byte[] syncBytes, int i, byte[] insertBytes) throws TeamException { - return SyncByteConverter.setSlot(syncBytes, i, insertBytes); - } - - private byte[] toBytes(String[] slots) { - return SyncByteConverter.toBytes(slots); - } - - private long getLocalTimestamp(IResource resource) throws TeamException { - try { - beginOperation(); - byte[] syncBytes = internalGetSyncBytes(resource); - if (syncBytes == null) return 0; - byte[] bytes = getSlot(syncBytes, 0); - if (bytes == null || bytes.length == 0) return 0; - return Long.parseLong(new String(bytes)); - } finally { - endOperation(); - } - } - - private boolean equals(byte[] syncBytes, byte[] oldBytes) { - if (syncBytes.length != oldBytes.length) return false; - for (int i = 0; i < oldBytes.length; i++) { - if (oldBytes[i] != syncBytes[i]) return false; - } - return true; - } - - /* - * Begin an access to the internal data structures of the synchronizer - */ - private void beginOperation() { - // Do not try to acquire the lock if the resources tree is locked - // The reason for this is that during the resource delta phase (i.e. when the tree is locked) - // the workspace lock is held. If we obtain our lock, there is - // a chance of dealock. It is OK if we don't as we are still protected - // by scheduling rules and the workspace lock. - if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; - lock.acquire(); - } - - /* - * End an access to the internal data structures of the synchronizer - */ - private void endOperation() { - // See beginOperation() for a description of why the lock is not obtained when the tree is locked - if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; - lock.release(); - } - - /* - * Begins a batch of operations in order to batch event changes. - * The provided scheduling rule indicates the resources - * that the resources affected by the operation while the returned scheduling rule - * is the rule obtained by the lock. It may differ from the provided rule. - */ - private ISchedulingRule beginBatching(ISchedulingRule resourceRule, IProgressMonitor monitor) { - return batchingLock.acquire(resourceRule, this /* IFlushOperation */, monitor); - } - - /* - * Ends a batch of operations. The provided rule must be the one that was returned - * by the corresponding call to beginBatching. - */ - private void endBatching(ISchedulingRule rule, IProgressMonitor monitor) throws TeamException { - batchingLock.release(rule, monitor); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/package.html b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/package.html deleted file mode 100644 index 0b1e91c13..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/package.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - Package-level Javadoc - - -Application programming interfaces for accessing and managing resource variants. -

              Package Specification

              -

              This package specifies the API for accessing and managing variants for local - workspace resources. The classes in this package can be used by Subscribers - (see the org.eclipse.team.core.subscribers package) or others. The classes are - roughly divided into three categories:
              -

              -

              Access to Resource Variants

              -

              The following interfaces define the API required for subscribers to access - and manage variants of local resources.

              -
                -
              • IResourceVariant: provides access to information about a variant resource, - such as it's name, its type (file or container) and its contents.
              • -
              • IResourceVariantComparator: supports the comparison of a local resource - with a variant or the comparison of two variants (if three-way comparison - is supported).
              • -
              • IResourceVariantTree: provides access to a tree of locally cached resource - variants along with API to refresh the cached variants.
              • -
              -

              Implementing Resource Variants

              -

              Several classes are available that provide partial, extandable implementations - of the above mentioned interfaces.

              -
                -
              • CachedResourceVariant: an IResourceVariant implementation that supports - the caching of the contents of the variant. Subclasses must override to provide - fecthing of contents.
              • -
              • AbstractResourceVariantTree: an IResourceVariantTree that contains logic - for performing a refresh of the cached resource variants. The caching mechanism - is delegated to subclasses as is the fetching of the resource variants. -
                  -
                • ResourceVariantTree: An AbstractResourceVariantTree that uses a ResourceVariantByteStore - to cache the resource variants. Subclasses must still provide the fecthing - of the remote state.
                • -
                -
              • -
              • ResourceVariantByteStore: An abstract class that defines the API required - for caching resource variants as byte arrays. -
                  -
                • PersistantResourceVariantByteStore: a ResourceVariantByteStore that - persists the bytes accross workbench invocations.
                • -
                • SessionResourceVariantByteStore: a ResourceVariantByteStore that caches - the bytes in a session store and does not persist them.
                • -
                -
              • -
              -

              Implementing Subscribers

              -

              This package also contains two partial subscriber implementations.

              -
                -
              • ResourceVariantTreeSubscriber: a subscriber that makes use of IResourceVariantTree - objects to provide the traversal and refresh of the base and remote trees.
              • -
              • ThreeWaySubscriber: a ResourceVariantTreeSubscriber that is build on top - of the following classes. -
                  -
                • ThreeWaySynchronizer: a byte store that maintains the complete synchronization - state (local, base and remote) required by a subscriber. It provides API - to access and set the base and remote bytes corresponding to resource - variants as well as change notification to registered ISynchronizerChangeListener - instances.
                • -
                • ThreeWayRemoteTree: A remote tree that uses the ThreeWaySynchronizer - remote slot as its byte store. Subclasses of ResourceVariantTreeSubscriber - must also subclass ThreeWayRemoteTree in order to provide the tree refresh - behavior.
                • -
                • ThreeWayResourceComparator: a IResourceVariantComparator that uses the - state from a ThreeWaySynchronizer to compare local resources to their - variants.
                • -
                -
              • -
              -

               

              - - diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Assert.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Assert.java deleted file mode 100644 index 50dbb156e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Assert.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - - -public final class Assert { - public static class AssertionFailedException extends RuntimeException { - // Field required to avoid compiler warning - private static final long serialVersionUID = -3361573629971779153L; - public AssertionFailedException() { - } - public AssertionFailedException(String detail) { - super(Policy.bind("Assert.assertionFailed", detail)); //$NON-NLS-1$ - } - } -/* This class is not intended to be instantiated. */ -private Assert() { -} -/** Asserts that an argument is legal. If the given boolean is - * not true, an IllegalArgumentException - * is thrown. - * - * @param expression the outcode of the check - * @return true if the check passes (does not return - * if the check fails) - * @exception IllegalArgumentException if the legality test failed - */ -public static boolean isLegal(boolean expression) { - return isLegal(expression, ""); //$NON-NLS-1$ -} -/** Asserts that an argument is legal. If the given boolean is - * not true, an IllegalArgumentException - * is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param expression the outcode of the check - * @param message the message to include in the exception - * @return true if the check passes (does not return - * if the check fails) - * @exception IllegalArgumentException if the legality test failed - */ -public static boolean isLegal(boolean expression, String message) { - if (!expression) - throw new IllegalArgumentException(message); - return expression; -} -/** Asserts that the given object is not null. If this - * is not the case, some kind of unchecked exception is thrown. - * - * @param object the value to test - * @exception IllegalArgumentException if the object is null - */ -public static void isNotNull(Object object) { - if (object == null) - throw new AssertionFailedException("null argument"); //$NON-NLS-1$ -} -/** Asserts that the given object is not null. If this - * is not the case, some kind of unchecked exception is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param object the value to test - * @param message the message to include in the exception - * @exception IllegalArgumentException if the object is null - */ -public static void isNotNull(Object object, String message) { - if (object == null) - throw new AssertionFailedException("null argument:" /*non NLS*/ + message); //$NON-NLS-1$ -} -/** Asserts that the given boolean is true. If this - * is not the case, some kind of unchecked exception is thrown. - * - * @param expression the outcode of the check - * @return true if the check passes (does not return - * if the check fails) - */ -public static boolean isTrue(boolean expression) { - return isTrue(expression, ""/*nonNLS*/); //$NON-NLS-1$ -} -/** Asserts that the given boolean is true. If this - * is not the case, some kind of unchecked exception is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param expression the outcode of the check - * @param message the message to include in the exception - * @return true if the check passes (does not return - * if the check fails) - */ -public static boolean isTrue(boolean expression, String message) { - if (!expression) - throw new AssertionFailedException("assert failed:" /*non NLS*/ + message); //$NON-NLS-1$ - return expression; -} -/** - * Indicates that the caller has not implemented the method. - * Usually this is a temporary condition. - */ -public static void notYetImplemented() { -} -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java deleted file mode 100644 index 628fc8bbd..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java +++ /dev/null @@ -1,429 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.team.core.TeamException; - -/** - * This class provides the infrastucture for processing/dispatching of events using a - * background job. This is useful in the following situations. - *
                - *
              • an operation is potentially long running but a resposive UI is desired - * while the operation is being performed.
              • - *
              • a change is a POST_CHANGE delta requires further modifications to the workspace - * which cannot be performed in the delta handler because the workspace is locked.
              • - *
              • a data structure is not thread safe and requires serialized operations.
              • - *
              - *

              - * @since 3.0 - */ -public abstract class BackgroundEventHandler { - - // Events that need to be processed - private List awaitingProcessing = new ArrayList(); - - // The job that runs when events need to be processed - private Job eventHandlerJob; - - // Indicate if the event handler has been shutdown - private boolean shutdown; - - // Accumulate exceptions that occur - private ExceptionCollector errors; - - // time the last dispath occured - private long timeOfLastDispatch = 0L; - - // the number of dispatches that have occurred since the job started - private int dispatchCount; - - // time between event dispatches - private static final long DISPATCH_DELAY = 1500; - - // time between dispatches if the dispatch threshoild has been exceeded - private static final long LONG_DISPATCH_DELAY = 10000; - - // the numbver of dispatches that can occur before using the long delay - private static final int DISPATCH_THRESHOLD = 3; - - // time to wait for messages to be queued - private static final long WAIT_DELAY = 1000; - - private String jobName; - - /** - * General event class. The type is specific to subclasses. - */ - public static class Event { - private int type; - public Event(int type) { - this.type = type; - } - public int getType() { - return type; - } - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("Background Event: "); //$NON-NLS-1$ - buffer.append(getTypeString()); - return buffer.toString(); - } - public IResource getResource() { - return null; - } - protected String getTypeString() { - return String.valueOf(type); - } - } - - /** - * Resource event class. The type is specific to subclasses. - */ - public static class ResourceEvent extends Event { - private IResource resource; - private int depth; - public ResourceEvent(IResource resource, int type, int depth) { - super(type); - this.resource = resource; - this.depth = depth; - } - public int getDepth() { - return depth; - } - public IResource getResource() { - return resource; - } - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("resource: "); //$NON-NLS-1$ - buffer.append(resource.getFullPath()); - buffer.append(" type: "); //$NON-NLS-1$ - buffer.append(getTypeString()); - buffer.append(" depth: "); //$NON-NLS-1$ - buffer.append(getDepthString()); - return buffer.toString(); - } - protected String getDepthString() { - switch (depth) { - case IResource.DEPTH_ZERO : - return "DEPTH_ZERO"; //$NON-NLS-1$ - case IResource.DEPTH_ONE : - return "DEPTH_ONE"; //$NON-NLS-1$ - case IResource.DEPTH_INFINITE : - return "DEPTH_INFINITE"; //$NON-NLS-1$ - default : - return "INVALID"; //$NON-NLS-1$ - } - } - } - - protected BackgroundEventHandler(String jobName, String errorTitle) { - this.jobName = jobName; - errors = - new ExceptionCollector( - errorTitle, - TeamPlugin.ID, - IStatus.ERROR, - null /* don't log */ - ); - createEventHandlingJob(); - schedule(); - } - - /** - * Create the job used for processing the events in the queue. The job stops working when - * the queue is empty. - */ - protected void createEventHandlingJob() { - eventHandlerJob = new Job(getName()) { - public IStatus run(IProgressMonitor monitor) { - return processEvents(monitor); - } - public boolean shouldRun() { - return ! isQueueEmpty(); - } - public boolean shouldSchedule() { - return ! isQueueEmpty(); - } - public boolean belongsTo(Object family) { - return family == getJobFamiliy(); - } - }; - eventHandlerJob.addJobChangeListener(new JobChangeAdapter() { - public void done(IJobChangeEvent event) { - jobDone(event); - } - }); - eventHandlerJob.setSystem(true); - eventHandlerJob.setPriority(Job.SHORT); - } - - /** - * Return the family that the background job for this - * event handler belongs to. - * @return the family that the background job for this - * event handler belongs to - */ - protected Object getJobFamiliy() { - return null; - } - - /** - * This method is invoked when the processing job completes. The - * default behavior of the handler is to restart the job if the queue - * is no longer empty and to clear the queue if the handler was shut down. - */ - protected void jobDone(IJobChangeEvent event) { - if (isShutdown()) { - // The handler has been shutdown. Clean up the queue. - synchronized(this) { - awaitingProcessing.clear(); - } - } else if (! isQueueEmpty()) { - // An event squeaked in as the job was finishing. Reschedule the job. - schedule(); - } - } - - /** - * Schedule the job to process the events now. - */ - protected void schedule() { - eventHandlerJob.schedule(); - } - - /** - * Shutdown the event handler. Any events on the queue will be removed from the queue - * and will not be processed. - */ - public void shutdown() { - shutdown = true; - eventHandlerJob.cancel(); - } - - /** - * Returns whether the handle has been shutdown. - * @return Returns whether the handle has been shutdown. - */ - public boolean isShutdown() { - return shutdown; - } - - /** - * Queue the event and start the job if it's not already doing work. If the job is - * already running then notify in case it was waiting. - * @param event the event to be queued - */ - protected synchronized void queueEvent(Event event, boolean front) { - if (Policy.DEBUG_BACKGROUND_EVENTS) { - System.out.println("Event queued on " + getName() + ":" + event.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - } - if (front) { - awaitingProcessing.add(0, event); - } else { - awaitingProcessing.add(event); - } - if (!isShutdown() && eventHandlerJob != null) { - if(eventHandlerJob.getState() == Job.NONE) { - schedule(); - } else { - notify(); - } - } - } - - /** - * Return the name that is to be associated with the background job. - * @return the job name - */ - protected String getName() { - return jobName; - } - - /* - * Return the next event that has been queued, removing it from the queue. - * @return the next event in the queue - */ - protected synchronized Event nextElement() { - if (isShutdown() || isQueueEmpty()) { - return null; - } - return (Event) awaitingProcessing.remove(0); - } - - protected synchronized Event peek() { - if (isShutdown() || isQueueEmpty()) { - return null; - } - return (Event) awaitingProcessing.get(0); - } - - /** - * Return whether there are unprocessed events on the event queue. - * @return whether there are unprocessed events on the queue - */ - protected synchronized boolean isQueueEmpty() { - return awaitingProcessing.isEmpty(); - } - - /** - * Process events from the events queue and dispatch results. This method does not - * directly check for or handle cancelation of the provided monitor. However, - * it does invoke processEvent(Event) which may check for and handle - * cancelation by shuting down the receiver. - *

              - * The isReadyForDispatch() method is used in conjuntion - * with the dispatchEvents(IProgressMonitor) to allow - * the output of the event handler to be batched in order to avoid - * fine grained UI updating. - * @param monitor a progress monitor - */ - protected IStatus processEvents(IProgressMonitor monitor) { - errors.clear(); - try { - // It's hard to know how much work is going to happen - // since the queue can grow. Use the current queue size as a hint to - // an infinite progress monitor - monitor.beginTask(null, IProgressMonitor.UNKNOWN); - IProgressMonitor subMonitor = Policy.infiniteSubMonitorFor(monitor, 90); - subMonitor.beginTask(null, 1024); - - Event event; - timeOfLastDispatch = System.currentTimeMillis(); - dispatchCount = 1; - while ((event = nextElement()) != null && ! isShutdown()) { - try { - processEvent(event, subMonitor); - if (Policy.DEBUG_BACKGROUND_EVENTS) { - System.out.println("Event processed on " + getName() + ":" + event.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - } - if(isReadyForDispatch(true /*wait if queue is empty*/)) { - dispatchEvents(Policy.subMonitorFor(subMonitor, 1)); - } - } catch (CoreException e) { - // handle exception but keep going - handleException(e); - } - } - } finally { - monitor.done(); - } - return errors.getStatus(); - } - - /** - * Dispatch any accumulated events by invoking doDispatchEvents - * and then rest the dispatch counters. - * @param monitor a progress monitor - * @throws TeamException - */ - protected final void dispatchEvents(IProgressMonitor monitor) throws TeamException { - if (doDispatchEvents(monitor)) { - // something was dispatched so adjust dispatch count. - dispatchCount++; - } - timeOfLastDispatch = System.currentTimeMillis(); - } - - /** - * Notify clients of processed events. - * @param monitor a progress monitor - */ - protected abstract boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException; - - /** - * Returns true if processed events should be dispatched and - * false otherwise. Events are dispatched at regular intervals - * to avoid fine grain events causing the UI to be too jumpy. Also, if the - * events queue is empty we will wait a small amount of time to allow - * pending events to be queued. The queueEvent notifies when events are - * queued. - * @return true if processed events should be dispatched and - * false otherwise - */ - protected boolean isReadyForDispatch(boolean wait) { - long duration = System.currentTimeMillis() - timeOfLastDispatch; - if((dispatchCount < DISPATCH_THRESHOLD && duration >= getShortDispatchDelay()) || - duration >= getLongDispatchDelay()) { - return true; - } - synchronized(this) { - if(! isQueueEmpty() || ! wait) { - return false; - } - try { - wait(WAIT_DELAY); - } catch (InterruptedException e) { - // just continue - } - } - return isQueueEmpty(); - } - - /** - * Return the value that is used to determine how often - * the events are dispatched (i.e. how often the UI is - * updated) for the first 3 cycles. The default value is 1.5 seconds. - * After the first 3 cycles, a longer delay is used - * @return the dispatch delay used for the first 3 cycles. - */ - protected long getShortDispatchDelay() { - return DISPATCH_DELAY; - } - - /** - * Return the value that is used to determine how often - * the events are dispatched (i.e. how often the UI is - * updated) after the first 3 cycles. The default value is 10 seconds. - * @return the dispatch delay used after the first 3 cycles. - */ - protected long getLongDispatchDelay() { - return LONG_DISPATCH_DELAY; - } - - /** - * Handle the exception by recording it in the errors list. - * @param e - */ - protected void handleException(CoreException e) { - errors.handleException(e); - } - - /** - * Process the event in the context of a running background job. Subclasses may - * (but are not required to) check the provided monitor for cancelation and shut down the - * receiver by invoking the shutdown() method. - *

              - * In many cases, a background event handler will translate incoming events into outgoing - * events. If this is the case, the handler should accumulate these events in the - * proceessEvent method and propogate them from the dispatchEvent - * method which is invoked periodically in order to batch outgoing events and avoid - * the UI becoming too jumpy. - * - * @param event the Event to be processed - * @param monitor a progress monitor - */ - protected abstract void processEvent(Event event, IProgressMonitor monitor) throws CoreException; - - /** - * Return the job from which the processedEvent method is invoked. - * @return Returns the background event handlig job. - */ - public Job getEventHandlerJob() { - return eventHandlerJob; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java deleted file mode 100644 index 7979cb149..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -public class DefaultFileModificationValidator implements IFileModificationValidator { - - /* - * A validator plugged in the the Team UI that will prompt - * the user to make read-only files writtable. In the absense of - * this validator, edit/save fail on read-only files. - */ - private IFileModificationValidator uiValidator; - - private IStatus getDefaultStatus(IFile file) { - return - file.isReadOnly() - ? new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.READ_ONLY_LOCAL, Policy.bind("FileModificationValidator.fileIsReadOnly", file.getFullPath().toString()), null) //$NON-NLS-1$ - : Status.OK_STATUS; - } - - /** - * @see IFileModificationValidator#validateEdit(IFile[], Object) - */ - public IStatus validateEdit(IFile[] files, Object context) { - IFile[] readOnlyFiles = getReadOnly(files); - if (readOnlyFiles.length == 0) - return Status.OK_STATUS; - synchronized (this) { - if (uiValidator == null) - uiValidator = loadUIValidator(); - } - if (uiValidator != null) { - return uiValidator.validateEdit(files, context); - } - // There was no plugged in validator so fail gracefully - return getStatus(files); - } - - protected IStatus getStatus(IFile[] files) { - if (files.length == 1) { - return getDefaultStatus(files[0]); - } - - IStatus[] stati = new Status[files.length]; - boolean allOK = true; - - for (int i = 0; i < files.length; i++) { - stati[i] = getDefaultStatus(files[i]); - if(! stati[i].isOK()) - allOK = false; - } - - return new MultiStatus(TeamPlugin.ID, - 0, stati, - Policy.bind( - allOK - ? "FileModificationValidator.ok" //$NON-NLS-1$ - : "FileModificationValidator.someReadOnly" ), //$NON-NLS-1$ - null); - } - - private IFile[] getReadOnly(IFile[] files) { - List result = new ArrayList(files.length); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - if (file.isReadOnly()) { - result.add(file); - } - } - return (IFile[]) result.toArray(new IFile[result.size()]); - } - - /** - * @see IFileModificationValidator#validateSave(IFile) - */ - public IStatus validateSave(IFile file) { - return getDefaultStatus(file); - } - - private IFileModificationValidator loadUIValidator() { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.DEFAULT_FILE_MODIFICATION_VALIDATOR_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - if (extensions.length > 0) { - IConfigurationElement[] configElements = extensions[0].getConfigurationElements(); - if (configElements.length > 0) { - try { - Object o = configElements[0].createExecutableExtension("class"); //$NON-NLS-1$ - if (o instanceof IFileModificationValidator) { - return (IFileModificationValidator)o; - } - } catch (CoreException e) { - TeamPlugin.log(e); - } - } - } - } - return null; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultMoveDeleteHook.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultMoveDeleteHook.java deleted file mode 100644 index 18dc39d63..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultMoveDeleteHook.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.resources.team.IResourceTree; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A class which provides the default behavior for resource deletions and moves. - * This class can be overridden by providers to change some or all of the behavior - * related to resources deletions or moves. - * - * @see org.eclipse.team.core.ResourceProvider#getMoveDeleteHook() - */ - -public class DefaultMoveDeleteHook implements IMoveDeleteHook { - - /** - * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor) - */ - public boolean deleteFile( - IResourceTree tree, - IFile file, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - - /** - * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor) - */ - public boolean deleteFolder( - IResourceTree tree, - IFolder folder, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - - /** - * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor) - */ - public boolean deleteProject( - IResourceTree tree, - IProject project, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - - /** - * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor) - */ - public boolean moveFile( - IResourceTree tree, - IFile source, - IFile destination, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - - /** - * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor) - */ - public boolean moveFolder( - IResourceTree tree, - IFolder source, - IFolder destination, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - - /** - * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor) - */ - public boolean moveProject( - IResourceTree tree, - IProject source, - IProjectDescription description, - int updateFlags, - IProgressMonitor monitor) { - return false; - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultProjectSetCapability.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultProjectSetCapability.java deleted file mode 100644 index c29f6590f..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultProjectSetCapability.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************** - Copyright (c) 2004 Dan Rubel and others. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Common Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/cpl-v10.html - - Contributors: - - Dan Rubel - initial API and implementation - - **********************************************************************/ - -package org.eclipse.team.internal.core; - -import org.eclipse.team.core.ProjectSetCapability; - -/** - * An internal class for backward compatibility with the - * {@link org.eclipse.team.core.IProjectSetSerializer} interface. - * - * @since 3.0 - */ -public class DefaultProjectSetCapability extends ProjectSetCapability { - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java deleted file mode 100644 index 8fb182356..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; - -/** - * Collects exceptions and can be configured to ignore duplicates exceptions. Exceptions can be logged - * and a MultiStatus containing all collected exceptions can be returned. - * - * @see org.eclipse.core.runtime.MultiStatus - * @see org.eclipse.core.runtime.IStatus - * - * @since 3.0 - */ -public class ExceptionCollector { - - private Map exceptionBucket = new HashMap(); - private List statuses = new ArrayList(); - private String message; - private String pluginId; - private int severity; - private ILog log; - private boolean ignoreDuplicates = false; - - /** - * Creates a collector and initializes the parameters for the top-level exception - * that would be returned from getStatus is exceptions are collected. - * - * @param message a human-readable message, localized to the current locale - * @param pluginId the unique identifier of the relevant plug-in - * @param severity the severity; one of OK, - * ERROR, INFO, or WARNING - * @param code the plug-in-specific status code, or OK - * @param log the log to output the exceptions to, or null if - * exceptions should not be logged. - */ - public ExceptionCollector(String message, String pluginId, int severity, ILog log) { - this.message = message; - this.pluginId = pluginId; - this.severity = severity; - this.log = log; - } - - /** - * Clears the exceptions collected. - */ - public void clear() { - statuses.clear(); - exceptionBucket.clear(); - } - - /** - * Returns a status that represents the exceptions collected. If the collector - * is empty IStatus.OK is returned. Otherwise a MultiStatus containing - * all collected exceptions is returned. - * @return a multistatus containing the exceptions collected or IStatus.OK if - * the collector is empty. - */ - public IStatus getStatus() { - if(statuses.isEmpty()) { - return Status.OK_STATUS; - } else { - MultiStatus multiStatus = new MultiStatus(pluginId, severity, message, null); - Iterator it = statuses.iterator(); - while (it.hasNext()) { - IStatus status = (IStatus) it.next(); - multiStatus.merge(status); - } - return multiStatus; - } - } - - /** - * Returns whether duplicate exceptions are being ignored. - * @return true if this collector is ignoring duplicate exceptions, and - * false otherwise. - */ - public boolean isIgnoreDuplicates() { - return ignoreDuplicates; - } - - /** - * Sets whether duplicate exceptions are being ignored. - * @param ignoreDuplicates true if this collector should ignore duplicate - * exceptions, and false otherwise. - */ - public void setIgnoreDuplicates(boolean ignoreDuplicates) { - this.ignoreDuplicates = ignoreDuplicates; - } - - /** - * Add this exception to the collector. If a log was specified in the constructor - * then the exception will be output to the log. You can retreive exceptions - * using getStatus. - * - * @param exception the exception to collect - */ - public void handleException(Exception e) { - IStatus status = null; - if(e instanceof CoreException) { - status = ((CoreException)e).getStatus(); - } - if(status != null) { - logStatus(status); - IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { - IStatus status2 = children[i]; - logStatus(status2); - } - } - } - - /** - * Log and accumulate exceptions once for each {plugid,code} combination. - */ - private void logStatus(IStatus status) { - String pluginId = status.getPlugin(); - List codes = (List)exceptionBucket.get(pluginId); - Integer code = new Integer(status.getCode()); - if(codes != null) { - if(codes.contains(code) && isIgnoreDuplicates()) { - return; - } - } - // collect the status - statuses.add(status); - - // update counts for this exception - codes = new ArrayList(1); - codes.add(code); - exceptionBucket.put(pluginId, codes); - - // log if necessary - if(log != null) { - log.log(new Status(status.getSeverity(), pluginId, status.getCode(), message, status.getException())); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java deleted file mode 100644 index 1db832230..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import java.util.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileModificationValidator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.team.core.RepositoryProvider; - -public class FileModificationValidatorManager implements IFileModificationValidator { - private IFileModificationValidator defaultValidator; - - /* - * @see IFileModificationValidator#validateEdit(IFile[], Object) - * For all files, determine which provider. - * Ask each provider once for its files. - * Collect the resulting status' and return a MultiStatus. - */ - public IStatus validateEdit(IFile[] files, Object context) { - ArrayList returnStati = new ArrayList(); - - //map provider to the files under that provider's control - Map providersToFiles = new HashMap(files.length); - - //for each file, determine which provider, map providers to files - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject()); - - if (!providersToFiles.containsKey(provider)) { - providersToFiles.put(provider, new ArrayList()); - } - - ((ArrayList)providersToFiles.get(provider)).add(file); - } - - Iterator providersIterator = providersToFiles.keySet().iterator(); - - boolean allOK = true; - - //for each provider, validate its files - while(providersIterator.hasNext()) { - RepositoryProvider provider = (RepositoryProvider)providersIterator.next(); - ArrayList filesList = (ArrayList)providersToFiles.get(provider); - IFile[] filesArray = (IFile[])filesList.toArray(new IFile[filesList.size()]); - IFileModificationValidator validator = getDefaultValidator(); - - //if no provider or no validator use the default validator - if (provider != null) { - IFileModificationValidator v = provider.getFileModificationValidator(); - if (v != null) validator = v; - } - - IStatus status = validator.validateEdit(filesArray, context); - if(!status.isOK()) - allOK = false; - - returnStati.add(status); - } - - if (returnStati.size() == 1) { - return (IStatus)returnStati.get(0); - } - - return new MultiStatus(TeamPlugin.ID, - 0, - (IStatus[])returnStati.toArray(new IStatus[returnStati.size()]), - Policy.bind( - allOK - ? "FileModificationValidator.ok" //$NON-NLS-1$ - : "FileModificationValidator.editFailed"), //$NON-NLS-1$ - null); //$NON-NLS-1$ - } - - /* - * @see IFileModificationValidator#validateSave(IFile) - */ - public IStatus validateSave(IFile file) { - RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject()); - IFileModificationValidator validator = getDefaultValidator(); - - //if no provider or no validator use the default validator - if (provider != null) { - IFileModificationValidator v = provider.getFileModificationValidator(); - if (v != null) validator = v; - } - - return validator.validateSave(file); - } - - private synchronized IFileModificationValidator getDefaultValidator() { - if (defaultValidator == null) { - defaultValidator = new DefaultFileModificationValidator(); - } - return defaultValidator; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/IJobListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/IJobListener.java deleted file mode 100644 index b747d5be2..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/IJobListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import org.eclipse.core.runtime.QualifiedName; - -/** - * This interface allows interested parties to receive notification - * when work has started or stopped for a given job type. The started - * method is invoked when the first job is started for the given jobType. - * The finish method is called when the last job of a given type stops. - * Several jobs for the job type may start and stop in the interum without causing - * notification to the listener. - */ -public interface IJobListener { - public void started(QualifiedName jobType); - public void finished(QualifiedName jobType); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java deleted file mode 100644 index 2f6baacdc..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; - -/** - * Provides an infinite progress monitor by subdividing by half repeatedly. - * - * The ticks parameter represents the number of ticks shown in the progress dialog - * (or propogated up to a parent IProgressMonitor). The totalWork parameter provided - * in actually a hint used to determine how work is translated into ticks. - * The number of totalWork that can actually be worked is n*totalWork/2 where - * 2^n = totalWork. What this means is that if you provide a totalWork of 32 (2^5) than - * the maximum number of ticks is 5*32/2 = 80. - * - */ -public class InfiniteSubProgressMonitor extends SubProgressMonitor { - - int totalWork; - int halfWay; - int currentIncrement; - int nextProgress; - int worked; - - /** - * Constructor for InfiniteSubProgressMonitor. - * @param monitor - * @param ticks - */ - public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks) { - this(monitor, ticks, 0); - } - - /** - * Constructor for InfiniteSubProgressMonitor. - * @param monitor - * @param ticks - * @param style - */ - public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks, int style) { - super(monitor, ticks, style); - } - - public void beginTask(String name, int totalWork) { - super.beginTask(name, totalWork); - this.totalWork = totalWork; - this.halfWay = totalWork / 2; - this.currentIncrement = 1; - this.nextProgress = currentIncrement; - this.worked = 0; - } - - public void worked(int work) { - if (worked >= totalWork) return; - if (--nextProgress <= 0) { - super.worked(1); - worked++; - if (worked >= halfWay) { - // we have passed the current halfway point, so double the - // increment and reset the halfway point. - currentIncrement *= 2; - halfWay += (totalWork - halfWay) / 2; - } - // reset the progress counter to another full increment - nextProgress = currentIncrement; - } - } - - /** - * Don't allow clearing of the subtask. This will stop the flickering - * of the subtask in the progress dialogs. - * - * @see IProgressMonitor#subTask(String) - */ - public void subTask(String name) { - if(name != null && ! name.equals("")) { //$NON-NLS-1$ - super.subTask(name); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/MoveDeleteManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/MoveDeleteManager.java deleted file mode 100644 index 694418e6b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/MoveDeleteManager.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.resources.team.IResourceTree; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.RepositoryProvider; - -public class MoveDeleteManager implements IMoveDeleteHook { - - private static final IMoveDeleteHook DEFAULT_HOOK = new DefaultMoveDeleteHook(); - - private IMoveDeleteHook getHookFor(IResource resource) { - IProject project = resource.getProject(); - RepositoryProvider provider = RepositoryProvider.getProvider(project); - if(provider==null) { - return DEFAULT_HOOK; - } - IMoveDeleteHook hook = provider.getMoveDeleteHook(); - if (hook == null) { - return DEFAULT_HOOK; - } - return hook; - } - - /* - * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor) - */ - public boolean deleteFile( - IResourceTree tree, - IFile file, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(file).deleteFile(tree, file, updateFlags, monitor); - } - - /* - * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor) - */ - public boolean deleteFolder( - IResourceTree tree, - IFolder folder, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(folder).deleteFolder(tree, folder, updateFlags, monitor); - } - - /* - * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor) - */ - public boolean deleteProject( - IResourceTree tree, - IProject project, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(project).deleteProject(tree, project, updateFlags, monitor); - } - - /* - * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor) - */ - public boolean moveFile( - IResourceTree tree, - IFile source, - IFile destination, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(source).moveFile(tree, source, destination, updateFlags, monitor); - } - - /* - * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor) - */ - public boolean moveFolder( - IResourceTree tree, - IFolder source, - IFolder destination, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(source).moveFolder(tree, source, destination, updateFlags, monitor); - } - - /* - * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor) - */ - public boolean moveProject( - IResourceTree tree, - IProject source, - IProjectDescription description, - int updateFlags, - IProgressMonitor monitor) { - - return getHookFor(source).moveProject(tree, source, description, updateFlags, monitor); - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/NullSubProgressMonitor.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/NullSubProgressMonitor.java deleted file mode 100644 index 50edd1a6a..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/NullSubProgressMonitor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; - -/** - * This sub-progress monitor can be used to ignore progress indication for - * methods but allow cancellation. - *

              - * This implementation supports cancelation. The default implementations of the - * other methods do nothing. - *

              - * @see NullProgressMonitor - * @see SubProgressMonitor - */ -public class NullSubProgressMonitor extends SubProgressMonitor { - /** - * Constructor for InfiniteSubProgressMonitor. - * @param monitor - * @param ticks - */ - public NullSubProgressMonitor(IProgressMonitor monitor) { - super(monitor, 0, 0); - } - - /** - * @see IProgressMonitor#beginTask(String, int) - */ - public void beginTask(String name, int totalWork) { - } - - /** - * @see IProgressMonitor#done() - */ - public void done() { - } - - /** - * @see IProgressMonitor#internalWorked(double) - */ - public void internalWorked(double work) { - } - - /** - * @see IProgressMonitor#subTask(String) - */ - public void subTask(String name) { - } - - /** - * @see IProgressMonitor#worked(int) - */ - public void worked(int work) { - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PessimisticResourceRuleFactory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PessimisticResourceRuleFactory.java deleted file mode 100644 index 67e4e4671..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PessimisticResourceRuleFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.team.ResourceRuleFactory; -import org.eclipse.core.runtime.jobs.ISchedulingRule; - -/** - * A pessimistic rule factory used to ensure older repository providers - * are not broken by new scheduling rule locking. The workspace root - * is returned for all rules. - */ -public class PessimisticResourceRuleFactory extends ResourceRuleFactory { - - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#copyRule(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IResource) - */ - public ISchedulingRule copyRule(IResource source, IResource destination) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#createRule(org.eclipse.core.resources.IResource) - */ - public ISchedulingRule createRule(IResource resource) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#deleteRule(org.eclipse.core.resources.IResource) - */ - public ISchedulingRule deleteRule(IResource resource) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#modifyRule(org.eclipse.core.resources.IResource) - */ - public ISchedulingRule modifyRule(IResource resource) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#moveRule(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IResource) - */ - public ISchedulingRule moveRule(IResource source, IResource destination) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#refreshRule(org.eclipse.core.resources.IResource) - */ - public ISchedulingRule refreshRule(IResource resource) { - return root; - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceRuleFactory#validateEditRule(org.eclipse.core.resources.IResource[]) - */ - public ISchedulingRule validateEditRule(IResource[] resources) { - return root; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java deleted file mode 100644 index b52f9a262..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.*; - -public class Policy { - protected static ResourceBundle bundle = null; - - //debug constants - public static boolean DEBUG_STREAMS = false; - public static boolean DEBUG_REFRESH_JOB = true; - public static boolean DEBUG_BACKGROUND_EVENTS = false; - public static boolean DEBUG_THREADING = false; - - static { - //init debug options - if (TeamPlugin.getPlugin().isDebugging()) { - DEBUG_STREAMS = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/streams"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_REFRESH_JOB = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/refreshjob"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_BACKGROUND_EVENTS = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/backgroundevents"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_THREADING = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/threading"));//$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - */ - public static String bind(String id, String binding1, String binding2) { - return bind(id, new String[] { binding1, binding2 }); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Progress monitor helpers - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor != null && monitor.isCanceled()) - throw new OperationCanceledException(); - } - public static IProgressMonitor monitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } - - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - - public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new InfiniteSubProgressMonitor(monitor, ticks); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java deleted file mode 100644 index 87d8a22e1..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.CachedResourceVariant; - -/** - * This class implements a caching facility that can be used by TeamProviders to cache contents - */ -public class ResourceVariantCache { - - // Directory to cache file contents - private static final String CACHE_DIRECTORY = ".cache"; //$NON-NLS-1$ - // Maximum lifespan of local cache file, in milliseconds - private static final long CACHE_FILE_LIFESPAN = 60*60*1000; // 1hr - - // Map of registered cahces indexed by local name of a QualifiedName - private static Map caches = new HashMap(); // String (local name) > RemoteContentsCache - - private String name; - private Map cacheEntries; - private long lastCacheCleanup; - private int cacheDirSize; - - // Lock used to serialize the writting of cache contents - private ILock lock = Platform.getJobManager().newLock(); - - /** - * Enables the use of remote contents caching for the given cacheId. The cache ID must be unique. - * A good candidate for this ID is the plugin ID of the plugin peforming the caching. - * - * @param cacheId the unique Id of the cache being enabled - * @throws TeamException if the cache area on disk could not be properly initialized - */ - public static synchronized void enableCaching(String cacheId) { - if (isCachingEnabled(cacheId)) return; - ResourceVariantCache cache = new ResourceVariantCache(cacheId); - cache.createCacheDirectory(); - caches.put(cacheId, cache); - } - - /** - * Returns whether caching has been enabled for the given Id. A cache should only be enabled once. - * It is conceivable that a cache be persisted over workbench invocations thus leading to a cahce that - * is enabled on startup without intervention by the owning plugin. - * - * @param cacheId the unique Id of the cache - * @return true if caching for the given Id is enabled - */ - public static boolean isCachingEnabled(String cacheId) { - return getCache(cacheId) != null; - } - - /** - * Disable the cache, dispoing of any file contents in the cache. - * - * @param cacheId the unique Id of the cache - * @throws TeamException if the cached contents could not be deleted from disk - */ - public static void disableCache(String cacheId) { - ResourceVariantCache cache = getCache(cacheId); - if (cache == null) { - // There is no cache to dispose of - return; - } - caches.remove(cacheId); - cache.deleteCacheDirectory(); - } - - /** - * Return the cache for the given id or null if caching is not enabled for the given id. - * @param cacheId - * @return - */ - public static synchronized ResourceVariantCache getCache(String cacheId) { - return (ResourceVariantCache)caches.get(cacheId); - } - - public static synchronized void shutdown() { - for (Iterator iter = caches.keySet().iterator(); iter.hasNext();) { - String id = (String) iter.next(); - disableCache(id); - } - } - - private ResourceVariantCache(String name) { - this.name = name; - } - - /** - * Return whether the cache contains an entry for the given id. Register a hit if it does. - * @param id the id of the cache entry - * @return true if there are contents cached for the id - */ - public boolean hasEntry(String id) { - return internalGetCacheEntry(id) != null; - } - - protected IPath getCachePath() { - return getStateLocation().append(CACHE_DIRECTORY).append(name); - } - - private IPath getStateLocation() { - return TeamPlugin.getPlugin().getStateLocation(); - } - - private synchronized void clearOldCacheEntries() { - long current = new Date().getTime(); - if ((lastCacheCleanup!=-1) && (current - lastCacheCleanup < CACHE_FILE_LIFESPAN)) return; - List stale = new ArrayList(); - for (Iterator iter = cacheEntries.values().iterator(); iter.hasNext();) { - ResourceVariantCacheEntry entry = (ResourceVariantCacheEntry) iter.next(); - long lastHit = entry.getLastAccessTimeStamp(); - if ((current - lastHit) > CACHE_FILE_LIFESPAN){ - stale.add(entry); - } - } - for (Iterator iter = stale.iterator(); iter.hasNext();) { - ResourceVariantCacheEntry entry = (ResourceVariantCacheEntry) iter.next(); - entry.dispose(); - } - } - - private synchronized void purgeFromCache(String id) { - ResourceVariantCacheEntry entry = (ResourceVariantCacheEntry)cacheEntries.get(id); - File f = entry.getFile(); - try { - deleteFile(f); - } catch (TeamException e) { - // Ignore the deletion failure. - // A failure only really matters when purging the directory on startup - } - cacheEntries.remove(id); - } - - private synchronized void createCacheDirectory() { - IPath cacheLocation = getCachePath(); - File file = cacheLocation.toFile(); - if (file.exists()) { - try { - deleteFile(file); - } catch (TeamException e) { - // Check to see if were in an acceptable state - if (file.exists() && (!file.isDirectory() || file.listFiles().length != 0)) { - TeamPlugin.log(e); - } - } - } - if (! file.exists() && ! file.mkdirs()) { - TeamPlugin.log(new TeamException(Policy.bind("RemoteContentsCache.fileError", file.getAbsolutePath()))); //$NON-NLS-1$ - } - cacheEntries = new HashMap(); - lastCacheCleanup = -1; - cacheDirSize = 0; - } - - private synchronized void deleteCacheDirectory() { - cacheEntries = null; - lastCacheCleanup = -1; - cacheDirSize = 0; - IPath cacheLocation = getCachePath(); - File file = cacheLocation.toFile(); - if (file.exists()) { - try { - deleteFile(file); - } catch (TeamException e) { - // Don't worry about problems deleting. - // The only case that matters is when the cache directory is created - } - } - } - - private void deleteFile(File file) throws TeamException { - if (file.isDirectory()) { - File[] children = file.listFiles(); - for (int i = 0; i < children.length; i++) { - deleteFile(children[i]); - } - } - if (! file.delete()) { - throw new TeamException(Policy.bind("RemoteContentsCache.fileError", file.getAbsolutePath())); //$NON-NLS-1$ - } - } - - /** - * Purge the given cache entry from the cache. This method should only be invoked from - * an instance of ResourceVariantCacheEntry after it has set it's state to DISPOSED. - * @param entry - */ - protected void purgeFromCache(ResourceVariantCacheEntry entry) { - purgeFromCache(entry.getId()); - } - - private synchronized ResourceVariantCacheEntry internalGetCacheEntry(String id) { - if (cacheEntries == null) { - // This probably means that the cache has been disposed - throw new IllegalStateException(Policy.bind("RemoteContentsCache.cacheDisposed", name)); //$NON-NLS-1$ - } - ResourceVariantCacheEntry entry = (ResourceVariantCacheEntry)cacheEntries.get(id); - if (entry != null) { - entry.registerHit(); - } - return entry; - } - - /** - * @param id the id that uniquely identifes the remote resource that is cached. - * @return - */ - public ResourceVariantCacheEntry getCacheEntry(String id) { - return internalGetCacheEntry(id); - } - - public synchronized ResourceVariantCacheEntry add(String id, CachedResourceVariant resource) { - clearOldCacheEntries(); - String filePath = String.valueOf(cacheDirSize++); - ResourceVariantCacheEntry entry = new ResourceVariantCacheEntry(this, lock, id, filePath); - entry.setResourceVariant(resource); - cacheEntries.put(id, entry); - return entry; - } - - public String getName() { - return name; - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java deleted file mode 100644 index 1b94be663..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -import java.io.*; -import java.util.Date; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.CachedResourceVariant; - -/** - * This class provides the implementation for the ICacheEntry - */ -public class ResourceVariantCacheEntry { - - public static final int UNINITIALIZED = 0; - public static final int READY = 1; - public static final int DISPOSED = 2; - - private String id; - private String filePath; - private ResourceVariantCache cache; - private int state = UNINITIALIZED; - private long lastAccess; - private CachedResourceVariant resourceVariant; - private ILock lock; - - public ResourceVariantCacheEntry(ResourceVariantCache cache, ILock lock, String id, String filePath) { - this.lock = lock; - state = UNINITIALIZED; - this.cache = cache; - this.id = id; - this.filePath = filePath; - registerHit(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ICacheEntry#getContents() - */ - public InputStream getContents() throws TeamException { - if (state != READY) return null; - registerHit(); - File ioFile = getFile(); - try { - try { - if (ioFile.exists()) { - return new FileInputStream(ioFile); - } - } catch (IOException e) { - // Try to purge the cache and continue - cache.purgeFromCache(this); - throw e; - } - } catch (IOException e) { - // We will end up here if we couldn't read or delete the cache file - throw new TeamException(Policy.bind("RemoteContentsCache.fileError", ioFile.getAbsolutePath()), e); //$NON-NLS-1$ - } - // This can occur when there is no remote contents - return new ByteArrayInputStream(new byte[0]); - } - - protected File getFile() { - return new File(cache.getCachePath().toFile(), filePath); - } - - /** - * Set the contents of for this cache entry. This method supports concurrency by only allowing - * one cache entry to be written at a time. In the case of two concurrent writes to the same cache entry, - * the contents from the first write is used and the content from subsequent writes is ignored. - * @param stream an InputStream that provides the contents to be cached - * @param monitor a progress monitor - * @throws TeamException if the entry is DISPOSED or an I/O error occurres - */ - public void setContents(InputStream stream, IProgressMonitor monitor) throws TeamException { - // Use a lock to only allow one write at a time - beginOperation(); - try { - internalSetContents(stream, monitor); - } finally { - endOperation(); - } - } - - private void endOperation() { - lock.release(); - } - - private void beginOperation() { - lock.acquire(); - } - - private void internalSetContents(InputStream stream, IProgressMonitor monitor) throws TeamException { - // if the state is DISPOSED then there is a problem - if (state == DISPOSED) { - throw new TeamException(Policy.bind("RemoteContentsCacheEntry.3", cache.getName(), id)); //$NON-NLS-1$ - } - // Otherwise, the state is UNINITIALIZED or READY so we can proceed - registerHit(); - File ioFile = getFile(); - try { - - // Open the cache file for writing - OutputStream out; - try { - if (state == UNINITIALIZED) { - out = new BufferedOutputStream(new FileOutputStream(ioFile)); - } else { - // If the entry is READY, the contents must have been read in another thread. - // We still need to red the contents but they can be ignored since presumably they are the same - out = new ByteArrayOutputStream(); - } - } catch (FileNotFoundException e) { - throw new TeamException(Policy.bind("RemoteContentsCache.fileError", ioFile.getAbsolutePath()), e); //$NON-NLS-1$ - } - - // Transfer the contents - try { - try { - byte[] buffer = new byte[1024]; - int read; - while ((read = stream.read(buffer)) >= 0) { - Policy.checkCanceled(monitor); - out.write(buffer, 0, read); - } - } finally { - out.close(); - } - } catch (IOException e) { - // Make sure we don't leave the cache file around as it may not have the right contents - cache.purgeFromCache(this); - throw e; - } - - // Mark the cache entry as ready - state = READY; - } catch (IOException e) { - throw new TeamException(Policy.bind("RemoteContentsCache.fileError", ioFile.getAbsolutePath()), e); //$NON-NLS-1$ - } finally { - try { - stream.close(); - } catch (IOException e1) { - // Ignore close errors - } - } - - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ICacheEntry#getState() - */ - public int getState() { - return state; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ICacheEntry#getSize() - */ - public long getSize() { - if (state != READY) return 0; - File ioFile = getFile(); - if (ioFile.exists()) { - return ioFile.length(); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ICacheEntry#getLastAccessTimeStamp() - */ - public long getLastAccessTimeStamp() { - return lastAccess; - } - - /** - * Registers a hit on this cache entry. This updates the last access timestamp. - * Thsi method is intended to only be invokded from inside this class or the cahce itself. - * Other clients should not use it. - */ - protected void registerHit() { - lastAccess = new Date().getTime(); - } - - public void dispose() { - // Use a lock to avoid changing state while another thread may be writting - beginOperation(); - try { - state = DISPOSED; - cache.purgeFromCache(this); - } finally { - endOperation(); - } - } - - - public String getId() { - return id; - } - - public CachedResourceVariant getResourceVariant() { - return resourceVariant; - } - - public void setResourceVariant(CachedResourceVariant resourceVariant) { - this.resourceVariant = resourceVariant; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Sorter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Sorter.java deleted file mode 100644 index c1689dd8b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Sorter.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - -/** - * The SortOperation takes a collection of objects and returns - * a sorted collection of these objects. Concrete instances of this - * class provide the criteria for the sorting of the objects based on - * the type of the objects. - */ -public abstract class Sorter { - /** - * Returns true is elementTwo is 'greater than' elementOne - * This is the 'ordering' method of the sort operation. - * Each subclass overides this method with the particular - * implementation of the 'greater than' concept for the - * objects being sorted. - */ - public abstract boolean compare(Object elementOne, Object elementTwo); - /** - * Sort the objects in sorted collection and return that collection. - */ - private Object[] quickSort(Object[] sortedCollection, int left, int right) { - int originalLeft = left; - int originalRight = right; - Object mid = sortedCollection[ (left + right) / 2]; - do { - while (compare(sortedCollection[left], mid)) - left++; - while (compare(mid, sortedCollection[right])) - right--; - if (left <= right) { - Object tmp = sortedCollection[left]; - sortedCollection[left] = sortedCollection[right]; - sortedCollection[right] = tmp; - left++; - right--; - } - } while (left <= right); - if (originalLeft < right) - sortedCollection = quickSort(sortedCollection, originalLeft, right); - if (left < originalRight) - sortedCollection = quickSort(sortedCollection, left, originalRight); - return sortedCollection; - } - /** - * Return a new sorted collection from this unsorted collection. - * Sort using quick sort. - */ - public Object[] sort(Object[] unSortedCollection) { - int size = unSortedCollection.length; - Object[] sortedCollection = new Object[size]; - //copy the array so can return a new sorted collection - System.arraycopy(unSortedCollection, 0, sortedCollection, 0, size); - if (size > 1) - quickSort(sortedCollection, 0, size - 1); - return sortedCollection; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StringMatcher.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StringMatcher.java deleted file mode 100644 index 5262fedaf..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StringMatcher.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import java.util.*; - -/** - * A string pattern matcher, suppporting * and ? wildcards. - * Note: code copied from org.eclipse.jdt.internal.core.util.StringMatcher on April 3, 2001 - * (version 0.1 - 010901H18 [rename jbl]). - */ -public class StringMatcher { - protected String fPattern; - protected int fLength; // pattern length - protected boolean fIgnoreWildCards; - protected boolean fIgnoreCase; - protected boolean fHasLeadingStar; - protected boolean fHasTrailingStar; - protected String fSegments[]; //the given pattern is split into * separated segments - - /* boundary value beyond which we don't need to search in the text */ - protected int fBound = 0; - - - protected static final char fSingleWildCard = '\u0000'; - - public static class Position { - int start; //inclusive - int end; //exclusive - public Position(int start, int end) { - this.start = start; - this.end = end; - } - public int getStart() { - return start; - } - public int getEnd() { - return end; - } - } - /** - * Find the first occurrence of the pattern between startend(exclusive). - * @param text, the String object to search in - * @param start, the starting index of the search range, inclusive - * @param end, the ending index of the search range, exclusive - * @return an StringMatcher.Position object that keeps the starting - * (inclusive) and ending positions (exclusive) of the first occurrence of the - * pattern in the specified range of the text; return null if not found or subtext - * is empty (start==end). A pair of zeros is returned if pattern is empty string - * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc" - * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned - */ - - public StringMatcher.Position find(String text, int start, int end) { - if (fPattern == null|| text == null) - throw new IllegalArgumentException(); - - int tlen = text.length(); - if (start < 0) - start = 0; - if (end > tlen) - end = tlen; - if (end < 0 ||start >= end ) - return null; - if (fLength == 0) - return new Position(start, start); - if (fIgnoreWildCards) { - int x = posIn(text, start, end); - if (x < 0) - return null; - return new Position(x, x+fLength); - } - - int segCount = fSegments.length; - if (segCount == 0)//pattern contains only '*'(s) - return new Position (start, end); - - int curPos = start; - int matchStart = -1; - int i; - for (i = 0; i < segCount && curPos < end; ++i) { - String current = fSegments[i]; - int nextMatch = regExpPosIn(text, curPos, end, current); - if (nextMatch < 0 ) - return null; - if(i == 0) - matchStart = nextMatch; - curPos = nextMatch + current.length(); - } - if (i < segCount) - return null; - return new Position(matchStart, curPos); - } - /** - * StringMatcher constructor takes in a String object that is a simple - * pattern which may contain '*' for 0 and many characters and - * '?' for exactly one character. - * - * Literal '*' and '?' characters must be escaped in the pattern - * e.g., "\*" means literal "*", etc. - * - * Escaping any other character (including the escape character itself), - * just results in that character in the pattern. - * e.g., "\a" means "a" and "\\" means "\" - * - * If invoking the StringMatcher with string literals in Java, don't forget - * escape characters are represented by "\\". - * - * @param aPattern the pattern to match text with - * @param ignoreCase if true, case is ignored - * @param ignoreWildCards if true, wild cards and their escape sequences are ignored - * (everything is taken literally). - */ - public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) { - fIgnoreCase = ignoreCase; - fIgnoreWildCards = ignoreWildCards; - fLength = aPattern.length(); - - /* convert case */ - if (fIgnoreCase) { - fPattern = aPattern.toUpperCase(); - } else { - fPattern = aPattern; - } - - if (fIgnoreWildCards) { - parseNoWildCards(); - } else { - parseWildCards(); - } - } - /** - * Given the starting (inclusive) and the ending (exclusive) poisitions in the - * text, determine if the given substring matches with aPattern - * @return true if the specified portion of the text matches the pattern - * @param String text, a String object that contains the substring to match - * @param int start marks the starting position (inclusive) of the substring - * @param int end marks the ending index (exclusive) of the substring - */ - public boolean match(String text, int start, int end) { - if (null == text) - throw new IllegalArgumentException(); - - if (start > end) - return false; - - if (fIgnoreWildCards) - return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); - int segCount= fSegments.length; - if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s) - return true; - if (start == end) - return fLength == 0; - if (fLength == 0) - return start == end; - - int tlen= text.length(); - if (start < 0) - start= 0; - if (end > tlen) - end= tlen; - - int tCurPos= start; - int bound= end - fBound; - if ( bound < 0) - return false; - int i=0; - String current= fSegments[i]; - int segLength= current.length(); - - /* process first segment */ - if (!fHasLeadingStar){ - if(!regExpRegionMatches(text, start, current, 0, segLength)) { - return false; - } else { - ++i; - tCurPos= tCurPos + segLength; - } - } - if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) { - // only one segment to match, no wildcards specified - return tCurPos == end; - } - /* process middle segments */ - while (i < segCount) { - current= fSegments[i]; - int currentMatch; - int k= current.indexOf(fSingleWildCard); - if (k < 0) { - currentMatch= textPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } else { - currentMatch= regExpPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } - tCurPos= currentMatch + current.length(); - i++; - } - - /* process final segment */ - if (!fHasTrailingStar && tCurPos != end) { - int clen= current.length(); - return regExpRegionMatches(text, end - clen, current, 0, clen); - } - return i == segCount ; - } - /** - * match the given text with the pattern - * @return true if matched eitherwise false - * @param text, a String object - */ - public boolean match(String text) { - return match(text, 0, text.length()); - } - /** - * This method parses the given pattern into segments seperated by wildcard '*' characters. - * Since wildcards are not being used in this case, the pattern consists of a single segment. - */ - private void parseNoWildCards() { - fSegments = new String[1]; - fSegments[0] = fPattern; - fBound = fLength; - } - /** - * This method parses the given pattern into segments seperated by wildcard '*' characters. - * @param p, a String object that is a simple regular expression with '*' and/or '?' - */ - private void parseWildCards() { - if(fPattern.startsWith("*"))//$NON-NLS-1$ - fHasLeadingStar = true; - if(fPattern.endsWith("*")) {//$NON-NLS-1$ - /* make sure it's not an escaped wildcard */ - if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') { - fHasTrailingStar = true; - } - } - - Vector temp = new Vector(); - - int pos = 0; - StringBuffer buf = new StringBuffer(); - while (pos < fLength) { - char c = fPattern.charAt(pos++); - switch (c) { - case '\\': - if (pos >= fLength) { - buf.append(c); - } else { - char next = fPattern.charAt(pos++); - /* if it's an escape sequence */ - if (next == '*' || next == '?' || next == '\\') { - buf.append(next); - } else { - /* not an escape sequence, just insert literally */ - buf.append(c); - buf.append(next); - } - } - break; - case '*': - if (buf.length() > 0) { - /* new segment */ - temp.addElement(buf.toString()); - fBound += buf.length(); - buf.setLength(0); - } - break; - case '?': - /* append special character representing single match wildcard */ - buf.append(fSingleWildCard); - break; - default: - buf.append(c); - } - } - - /* add last buffer to segment list */ - if (buf.length() > 0) { - temp.addElement(buf.toString()); - fBound += buf.length(); - } - - fSegments = new String[temp.size()]; - temp.copyInto(fSegments); - } - /** - * @param text, a string which contains no wildcard - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int posIn(String text, int start, int end) {//no wild card in pattern - int max = end - fLength; - - if (!fIgnoreCase) { - int i = text.indexOf(fPattern, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i = start; i <= max; ++i) { - if (text.regionMatches(true, i, fPattern, 0, fLength)) - return i; - } - - return -1; - } - /** - * @param text, a simple regular expression that may only contain '?'(s) - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param p, a simple regular expression that may contains '?' - * @param caseIgnored, wether the pattern is not casesensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int regExpPosIn(String text, int start, int end, String p) { - int plen = p.length(); - - int max = end - plen; - for (int i = start; i <= max; ++i) { - if (regExpRegionMatches(text, i, p, 0, plen)) - return i; - } - return -1; - } - /** - * - * @return boolean - * @param text, a String to match - * @param start, int that indicates the starting index of match, inclusive - * @param end int that indicates the ending index of match, exclusive - * @param p, String, String, a simple regular expression that may contain '?' - * @param ignoreCase, boolean indicating wether code>p is case sensitive - */ - protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { - while (plen-- > 0) { - char tchar = text.charAt(tStart++); - char pchar = p.charAt(pStart++); - - /* process wild cards */ - if (!fIgnoreWildCards) { - /* skip single wild cards */ - if (pchar == fSingleWildCard) { - continue; - } - } - if (pchar == tchar) - continue; - if (fIgnoreCase) { - char tc = Character.toUpperCase(tchar); - if (tc == pchar) - continue; - } - return false; - } - return true; - } - /** - * @param text, the string to match - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param code>p, a string that has no wildcard - * @param ignoreCase, boolean indicating wether code>p is case sensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int textPosIn(String text, int start, int end, String p) { - - int plen = p.length(); - int max = end - plen; - - if (!fIgnoreCase) { - int i = text.indexOf(p, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i = start; i <= max; ++i) { - if (text.regionMatches(true, i, p, 0, plen)) - return i; - } - - return -1; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamHookDispatcher.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamHookDispatcher.java deleted file mode 100644 index 843ef4ac2..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamHookDispatcher.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.team.internal.core; - -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.team.ResourceRuleFactory; -import org.eclipse.core.resources.team.TeamHook; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.RepositoryProvider; - -/** - * This class forwards TeamHook callbacks to the proper RepositoryProvider - */ -public class TeamHookDispatcher extends TeamHook { - - private static final ResourceRuleFactory defaultFactory = new ResourceRuleFactory() {}; - private static TeamHookDispatcher instance; - - public static void setProviderRuleFactory(IProject project, IResourceRuleFactory factory) { - if (instance != null) { - if (factory == null) { - factory = defaultFactory; - } - instance.setRuleFactory(project, factory); - } - } - - public TeamHookDispatcher() { - instance = this; - } - - /** - * @see org.eclipse.core.resources.team.TeamHook#validateCreateLink(org.eclipse.core.resources.IFile, int, org.eclipse.core.runtime.IPath) - */ - public IStatus validateCreateLink(IFile file, int updateFlags, IPath location) { - RepositoryProvider provider = getProvider(file); - if (provider == null) { - return super.validateCreateLink(file, updateFlags, location); - } else { - return provider.validateCreateLink(file, updateFlags, location); - } - } - - /** - * @see org.eclipse.core.resources.team.TeamHook#validateCreateLink(org.eclipse.core.resources.IFolder, int, org.eclipse.core.runtime.IPath) - */ - public IStatus validateCreateLink(IFolder folder, int updateFlags, IPath location) { - RepositoryProvider provider = getProvider(folder); - if (provider == null) { - return super.validateCreateLink(folder, updateFlags, location); - } else { - return provider.validateCreateLink(folder, updateFlags, location); - } - } - - /** - * Method getProvider. - * @param folder - * @return RepositoryProvider - */ - private RepositoryProvider getProvider(IResource resource) { - return RepositoryProvider.getProvider(resource.getProject()); - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.team.TeamHook#getRuleFactory(org.eclipse.core.resources.IProject) - */ - public IResourceRuleFactory getRuleFactory(IProject project) { - if (RepositoryProvider.isShared(project)) { - RepositoryProvider provider = getProvider(project); - // Provider can be null if the provider plugin is not available - if (provider != null) { - return provider.getRuleFactory(); - } - } - // Use the default provided by the superclass - return super.getRuleFactory(project); - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java deleted file mode 100644 index a5fa77c7b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.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.team.internal.core; - -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.IContentTypeManager; -import org.eclipse.team.core.*; -import org.osgi.framework.BundleContext; - -/** - * TeamPlugin is the plug-in runtime class for the Team - * resource management plugin. - *

              - * - * @see Team - * @see RepositoryProvider - * - * @since 2.0 - */ -final public class TeamPlugin extends Plugin { - - // The id of the core team plug-in - public static final String ID = "org.eclipse.team.core"; //$NON-NLS-1$ - - // The id of the providers extension point - public static final String PROVIDER_EXTENSION = "repository-provider-type"; //$NON-NLS-1$ - - // The id of the file types extension point - public static final String FILE_TYPES_EXTENSION = "fileTypes"; //$NON-NLS-1$ - - // The id of the global ignore extension point - public static final String IGNORE_EXTENSION = "ignore"; //$NON-NLS-1$ - // The id of the project set extension point - public static final String PROJECT_SET_EXTENSION = "projectSets"; //$NON-NLS-1$ - // The id of the repository extension point - public static final String REPOSITORY_EXTENSION = "repository"; //$NON-NLS-1$ - // The id of the default file modification vaidator extension point - public static final String DEFAULT_FILE_MODIFICATION_VALIDATOR_EXTENSION = "defaultFileModificationValidator"; //$NON-NLS-1$ - - - // The one and only plug-in instance - private static TeamPlugin plugin; - - /** - * Constructs a plug-in runtime class. - */ - public TeamPlugin() { - super(); - plugin = this; - } - - /** - * @see Plugin#start(BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - Policy.localize("org.eclipse.team.internal.core.messages"); //$NON-NLS-1$ - Team.startup(); - } - - /** - * @see Plugin#stop(BundleContext) - */ - public void stop(BundleContext context) throws Exception { - try { - Team.shutdown(); - ResourceVariantCache.shutdown(); - } finally { - super.stop(context); - } - } - - /** - * Returns the Team plug-in. - * - * @return the single instance of this plug-in runtime class - */ - public static TeamPlugin getPlugin() { - return plugin; - } - - /** - * Log the given exception alloing with the provided message and severity indicator - */ - public static void log(int severity, String message, Throwable e) { - plugin.getLog().log(new Status(severity, ID, 0, message, e)); - } - - /** - * Log the given CoreException in a manner that will include the stacktrace of - * the exception in the log. - */ - public static void log(CoreException e) { - log(e.getStatus().getSeverity(), e.getMessage(), e); - } - - /* - * Static helper methods for creating exceptions - */ - public static TeamException wrapException(Exception e) { - return new TeamException(new Status(IStatus.ERROR, ID, 0, e.getMessage() != null ? e.getMessage() : "", e)); //$NON-NLS-1$ - } - - public static TeamException wrapException(CoreException e) { - IStatus status = e.getStatus(); - return new TeamException(new Status(status.getSeverity(), ID, status.getCode(), status.getMessage(), e)); - } - - public static String getCharset(String name, InputStream stream) throws IOException { - IContentDescription description = getContentDescription(name, stream); - return description == null ? null : description.getCharset(); - - } - public static IContentDescription getContentDescription(String name, InputStream stream) throws IOException { - // tries to obtain a description for this file contents - IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); - try { - return contentTypeManager.getDescriptionFor(stream, name, IContentDescription.ALL); - } finally { - if (stream != null) - try { - stream.close(); - } catch (IOException e) { - // Ignore exceptions on close - } - } - } - - public static RepositoryProviderType getAliasType(String id) { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - String aliasId = configElements[j].getAttribute("canImportId"); //$NON-NLS-1$ - if (aliasId != null && aliasId.equals(id)) { - String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - if (extensionId != null) { - return RepositoryProviderType.getProviderType(extensionId); - } - } - } - } - } - return null; - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties deleted file mode 100644 index 22dfa1eb2..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties +++ /dev/null @@ -1,126 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -ok=OK -concatStrings={0} {1} - -Assert.assertionFailed=Assertion failed: {0} - -manager.providerAlreadyMapped=Error associating {0} with provider named {1}. The project is already associated with a provider. -manager.errorFlushSync=Error flushing provider mapping information for {0}. -manager.errorDeconfigure=Error deconfiguring provider named {0} from project {1}. -manager.providerTypeInvalid=The provider type is not registered: {0}. -manager.providerExtensionNotFound=TeamPlugin provider extension not found. -manager.providerNoConfigElems=No configuration elements found for extension: {0}. -manager.cannotInstantiateExt=Cannot instantiate extension: {0}. -manager.errorSerialize=Error serializing provider mappings for {0}. -manager.errorUnserializeProvider=Cannot unserialize association of {0} with provider of type: {1}. It is no longer a registered provider type. -manager.errorUnserialize=Error un-serializing provider mappings {0}. -manager.notTeamNature=Error setting nature: {0} is not a registered team nature. -manager.errorSettingNature=Error setting nature {1} on project {0}. -manager.errorRemovingNature=Error removing nature {1} on project {0}. - -manager.badClassType=Error creating validator decorator: bad class type -manager.coreException=Error creating validator decorator: core exception - -FileModificationValidator.someReadOnly=Some files are read-only. -FileModificationValidator.fileIsReadOnly=File {0} is read-only. -FileModificationValidator.editFailed=Files are read-only. - -RepositoryProvider_Error_removing_nature_from_project___1=Error removing nature from project: -RepositoryProvider_Too_many_providers_associated_with_project___2=Too many providers associated with project: -RepositoryProviderTypeduplicate_provider_found_in_plugin.xml___1=duplicate provider found in plugin.xml: -RepositoryProviderTypeRepositoryProvider_assigned_to_the_project_must_be_a_subclass_of_RepositoryProvider___2=RepositoryProvider assigned to the project must be a subclass of RepositoryProvider: -RepositoryProviderTypeRepositoryProvider_not_registered_as_a_nature_id___3=RepositoryProvider not registered as a nature id: {0}. -RepositoryProvider_providerTypeIdNotRegistered=Error configuring the RepositoryProvider the nature id is not registered as a valid RepositoryProviderType id. -RepositoryProvider.couldNotInstantiateProvider=Could not instantiate provider {1} for project {0}. -RepositoryProvider.No_Provider_Registered=No provider registered for {0}. -RepositoryProvider.propertyMismatch=Inconsistent session/persistent property state looking up provider {1}. -RepositoryProvider.linkedResourcesExist=Project ''{0}'' contains linked resources but the''{1}'' repository provider does not supported them. -RepositoryProvider.linkedResourcesNotSupported=Project ''{0}'' is mapped to repository type ''{1}'' which does not support linked resources. -RepositoryProvider.couldNotClearAfterError=A serious error has occurred trying to map project ''{0}'' to provider ''{1}''. Please restart Eclipse. -RepositoryProvider.invalidClass=Class ''{1}'' registered for id ''{0}'' is not a subclass of RepositoryProvider. - -TeamPlugin_setting_global_ignore_7=setting global ignore - -Team.couldNotDelete=Could not delete previous state file ''{0}''. -Team.couldNotRename=Could not rename new state file from ''{0}'' to ''{1}''. -Team.writeError=An error occurred writing the state file ''{0}''. -Team.readError=An error occurred reading the state file ''{0}'' -Team.Could_not_delete_state_file_1=Could not delete state file -Team.Could_not_rename_state_file_2=Could not rename state file - -PollingInputStream.readTimeout=Timeout while reading from input stream -PollingInputStream.closeTimeout=Timeout while closing input stream -PollingOutputStream.writeTimeout=Timeout while writing to output stream -PollingOutputStream.closeTimeout=Timeout while closing output stream -TimeoutOutputStream.cannotWriteToStream=Cannot write to output stream - -Config.error=Error configuring the provider - -teamStatus.notCheckedOut=Not checked out. -teamStatus.notCheckedIn=Not checked in. -teamStatus.unmanagedResource=Unmanaged resource. -teamStatus.noRemoteResource=Remote resource does not exist. -teamStatus.ioFailed=An IO error occurred. -teamStatus.conflict=A conflict occurred. - -multiStatus.errorsOccurred=Errors occurred. -provider.configuration.missing=Required configuration value missing. -provider.configuration.invalid=Configuration value is invalid. -filetransfer.monitor={0} ({1}K of {2}K bytes) - -SynchronizedTargetProvider.invalidURLCombination=Could not form a valid URL from {0} and {1} - -RemoteSyncElement.delimit=[{0}] -RemoteSyncElement.insync=in-sync -RemoteSyncElement.conflicting=conflicting -RemoteSyncElement.outgoing=outgoing -RemoteSyncElement.incoming=incoming -RemoteSyncElement.change=change -RemoteSyncElement.addition=addition -RemoteSyncElement.deletion=deletion -RemoteSyncElement.manual={manual} -RemoteSyncElement.auto={auto} - -Team.Error_loading_ignore_state_from_disk_1=Error loading ignore state from disk - -RemoteContentsCache.cacheNotEnabled=The cache for {0} is not enabled. -RemoteContentsCache.cacheDisposed=The cache for {0} is disposed. -RemoteContentsCache.fileError=An I/O error performing an operation on {0}. -TeamProvider.10=Error restoring subscribers. Cannot find factory with id: {0} -TeamProvider.11=Error saving subscribers. Cannot find factory with id: {0} -ContentComparisonCriteria.2=Comparing content {0} -ContentComparisonCriteria.3=\ ignoring whitespace - -SubscriberEventHandler.2=Updating {0}. -SubscriberEventHandler.jobName=Updating {0}. -SubscriberChangeSetCollector.0=An error occurred while reconciling change sets. Restarting the application is recommended. -SubscriberChangeSetCollector.1=Updating Change Sets for {0} -SubscriberChangeSetCollector.2=Errors occurred while updating the change sets for {0} -SubscriberChangeSetCollector.3=An error occurred saving the change set state for {0} -SubscriberChangeSetCollector.4=An error occurred restoring the change set state for {0} -SubscriberEventHandler.errors=Errors have occured while calculating the synchronization state for {0}. -RemoteContentsCacheEntry.3=Cache entry in {0} for {1} has been disposed -SynchronizationCacheRefreshOperation.0=Processing {0} -SubscriberEventHandler.8=The members of folder {0} could not be retrieved: {1} -SubscriberEventHandler.9=The synchronization state for resource {0} could not be determined: {1} -SubscriberEventHandler.10=An internal error occurred processing subscriber events. -SubscriberEventHandler.11=An internal error occurred processing resource {0}: {1} -CachedResourceVariant.0=There is no cached contents for resource {0}. -CachedResourceVariant.1=As error occurred computing the content type of resource variant {0} -SyncInfoTree.0=Sync info is missing for resource {0}. -ResourceVariantTreeSubscriber.1=Problems reported while synchronizing {0}. {1} of {2} resources were synchronized. -ResourceVariantTreeSubscriber.2=An error occurred synchronizing {0}: {1} -SyncByteConverter.1=Malformed sync byte format detected in {0} -BatchingLock.11=An error occurred while flushing batched changes -SubscriberEventHandler.12=Synchronization state collection cancelled by a user action. -ProjectSetCapability.0=Failed to create project references -ProjectSetCapability.1=Failed to load projects diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/simpleAccess/SimpleAccessOperations.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/simpleAccess/SimpleAccessOperations.java deleted file mode 100644 index db7d7fc06..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/simpleAccess/SimpleAccessOperations.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.simpleAccess; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/* - * This class represents provisional API. Its here to allow experimentation with 3rd party tools - * calling providers in a repository neutral manner. - * - * A provider is not required to implement this API. - * Implementers, and those who reference it, do so with the awareness that this class may be - * removed or substantially changed at future times without warning. - * - * The SimpleAccessOperations class exposes a basic repository model that - * providers may implement to allow third-party plugins to perform repository operations - * programmatically. For example, a code generation tool may want to get source - * files before generating the code, and check-in the results. If a provider plugin does - * not adhere to the semantics of the SimpleAccessOperations class - * as described, they are free to opt out of implementing it. - * - * @since 2.0 - */ -public interface SimpleAccessOperations { - /* - * Updates the local resource to have the same content as the corresponding remote - * resource. Where the local resource does not exist, this method will create it. - *

              - * If the remote resource is a container (e.g. folder or project) this operation is equivalent - * to getting each non-container member of the remote resource, thereby updating the - * content of existing local members, creating local members to receive new remote resources, - * and deleting local members that no longer have a corresponding remote resource.

              - *

              - * The method is applied to all resources satisfying the depth parameter, described above.

              - *

              - * Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.

              - * - * @param resources an array of local resources to update from the corresponding remote - * resources. - * @param depth the depth to traverse the given resources, taken from IResource - * static constants. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamException if there is a problem getting one or more of the resources. The - * exception will contain multiple statuses, one for each resource in the resources - * array. Possible status codes include: - *
                - *
              • NO_REMOTE_RESOURCE
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - */ - public void get(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; - - /* - * Changes the state of the local resource from checked-in to checked-out and transfers the content - * of the remote resource to the local resource. - *

              - * Where no corresponding local resource exists in the workspace, one is created (including any - * intermediate parent containers) to receive the contents of the remote resource.

              - *

              - * Implementations may optimistically only flag the state change locally and rely on resolving conflicts - * during check-in, or they may pessimistically also checkout or lock the remote resource during a - * local resource checkout to avoid conflicts. The provider API does not subscribe to either model - * and supports each equally.

              - *

              - * Where checkout is applied to a resource that is already checked-out the method has no - * effect.

              - * - * @param resources the array of local resources to be checked-out. - * @param depth the depth to traverse the given resources, taken from IResource - * constants. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamProviderException if there is a problem checking-out one or more of the resources. - * The exception will contain multiple statuses, one for each resource in the resources - * array. Possible status codes include: - *
                - *
              • NOT_CHECKED_IN
              • - *
              • NO_REMOTE_RESOURCE
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - * @see checkin(IResource[], int, IProgressMonitor) - */ - public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; - - /* - * Transfers the content of the local resource to the corresponding remote resource, and changes the - * state of the local resource from checked-out to checked-in. - *

              - * If a remote resource does not exist this method creates a new remote resource with the same content - * as the given local resource. The local resource is said to correspond to the new remote resource.

              - *

              - * Where providers deal with stores that check-out or lock resources this method is an opportunity - * to transfer the content and make the corresponding remote check-in or unlock. It is envisaged that - * where the server maintains resource versions, checkin creates a new version of the remote resource.

              - *

              - * Note that some providers may require that a resource is checked-out before it can be - * checked-in. However, all providers must support the explicit checking out a resource before checking - * it in (e.g., even if the check out is a no-op).

              - * - * @param resources an array of local resources to be checked-in. - * @param the depth to traverse the given resources, taken from IResource - * constants. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamException if there is a problem checking-in one or more of the resources. - * The exception will contain multiple statuses, one for each resource in the resources - * array. Possible status codes include: - *
                - *
              • NOT_CHECKED_OUT
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - * @see checkout(IResource[], int, IProgressMonitor) - */ - public void checkin(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; - - /* - * Changes the state of the local resource from checked-out to checked-in without updating the contents - * of the remote resource. - *

              - * Note that where the provider is a versioning provider, it is envisaged (though not required) that the - * uncheckout operation does not create a new version.

              - *

              - * Note also that uncheckout() does not affect the content of the local resource. The - * caller is required to perform a get() to revert the local resource if that is required - * (otherwise the local resource will be left with the changes that were made while the remote resource - * was checked-out. Furthermore, it is valid to call uncheckout() with an - * IResource that does not exist locally.

              - * - * @param resources an array of the local resources that are to be unchecked-out. - * @param depth the depth to traverse the given resources, taken from IResource - * constants. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamProviderException if there is a problem undoing the check-out of one or more of - * the resources. The exception will contain multiple statuses, one for each resource in the - * resources array. Possible status codes include: - *
                - *
              • NOT_CHECKED_OUT
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - * @see checkin(IResource) - * @see uncheckout(IResource) - */ - public void uncheckout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; - - /* - * Deletes the remote resource corresponding to the given local resource. - *

              - * The notion of delete is simply to make the remote resource unavailable. Where the provider - * supports versioning it is not specified whether the delete operation makes the version - * temporarily or forever unavailable, or indeed whether the entire history is made unavailable.

              - *

              - * Note that the IResource's passed as arguments may be non-existant in the - * workbench, the typical case is when such a resource has been received in a core callback.

              - *

              - * The resource may be checked-in or checked-out prior to deletion. The local resource is not - * deleted by this method.

              - *

              - * Resource deletions are inherently deep.

              - * - * @param resources the array of resources whose corresponding remote resources are to be deleted. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamProviderException if there is a problem deleting one or more of - * the resources. The exception will contain multiple statuses, one for each resource in the - * resources array. Possible status codes include: - *
                - *
              • NO_REMOTE_RESOURCE
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - */ - public void delete(IResource[] resources, IProgressMonitor progress) throws TeamException; - - /* - * Informs the provider that a local resource's name or path has changed. - *

              - * Some providers, such as versioning providers, may require this information to track the resource - * across name changes.

              - *

              - * Note that this method is always called after the local resource has been moved.

              - * - * @param source the full name of the resource before it was moved. - * @param target the resource that was moved. - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * @throws TeamProviderException if there is a problem recording the move. The exception will - * contain a single status. Possible status codes are: - *
                - *
              • NO_REMOTE_RESOURCE
              • - *
              • IO_FAILED
              • - *
              • NOT_AUTHORIZED
              • - *
              • UNABLE
              • - *
              - */ - public void moved(IPath source, IResource target, IProgressMonitor progress) throws TeamException; - - /* - * Implementor's Note: - * The following methods are required to return promptly (i.e., they may be used to determine the state of - * a resource in a UI where long delays are unacceptable). Implementations may cache these values - * and update the cache on an explicit call to #refreshState(). - * - * They are currently listed in the provider API, however, they may be moved to a new or different - * interface in the future to better reflect their UI-orientation. - */ - - /* - * Answers if the remote resource state is checked-out. If the resource has never been checked in this - * method will return true. - *

              - * It is undefined whether this method tests for a resource being checked out to this workspace - * or any workspace.

              - * - * @param resource the local resource to test. - * @return true if the resource is checked-out and false if it is not. - * @see checkout(IResource[], int, IProgressMonitor) - */ - public boolean isCheckedOut(IResource resource); - - /* - * Answers whether the resource has a corresponding remote resource. - *

              - * Before a resource is checked-in, the resource will occur locally but not remotely, and calls to this - * method will return false. Once a local resource is checked in (and assuming the local - * local resource is not moved or the remote resource deleted) there will be a corresponding remote - * resource and this method returns true.

              - * - * @param resource the local resource to test. - * @return true if the local resource has a corresponding remote resource, - * and false otherwise. - * @see checkin(IResource[], int, IProgressMonitor) - * @see refreshState(IResource[], int, IProgressMonitor) - */ - public boolean hasRemote(IResource resource); - - /* - * Answer if the local resource currently has a different timestamp to the base timestamp - * for this resource. - * - * @param resource the resource to test. - * @return true if the resource has a different modification - * timestamp, and false otherwise. - */ - public boolean isDirty(IResource resource); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/CRLFtoLFInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/CRLFtoLFInputStream.java deleted file mode 100644 index 9a52b0871..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/CRLFtoLFInputStream.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; - -/** - * Converts CR/LFs in the underlying input stream to LF. - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public class CRLFtoLFInputStream extends FilterInputStream { - private boolean pendingByte = false; - private int lastByte = -1; - - /** - * Creates a new filtered input stream. - * @param in the underlying input stream - */ - public CRLFtoLFInputStream(InputStream in) { - super(in); - } - - /** - * Wraps the underlying stream's method. - * Translates CR/LF sequences to LFs transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - if (! pendingByte) { - lastByte = in.read(); // ok if this throws - pendingByte = true; // remember the byte in case we throw an exception later on - } - if (lastByte == '\r') { - lastByte = in.read(); // ok if this throws - if (lastByte != '\n') { - if (lastByte == -1) pendingByte = false; - return '\r'; // leaves the byte pending for later - } - } - pendingByte = false; - return lastByte; - } - - /** - * Wraps the underlying stream's method. - * Translates CR/LF sequences to LFs transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int off, int len) throws IOException { - // handle boundary cases cleanly - if (len == 0) { - return 0; - } else if (len == 1) { - int b = read(); - if (b == -1) return -1; - buffer[off] = (byte) b; - return 1; - } - // read some bytes from the stream - // prefix with pending byte from last read if any - int count = 0; - if (pendingByte) { - buffer[off] = (byte) lastByte; - pendingByte = false; - count = 1; - } - InterruptedIOException iioe = null; - try { - len = in.read(buffer, off + count, len - count); - if (len == -1) { - return (count == 0) ? -1 : count; - } - } catch (InterruptedIOException e) { - len = e.bytesTransferred; - iioe = e; - } - count += len; - // strip out CR's in CR/LF pairs - // pendingByte will be true iff previous byte was a CR - int j = off; - for (int i = off; i < off + count; ++i) { // invariant: j <= i - lastByte = buffer[i]; - if (lastByte == '\r') { - if (pendingByte) { - buffer[j++] = '\r'; // write out orphan CR - } else { - pendingByte = true; - } - } else { - if (pendingByte) { - if (lastByte != '\n') buffer[j++] = '\r'; // if LF, don't write the CR - pendingByte = false; - } - buffer[j++] = (byte) lastByte; - } - } - if (iioe != null) { - iioe.bytesTransferred = j - off; - throw iioe; - } - return j - off; - } - - /** - * Calls read() to skip the specified number of bytes - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public long skip(long count) throws IOException { - int actualCount = 0; // assumes count < Integer.MAX_INT - try { - while (count-- > 0 && read() != -1) actualCount++; // skip the specified number of bytes - return actualCount; - } catch (InterruptedIOException e) { - e.bytesTransferred = actualCount; - throw e; - } - } - - /** - * Wraps the underlying stream's method. - * Returns the number of bytes that can be read without blocking; accounts for - * possible translation of CR/LF sequences to LFs in these bytes. - * @throws IOException if an i/o error occurs - */ - public int available() throws IOException { - return in.available() / 2; // we can guarantee at least this amount after contraction - } - - /** - * Mark is not supported by the wrapper even if the underlying stream does, returns false. - */ - public boolean markSupported() { - return false; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java deleted file mode 100644 index 9c14ffb86..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; - -/** - * Converts LFs in the underlying input stream to CR/LF. - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public class LFtoCRLFInputStream extends FilterInputStream { - private boolean mustReturnLF = false; - - /** - * Creates a new filtered input stream. - * @param in the underlying input stream - */ - public LFtoCRLFInputStream(InputStream in) { - super(in); - } - - /** - * Wraps the underlying stream's method. - * Translates LFs to CR/LF sequences transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - if (mustReturnLF) { - mustReturnLF = false; - return '\n'; - } - int b = in.read(); // ok if this throws - if (b == '\n') { - mustReturnLF = true; - b = '\r'; - } - return b; - } - - /** - * Wraps the underlying stream's method. - * Translates LFs to CR/LF sequences transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int off, int len) throws IOException { - // handle boundary cases cleanly - if (len == 0) { - return 0; - } else if (len == 1) { - int b = read(); - if (b == -1) return -1; - buffer[off] = (byte) b; - return 1; - } - // prefix with remembered \n from last read, but don't expand it a second time - int count = 0; - if (mustReturnLF) { - mustReturnLF = false; - buffer[off++] = '\n'; - --len; - count = 1; - if (len < 2) return count; // is there still enough room to expand more? - } - // read some bytes from the stream into the back half of the buffer - // this guarantees that there is always room to expand - len /= 2; - int j = off + len; - InterruptedIOException iioe = null; - try { - len = in.read(buffer, j, len); - if (len == -1) { - return (count == 0) ? -1 : count; - } - } catch (InterruptedIOException e) { - len = e.bytesTransferred; - iioe = e; - } - count += len; - // copy bytes from the middle to the front of the array, expanding LF->CR/LF - while (len-- > 0) { - byte b = buffer[j++]; - if (b == '\n') { - buffer[off++] = '\r'; - count++; - } - buffer[off++] = b; - } - if (iioe != null) { - iioe.bytesTransferred = count; - throw iioe; - } - return count; - } - - /** - * Calls read() to skip the specified number of bytes - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public long skip(long count) throws IOException { - int actualCount = 0; // assumes count < Integer.MAX_INT - try { - while (count-- > 0 && read() != -1) actualCount++; // skip the specified number of bytes - return actualCount; - } catch (InterruptedIOException e) { - e.bytesTransferred = actualCount; - throw e; - } - } - - /** - * Wraps the underlying stream's method. - * Returns the number of bytes that can be read without blocking; accounts for - * possible translation of LFs to CR/LF sequences in these bytes. - * @throws IOException if an i/o error occurs - */ - public int available() throws IOException { - return in.available(); // we can guarantee at least this amount after expansion - } - - /** - * Mark is not supported by the wrapper even if the underlying stream does, returns false. - */ - public boolean markSupported() { - return false; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java deleted file mode 100644 index f8d7bc99d..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * Polls a progress monitor periodically and handles timeouts over extended durations. - * For this class to be effective, a high numAttempts should be specified, and the - * underlying stream should time out frequently on reads (every second or so). - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public class PollingInputStream extends FilterInputStream { - private static final boolean DEBUG = Policy.DEBUG_STREAMS; - private int numAttempts; - private IProgressMonitor monitor; - private boolean cancellable; - - /** - * Creates a new polling input stream. - * @param in the underlying input stream - * @param numAttempts the number of attempts before issuing an InterruptedIOException, - * if 0, retries indefinitely until canceled - * @param monitor the progress monitor to be polled for cancellation - */ - public PollingInputStream(InputStream in, int numAttempts, IProgressMonitor monitor) { - super(in); - this.numAttempts = numAttempts; - this.monitor = monitor; - this.cancellable = true; - } - - /** - * Wraps the underlying stream's method. - * It may be important to wait for an input stream to be closed because it - * holds an implicit lock on a system resoure (such as a file) while it is - * open. Closing a stream may take time if the underlying stream is still - * servicing a previous request. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - int attempts = 0; - try { - readPendingInput(); - } catch (IOException e) { - // We shouldn't get an exception when we're getting the available input. - // If we do, just log it so we can close. - TeamPlugin.log(IStatus.ERROR, e.getMessage(), e); - } finally { - boolean stop = false; - while (!stop) { - try { - in.close(); - stop = true; - } catch (InterruptedIOException e) { - if (checkCancellation()) throw new OperationCanceledException(); - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingInputStream.closeTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("close retry=" + attempts); //$NON-NLS-1$ - } - } - } - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times - * and no data was received, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - return in.read(); - } catch (InterruptedIOException e) { - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times - * and no data was received, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int off, int len) throws IOException { - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - return in.read(buffer, off, len); - } catch (InterruptedIOException e) { - if (e.bytesTransferred != 0) return e.bytesTransferred; // keep partial transfer - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times - * and no data was received, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public long skip(long count) throws IOException { - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - return in.skip(count); - } catch (InterruptedIOException e) { - if (e.bytesTransferred != 0) return e.bytesTransferred; // keep partial transfer - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Reads any pending input from the input stream so that - * the stream can savely be closed. - */ - protected void readPendingInput() throws IOException { - byte[] buffer= new byte[2048]; - while (true) { - int available = in.available(); - if (available < 1) break; - if (available > buffer.length) available = buffer.length; - if (in.read(buffer, 0, available) < 1) break; - } - } - - /** - * Called to set whether cancellation will be checked by this stream. Turning cancellation checking - * off can be very useful for protecting critical portions of a protocol that shouldn't be interrupted. - * For example, it is often necessary to protect login sequences. - * @param cancellable a flag controlling whether this stream will check for cancellation. - */ - public void setIsCancellable(boolean cancellable) { - this.cancellable = cancellable; - } - - /** - * Checked whether the monitor for this stream has been cancelled. If the cancellable - * flag is false then the monitor is never cancelled. - * @return true if the monitor has been cancelled and false - * otherwise. - */ - private boolean checkCancellation() { - if(cancellable) { - return monitor.isCanceled(); - } else { - return false; - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java deleted file mode 100644 index 8227c30fd..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.team.internal.core.Policy; - -/** - * Polls a progress monitor periodically and handles timeouts over extended durations. - * For this class to be effective, a high numAttempts should be specified, and the - * underlying stream should time out frequently on writes (every second or so). - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public class PollingOutputStream extends FilterOutputStream { - private static final boolean DEBUG = Policy.DEBUG_STREAMS; - private int numAttempts; - private IProgressMonitor monitor; - private boolean cancellable; - - /** - * Creates a new polling output stream. - * @param in the underlying output stream - * @param numAttempts the number of attempts before issuing an InterruptedIOException, - * if 0, retries indefinitely until canceled - * @param monitor the progress monitor to be polled for cancellation - */ - public PollingOutputStream(OutputStream out, int numAttempts, IProgressMonitor monitor) { - super(out); - this.numAttempts = numAttempts; - this.monitor = monitor; - this.cancellable = true; - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times - * and no data was sent, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public void write(int b) throws IOException { - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - out.write(b); - return; - } catch (InterruptedIOException e) { - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times, - * bytesTransferred will reflect the number of bytes sent - * @throws IOException if an i/o error occurs - */ - public void write(byte[] buffer, int off, int len) throws IOException { - int count = 0; - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - out.write(buffer, off, len); - return; - } catch (InterruptedIOException e) { - int amount = e.bytesTransferred; - if (amount != 0) { // keep partial transfer - len -= amount; - if (len <= 0) return; - off += amount; - count += amount; - attempts = 0; // made some progress, don't time out quite yet - } - if (++attempts == numAttempts) { - e = new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$ - e.bytesTransferred = count; - throw e; - } - if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Wraps the underlying stream's method. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times, - * bytesTransferred will reflect the number of bytes sent - * @throws IOException if an i/o error occurs - */ - public void flush() throws IOException { - int count = 0; - int attempts = 0; - for (;;) { - if (checkCancellation()) throw new OperationCanceledException(); - try { - out.flush(); - return; - } catch (InterruptedIOException e) { - int amount = e.bytesTransferred; - if (amount != 0) { // keep partial transfer - count += amount; - attempts = 0; // made some progress, don't time out quite yet - } - if (++attempts == numAttempts) { - e = new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$ - e.bytesTransferred = count; - throw e; - } - if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$ - } - } - } - - /** - * Calls flush() then close() on the underlying stream. - * @throws OperationCanceledException if the progress monitor is canceled - * @throws InterruptedIOException if the underlying operation times out numAttempts times, - * bytesTransferred will reflect the number of bytes sent during the flush() - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - int attempts = numAttempts - 1; // fail fast if flush() does times out - try { - out.flush(); - attempts = 0; - } finally { - boolean stop = false; - while (!stop) { - try { - out.close(); - stop = true; - } catch (InterruptedIOException e) { - if (checkCancellation()) throw new OperationCanceledException(); - if (++attempts == numAttempts) - throw new InterruptedIOException(Policy.bind("PollingOutputStream.closeTimeout")); //$NON-NLS-1$ - if (DEBUG) System.out.println("close retry=" + attempts); //$NON-NLS-1$ - } - } - } - } - - /** - * Called to set whether cancellation will be checked by this stream. Turning cancellation checking - * off can be very useful for protecting critical portions of a protocol that shouldn't be interrupted. - * For example, it is often necessary to protect login sequences. - * @param cancellable a flag controlling whether this stream will check for cancellation. - */ - public void setIsCancellable(boolean cancellable) { - this.cancellable = cancellable; - } - - /** - * Checked whether the monitor for this stream has been cancelled. If the cancellable - * flag is false then the monitor is never cancelled. - * @return true if the monitor has been cancelled and false - * otherwise. - */ - private boolean checkCancellation() { - if(cancellable) { - return monitor.isCanceled(); - } else { - return false; - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java deleted file mode 100644 index 54b2e4aff..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * Updates a progress monitor as bytes are read from the input stream. - * Also starts a background thread to provide responsive cancellation on read(). - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public abstract class ProgressMonitorInputStream extends FilterInputStream { - private IProgressMonitor monitor; - private int updateIncrement; - private long bytesTotal; - private long bytesRead = 0; - private long lastUpdate = -1; - private long nextUpdate = 0; - - /** - * Creates a progress monitoring input stream. - * @param in the underlying input stream - * @param bytesTotal the number of bytes to read in total (passed to updateMonitor()) - * @param updateIncrement the number of bytes read between updates - * @param monitor the progress monitor - */ - public ProgressMonitorInputStream(InputStream in, long bytesTotal, int updateIncrement, IProgressMonitor monitor) { - super(in); - this.bytesTotal = bytesTotal; - this.updateIncrement = updateIncrement; - this.monitor = monitor; - update(true); - } - - protected abstract void updateMonitor(long bytesRead, long size, IProgressMonitor monitor); - - /** - * Wraps the underlying stream's method. - * Updates the progress monitor to the final number of bytes read. - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - try { - in.close(); - } finally { - update(true); - } - } - - /** - * Wraps the underlying stream's method. - * Updates the progress monitor if the next update increment has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - int b = in.read(); - if (b != -1) { - bytesRead += 1; - update(false); - } - return b; - } - - /** - * Wraps the underlying stream's method. - * Updates the progress monitor if the next update increment has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int offset, int length) throws IOException { - try { - int count = in.read(buffer, offset, length); - if (count != -1) { - bytesRead += count; - update(false); - } - return count; - } catch (InterruptedIOException e) { - bytesRead += e.bytesTransferred; - update(false); - throw e; - } - } - - /** - * Wraps the underlying stream's method. - * Updates the progress monitor if the next update increment has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public long skip(long amount) throws IOException { - try { - long count = in.skip(amount); - bytesRead += count; - update(false); - return count; - } catch (InterruptedIOException e) { - bytesRead += e.bytesTransferred; - update(false); - throw e; - } - } - - /** - * Mark is not supported by the wrapper even if the underlying stream does, returns false. - */ - public boolean markSupported() { - return false; - } - - private void update(boolean now) { - if (bytesRead >= nextUpdate || now) { - nextUpdate = bytesRead - (bytesRead % updateIncrement); - if (nextUpdate != lastUpdate) updateMonitor(nextUpdate, bytesTotal, monitor); - lastUpdate = nextUpdate; - nextUpdate += updateIncrement; - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java deleted file mode 100644 index d7d26cac8..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; - -import org.eclipse.core.runtime.OperationCanceledException; - -/** - * Simulates a stream that represents only a portion of the underlying stream. - * Will report EOF when this portion has been fully read and prevent further reads. - * The underlying stream is not closed on close(), but the remaining unread input - * may optionally be skip()'d. - * - * Supports resuming partially completed operations after an InterruptedIOException - * if the underlying stream does. Check the bytesTransferred field to determine how - * much of the operation completed; conversely, at what point to resume. - */ -public class SizeConstrainedInputStream extends FilterInputStream { - private boolean discardOnClose; - private long bytesRemaining; - - /** - * Creates a size contrained input stream. - * @param in the underlying input stream, never actually closed by this filter - * @param size the maximum number of bytes of the underlying input stream that - * can be read through this filter - * @param discardOnClose if true, discards remaining unread bytes on close() - */ - public SizeConstrainedInputStream(InputStream in, long size, boolean discardOnClose) { - super(in); - this.bytesRemaining = size; - this.discardOnClose = discardOnClose; - } - - /** - * Prevents further reading from the stream but does not close the underlying stream. - * If discardOnClose, skip()'s over any remaining unread bytes in the constrained region. - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - try { - if (discardOnClose) { - while (bytesRemaining != 0 && skip(bytesRemaining) != 0); - } - } catch (OperationCanceledException e) { - // The receiver is likely wrapping a PollingInputStream which could throw - // an OperationCanceledException on a skip. - // Since we're closing, just ignore the cancel and let the caller check the monitor - } finally { - bytesRemaining = 0; - } - } - - /** - * Wraps the underlying stream's method. - * Simulates an end-of-file condition if the end of the constrained region has been reached. - * @throws IOException if an i/o error occurs - */ - public int available() throws IOException { - int amount = in.available(); - if (amount > bytesRemaining) amount = (int) bytesRemaining; - return amount; - } - - /** - * Wraps the underlying stream's method. - * Simulates an end-of-file condition if the end of the constrained region has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - if (bytesRemaining == 0) return -1; - int b = in.read(); - if (b != -1) bytesRemaining -= 1; - return b; - } - - /** - * Wraps the underlying stream's method. - * Simulates an end-of-file condition if the end of the constrained region has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int offset, int length) throws IOException { - if (length > bytesRemaining) { - if (bytesRemaining == 0) return -1; - length = (int) bytesRemaining; - } - try { - int count = in.read(buffer, offset, length); - if (count != -1) bytesRemaining -= count; - return count; - } catch (InterruptedIOException e) { - bytesRemaining -= e.bytesTransferred; - throw e; - } - } - - /** - * Wraps the underlying stream's method. - * Simulates an end-of-file condition if the end of the constrained region has been reached. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public long skip(long amount) throws IOException { - if (amount > bytesRemaining) amount = bytesRemaining; - try { - long count = in.skip(amount); - bytesRemaining -= count; - return count; - } catch (InterruptedIOException e) { - bytesRemaining -= e.bytesTransferred; - throw e; - } - } - - /** - * Mark is not supported by the wrapper even if the underlying stream does, returns false. - */ - public boolean markSupported() { - return false; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutInputStream.java deleted file mode 100644 index 4ea6eb809..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutInputStream.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; -import org.eclipse.team.internal.core.Policy; - -/** - * Wraps an input stream that blocks indefinitely to simulate timeouts on read(), - * skip(), and close(). The resulting input stream is buffered and supports - * retrying operations that failed due to an InterruptedIOException. - * - * Supports resuming partially completed operations after an InterruptedIOException - * REGARDLESS of whether the underlying stream does unless the underlying stream itself - * generates InterruptedIOExceptions in which case it must also support resuming. - * Check the bytesTransferred field to determine how much of the operation completed; - * conversely, at what point to resume. - */ -public class TimeoutInputStream extends FilterInputStream { - // unsynchronized variables - private final long readTimeout; // read() timeout in millis - private final long closeTimeout; // close() timeout in millis, or -1 - - // requests for the thread (synchronized) - private boolean closeRequested = false; // if true, close requested - - // responses from the thread (synchronized) - private Thread thread; // if null, thread has terminated - private byte[] iobuffer; // circular buffer - private int head = 0; // points to first unread byte - private int length = 0; // number of remaining unread bytes - private IOException ioe = null; // if non-null, contains a pending exception - private boolean waitingForClose = false; // if true, thread is waiting for close() - - private boolean growWhenFull = false; // if true, buffer will grow when it is full - - /** - * Creates a timeout wrapper for an input stream. - * @param in the underlying input stream - * @param bufferSize the buffer size in bytes; should be large enough to mitigate - * Thread synchronization and context switching overhead - * @param readTimeout the number of milliseconds to block for a read() or skip() before - * throwing an InterruptedIOException; 0 blocks indefinitely - * @param closeTimeout the number of milliseconds to block for a close() before throwing - * an InterruptedIOException; 0 blocks indefinitely, -1 closes the stream in the background - */ - public TimeoutInputStream(InputStream in, int bufferSize, long readTimeout, long closeTimeout) { - super(in); - this.readTimeout = readTimeout; - this.closeTimeout = closeTimeout; - this.iobuffer = new byte[bufferSize]; - thread = new Thread(new Runnable() { - public void run() { - runThread(); - } - }, "TimeoutInputStream");//$NON-NLS-1$ - thread.setDaemon(true); - thread.start(); - } - - public TimeoutInputStream(InputStream in, int bufferSize, long readTimeout, long closeTimeout, boolean growWhenFull) { - this(in, bufferSize, readTimeout, closeTimeout); - this.growWhenFull = growWhenFull; - } - - /** - * Wraps the underlying stream's method. - * It may be important to wait for a stream to actually be closed because it - * holds an implicit lock on a system resoure (such as a file) while it is - * open. Closing a stream may take time if the underlying stream is still - * servicing a previous request. - * @throws InterruptedIOException if the timeout expired - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - Thread oldThread; - synchronized (this) { - if (thread == null) return; - oldThread = thread; - closeRequested = true; - thread.interrupt(); - checkError(); - } - if (closeTimeout == -1) return; - try { - oldThread.join(closeTimeout); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // we weren't expecting to be interrupted - } - synchronized (this) { - checkError(); - if (thread != null) throw new InterruptedIOException(); - } - } - - /** - * Returns the number of unread bytes in the buffer. - * @throws IOException if an i/o error occurs - */ - public synchronized int available() throws IOException { - if (length == 0) checkError(); - return length > 0 ? length : 0; - } - - /** - * Reads a byte from the stream. - * @throws InterruptedIOException if the timeout expired and no data was received, - * bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public synchronized int read() throws IOException { - if (! syncFill()) return -1; // EOF reached - int b = iobuffer[head++] & 255; - if (head == iobuffer.length) head = 0; - length--; - notify(); - return b; - } - - /** - * Reads multiple bytes from the stream. - * @throws InterruptedIOException if the timeout expired and no data was received, - * bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public synchronized int read(byte[] buffer, int off, int len) throws IOException { - if (! syncFill()) return -1; // EOF reached - int pos = off; - if (len > length) len = length; - while (len-- > 0) { - buffer[pos++] = iobuffer[head++]; - if (head == iobuffer.length) head = 0; - length--; - } - notify(); - return pos - off; - } - - /** - * Skips multiple bytes in the stream. - * @throws InterruptedIOException if the timeout expired before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public synchronized long skip(long count) throws IOException { - long amount = 0; - try { - do { - if (! syncFill()) break; // EOF reached - int skip = (int) Math.min(count - amount, length); - head = (head + skip) % iobuffer.length; - length -= skip; - amount += skip; - } while (amount < count); - } catch (InterruptedIOException e) { - e.bytesTransferred = (int) amount; // assumes amount < Integer.MAX_INT - throw e; - } - notify(); - return amount; - } - - /** - * Mark is not supported by the wrapper even if the underlying stream does, returns false. - */ - public boolean markSupported() { - return false; - } - - /** - * Waits for the buffer to fill if it is empty and the stream has not reached EOF. - * @return true if bytes are available, false if EOF has been reached - * @throws InterruptedIOException if EOF not reached but no bytes are available - */ - private boolean syncFill() throws IOException { - if (length != 0) return true; - checkError(); // check errors only after we have read all remaining bytes - if (waitingForClose) return false; - notify(); - try { - wait(readTimeout); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // we weren't expecting to be interrupted - } - if (length != 0) return true; - checkError(); // check errors only after we have read all remaining bytes - if (waitingForClose) return false; - throw new InterruptedIOException(); - } - - /** - * If an exception is pending, throws it. - */ - private void checkError() throws IOException { - if (ioe != null) { - IOException e = ioe; - ioe = null; - throw e; - } - } - - /** - * Runs the thread in the background. - */ - private void runThread() { - try { - readUntilDone(); - } catch (IOException e) { - synchronized (this) { ioe = e; } - } finally { - waitUntilClosed(); - try { - in.close(); - } catch (IOException e) { - synchronized (this) { ioe = e; } - } finally { - synchronized (this) { - thread = null; - notify(); - } - } - } - } - - /** - * Waits until we have been requested to close the stream. - */ - private synchronized void waitUntilClosed() { - waitingForClose = true; - notify(); - while (! closeRequested) { - try { - wait(); - } catch (InterruptedException e) { - closeRequested = true; // alternate quit signal - } - } - } - - /** - * Reads bytes into the buffer until EOF, closed, or error. - */ - private void readUntilDone() throws IOException { - for (;;) { - int off, len; - synchronized (this) { - while (isBufferFull()) { - if (closeRequested) return; // quit signal - waitForRead(); - } - off = (head + length) % iobuffer.length; - len = ((head > off) ? head : iobuffer.length) - off; - } - int count; - try { - // the i/o operation might block without releasing the lock, - // so we do this outside of the synchronized block - count = in.read(iobuffer, off, len); - if (count == -1) return; // EOF encountered - } catch (InterruptedIOException e) { - count = e.bytesTransferred; // keep partial transfer - } - synchronized (this) { - length += count; - notify(); - } - } - } - - /* - * Wait for a read when the buffer is full (with the implication - * that space will become available in the buffer after the read - * takes place). - */ - private synchronized void waitForRead() { - try { - if (growWhenFull) { - // wait a second before growing to let reads catch up - wait(readTimeout); - } else { - wait(); - } - } catch (InterruptedException e) { - closeRequested = true; // alternate quit signal - } - // If the buffer is still full, give it a chance to grow - if (growWhenFull && isBufferFull()) { - growBuffer(); - } - } - - private synchronized void growBuffer() { - int newSize = 2 * iobuffer.length; - if (newSize > iobuffer.length) { - if (Policy.DEBUG_STREAMS) { - System.out.println("InputStream growing to " + newSize + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$ - } - byte[] newBuffer = new byte[newSize]; - int pos = 0; - int len = length; - while (len-- > 0) { - newBuffer[pos++] = iobuffer[head++]; - if (head == iobuffer.length) head = 0; - } - iobuffer = newBuffer; - head = 0; - // length instance variable was not changed by this method - } - } - - private boolean isBufferFull() { - return length == iobuffer.length; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java deleted file mode 100644 index 0041e6bbd..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java +++ /dev/null @@ -1,289 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.streams; - -import java.io.BufferedOutputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.io.OutputStream; - -import org.eclipse.team.internal.core.Policy; - -/** - * Wraps an output stream that blocks indefinitely to simulate timeouts on write(), - * flush(), and close(). The resulting output stream is buffered and supports - * retrying operations that failed due to an InterruptedIOException. - * - * Supports resuming partially completed operations after an InterruptedIOException - * REGARDLESS of whether the underlying stream does unless the underlying stream itself - * generates InterruptedIOExceptions in which case it must also support resuming. - * Check the bytesTransferred field to determine how much of the operation completed; - * conversely, at what point to resume. - */ -public class TimeoutOutputStream extends FilterOutputStream { - // unsynchronized variables - private final long writeTimeout; // write() timeout in millis - private final long closeTimeout; // close() timeout in millis, or -1 - - // requests for the thread (synchronized) - private byte[] iobuffer; // circular buffer - private int head = 0; // points to first unwritten byte - private int length = 0; // number of remaining unwritten bytes - private boolean closeRequested = false; // if true, close requested - private boolean flushRequested = false; // if true, flush requested - - // responses from the thread (synchronized) - private Thread thread; - private boolean waitingForClose = false; // if true, the thread is waiting for close() - private IOException ioe = null; - - /** - * Creates a timeout wrapper for an output stream. - * @param out the underlying input stream - * @param bufferSize the buffer size in bytes; should be large enough to mitigate - * Thread synchronization and context switching overhead - * @param writeTimeout the number of milliseconds to block for a write() or flush() before - * throwing an InterruptedIOException; 0 blocks indefinitely - * @param closeTimeout the number of milliseconds to block for a close() before throwing - * an InterruptedIOException; 0 blocks indefinitely, -1 closes the stream in the background - */ - public TimeoutOutputStream(OutputStream out, int bufferSize, long writeTimeout, long closeTimeout) { - super(new BufferedOutputStream(out, bufferSize)); - this.writeTimeout = writeTimeout; - this.closeTimeout = closeTimeout; - this.iobuffer = new byte[bufferSize]; - thread = new Thread(new Runnable() { - public void run() { - runThread(); - } - }, "TimeoutOutputStream");//$NON-NLS-1$ - thread.setDaemon(true); - thread.start(); - } - - /** - * Wraps the underlying stream's method. - * It may be important to wait for a stream to actually be closed because it - * holds an implicit lock on a system resoure (such as a file) while it is - * open. Closing a stream may take time if the underlying stream is still - * servicing a previous request. - * @throws InterruptedIOException if the timeout expired, bytesTransferred will - * reflect the number of bytes flushed from the buffer - * @throws IOException if an i/o error occurs - */ - public void close() throws IOException { - Thread oldThread; - synchronized (this) { - if (thread == null) return; - oldThread = thread; - closeRequested = true; - thread.interrupt(); - checkError(); - } - if (closeTimeout == -1) return; - try { - oldThread.join(closeTimeout); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // we weren't expecting to be interrupted - } - synchronized (this) { - checkError(); - if (thread != null) throw new InterruptedIOException(); - } - } - - /** - * Writes a byte to the stream. - * @throws InterruptedIOException if the timeout expired and no data was sent, - * bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public synchronized void write(int b) throws IOException { - syncCommit(true); - iobuffer[(head + length) % iobuffer.length] = (byte) b; - length++; - notify(); - } - - /** - * Writes multiple bytes to the stream. - * @throws InterruptedIOException if the timeout expired, bytesTransferred will - * reflect the number of bytes sent - * @throws IOException if an i/o error occurs - */ - public synchronized void write(byte[] buffer, int off, int len) throws IOException { - int amount = 0; - try { - do { - syncCommit(true); - while (amount < len && length != iobuffer.length) { - iobuffer[(head + length) % iobuffer.length] = buffer[off++]; - length++; - amount++; - } - } while (amount < len); - } catch (InterruptedIOException e) { - e.bytesTransferred = amount; - throw e; - } - notify(); - } - - /** - * Flushes the stream. - * @throws InterruptedIOException if the timeout expired, bytesTransferred will - * reflect the number of bytes flushed from the buffer - * @throws IOException if an i/o error occurs - */ - public synchronized void flush() throws IOException { - int oldLength = length; - flushRequested = true; - try { - syncCommit(false); - } catch (InterruptedIOException e) { - e.bytesTransferred = oldLength - length; - throw e; - } - notify(); - } - - /** - * Waits for the buffer to drain if it is full. - * @param partial if true, waits until the buffer is partially empty, else drains it entirely - * @throws InterruptedIOException if the buffer could not be drained as requested - */ - private void syncCommit(boolean partial) throws IOException { - checkError(); // check errors before allowing the addition of new bytes - if (partial && length != iobuffer.length || length == 0) return; - if (waitingForClose) throw new IOException(Policy.bind("TimeoutOutputStream.cannotWriteToStream")); //$NON-NLS-1$ - notify(); - try { - wait(writeTimeout); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // we weren't expecting to be interrupted - } - checkError(); // check errors before allowing the addition of new bytes - if (partial && length != iobuffer.length || length == 0) return; - throw new InterruptedIOException(); - } - - /** - * If an exception is pending, throws it. - */ - private void checkError() throws IOException { - if (ioe != null) { - IOException e = ioe; - ioe = null; - throw e; - } - } - - /** - * Runs the thread in the background. - */ - private void runThread() { - try { - writeUntilDone(); - } catch (IOException e) { - synchronized (this) { ioe = e; } - } finally { - waitUntilClosed(); - try { - out.close(); - } catch (IOException e) { - synchronized (this) { ioe = e; } - } finally { - synchronized (this) { - thread = null; - notify(); - } - } - } - } - - /** - * Waits until we have been requested to close the stream. - */ - private synchronized void waitUntilClosed() { - waitingForClose = true; - notify(); - while (! closeRequested) { - try { - wait(); - } catch (InterruptedException e) { - closeRequested = true; // alternate quit signal - } - } - } - - /** - * Writes bytes from the buffer until closed and buffer is empty - */ - private void writeUntilDone() throws IOException { - int bytesUntilFlush = -1; // if > 0, then we will flush after that many bytes have been written - for (;;) { - int off, len; - synchronized (this) { - for (;;) { - if (closeRequested && length == 0) return; // quit signal - if (length != 0 || flushRequested) break; - try { - wait(); - } catch (InterruptedException e) { - closeRequested = true; // alternate quit signal - } - } - off = head; - len = iobuffer.length - head; - if (len > length) len = length; - if (flushRequested && bytesUntilFlush < 0) { - flushRequested = false; - bytesUntilFlush = length; - } - } - - // If there are bytes to be written, write them - if (len != 0) { - // write out all remaining bytes from the buffer before flushing - try { - // the i/o operation might block without releasing the lock, - // so we do this outside of the synchronized block - out.write(iobuffer, off, len); - } catch (InterruptedIOException e) { - len = e.bytesTransferred; - } - } - - // If there was a pending flush, do it - if (bytesUntilFlush >= 0) { - bytesUntilFlush -= len; - if (bytesUntilFlush <= 0) { - // flush the buffer now - try { - out.flush(); - } catch (InterruptedIOException e) { - } - bytesUntilFlush = -1; // might have been 0 - } - } - - // If bytes were written, update the circular buffer - if (len != 0) { - synchronized (this) { - head = (head + len) % iobuffer.length; - length -= len; - notify(); - } - } - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java deleted file mode 100644 index fdb9c675c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IResource; -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.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * Provides a per-thread nested locking mechanism. A thread can acquire a - * lock on a specific resource by calling acquire(). Subsequently, acquire() can be called - * multiple times on the resource or any of its children from within the same thread - * without blocking. Other threads that try - * and acquire the lock on those same resources will be blocked until the first - * thread releases all it's nested locks. - *

              - * The locking is managed by the platform via scheduling rules. This class simply - * provides the nesting mechnism in order to allow the client to determine when - * the lock for the thread has been released. Therefore, this lock will block if - * another thread already locks the same resource.

              - */ -public class BatchingLock { - - private final static boolean DEBUG = Policy.DEBUG_THREADING; - - // This is a placeholder rule used to indicate that no scheduling rule is needed - /* internal use only */ static final ISchedulingRule NULL_SCHEDULING_RULE= new ISchedulingRule() { - public boolean contains(ISchedulingRule rule) { - return false; - } - public boolean isConflicting(ISchedulingRule rule) { - return false; - } - }; - - public class ThreadInfo { - private Set changedResources = new HashSet(); - private IFlushOperation operation; - private List rules = new ArrayList(); - public ThreadInfo(IFlushOperation operation) { - this.operation = operation; - } - /** - * Push a scheduling rule onto the stack for this thread and - * acquire the rule if it is not the workspace root. - * @param resource - */ - public ISchedulingRule pushRule(ISchedulingRule resource, IProgressMonitor monitor) { - // The scheduling rule is either the project or the resource's parent - ISchedulingRule rule = getRuleForResoure(resource); - if (rule != NULL_SCHEDULING_RULE) { - boolean success = false; - try { - Platform.getJobManager().beginRule(rule, monitor); - addRule(rule); - success = true; - } finally { - if (!success) { - try { - // The begin was cancelled (or some other problem occurred). - // Free the scheduling rule - // so the clients of ReentrantLock don't need to - // do an endRule when the operation is cancelled. - Platform.getJobManager().endRule(rule); - } catch (RuntimeException e) { - // Log and ignore so the original exception is not lost - TeamPlugin.log(IStatus.ERROR, "Failed to end scheduling rule", e); //$NON-NLS-1$ - } - } - } - } else { - // Record the fact that we didn't push a rule so we - // can match it when we pop - addRule(rule); - } - return rule; - } - /** - * Pop the scheduling rule from the stack and release it if it - * is not the workspace root. Flush any changed sync info to - * disk if necessary. A flush is necessary if the stack is empty - * or if the top-most non-null scheduling rule was popped as a result - * of this operation. - * @param monitor - * @throws CVSException - */ - public void popRule(ISchedulingRule rule, IProgressMonitor monitor) throws TeamException { - try { - if (isFlushRequired()) { - flush(monitor); - } - } finally { - ISchedulingRule stackedRule = removeRule(); - if (rule == null) { - rule = NULL_SCHEDULING_RULE; - } - Assert.isTrue(stackedRule.equals(rule), "end for resource '" + rule + "' does not match stacked rule '" + stackedRule + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (rule != NULL_SCHEDULING_RULE) { - Platform.getJobManager().endRule(rule); - } - } - } - private ISchedulingRule getRuleForResoure(ISchedulingRule resourceRule) { - ISchedulingRule rule; - if (resourceRule instanceof IResource) { - IResource resource = (IResource)resourceRule; - if (resource.getType() == IResource.ROOT) { - // Never lock the whole workspace - rule = NULL_SCHEDULING_RULE; - } else if (resource.getType() == IResource.PROJECT) { - rule = resource; - } else { - rule = resource.getParent(); - } - } else if (resourceRule instanceof MultiRule) { - // Create a MultiRule for all projects from the given rule - ISchedulingRule[] rules = ((MultiRule)resourceRule).getChildren(); - Set projects = new HashSet(); - for (int i = 0; i < rules.length; i++) { - ISchedulingRule childRule = rules[i]; - if (childRule instanceof IResource) { - projects.add(((IResource)childRule).getProject()); - } - } - if (projects.isEmpty()) { - rule = NULL_SCHEDULING_RULE; - } else if (projects.size() == 1) { - rule = (ISchedulingRule)projects.iterator().next(); - } else { - rule = new MultiRule((ISchedulingRule[]) projects.toArray(new ISchedulingRule[projects.size()])); - } - } else { - // Rule is not associated with resources so ignore it - rule = NULL_SCHEDULING_RULE; - } - return rule; - } - /** - * Return true if we are still nested in - * an acquire for this thread. - * - * @return - */ - public boolean isNested() { - return !rules.isEmpty(); - } - public void addChangedResource(IResource resource) { - changedResources.add(resource); - } - public boolean isEmpty() { - return changedResources.isEmpty(); - } - public IResource[] getChangedResources() { - return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]); - } - public void flush(IProgressMonitor monitor) throws TeamException { - try { - operation.flush(this, monitor); - } catch (OutOfMemoryError e) { - throw e; - } catch (Error e) { - handleAbortedFlush(e); - throw e; - } catch (RuntimeException e) { - handleAbortedFlush(e); - throw e; - } finally { - // We have to clear the resources no matter what since the next attempt - // to fluch may not have an appropriate scheduling rule - changedResources.clear(); - } - } - private boolean isFlushRequired() { - return rules.size() == 1 || remainingRulesAreNull(); - } - /* - * Return true if all but the last rule in the stack is null - */ - private boolean remainingRulesAreNull() { - for (int i = 0; i < rules.size() - 1; i++) { - ISchedulingRule rule = (ISchedulingRule) rules.get(i); - if (rule != NULL_SCHEDULING_RULE) { - return false; - } - } - return true; - } - private void handleAbortedFlush(Throwable t) { - TeamPlugin.log(IStatus.ERROR, Policy.bind("BatchingLock.11"), t); //$NON-NLS-1$ - } - private void addRule(ISchedulingRule rule) { - rules.add(rule); - } - private ISchedulingRule removeRule() { - return (ISchedulingRule)rules.remove(rules.size() - 1); - } - public boolean ruleContains(IResource resource) { - for (Iterator iter = rules.iterator(); iter.hasNext();) { - ISchedulingRule rule = (ISchedulingRule) iter.next(); - if (rule != NULL_SCHEDULING_RULE && rule.contains(resource)) { - return true; - } - } - return false; - } - } - - public interface IFlushOperation { - public void flush(ThreadInfo info, IProgressMonitor monitor) throws TeamException; - } - - private Map infos = new HashMap(); - - /** - * Return the thread info for the current thread - * @return the thread info for the current thread - */ - protected ThreadInfo getThreadInfo() { - Thread thisThread = Thread.currentThread(); - synchronized (infos) { - ThreadInfo info = (ThreadInfo)infos.get(thisThread); - return info; - } - } - - private ThreadInfo getThreadInfo(IResource resource) { - synchronized (infos) { - for (Iterator iter = infos.values().iterator(); iter.hasNext();) { - ThreadInfo info = (ThreadInfo) iter.next(); - if (info.ruleContains(resource)) { - return info; - } - } - return null; - } - } - - public ISchedulingRule acquire(ISchedulingRule resourceRule, IFlushOperation operation, IProgressMonitor monitor) { - ThreadInfo info = getThreadInfo(); - boolean added = false; - synchronized (infos) { - if (info == null) { - info = createThreadInfo(operation); - Thread thisThread = Thread.currentThread(); - infos.put(thisThread, info); - added = true; - if(DEBUG) System.out.println("[" + thisThread.getName() + "] acquired batching lock on " + resourceRule); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - try { - return info.pushRule(resourceRule, monitor); - } catch (OperationCanceledException e) { - // The operation was cancelled. - // If this is the outermost acquire then remove the info that was just added - if (added) { - synchronized (infos) { - infos.remove(Thread.currentThread()); - } - } - throw e; - } - } - - /** - * Create the ThreadInfo instance used to cache the lock state for the - * current thread. Subclass can override to provide a subclass of - * ThreadInfo. - * @param operation the flush operation - * @return a ThreadInfo instance - */ - protected ThreadInfo createThreadInfo(IFlushOperation operation) { - return new ThreadInfo(operation); - } - - /** - * Release the lock held on any resources by this thread. The provided rule must - * be identical to the rule returned by the corresponding acquire(). If the rule - * for the release is non-null and all remaining rules held by the lock are null, - * the the flush operation provided in the acquire method will be executed. - */ - public void release(ISchedulingRule rule, IProgressMonitor monitor) throws TeamException { - ThreadInfo info = getThreadInfo(); - Assert.isNotNull(info, "Unmatched acquire/release."); //$NON-NLS-1$ - Assert.isTrue(info.isNested(), "Unmatched acquire/release."); //$NON-NLS-1$ - info.popRule(rule, monitor); - synchronized (infos) { - if (!info.isNested()) { - Thread thisThread = Thread.currentThread(); - if(DEBUG) System.out.println("[" + thisThread.getName() + "] released batching lock"); //$NON-NLS-1$ //$NON-NLS-2$ - infos.remove(thisThread); - } - } - } - - public void resourceChanged(IResource resource) { - ThreadInfo info = getThreadInfo(); - Assert.isNotNull(info, "Folder changed outside of resource lock"); //$NON-NLS-1$ - info.addChangedResource(resource); - } - - /** - * Flush any changes accumulated by the lock so far. - */ - public void flush(IProgressMonitor monitor) throws TeamException { - ThreadInfo info = getThreadInfo(); - Assert.isNotNull(info, "Flush requested outside of resource lock"); //$NON-NLS-1$ - info.flush(monitor); - } - - public boolean isWithinActiveOperationScope(IResource resource) { - synchronized (infos) { - return getThreadInfo(resource) != null; - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ContentComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ContentComparator.java deleted file mode 100644 index c4184592f..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ContentComparator.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.io.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * This is an internal class that is usd by the ContentComparisonSyncInfoFilter - * to compare the comtents of the local and remote resources - */ -public class ContentComparator { - - private boolean ignoreWhitespace = false; - - public ContentComparator(boolean ignoreWhitespace) { - this.ignoreWhitespace = ignoreWhitespace; - } - - public boolean compare(Object e1, Object e2, IProgressMonitor monitor) { - InputStream is1 = null; - InputStream is2 = null; - try { - monitor.beginTask(null, 100); - is1 = getContents(e1, Policy.subMonitorFor(monitor, 50)); - is2 = getContents(e2, Policy.subMonitorFor(monitor, 50)); - return contentsEqual(is1, is2, shouldIgnoreWhitespace()); - } catch(TeamException e) { - TeamPlugin.log(e); - return false; - } finally { - try { - try { - if (is1 != null) { - is1.close(); - } - } finally { - if (is2 != null) { - is2.close(); - } - } - } catch (IOException e) { - // Ignore - } - monitor.done(); - } - } - - protected boolean shouldIgnoreWhitespace() { - return ignoreWhitespace; - } - - /** - * Returns true if both input streams byte contents is - * identical. - * - * @param input1 - * first input to contents compare - * @param input2 - * second input to contents compare - * @return true if content is equal - */ - private boolean contentsEqual(InputStream is1, InputStream is2, boolean ignoreWhitespace) { - try { - if (is1 == is2) - return true; - - if (is1 == null && is2 == null) // no byte contents - return true; - - if (is1 == null || is2 == null) // only one has - // contents - return false; - - while (true) { - int c1 = is1.read(); - while (shouldIgnoreWhitespace() && isWhitespace(c1)) - c1 = is1.read(); - int c2 = is2.read(); - while (shouldIgnoreWhitespace() && isWhitespace(c2)) - c2 = is2.read(); - if (c1 == -1 && c2 == -1) - return true; - if (c1 != c2) - break; - - } - } catch (IOException ex) { - } finally { - try { - try { - if (is1 != null) { - is1.close(); - } - } finally { - if (is2 != null) { - is2.close(); - } - } - } catch (IOException e) { - // Ignore - } - } - return false; - } - - private boolean isWhitespace(int c) { - if (c == -1) - return false; - return Character.isWhitespace((char) c); - } - - private InputStream getContents(Object resource, IProgressMonitor monitor) throws TeamException { - try { - if (resource instanceof IFile) { - return new BufferedInputStream(((IFile) resource).getContents()); - } else if(resource instanceof IResourceVariant) { - IResourceVariant remote = (IResourceVariant)resource; - if (!remote.isContainer()) { - return new BufferedInputStream(remote.getStorage(monitor).getContents()); - } - } - return null; - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java deleted file mode 100644 index 1e7f5af9d..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.*; - -/** - * A ResourceVariantByteStore that optimizes the memory footprint - * of a remote resource variant tree by only storing those bytes that - * differ from a base resource variant tree. This class should only be used - * for cases where the base and remote are on the same line-of-descent. - * For example, when the remote tree represents the current state of a branch - * and the base represents the state of the same branch when the local workspace - * as last refreshed. - *

              - * This class also contains the logic that allows subclasses to determine if - * bytes stored in the remote tree are on a different line-of-descent than the base. - * This is necessary because it is possible for the base tree to change in ways that - * invalidate the stored remote variants. For example, if the local resources are moved - * from the main trunck to a branch, any cached remote resource variants would be stale. - * - * @since 3.0 - */ -public abstract class DescendantResourceVariantByteStore extends ResourceVariantByteStore { - - ResourceVariantByteStore baseStore, remoteStore; - - public DescendantResourceVariantByteStore(ResourceVariantByteStore baseCache, ResourceVariantByteStore remoteCache) { - this.baseStore = baseCache; - this.remoteStore = remoteCache; - } - - /** - * This method will dispose the remote cache but not the base cache. - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose() - */ - public void dispose() { - remoteStore.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#getBytes(org.eclipse.core.resources.IResource) - */ - public byte[] getBytes(IResource resource) throws TeamException { - byte[] remoteBytes = remoteStore.getBytes(resource); - byte[] baseBytes = baseStore.getBytes(resource); - if (baseBytes == null) { - // There is no base so use the remote bytes - return remoteBytes; - } - if (remoteBytes == null) { - if (isVariantKnown(resource)) { - // The remote is known to not exist - // TODO: The check for NO_REMOTE does not take into consideration the line-of-descent - return remoteBytes; - } else { - // The remote was either never queried or was the same as the base. - // In either of these cases, the base bytes are used. - return baseBytes; - } - } - if (isDescendant(resource, baseBytes, remoteBytes)) { - // Only use the remote bytes if they are later on the same line-of-descent as the base - return remoteBytes; - } - // Use the base sbytes since the remote bytes must be stale (i.e. are - // not on the same line-of-descent - return baseBytes; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#setBytes(org.eclipse.core.resources.IResource, byte[]) - */ - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - byte[] baseBytes = baseStore.getBytes(resource); - if (baseBytes != null && equals(baseBytes, bytes)) { - // Remove the existing bytes so the base will be used (thus saving space) - return remoteStore.flushBytes(resource, IResource.DEPTH_ZERO); - } else { - return remoteStore.setBytes(resource, bytes); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#removeBytes(org.eclipse.core.resources.IResource, int) - */ - public boolean flushBytes(IResource resource, int depth) throws TeamException { - return remoteStore.flushBytes(resource, depth); - } - - /** - * Return true if the variant associated with the given local - * resource has been cached. This method is useful for those cases when - * there are no bytes for a resource variant and the client wants to - * know if this means that the remote does exist (i.e. this method returns - * true) or the remote has not been fetched (i.e. this method returns - * false). - * @param resource the local resource - * @return true if the variant associated with the given local - * resource has been cached. - * @throws TeamException - */ - public abstract boolean isVariantKnown(IResource resource) throws TeamException; - - /** - * This method indicates whether the remote bytes are a later revision or version - * on the same line-of-descent as the base. A line of descent may be a branch or a fork - * (depending on the terminology used by the versioing server). If this method returns - * false then the remote bytes will be ignored by this tree. - * @param resource the local resource - * @param baseBytes the base bytes for the local resoource - * @param remoteBytes the remote bytes for the local resoource - * @return whether the remote bytes are later on the same line-of-descent as the base bytes - */ - protected abstract boolean isDescendant(IResource resource, byte[] baseBytes, byte[] remoteBytes) throws TeamException; - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#setVariantDoesNotExist(org.eclipse.core.resources.IResource) - */ - public boolean deleteBytes(IResource resource) throws TeamException { - return remoteStore.deleteBytes(resource); - } - - /** - * Return the base tree from which the remote is descendant. - * @return Returns the base tree. - */ - protected ResourceVariantByteStore getBaseStore() { - return baseStore; - } - - /** - * Return the remote tree which contains bytes only for the resource variants - * that differ from those in the base tree. - * @return Returns the remote tree. - */ - protected ResourceVariantByteStore getRemoteStore() { - return remoteStore; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) throws TeamException { - IResource[] remoteMembers = getRemoteStore().members(resource); - IResource[] baseMembers = getBaseStore().members(resource); - Set members = new HashSet(); - for (int i = 0; i < remoteMembers.length; i++) { - members.add(remoteMembers[i]); - } - for (int i = 0; i < baseMembers.length; i++) { - IResource member = baseMembers[i]; - // Add the base only if the remote does not know about it - // (i.e. hasn't marked it as deleted - if (!isVariantKnown(member)) { - members.add(member); - } - } - return (IResource[]) members.toArray(new IResource[members.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { - remoteStore.run(root, runnable, monitor); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java deleted file mode 100644 index e01d94498..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java +++ /dev/null @@ -1,490 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.*; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.core.*; - -/** - * This handler collects changes and removals to resources and calculates their - * synchronization state in a background job. The result is fed input the SyncSetInput. - * - * Exceptions that occur when the job is processing the events are collected and - * returned as part of the Job's status. - */ -public class SubscriberEventHandler extends BackgroundEventHandler { - // The set that receives notification when the resource synchronization state - // has been calculated by the job. - private SyncSetInputFromSubscriber syncSetInput; - - // Changes accumulated by the event handler - private List resultCache = new ArrayList(); - - private boolean started = false; - private boolean initializing = true; - - private IProgressMonitor progressGroup; - - private int ticks; - - private IResource[] roots; - - /** - * Internal resource synchronization event. Can contain a result. - */ - class SubscriberEvent extends ResourceEvent{ - static final int REMOVAL = 1; - static final int CHANGE = 2; - static final int INITIALIZE = 3; - SyncInfo result; - - SubscriberEvent(IResource resource, int type, int depth) { - super(resource, type, depth); - } - public SubscriberEvent( - IResource resource, - int type, - int depth, - SyncInfo result) { - this(resource, type, depth); - this.result = result; - } - public SyncInfo getResult() { - return result; - } - protected String getTypeString() { - switch (getType()) { - case REMOVAL : - return "REMOVAL"; //$NON-NLS-1$ - case CHANGE : - return "CHANGE"; //$NON-NLS-1$ - case INITIALIZE : - return "INITIALIZE"; //$NON-NLS-1$ - default : - return "INVALID"; //$NON-NLS-1$ - } - } - } - - /** - * This is a special event used to reset and connect sync sets. - * The preemtive flag is used to indicate that the runnable should take - * the highest priority and thus be placed on the front of the queue - * and be processed as soon as possible, preemting any event that is currently - * being processed. The curent event will continue processing once the - * high priority event has been processed - */ - public class RunnableEvent extends Event { - static final int RUNNABLE = 1000; - private IWorkspaceRunnable runnable; - private boolean preemtive; - public RunnableEvent(IWorkspaceRunnable runnable, boolean preemtive) { - super(RUNNABLE); - this.runnable = runnable; - this.preemtive = preemtive; - } - public void run(IProgressMonitor monitor) throws CoreException { - runnable.run(monitor); - } - public boolean isPreemtive() { - return preemtive; - } - } - - /** - * Create a handler. This will initialize all resources for the subscriber associated with - * the set. - * @param set the subscriber set to feed changes into - */ - public SubscriberEventHandler(Subscriber subscriber, IResource[] roots) { - super( - Policy.bind("SubscriberEventHandler.jobName", subscriber.getName()), //$NON-NLS-1$ - Policy.bind("SubscriberEventHandler.errors", subscriber.getName())); //$NON-NLS-1$ - this.roots = roots; - this.syncSetInput = new SyncSetInputFromSubscriber(subscriber, this); - } - - /** - * Start the event handler by queuing events to prime the sync set input with the out-of-sync - * resources of the subscriber. - */ - public synchronized void start() { - // Set the started flag to enable event queueing. - // We are gaurenteed to be the first since this method is synchronized. - started = true; - IResource[] resources = this.roots; - if (resources == null) { - resources = syncSetInput.getSubscriber().roots(); - } - reset(resources, SubscriberEvent.INITIALIZE); - initializing = false; - } - - protected synchronized void queueEvent(Event event, boolean front) { - // Only post events if the handler is started - if (started) { - super.queueEvent(event, front); - } - } - /** - * Schedule the job or process the events now. - */ - public void schedule() { - Job job = getEventHandlerJob(); - if (job.getState() == Job.NONE) { - if(progressGroup != null) { - job.setSystem(false); - job.setProgressGroup(progressGroup, ticks); - } else { - job.setSystem(!initializing); - } - } - getEventHandlerJob().schedule(); - } - - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#jobDone(org.eclipse.core.runtime.jobs.IJobChangeEvent) - */ - protected void jobDone(IJobChangeEvent event) { - super.jobDone(event); - progressGroup = null; - } - - /** - * Initialize all resources for the subscriber associated with the set. This will basically recalculate - * all synchronization information for the subscriber. - *

              - * This method is sycnrhonized with the queueEvent method to ensure that the two events - * queued by this method are back-to-back - */ - public synchronized void reset(IResource[] roots) { - if (roots == null) { - roots = syncSetInput.getSubscriber().roots(); - } else { - this.roots = roots; - } - // First, reset the sync set input to clear the sync set - run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - syncSetInput.reset(monitor); - } - }, false /* keep ordering the same */); - // Then, prime the set from the subscriber - reset(roots, SubscriberEvent.CHANGE); - } - - /** - * Called by a client to indicate that a resource has changed and its synchronization state - * should be recalculated. - * @param resource the changed resource - * @param depth the depth of the change calculation - */ - public void change(IResource resource, int depth) { - queueEvent(new SubscriberEvent(resource, SubscriberEvent.CHANGE, depth), false); - } - - /** - * Called by a client to indicate that a resource has been removed and should be removed. The - * removal will propagate to the set. - * @param resource the resource that was removed - */ - public void remove(IResource resource) { - queueEvent( - new SubscriberEvent(resource, SubscriberEvent.REMOVAL, IResource.DEPTH_INFINITE), false); - } - - /** - * Collect the calculated synchronization information for the given resource at the given depth. The - * results are added to the provided list. - */ - private void collect( - IResource resource, - int depth, - IProgressMonitor monitor) { - - // handle any preemtive events before continuing - handlePreemptiveEvents(monitor); - - if (resource.getType() != IResource.FILE - && depth != IResource.DEPTH_ZERO) { - try { - IResource[] members = - syncSetInput.getSubscriber().members(resource); - for (int i = 0; i < members.length; i++) { - collect( - members[i], - depth == IResource.DEPTH_INFINITE - ? IResource.DEPTH_INFINITE - : IResource.DEPTH_ZERO, - monitor); - } - } catch (TeamException e) { - handleException(e, resource, ITeamStatus.SYNC_INFO_SET_ERROR, Policy.bind("SubscriberEventHandler.8", resource.getFullPath().toString(), e.getMessage())); //$NON-NLS-1$ - } - } - - monitor.subTask(Policy.bind("SubscriberEventHandler.2", resource.getFullPath().toString())); //$NON-NLS-1$ - try { - SyncInfo info = syncSetInput.getSubscriber().getSyncInfo(resource); - // resource is no longer under the subscriber control - if (info == null) { - resultCache.add( - new SubscriberEvent(resource, SubscriberEvent.REMOVAL, IResource.DEPTH_ZERO)); - } else { - resultCache.add( - new SubscriberEvent(resource, SubscriberEvent.CHANGE, IResource.DEPTH_ZERO, info)); - } - handlePendingDispatch(monitor); - } catch (TeamException e) { - handleException(e, resource, ITeamStatus.RESOURCE_SYNC_INFO_ERROR, Policy.bind("SubscriberEventHandler.9", resource.getFullPath().toString(), e.getMessage())); //$NON-NLS-1$ - } - monitor.worked(1); - } - - private void handlePendingDispatch(IProgressMonitor monitor) { - if (isReadyForDispatch(false /*don't wait if queue is empty*/)) { - try { - dispatchEvents(Policy.subMonitorFor(monitor, 5)); - } catch (TeamException e) { - handleException(e, null, ITeamStatus.SYNC_INFO_SET_ERROR, e.getMessage()); - } - } - } - - /* - * Handle the exception by returning it as a status from the job but also by - * dispatching it to the sync set input so any down stream views can react - * accordingly. - * The resource passed may be null. - */ - private void handleException(CoreException e, IResource resource, int code, String message) { - handleException(e); - syncSetInput.handleError(new TeamStatus(IStatus.ERROR, TeamPlugin.ID, code, message, e, resource)); - } - - /** - * Called to initialize to calculate the synchronization information using the optimized subscriber method. For - * subscribers that don't support the optimization, all resources in the subscriber are manually re-calculated. - * @param resources the resources to check - * @param depth the depth - * @param monitor - * @return Event[] the change events - * @throws TeamException - */ - private void collectAll( - IResource resource, - int depth, - IProgressMonitor monitor) { - - - monitor.beginTask(null, IProgressMonitor.UNKNOWN); - try { - - // Create a monitor that will handle preemptions and dispatch if required - IProgressMonitor collectionMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN) { - boolean dispatching = false; - public void subTask(String name) { - dispatch(); - super.subTask(name); - } - private void dispatch() { - if (dispatching) return; - try { - dispatching = true; - handlePreemptiveEvents(this); - handlePendingDispatch(this); - } finally { - dispatching = false; - } - } - public void worked(int work) { - dispatch(); - super.worked(work); - } - }; - - // Create a sync set that queues up resources and errors for dispatch - SyncInfoSet collectionSet = new SyncInfoSet() { - public void add(SyncInfo info) { - super.add(info); - resultCache.add( - new SubscriberEvent(info.getLocal(), SubscriberEvent.CHANGE, IResource.DEPTH_ZERO, info)); - } - public void addError(ITeamStatus status) { - super.addError(status); - TeamPlugin.getPlugin().getLog().log(status); - syncSetInput.handleError(status); - } - public void remove(IResource resource) { - super.remove(resource); - resultCache.add( - new SubscriberEvent(resource, SubscriberEvent.REMOVAL, IResource.DEPTH_ZERO)); - } - }; - - syncSetInput.getSubscriber().collectOutOfSync(new IResource[] { resource }, depth, collectionSet, collectionMonitor); - - } finally { - monitor.done(); - } - } - - /** - * Feed the given events to the set. The appropriate method on the set is called - * for each event type. - * @param events - */ - private void dispatchEvents(SubscriberEvent[] events, IProgressMonitor monitor) { - // this will batch the following set changes until endInput is called. - SubscriberSyncInfoSet syncSet = syncSetInput.getSyncSet(); - try { - syncSet.beginInput(); - for (int i = 0; i < events.length; i++) { - SubscriberEvent event = events[i]; - switch (event.getType()) { - case SubscriberEvent.CHANGE : - syncSetInput.collect(event.getResult(), monitor); - break; - case SubscriberEvent.REMOVAL : - syncSet.remove(event.getResource(), event.getDepth()); - break; - } - } - } finally { - syncSet.endInput(monitor); - } - } - - /** - * Initialize all resources for the subscriber associated with the set. This will basically recalculate - * all synchronization information for the subscriber. - * @param type can be Event.CHANGE to recalculate all states or Event.INITIALIZE to perform the - * optimized recalculation if supported by the subscriber. - */ - private void reset(IResource[] roots, int type) { - IResource[] resources = roots; - for (int i = 0; i < resources.length; i++) { - queueEvent(new SubscriberEvent(resources[i], type, IResource.DEPTH_INFINITE), false); - } - } - - protected void processEvent(Event event, IProgressMonitor monitor) { - try { - // Cancellation is dangerous because this will leave the sync info in a bad state. - // Purposely not checking - - int type = event.getType(); - switch (type) { - case RunnableEvent.RUNNABLE : - executeRunnable(event, monitor); - break; - case SubscriberEvent.REMOVAL : - resultCache.add(event); - break; - case SubscriberEvent.CHANGE : - collect( - event.getResource(), - ((ResourceEvent)event).getDepth(), - monitor); - break; - case SubscriberEvent.INITIALIZE : - monitor.subTask(Policy.bind("SubscriberEventHandler.2", event.getResource().getFullPath().toString())); //$NON-NLS-1$ - collectAll( - event.getResource(), - ((ResourceEvent)event).getDepth(), - Policy.subMonitorFor(monitor, 64)); - break; - } - } catch (OperationCanceledException e) { - // the job has been cancelled. - // Clear the queue and propogate the cancellation through the sets. - resultCache.clear(); - syncSetInput.handleError(new TeamStatus(IStatus.ERROR, TeamPlugin.ID, ITeamStatus.SYNC_INFO_SET_CANCELLATION, Policy.bind("SubscriberEventHandler.12"), e, ResourcesPlugin.getWorkspace().getRoot())); //$NON-NLS-1$ - } catch (RuntimeException e) { - // handle the exception and keep processing - handleException(new TeamException(Policy.bind("SubscriberEventHandler.10"), e), event.getResource(), ITeamStatus.SYNC_INFO_SET_ERROR, Policy.bind("SubscriberEventHandler.11", event.getResource().getFullPath().toString(), e.getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /* - * Execute the RunnableEvent - */ - private void executeRunnable(Event event, IProgressMonitor monitor) { - try { - // Dispatch any queued results to clear pending output events - dispatchEvents(Policy.subMonitorFor(monitor, 1)); - } catch (TeamException e) { - handleException(e, null, ITeamStatus.SYNC_INFO_SET_ERROR, e.getMessage()); - } - try { - ((RunnableEvent)event).run(Policy.subMonitorFor(monitor, 1)); - } catch (CoreException e) { - handleException(e, null, ITeamStatus.SYNC_INFO_SET_ERROR, e.getMessage()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#dispatchEvents() - */ - protected boolean doDispatchEvents(IProgressMonitor monitor) { - if (!resultCache.isEmpty()) { - dispatchEvents((SubscriberEvent[]) resultCache.toArray(new SubscriberEvent[resultCache.size()]), monitor); - resultCache.clear(); - return true; - } - return false; - } - - /** - * Queue up the given runnable in an event to be processed by this job - * @param runnable the runnable to be run by the handler - */ - public void run(IWorkspaceRunnable runnable, boolean frontOnQueue) { - queueEvent(new RunnableEvent(runnable, frontOnQueue), frontOnQueue); - } - - /** - * Return the sync set input that was created by this event handler - * @return - */ - public SyncSetInputFromSubscriber getSyncSetInput() { - return syncSetInput; - } - - public void setProgressGroupHint(IProgressMonitor progressGroup, int ticks) { - this.progressGroup = progressGroup; - this.ticks = ticks; - } - - /** - * @return Returns the started. - */ - protected boolean isStarted() { - return started; - } - - private void handlePreemptiveEvents(IProgressMonitor monitor) { - Event event = peek(); - if (event instanceof RunnableEvent && ((RunnableEvent)event).isPreemtive()) { - executeRunnable(nextElement(), monitor); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java deleted file mode 100644 index 8bc89a397..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import org.eclipse.core.resources.*; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.internal.core.Assert; - -/** - * This class acts as a superclass for any class that is collecting subscriber - * resources. It provides funtionality that listens to resource deltas and subscriber change events - * in order to determine when the state of resources that are supervised by a subscriber may have changed. - */ -public abstract class SubscriberResourceCollector implements IResourceChangeListener, ISubscriberChangeListener { - - Subscriber subscriber; - - /** - * Create the collector and register it as a listener with the workspace - * and the subscriber. - */ - public SubscriberResourceCollector(Subscriber subscriber) { - Assert.isNotNull(subscriber); - this.subscriber = subscriber; - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - subscriber.addListener(this); - } - - /** - * Returns the Subscriber associated with this collector. - * - * @return the Subscriber associated with this collector. - */ - public Subscriber getSubscriber() { - return subscriber; - } - - /** - * Deregister the listeners for this collector. - */ - public void dispose() { - getSubscriber().removeListener(this); - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.sync.TeamDelta[]) - */ - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - try { - beginInput(); - IResource[] roots = getRoots(); - for (int i = 0; i < deltas.length; i++) { - switch (deltas[i].getFlags()) { - case ISubscriberChangeEvent.SYNC_CHANGED : - if (isAllRootsIncluded() || isDescendantOfRoot(deltas[i].getResource(), roots)) { - change(deltas[i].getResource(), IResource.DEPTH_ZERO); - } - break; - case ISubscriberChangeEvent.ROOT_REMOVED : - remove(deltas[i].getResource()); - break; - case ISubscriberChangeEvent.ROOT_ADDED : - if (isAllRootsIncluded() || isDescendantOfRoot(deltas[i].getResource(), roots)) { - change(deltas[i].getResource(), IResource.DEPTH_INFINITE); - } - break; - } - } - } finally { - endInput(); - } - } - - /** - * This method is invoked at the beginning of a subscriber change event - * or resource delta event. The endInput methos will be invoked at some point - * following this. There may be several invokations of remove or change - * in between. - */ - protected void beginInput() { - // Do nothing by default - } - - /** - * The processing of the resource or subscriber delta has finished. - * Subclasses can accumulate removals and changes and handle them - * at this point to allow batched change events. - */ - protected void endInput() { - // Do nothing by default - } - - - /*(non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - beginInput(); - processDelta(event.getDelta(), getRoots()); - } finally { - endInput(); - } - } - - /** - * Process the resource delta and posts all necessary events to the background - * event handler. - * - * @param delta the resource delta to analyse - */ - protected void processDelta(IResourceDelta delta, IResource[] roots) { - IResource resource = delta.getResource(); - int kind = delta.getKind(); - - if (resource.getType() == IResource.PROJECT) { - // Handle projects that should be removed from the collector - if (((kind & IResourceDelta.REMOVED) != 0) /* deleted project */ - || (delta.getFlags() & IResourceDelta.OPEN) != 0 && !((IProject) resource).isOpen() /* closed project */ - || !isAncestorOfRoot(resource, roots)) /* not within subscriber roots */ { - // If the project has any entries in the sync set, remove them - if (hasMembers(resource)) { - remove(resource); - } - } - } - - boolean visitChildren = false; - if (isDescendantOfRoot(resource, roots)) { - visitChildren = true; - // If the resource has changed type, remove the old resource handle - // and add the new one - if ((delta.getFlags() & IResourceDelta.TYPE) != 0) { - remove(resource); - change(resource, IResource.DEPTH_INFINITE); - } - - // Check the flags for changes the SyncSet cares about. - // Notice we don't care about MARKERS currently. - int changeFlags = delta.getFlags(); - if ((changeFlags & (IResourceDelta.OPEN | IResourceDelta.CONTENT)) != 0) { - change(resource, IResource.DEPTH_ZERO); - } - - // Check the kind and deal with those we care about - if ((delta.getKind() & (IResourceDelta.REMOVED | IResourceDelta.ADDED)) != 0) { - change(resource, IResource.DEPTH_ZERO); - } - } - - // Handle changed children - if (visitChildren || isAncestorOfRoot(resource, roots)) { - IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED | IResourceDelta.REMOVED | IResourceDelta.ADDED); - for (int i = 0; i < affectedChildren.length; i++) { - processDelta(affectedChildren[i], roots); - } - } - } - - /** - * Return the root resources that are to be considered by this handler. - * These may be either the subscriber roots or a set of resources that are - * contained by the subscriber's roots. - * @return the root resources that are to be considered by this handler - */ - protected IResource[] getRoots() { - return getSubscriber().roots(); - } - - /** - * Return whether the given resource, which is not - * within the roots of this handler, has children - * that are. - * @param resource the resource - * @return whether the resource has children that are being considered - * by this handler. - */ - protected boolean hasMembers(IResource resource) { - IResource[] roots = getRoots(); - for (int i = 0; i < roots.length; i++) { - IResource root = roots[i]; - if (resource.getFullPath().isPrefixOf(root.getFullPath())) { - return true; - } - } - return false; - } - - /** - * The resource is no longer of concern to the subscriber. - * Remove the resource and any of it's descendants - * from the set of resources being collected. - * @param resource the resource to be removed along with its - * descendants. - */ - protected abstract void remove(IResource resource); - - /** - * The resource sync state has changed to the depth specified. - * @param resource the resource - * @param depth the depth - */ - protected abstract void change(IResource resource, int depth); - - /** - * Return whether all roots of a subscriber are included or - * if the collector is only consider a subset of the resources. - * @return whether all roots of a subscriber are included - */ - protected boolean isAllRootsIncluded() { - return true; - } - - private boolean isAncestorOfRoot(IResource parent, IResource[] roots) { - // Always traverse into projects in case a root was removed - if (parent.getType() == IResource.ROOT) return true; - for (int i = 0; i < roots.length; i++) { - IResource resource = roots[i]; - if (parent.getFullPath().isPrefixOf(resource.getFullPath())) { - return true; - } - } - return false; - } - - private boolean isDescendantOfRoot(IResource resource, IResource[] roots) { - for (int i = 0; i < roots.length; i++) { - IResource root = roots[i]; - if (root.getFullPath().isPrefixOf(resource.getFullPath())) { - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java deleted file mode 100644 index b9de6d77c..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.Policy; - -/** - * This collector maintains a {@link SyncInfoSet} for a particular team subscriber keeping - * it up-to-date with both incoming changes and outgoing changes as they occur for - * resources in the workspace. The collector can be configured to consider all the subscriber's - * roots or only a subset. - *

              - * The advantage of this collector is that it processes both resource and team - * subscriber deltas in a background thread. - *

              - * @since 3.0 - */ -public final class SubscriberSyncInfoCollector extends SubscriberResourceCollector { - - private SyncSetInputFromSubscriber subscriberInput; - private SyncSetInputFromSyncSet filteredInput; - private SubscriberEventHandler eventHandler; - private IResource[] roots; - - /** - * Create a collector that collects out-of-sync resources that are children of - * the given roots. If the roots are null, then all out-of-sync resources - * from the subscriber are collected. An empty array of roots will cause no resources - * to be collected. The start() method must be called after creation - * to rpime the collector's sync sets. - * @param subscriber the Subscriber - * @param roots the roots of the out-of-sync resources to be collected - */ - public SubscriberSyncInfoCollector(Subscriber subscriber, IResource[] roots) { - super(subscriber); - this.roots = roots; - this.eventHandler = new SubscriberEventHandler(subscriber, roots); - this.subscriberInput = eventHandler.getSyncSetInput(); - filteredInput = new SyncSetInputFromSyncSet(subscriberInput.getSyncSet(), getEventHandler()); - filteredInput.setFilter(new SyncInfoFilter() { - public boolean select(SyncInfo info, IProgressMonitor monitor) { - return true; - } - }); - - } - - public void setProgressGroup(IProgressMonitor monitor, int ticks) { - getEventHandler().setProgressGroupHint(monitor, ticks); - } - - /** - * Start the collector. - */ - public void start() { - eventHandler.start(); - } - - /** - * This causes the calling thread to wait any background collection of out-of-sync resources - * to stop before returning. - * @param monitor a progress monitor - */ - public void waitForCollector(IProgressMonitor monitor) { - monitor.worked(1); - // wait for the event handler to process changes. - while(eventHandler.getEventHandlerJob().getState() != Job.NONE) { - monitor.worked(1); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } - Policy.checkCanceled(monitor); - } - monitor.worked(1); - } - - /** - * Clears this collector's sync info sets and causes them to be recreated from the - * associated Subscriber. The reset will occur in the background. If the - * caller wishes to wait for the reset to complete, they should call - * {@link waitForCollector(IProgressMonitor)}. - */ - public void reset() { - eventHandler.reset(getRoots()); - } - - /** - * Disposes of the background job associated with this collector and deregisters - * all it's listeners. This method must be called when the collector is no longer - * referenced and could be garbage collected. - */ - public void dispose() { - eventHandler.shutdown(); - subscriberInput.disconnect(); - if(filteredInput != null) { - filteredInput.disconnect(); - } - super.dispose(); - } - - /** - * Return the roots that are being considered by this collector. - * By default, the collector is interested in the roots of its - * subscriber. However, the set can be reduced using {@link setRoots(IResource)). - * @return - */ - public IResource[] getRoots() { - if (roots == null) { - return super.getRoots(); - } else { - return roots; - } - } - - /* - * Returns whether the collector is configured to collect for - * all roots of the subscriber or not - * @return true if the collector is considering all - * roots of the subscriber and false otherwise - */ - public boolean isAllRootsIncluded() { - return roots == null; - } - - /** - * Return the event handler that performs the background processing for this collector. - * The event handler also serves the purpose of serializing the modifications and adjustments - * to the collector's sync sets in order to ensure that the state of the sets is kept - * consistent. - * @return Returns the eventHandler. - */ - protected SubscriberEventHandler getEventHandler() { - return eventHandler; - } - - /** - * Return the SyncInfoSet that contains all the all the out-of-sync resources for the - * subscriber that are descendants of the roots of this collector. The set will contain only those resources that are children of the roots - * of the collector unless the roots of the colletor has been set to null - * in which case all out-of-sync resources from the subscriber are collected. - * @return the subscriber sync info set - */ - public SyncInfoTree getSubscriberSyncInfoSet() { - return subscriberInput.getSyncSet(); - } - - public SyncInfoTree getSyncInfoSet() { - return filteredInput.getSyncSet(); - } - - /** - * Set the filter for this collector. Only elements that match the filter will - * be in the out sync info set. - * @see getSyncInfoSet() - * @param filter the sync info filter - */ - public void setFilter(SyncInfoFilter filter) { - filteredInput.setFilter(filter); - filteredInput.reset(); - } - - /** - * Return the filter that is filtering the output of this collector. - * @return a sync info filter - */ - public SyncInfoFilter getFilter() { - if(filteredInput != null) { - return filteredInput.getFilter(); - } - return null; - } - - /** - * @param roots2 - */ - public void setRoots(IResource[] roots) { - this.roots = roots; - reset(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#hasMembers(org.eclipse.core.resources.IResource) - */ - protected boolean hasMembers(IResource resource) { - return getSubscriberSyncInfoSet().hasMembers(resource); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#remove(org.eclipse.core.resources.IResource) - */ - protected void remove(IResource resource) { - eventHandler.remove(resource); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#change(org.eclipse.core.resources.IResource, int) - */ - protected void change(IResource resource, int depth) { - eventHandler.change(resource, depth); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoSet.java deleted file mode 100644 index f719cb187..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoSet.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.team.internal.core.subscribers; - -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.core.Policy; - -/** - * The SubscriberSyncInfoSet is a SyncInfoSet that provides the ability to add, - * remove and change SyncInfo and fires change event notifications to registered listeners. - * It also provides the ability - * to batch changes in a single change notification as well as optimizations for sync info retrieval. - * - * This class uses synchronized methods and synchronized blocks to protect internal data structures during both access - * and modify operations and uses an ILock to make modification operations thread-safe. The events - * are fired while this lock is held so clients responding to these events should not obtain their own internal locks - * while processing change events. - * - * TODO: Override modification methods to enforce use with handler - * - */ -public class SubscriberSyncInfoSet extends SyncInfoTree { - - protected SubscriberEventHandler handler; - - public SubscriberSyncInfoSet(SubscriberEventHandler handler) { - this.handler = handler; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.SyncInfoSet#connect(org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener, org.eclipse.core.runtime.IProgressMonitor) - */ - public void connect(ISyncInfoSetChangeListener listener, IProgressMonitor monitor) { - if (handler == null) { - super.connect(listener, monitor); - } else { - connect(listener); - } - } - - /** - * Variation of connect that does not need progress and does not throw an exception. - * Progress is provided by the background event handler and errors are passed through - * the chain to the view. - * @param listener - */ - public void connect(final ISyncInfoSetChangeListener listener) { - if (handler == null) { - // Should only use this connect if the set has a handler - throw new UnsupportedOperationException(); - } else { - handler.run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) { - try { - beginInput(); - monitor.beginTask(null, 100); - removeSyncSetChangedListener(listener); - addSyncSetChangedListener(listener); - listener.syncInfoSetReset(SubscriberSyncInfoSet.this, Policy.subMonitorFor(monitor, 95)); - } finally { - endInput(Policy.subMonitorFor(monitor, 5)); - monitor.done(); - } - } - }, true /* high priority */); - } - } - - /** - * Return the handler that is used to provide event serialization - * and thread-safety the set population. - * @return the handler that is used to provide event serialization - * and thread-safety the set population - */ - public SubscriberEventHandler getHandler() { - return handler; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncByteConverter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncByteConverter.java deleted file mode 100644 index e19a7e68e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncByteConverter.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.Policy; - -/** - * Utility for managing slash separated sync information fields. - */ -public class SyncByteConverter { - - protected static final byte SEPARATOR_BYTE = (byte)'/'; - - public static String[] parseIntoSubstrings(String string, String delimiter) { - List result = new ArrayList(); - int start = 0; - int index = string.indexOf(delimiter); - String next; - while (index != -1) { - next = string.substring(start, index); - result.add(next); - start = index + 1; - index = string.indexOf(delimiter, start); - } - if (start >= string.length()) { - next = "";//$NON-NLS-1$ - } else { - next = string.substring(start); - } - result.add(next); - return (String[]) result.toArray(new String[result.size()]); - } - - /** - * Method setSlot. - * @param syncBytes - * @param i - * @param b - * @return byte[] - */ - public static byte[] setSlot(byte[] syncBytes, int slot, byte[] newBytes) throws TeamException { - int start = startOfSlot(syncBytes, slot); - if (start == -1) { - throw new TeamException(Policy.bind("SyncByteConverter.1", new String(syncBytes))); //$NON-NLS-1$ - } - int end = startOfSlot(syncBytes, slot + 1); - int totalLength = start + 1 + newBytes.length; - if (end != -1) { - totalLength += syncBytes.length - end; - } - byte[] result = new byte[totalLength]; - System.arraycopy(syncBytes, 0, result, 0, start + 1); - System.arraycopy(newBytes, 0, result, start + 1, newBytes.length); - if (end != -1) { - System.arraycopy(syncBytes, end, result, start + 1 + newBytes.length, syncBytes.length - end); - } - return result; - } - - /** - * Method startOfSlot returns the index of the slash that occurs before the - * given slot index. The provided index should be >= 1 which assumes that - * slot zero occurs before the first slash. - * - * @param syncBytes - * @param i - * @return int - */ - private static int startOfSlot(byte[] syncBytes, int slot) { - int count = 0; - for (int j = 0; j < syncBytes.length; j++) { - if (syncBytes[j] == SEPARATOR_BYTE) { - count++; - if (count == slot) return j; - } - } - return -1; - } - - /** - * Return the offset the the Nth delimeter from the given start index. - * @param bytes - * @param delimiter - * @param start - * @param n - * @return int - */ - private static int getOffsetOfDelimeter(byte[] bytes, byte delimiter, int start, int n) { - int count = 0; - for (int i = start; i < bytes.length; i++) { - if (bytes[i] == delimiter) count++; - if (count == n) return i; - } - // the Nth delimeter was not found - return -1; - } - - /** - * Method getBytesForSlot. - * @param syncBytes - * @param SEPARATOR_BYTE - * @param i - * @param b - * @return byte[] - */ - public static byte[] getSlot(byte[] bytes, int index, boolean includeRest) { - // Find the starting index - byte delimiter = SEPARATOR_BYTE; - int start; - if (index == 0) { - // make start -1 so that end determination will start at offset 0. - start = -1; - } else { - start = getOffsetOfDelimeter(bytes, delimiter, 0, index); - if (start == -1) return null; - } - // Find the ending index - int end = getOffsetOfDelimeter(bytes, delimiter, start + 1, 1); - // Calculate the length - int length; - if (end == -1 || includeRest) { - length = bytes.length - start - 1; - } else { - length = end - start - 1; - } - byte[] result = new byte[length]; - System.arraycopy(bytes, start + 1, result, 0, length); - return result; - } - - public static byte[] toBytes(String[] slots) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < slots.length; i++) { - String string = slots[i]; - buffer.append(string); - buffer.append(new String(new byte[] {SyncByteConverter.SEPARATOR_BYTE })); - } - return buffer.toString().getBytes(); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoStatistics.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoStatistics.java deleted file mode 100644 index ad8d44eb7..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoStatistics.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.team.core.synchronize.SyncInfo; - -/** - * Counts SyncInfo states and allows for easy querying for different sync states. - */ -public class SyncInfoStatistics { - // {int sync kind -> int number of infos with that sync kind in this sync set} - protected Map stats = new HashMap(); - - /** - * Count this sync kind. Only the type of the sync info is stored. - * @param info the new info - */ - public void add(SyncInfo info) { - // update statistics - Long count = (Long)stats.get(new Integer(info.getKind())); - if(count == null) { - count = new Long(0); - } - stats.put(new Integer(info.getKind()), new Long(count.longValue() + 1)); - } - - /** - * Remove this sync kind. - * @param info the info type to remove - */ - public void remove(SyncInfo info) { - // update stats - Integer kind = new Integer(info.getKind()); - Long count = (Long)stats.get(kind); - if(count == null) { - // error condition, shouldn't be removing if we haven't added yet - // programmer error calling remove before add. - } else { - long newCount = count.intValue() - 1; - if(newCount > 0) { - stats.put(kind, new Long(newCount)); - } else { - stats.remove(kind); - } - } - } - - /** - * Return the count of sync infos for the specified sync kind. A mask can be used to acucmulate - * counts for specific directions or change types. - * To return the number of outgoing changes: - * long outgoingChanges = stats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK); - * - * @param kind the sync kind for which to return the count - * @param mask the mask applied to the stored sync kind - * @return the number of sync info types added for the specific kind - */ - public long countFor(int kind, int mask) { - if(mask == 0) { - Long count = (Long)stats.get(new Integer(kind)); - return count == null ? 0 : count.longValue(); - } else { - Iterator it = stats.keySet().iterator(); - long count = 0; - while (it.hasNext()) { - Integer key = (Integer) it.next(); - if((key.intValue() & mask) == kind) { - count += ((Long)stats.get(key)).intValue(); - } - } - return count; - } - } - - /** - * Clear the statistics counts. All calls to countFor() will return 0 until new - * sync infos are added. - */ - public void clear() { - stats.clear(); - } - - /** - * For debugging - */ - public String toString() { - StringBuffer out = new StringBuffer(); - Iterator it = stats.keySet().iterator(); - while (it.hasNext()) { - Integer kind = (Integer) it.next(); - out.append(SyncInfo.kindToString(kind.intValue()) + ": " + stats.get(kind) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - } - return out.toString(); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java deleted file mode 100644 index db58b435b..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent; -import org.eclipse.team.core.synchronize.SyncInfoSet; - -public class SyncInfoTreeChangeEvent extends SyncSetChangedEvent implements ISyncInfoTreeChangeEvent { - - private Set removedSubtrees = new HashSet(); - private Set addedSubtrees = new HashSet(); - - public SyncInfoTreeChangeEvent(SyncInfoSet set) { - super(set); - } - - public void removedSubtreeRoot(IResource root) { - if (addedSubtrees.contains(root)) { - // The root was added and removed which is a no-op - addedSubtrees.remove(root); - } else if (isDescendantOfAddedRoot(root)) { - // Nothing needs to be done since no listeners ever knew about the root - } else { - // check if the root is a child of an existing root - // (in which case it need not be added). - // Also, remove any exisiting roots that are children - // of the new root - for (Iterator iter = removedSubtrees.iterator(); iter.hasNext();) { - IResource element = (IResource) iter.next(); - // check if the root is already in the list - if (root.equals(element)) return; - if (isParent(root, element)) { - // the root invalidates the current element - iter.remove(); - } else if (isParent(element, root)) { - // the root is a child of an existing element - return; - } - } - removedSubtrees.add(root); - } - } - - private boolean isParent(IResource root, IResource element) { - return root.getFullPath().isPrefixOf(element.getFullPath()); - } - - public void addedSubtreeRoot(IResource parent) { - if (removedSubtrees.contains(parent)) { - // The root was re-added. Just removing the removedRoot - // may not give the proper event. - // Since we can't be sure, just force a reset. - reset(); - } else { - // only add the root if their isn't a higher root in the list already - if (!isDescendantOfAddedRoot(parent)) { - addedSubtrees.add(parent); - } - } - } - - private boolean isDescendantOfAddedRoot(IResource resource) { - for (Iterator iter = addedSubtrees.iterator(); iter.hasNext();) { - IResource root = (IResource) iter.next(); - if (isParent(root, resource)) { - // There is a higher added root already in the list - return true; - } - } - return false; - } - - public IResource[] getAddedSubtreeRoots() { - return (IResource[]) addedSubtrees.toArray(new IResource[addedSubtrees.size()]); - } - - public IResource[] getRemovedSubtreeRoots() { - return (IResource[]) removedSubtrees.toArray(new IResource[removedSubtrees.size()]); - } - - public boolean isEmpty() { - return super.isEmpty() && removedSubtrees.isEmpty() && addedSubtrees.isEmpty(); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoWorkingSetFilter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoWorkingSetFilter.java deleted file mode 100644 index 5a671b41e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoWorkingSetFilter.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.team.internal.core.subscribers; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * WorkingSet filter for a SyncSet. - */ -public class SyncInfoWorkingSetFilter extends FastSyncInfoFilter { - - private IResource[] resources; - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SyncInfoFilter#select(org.eclipse.team.core.subscribers.SyncInfo) - */ - public boolean select(SyncInfo info) { - // if there's no set, the resource is included - if (isEmpty()) return true; - return isIncluded(info.getLocal()); - } - - /* - * Answer true if the given resource is included in the working set - */ - private boolean isIncluded(IResource resource) { - // otherwise, if their is a parent of the resource in the set, - // it is included - for (int i = 0; i < resources.length; i++) { - IResource setResource = resources[i]; - if (isParent(setResource, resource)) { - return true; - } - } - return false; - } - - private boolean isParent(IResource parent, IResource child) { - return (parent.getFullPath().isPrefixOf(child.getFullPath())); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.sync.views.SyncSetInputFromSubscriber#getRoots() - */ - public IResource[] getRoots(Subscriber subscriber) { - IResource[] roots = subscriber.roots(); - if (isEmpty()) return roots; - - // filter the roots by the selected working set - Set result = new HashSet(); - for (int i = 0; i < roots.length; i++) { - IResource resource = roots[i]; - result.addAll(Arrays.asList(getIntersectionWithSet(subscriber, resource))); - } - return (IResource[]) result.toArray(new IResource[result.size()]); - } - - /* - * Answer the intersection between the given resource and it's children - * and the receiver's working set. - */ - private IResource[] getIntersectionWithSet(Subscriber subscriber, IResource resource) { - List result = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource setResource = resources[i]; - if (setResource != null) { - if (isParent(resource, setResource)) { - try { - if (subscriber.isSupervised(setResource)) { - result.add(setResource); - } - } catch (TeamException e) { - // Log the exception and add the resource to the list - TeamPlugin.log(e); - result.add(setResource); - } - } else if (isParent(setResource, resource)) { - result.add(resource); - } - } - } - return (IResource[]) result.toArray(new IResource[result.size()]); - } - - public void setWorkingSet(IResource[] resources) { - this.resources = resources; - } - - public IResource[] getWorkingSet() { - return this.resources; - } - - private boolean isEmpty() { - return resources == null || resources.length == 0; - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetChangedEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetChangedEvent.java deleted file mode 100644 index c9dd433e4..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetChangedEvent.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.synchronize.*; - -/** - * This event keeps track of the changes in a sync set - */ -public class SyncSetChangedEvent implements ISyncInfoSetChangeEvent { - - private SyncInfoSet set; - - // List that accumulate changes - // SyncInfo - private Map changedResources = new HashMap(); - private Set removedResources = new HashSet(); - private Map addedResources = new HashMap(); - - private boolean reset = false; - - private List errors = new ArrayList(); - - public SyncSetChangedEvent(SyncInfoSet set) { - super(); - this.set = set; - } - - public void added(SyncInfo info) { - if (removedResources.contains(info.getLocal())) { - // A removal followed by an addition is treated as a change - removedResources.remove(info.getLocal()); - changed(info); - } else { - addedResources.put(info.getLocal(), info); - } - } - - public void removed(IResource resource, SyncInfo info) { - if (changedResources.containsKey(resource)) { - // No use in reporting the change since it has subsequently been removed - changedResources.remove(resource); - } else if (addedResources.containsKey(resource)) { - // An addition followed by a removal can be dropped - addedResources.remove(resource); - return; - } - removedResources.add(resource); - } - - public void changed(SyncInfo info) { - IResource resource = info.getLocal(); - if (addedResources.containsKey(resource)) { - // An addition followed by a change is an addition - addedResources.put(resource, info); - return; - } - changedResources.put(resource, info); - } - - public SyncInfo[] getAddedResources() { - return (SyncInfo[]) addedResources.values().toArray(new SyncInfo[addedResources.size()]); - } - - public SyncInfo[] getChangedResources() { - return (SyncInfo[]) changedResources.values().toArray(new SyncInfo[changedResources.size()]); - } - - public IResource[] getRemovedResources() { - return (IResource[]) removedResources.toArray(new IResource[removedResources.size()]); - } - - public SyncInfoSet getSet() { - return set; - } - - public void reset() { - reset = true; - } - - public boolean isReset() { - return reset; - } - - public boolean isEmpty() { - return changedResources.isEmpty() && removedResources.isEmpty() && addedResources.isEmpty() && errors.isEmpty(); - } - - public void errorOccurred(ITeamStatus status) { - errors.add(status); - } - - public ITeamStatus[] getErrors() { - return (ITeamStatus[]) errors.toArray(new ITeamStatus[errors.size()]); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java deleted file mode 100644 index 716322230..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.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.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.Policy; - -/** - * This is the superclass for all SyncSet input providers - */ -public abstract class SyncSetInput { - - private SubscriberSyncInfoSet syncSet; - private SyncInfoFilter filter = new FastSyncInfoFilter(); - - public SyncSetInput(SubscriberEventHandler handler) { - syncSet = new SubscriberSyncInfoSet(handler); - } - - public SubscriberSyncInfoSet getSyncSet() { - return syncSet; - } - - /** - * This method is invoked from reset to get all the sync information from - * the input source. - */ - protected abstract void fetchInput(IProgressMonitor monitor) throws TeamException; - - /** - * The input is no longer being used. Disconnect it from its source. - */ - public abstract void disconnect(); - - /** - * Reset the input. This will clear the current contents of the sync set and - * obtain the contents from the input source. - */ - public void reset(IProgressMonitor monitor) throws TeamException { - - try { - syncSet.beginInput(); - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - syncSet.clear(); - fetchInput(Policy.subMonitorFor(monitor, 90)); - } finally { - syncSet.endInput(Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - } - - /** - * Collect the change in the provided sync info. - */ - protected void collect(SyncInfo info, IProgressMonitor monitor) { - boolean isOutOfSync = filter.select(info, monitor); - SyncInfo oldInfo = syncSet.getSyncInfo(info.getLocal()); - boolean wasOutOfSync = oldInfo != null; - if (isOutOfSync) { - syncSet.add(info); - } else if (wasOutOfSync) { - syncSet.remove(info.getLocal()); - } - } - - protected void remove(IResource resource) { - SyncInfo oldInfo = syncSet.getSyncInfo(resource); - if (oldInfo != null) { - syncSet.remove(resource); - } - } - - public SyncInfoFilter getFilter() { - return filter; - } - - public void setFilter(SyncInfoFilter filter) { - this.filter = filter; - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java deleted file mode 100644 index 9e0585325..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.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.team.internal.core.subscribers; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; - -/** - * Records resource synchronization changes from a Team subscriber. The actual changes - * are calculated via the SubscriberEventHandler and stored in this input. - */ -public class SyncSetInputFromSubscriber extends SyncSetInput { - - private Subscriber subscriber; - - public SyncSetInputFromSubscriber(Subscriber subscriber, SubscriberEventHandler handler) { - super(handler); - this.subscriber = subscriber; - } - - public void disconnect() { - } - - public Subscriber getSubscriber() { - return subscriber; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.sync.views.SyncSetInput#fetchInput(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void fetchInput(IProgressMonitor monitor) throws TeamException { - // don't calculate changes. The SubscriberEventHandler will fetch the - // input in a job and update this sync set when the changes are - // calculated. - } - - /** - * Handle an error that occurred while populating the receiver's set. - * The ITeamStatus includes the resource for which the - * error occurred. - * This error is propogated to any set listeners. - * @param status the error status - */ - public void handleError(ITeamStatus status) { - getSyncSet().addError(status); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java deleted file mode 100644 index 13deb259e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.Policy; - -/** - * Ths class uses the contents of one sync set as the input of another. - */ -public class SyncSetInputFromSyncSet extends SyncSetInput implements ISyncInfoSetChangeListener { - - SubscriberSyncInfoSet inputSyncSet; - - public SyncSetInputFromSyncSet(SubscriberSyncInfoSet set, SubscriberEventHandler handler) { - super(handler); - this.inputSyncSet = set; - inputSyncSet.addSyncSetChangedListener(this); - } - - public SyncInfoSet getInputSyncSet() { - return inputSyncSet; - } - - public void disconnect() { - if (inputSyncSet == null) return; - inputSyncSet.removeSyncSetChangedListener(this); - inputSyncSet = null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ccvs.syncviews.views.AbstractSyncSet#initialize(java.lang.String, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void fetchInput(IProgressMonitor monitor) { - if (inputSyncSet == null) return; - SyncInfo[] infos = inputSyncSet.getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - collect(infos[i], monitor); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ccvs.syncviews.views.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent) - */ - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - SyncInfoSet syncSet = getSyncSet(); - try { - syncSet.beginInput(); - monitor.beginTask(null, 105); - syncSetChanged(event.getChangedResources(), Policy.subMonitorFor(monitor, 50)); - syncSetChanged(event.getAddedResources(), Policy.subMonitorFor(monitor, 50)); - remove(event.getRemovedResources()); - } finally { - syncSet.endInput(Policy.subMonitorFor(monitor, 5)); - } - } - - private void syncSetChanged(SyncInfo[] infos, IProgressMonitor monitor) { - for (int i = 0; i < infos.length; i++) { - collect(infos[i], monitor); - } - } - - private void remove(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - remove(resources[i]); - } - } - - public void reset() { - inputSyncSet.connect(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - if(inputSyncSet == null) { - set.removeSyncSetChangedListener(this); - } else { - SyncInfoSet syncSet = getSyncSet(); - try { - syncSet.beginInput(); - monitor.beginTask(null, 100); - syncSet.clear(); - fetchInput(Policy.subMonitorFor(monitor, 95)); - } finally { - syncSet.endInput(Policy.subMonitorFor(monitor, 5)); - monitor.done(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - SubscriberSyncInfoSet syncSet = getSyncSet(); - try { - syncSet.beginInput(); - for (int i = 0; i < errors.length; i++) { - ITeamStatus status = errors[i]; - syncSet.addError(status); - } - } finally { - syncSet.endInput(monitor); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java deleted file mode 100644 index 1d7d1cb67..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.ResourceVariantByteStore; -import org.eclipse.team.core.variants.ResourceVariantTree; -import org.eclipse.team.core.variants.ThreeWaySubscriber; - -/** - * Allow access to the base resource variants but do not support refresh - * or modification. - */ -public final class ThreeWayBaseTree extends ResourceVariantTree { - - private ThreeWaySubscriber subscriber; - - /* - * A resource variant byte store that accesses the base bytes from a three-way - * synchronizer. The modification methods are disabled as the base should - * only be modified in the synchronizer directly. - */ - static class BaseResourceVariantByteStore extends ResourceVariantByteStore { - private ThreeWaySubscriber subscriber; - public BaseResourceVariantByteStore(ThreeWaySubscriber subscriber) { - this.subscriber = subscriber; - } - public void dispose() { - // Nothing to do - } - public byte[] getBytes(IResource resource) throws TeamException { - return subscriber.getSynchronizer().getBaseBytes(resource); - } - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - // Base bytes are set directly in the synchronizer - return false; - } - public boolean flushBytes(IResource resource, int depth) throws TeamException { - // Base bytes are flushed directly in the synchronizer - return false; - } - public boolean deleteBytes(IResource resource) throws TeamException { - // Base bytes are deleted directly in the synchronizer - return false; - } - public IResource[] members(IResource resource) throws TeamException { - return subscriber.getSynchronizer().members(resource); - } - } - - /** - * Create a base resource variant tree that accesses the base bytes - * from a three-way synchronizer. - * @param subscriber the three-way subscriber - */ - public ThreeWayBaseTree(ThreeWaySubscriber subscriber) { - super(new BaseResourceVariantByteStore(subscriber)); - this.subscriber = subscriber; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.AbstractResourceVariantTree#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - return new IResource[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.AbstractResourceVariantTree#fetchMembers(org.eclipse.team.core.synchronize.IResourceVariant, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException { - // Refresh not supported - return new IResourceVariant[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.AbstractResourceVariantTree#fetchVariant(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - // Refresh not supported - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#roots() - */ - public IResource[] roots() { - return getSubscriber().roots(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#getResourceVariant(org.eclipse.core.resources.IResource) - */ - public IResourceVariant getResourceVariant(IResource resource) throws TeamException { - return getSubscriber().getResourceVariant(resource, getByteStore().getBytes(resource)); - } - - private ThreeWaySubscriber getSubscriber() { - return subscriber; - } - -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java deleted file mode 100644 index dce19545e..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.core.Policy; - -/** - * This collector maintains a {@link SyncInfoSet} for a particular team subscriber keeping - * it up-to-date with both incoming changes and outgoing changes as they occur for - * resources in the workspace. The collector can be configured to consider all the subscriber's - * roots or only a subset. - *

              - * The advantage of this collector is that it processes both resource and team - * subscriber deltas in a background thread. - *

              - * @since 3.0 - */ -public final class WorkingSetFilteredSyncInfoCollector { - - private WorkingSetSyncSetInput workingSetInput; - private SyncSetInputFromSyncSet filteredInput; - private SubscriberEventHandler eventHandler; - private IResource[] roots; - - /** - * Create a collector that collects out-of-sync resources that are children of - * the given roots. If the roots are null, then all out-of-sync resources - * from the subscriber are collected. An empty array of roots will cause no resources - * to be collected. The start() method must be called after creation - * to rpime the collector's sync sets. - * @param subscriber the Subscriber - * @param roots the roots of the out-of-sync resources to be collected - */ - public WorkingSetFilteredSyncInfoCollector(SubscriberSyncInfoCollector collector, IResource[] roots) { - this.roots = roots; - this.eventHandler = collector.getEventHandler(); - // TODO: optimize and don't use working set if no roots are passed in - workingSetInput = new WorkingSetSyncSetInput((SubscriberSyncInfoSet)collector.getSyncInfoSet(), getEventHandler()); - filteredInput = new SyncSetInputFromSyncSet(workingSetInput.getSyncSet(), getEventHandler()); - filteredInput.setFilter(new SyncInfoFilter() { - public boolean select(SyncInfo info, IProgressMonitor monitor) { - return true; - } - }); - } - - /** - * Return the set that provides access to the out-of-sync resources for the collector's - * subscriber that are descendants of the roots for the collector, - * are in the collector's working set and match the collectors filter. - * @see getSubscriberSyncInfoSet() - * @see getWorkingSetSyncInfoSet() - * @return a SyncInfoSet containing out-of-sync resources - */ - public SyncInfoTree getSyncInfoTree() { - return filteredInput.getSyncSet(); - } - - /** - * This causes the calling thread to wait any background collection of out-of-sync resources - * to stop before returning. - * @param monitor a progress monitor - */ - public void waitForCollector(IProgressMonitor monitor) { - monitor.worked(1); - // wait for the event handler to process changes. - while(eventHandler.getEventHandlerJob().getState() != Job.NONE) { - monitor.worked(1); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } - Policy.checkCanceled(monitor); - } - monitor.worked(1); - } - - /** - * Return the roots that are being considered by this collector. - * By default, the collector is interested in the roots of its - * subscriber. However, the set can be reduced using {@link setRoots(IResource)). - * @return - */ - public IResource[] getRoots() { - return roots; - } - - /** - * Clears this collector's sync info sets and causes them to be recreated from the - * associated Subscriber. The reset will occur in the background. If the - * caller wishes to wait for the reset to complete, they should call - * {@link waitForCollector(IProgressMonitor)}. - */ - public void reset() { - workingSetInput.reset(); - } - - /** - * Disposes of the background job associated with this collector and deregisters - * all it's listeners. This method must be called when the collector is no longer - * referenced and could be garbage collected. - */ - public void dispose() { - workingSetInput.disconnect(); - if(filteredInput != null) { - filteredInput.disconnect(); - } - } - - /** - * Return the event handler that performs the background processing for this collector. - * The event handler also serves the purpose of serializing the modifications and adjustments - * to the collector's sync sets in order to ensure that the state of the sets is kept - * consistent. - * @return Returns the eventHandler. - */ - protected SubscriberEventHandler getEventHandler() { - return eventHandler; - } - - /** - * Set the working set resources used to filter the output SyncInfoSet. - * @see getWorkingSetSyncInfoSet() - * @param resources the working set resources - */ - public void setWorkingSet(IResource[] resources) { - workingSetInput.setWorkingSet(resources); - workingSetInput.reset(); - } - - /** - * Get th working set resources used to filter the output sync info set. - * @return the working set resources - */ - public IResource[] getWorkingSet() { - return workingSetInput.getWorkingSet(); - } - - /** - * Set the filter for this collector. Only elements that match the filter will - * be in the out sync info set. - * @see getSyncInfoSet() - * @param filter the sync info filter - */ - public void setFilter(SyncInfoFilter filter) { - filteredInput.setFilter(filter); - filteredInput.reset(); - } - - /** - * Return the filter that is filtering the output of this collector. - * @return a sync info filter - */ - public SyncInfoFilter getFilter() { - if(filteredInput != null) { - return filteredInput.getFilter(); - } - return null; - } - - /** - * Return a SyncInfoSet that contains the out-of-sync elements - * from the subsciber sync info set filtered - * by the working set resources but not the collector's SyncInfoFilter. - * @see getSubscriberSyncInfoSet() - * @return a SyncInfoSet - */ - public SyncInfoSet getWorkingSetSyncInfoSet() { - return workingSetInput.getSyncSet(); - } - - /** - * Run the given runnable in the event handler of the collector - * @param runnable a runnable - */ - public void run(IWorkspaceRunnable runnable) { - eventHandler.run(runnable, true /* front of queue */); - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java deleted file mode 100644 index 2f220a7eb..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.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.team.internal.core.subscribers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.subscribers.Subscriber; - -public class WorkingSetSyncSetInput extends SyncSetInputFromSyncSet { - - private SyncInfoWorkingSetFilter workingSetFilter = new SyncInfoWorkingSetFilter(); - - public WorkingSetSyncSetInput(SubscriberSyncInfoSet set, SubscriberEventHandler handler) { - super(set, handler); - setFilter(workingSetFilter); - } - - public void setWorkingSet(IResource[] resources) { - workingSetFilter.setWorkingSet(resources); - } - - public IResource[] getWorkingSet() { - return workingSetFilter.getWorkingSet(); - } - - public IResource[] roots(Subscriber subscriber) { - return workingSetFilter.getRoots(subscriber); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/.classpath b/bundles/org.eclipse.team.cvs.core/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/bundles/org.eclipse.team.cvs.core/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.core/.cvsignore b/bundles/org.eclipse.team.cvs.core/.cvsignore deleted file mode 100644 index c5e82d745..000000000 --- a/bundles/org.eclipse.team.cvs.core/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/.options b/bundles/org.eclipse.team.cvs.core/.options deleted file mode 100644 index 24500e974..000000000 --- a/bundles/org.eclipse.team.cvs.core/.options +++ /dev/null @@ -1,18 +0,0 @@ -# Debugging options for the org.eclipse.team.cvs.core plugin. - -# Turn on debugging for the plugin. -org.eclipse.team.cvs.core/debug=false - -# Shows when meta-files are modified by a 3rd party -org.eclipse.team.cvs.core/metafiles=false - -# Shows cvs client/server protocol -org.eclipse.team.cvs.core/cvsprotocol=true -# Shows stream debugging information -org.eclipse.team.cvs.core/threading=false - -# Shows dirty state caching debugging information -org.eclipse.team.cvs.core/dirtycaching=false - -# Shows dirty state caching debugging information -org.eclipse.team.cvs.core/syncchangeevents=false \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/.project b/bundles/org.eclipse.team.cvs.core/.project deleted file mode 100644 index 6ffdf00f9..000000000 --- a/bundles/org.eclipse.team.cvs.core/.project +++ /dev/null @@ -1,32 +0,0 @@ - - - org.eclipse.team.cvs.core - - - org.eclipse.core.boot - org.eclipse.core.resources - org.eclipse.core.runtime - org.eclipse.team.core - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.team.cvs.core/about.html b/bundles/org.eclipse.team.cvs.core/about.html deleted file mode 100644 index 42aa848cb..000000000 --- a/bundles/org.eclipse.team.cvs.core/about.html +++ /dev/null @@ -1,45 +0,0 @@ - - - -About - - - -

              About This Content

              - -

              23rd March, 2004

              -

              License

              -

              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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

              - -

              Third Party Content

              - -

              The Content includes items that have been sourced from third parties as follows:

              - -

              Ant 1.6.1

              -

              The plug-in is based on software developed by The Apache Software Foundation as part of the Ant project.

              - -

              The class org.eclipse.team.internal.ccvs.core.connection.PServerConnection ("Ant-Derived Work") contained in teamcvs.jar and teamcvssrc.zip is based on Ant code from the file CVSPass.java in the package org.apache.tools.ant.taskdefs.

              - -

              Your use of the Ant-Derived Work is subject to the terms and conditions of the Apache Software License 2.0. A copy of the license is contained -in the file asl-v20.txt and is also available at http://www.apache.org/licenses/LICENSE-2.0.html. - -

              The names "Ant" and "Apache Software Foundation" must not be used to endorse or promote products derived from this -software without prior written permission. For written permission, please contact apache@apache.org.

              - -

              Contributions

              - -

              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.

              - -

              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.

              - - - \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/asl-v20.txt b/bundles/org.eclipse.team.cvs.core/asl-v20.txt deleted file mode 100644 index d64569567..000000000 --- a/bundles/org.eclipse.team.cvs.core/asl-v20.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/bundles/org.eclipse.team.cvs.core/build.properties b/bundles/org.eclipse.team.cvs.core/build.properties deleted file mode 100644 index ec96f1819..000000000 --- a/bundles/org.eclipse.team.cvs.core/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# Eclipse build contribution -bin.includes=about.html,plugin.xml,plugin.properties,*.jar,.options -source.cvs.jar=src/ -src.includes=about.html diff --git a/bundles/org.eclipse.team.cvs.core/buildnotes_cvs.html b/bundles/org.eclipse.team.cvs.core/buildnotes_cvs.html deleted file mode 100644 index 8821e1e74..000000000 --- a/bundles/org.eclipse.team.cvs.core/buildnotes_cvs.html +++ /dev/null @@ -1,751 +0,0 @@ - - - -Eclipse CVS Plugin - Build notes - - - - - - - - - - - -
              Eclipse CVS
              build notes
              - - - - - - - - - - - - - - - - - - -
              Here are the build notes for the CVS Plugin - which includes changes to org.eclipse.team.cvs.core, - org.eclipse.team.cvs.ui, - org.eclipse.team.cvs.ssh. -
              3.1 Builds
              - -

              September 23rd 2004 - 3.1 M2

              -

              Interesting changes

              -
                -
              • The CVS decorator now allows for color and font decorations to be - specified for ignored and modified resources. Also, the CVS Decorator - preference page has been improved to show how the selected decorations - in an example tree viewer.
              • -
              • Enabling and disabling of Commit Sets in the Synchronize view is - now done using a toolbar button. Commit sets also use the selected - layout as the sub-layout to be used in each commit set.
              • -
              • The ability to assign outgoing changes to commit sets has also been - added to the Synchronize view. The comment associated with such a - commit set is used when the files are committed.
              • -
              -

              Fixed bugs

              -

              See this - bugzilla query to list all fixed bugs in this build.

              -
              3.0 Builds
              - -

              September 23rd 2003 - 3.0 (I20030923)

              -

              Interesting changes

              -
                -
              • CVS operations performed from the Synchronize View are run in the - background. Depending on the operation, the resources affected by - the CVS command are locked for modification and other operations run - may block (e.g. saving a file or creating a new file) until the background - job is done. The use-case of a background job blocking annother operation - is being addressed by an improved progress monitor that is yet to - be released.
              • -
              • A CVS repository location can be configured to use different locations - for reading and writing. This can - speed up CVS operations for which most of the time is consumed by - costly extssh authentication and only read access is required (e.g. - opening remote files, browsing a remote repository, opening a compare - editor). To configure a read and write locations, first create a read - location (e.g. for Eclipse developers, a useful read location would - be the anonymous pserver location), then from the CVS Repositories - View select the Properties page of a location and configure the read - or write locations.
              • -
              • The CVS History View can now be linked to the active editor. The - linking is enabled for editors with the following inputs: IFileEditorInput, - RemoteFileInput (e.g. created when browing remote CVS files), and - SyncInfoEditorInput (e.g. created when browing changes in a compare - editor from the Synchronize View).
              • -
              • The CVS synchronize action now opens the new Synchronize View.
              • -
              -

              Fixed bugs

              -

              See this - bugzilla query to list all fixed bugs in this build.

              -

              - August 6th 2003 - 3.0 (I20030806)

              -

              Interesting changes

              -
                -
              • Annotate view action switches to the CVS perspective. This allows - the command to layout the views (history, editor, annotate) for linking.
              • -
              • Update and Commit actions in the new Synchronize View no longer - prompt for overwriting changes. Instead, an Override and Commit - action has been added. To override local changes use the Replace - With CVS actions.
              • -
              • The new Synchronize View can be activated via a CVS > - Work In Progress preference. When this is enabled, the new - Synchronize View will restrict the resources it handles based on a - working set created when ever a Team > Synchronize view - Repository is run. This will allow large workspaces with - many CVS projects to be responsive.
              • -
              • To help debug problems with the CVS plugin a preference has been - added to enable/disable the CVS protocol trace to stdout. Previously - you had to create an options file and restart Eclipse.
              • -
              -

              Fixed bugs (27 fixed)

              -

              See this - bugzilla query to list all fixed bugs in this build.

              - -
              -
              -Archive for 2.0 and 2.1 Builds
              - -

              Build submission for Integration Build 20021116

              - -

              What's new in this build

              - -

              Eclipse now supports CVS Watch/Edit. There is a CVS preference for indicating that projects should -be checked out as read-only and there are Edit and Unedit actions available in the Team menu. Also, -Eclipse will automatically perform a "cvs edit" on files that are modified in an open editor. - -

              The CVS Repositories view has undergone a few more changes. Modules now appear as folders -under HEAD with their own icon to differentiate them from regular -folders. Also, refreshing the tags for a module may not work properly because this feature requires the use of an -auto-refresh file. If your modules are not appearing in the version or branch categories, perform -a "Configure Branches and Versions" on the module and assign the tags to the module and/or set the -auto-refresh file. - -

              Several optimizations have also been performed on the CVS plugin. CVS now uses the new light-weight -decorators provided by Platform UI. Also, the determination of a folder's dirty status has been optimized -using caching. The caching scheme uses a combination of persistant and session properties (facilities -provided by Platform Core). Persistant properties have a certain overhead so that the first query of -the dirty status of a folder will be longer running then subsequent queries. - -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20021112 Nov 12, 2002

              - -

              Build submission for Integration Build 20021112

              - -

              What's new in this build

              - -

              The CVS Repositories view has undergone some changes. Here is a summary of the changes:

              -
                -
              • Users can now define working sets which will limit the number of projects shown in the view. -
              • Branches only contain projects that are "known" to be in the branch. Similarly, the Versions category -has been changed and now displayes all the "known" projects in a version (as opposed to providing a list of -verions). -
              • The version and branch items will start out empty and must be populated by the user. This can be -done by performing a "Refresh Branches and Versions" from the popup menu of a repository location or -by using "Configure Branches and Tags". The user should define a working set before refreshing the tags -of the repository location since the refresh operation will search each project in the working set (or -each project in the repository if no working set is defined). -
              • Comparing multiple versions of the same project can be done by choosing "Compare With..." from -popup menu of any folder or file in the view. -
              • There is no longer a "Show Modules" mode. Instead, there is a Modules category under HEAD which can -be expanded to see the modules defined in the CVSROOT/modules file. -
              -

              Further work will be done on this view to fine-tune the tag discovery mechanisms. -

              - -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20021015 Oct 15, 2002

              - -

              Build submission for Integration Build 20021015

              - -

              What's new in this build

              - -

              Deleted files can now be queried and restored from the repository using the "Team > Restore from Repository..." -command, which is available on CVS projects and folders. -

              - -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20021008 Oct 8, 2002

              - -

              Build submission for Integration Build 20021008

              - -

              What's new in this build

              - -

              Several improvements related to support of CVS modules have been added. -

                -
              • "Checkout Into..." -can be used from the CVS Repositories view to check out a folder into an existing project.
              • -
              • Folders, such as those loaded using "Checkout Into...", can be disconnected from CVS control -from the folder's CVS properties page, allowing the folder to be removed from a local project -without resulting in outgoing deletions.
              • -
              • A project shared with CVS can now be configured to not fetch absent directories on update -(i.e. previously, "cvs update" was always performed with "-d". Now a project can be configured -to perform updates without "-d"). -
              -

              - -

              Also, "Tag with Existing" can now be performed in the resource history view.

              -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20020917 Sept 17, 2002

              - -

              Build submission for Integration Build 20020917

              - -

              What's new in this build

              - -

              A "quick sync" button has been added to the CVS action set which will display the list -of all projects shared with CVS and allow the user to choose which projects to sync, either -directly or by working set. -

              -

              Performing a commit in the sync view or the navigator will present the user with a -dialog that shows the user any new resources that are not yet under version control or not yet -ignored. The user can select which resources they would like to add before the commit -is performed. -

              -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20020909 Sept 09, 2002

              - -

              Build submission for Integration Build 20020910

              - -

              What's new in this build

              - -

              When using the EXT connection method, the parameter format can be specified -on the EXT Connection Method preference page. The parameter list can include -variables representing the corresponding values from the location. The variables -are user, password, host and port. The default parameter list is "{host} -l {user}". -

              -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              -

              CVS build I20020517 May 17 2002

              - -

              Build submission for Integration Build 20020517

              - -

              What's new in this build

              - -

              Starting with this build, if you "Check Out As..." on a project from the -repository which has no .project file, you will be prompted to specify what -type of project you would like to create. (A typical example is to create -a Java project at this point).
              -

              -

              Also new in this build is the ability to select "Share Project..." on -a project for which remote content already exists. Previously, sharing the -project would automatically try to import your files into the repository; -now, it detects that remote files already exists and opens the sync view -for you to reconcile the differences.
              -

              -

              Numerous other bugs are fixed. As always, you can check in Bugzilla.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020430 April 30 2002

              - -

              Build submission for Integration Build 20020430

              - -

              What's new in this build

              - -

              Added support for moving CVS tags. Ths fuctionality is available in the -Repositories view under "Tag with Existing Tag". This allows one to change -a version lineup.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020423 April 23 2002

              - -

              Build submission for Integration Build 20020423

              - -

              What's new in this build

              - -

              Branching/Merging changes:
              -

              - -
                -
              • merge allowed on multiple selection of non-overlapping resources, - merge results show in same merge editor (e.g. you no longer need X editors - to merge X projects). We should do the same for compare.
              • - -
              - -

              - -
                -
              • merge allowed on all resource types
              • - -
              - -

              - -
                -
              • branching allowed on all resource types
              • - -
              - -

              - -
                -
              • "replace with" allowed on all resource types with multiple selection
              • - -
              - -

              - -
                -
              • warning dialog added when ever a user creates a project with mixed - tags. It warns about the implied CVS behavior. Can be turned off.
              • - -
              - -

              - -
                -
              • tags only shown if different than parent tag (reduces tag clutter - and makes it more obvious when a tag is different)
                -
              • - -
              - -

              - -
                -
              • get revision for files allowed from history/replace/compare dialogs, - to revert from a sticky revision use "replace with tag" and select the branch - you are working on
                -
              • - -
              - -

              - -
                -
              • CVS text decorations consolidated and as a result the text decorations - in the sync view will follow the users preferences (except for the dirty -flag which is not shown in the sync view.
              • - -
              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020409 April 9 2002

              - -

              Build submission for Integration Build 20020409

              - -

              What's new in this build

              - -

              GZIP compression support for CVS communication has been - introduced in this build. It is turned on by default and can be configured - on the CVS preference page.
              -

              - -


              - Support for communicating with CVS NT servers has been improved. Note - that CVS NT is still not a supported platform. CVS support should now work - much better with CVS NT versions 1.11.1.1 and higher, including 1.11.1.3.
              -

              - -


              - Support for branch and version tags in the UI has been improved. See -the "Configure Tags" dialog, which is available nearly anywhere in the UI -where tags are needed. (e.g. in the Compare With Tag action, Replace With -Tag action, and in the Repositories View).
              -

              - -


              - Cancellation and progress have been greatly improved. For example, it - should be possible to cancel connections to unresponsive servers without - waiting for operations to time out.
              -

              - -


              - The CVS Console is much more usable. Output from different actions is - easily distinguished, and color coding of server responses has been added.
              -

              -
              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020402 April 2 2002

              - -

              Build submission for Integration Build 20020402

              - -

              What's new in this build

              - -

              The CVS plug-ins are now turned on by default. The old - VCM plug-ins are still included in the build but are turned off by default.
              -
              -

              - -

              Additions, deletions and moved resorces are handled -differently in this build:

              - -


              -

              - -

              1) The user will be prompted with a warning on deletion - of files to
              - indicate that the file will be marked as an outgoing deletion. An
              - information marker will appear in the task view which indicates this. - The
              - user can use the Auto Fix item in the task's context menu to restore - the
              - file (from the server or local history) or commit the deletion. The -user
              - can also commit the deletion as before (Commit on ancestor in Team -menu or
              - Sync view) as well.
              -
              - 2) A similar warning will appear for folder deletions. However, the -folders
              - themselves will not be deleted and files in the folders will appear -as
              - outgoing deletions. On commit, any empty folders that contained outgoing
              - deletions will be pruned.
              -
              - 3) When files are added to a folder shared with CVS, an information -marker
              - will appear in the task view until the file is either added to CVS -control
              - or ignored (Autofix items are available for this).
              -
              - Options are available in the CVS preferences page to disable both the
              - prompting and markers.
              -

              - -


              -

              - -


              - The CVS support now takes advantage of the new Core facilities for -private resources. As such, CVS/ folders will be marked as private and -should not show up anywhere in the UI. Also, if you copy or move a folder -structure in the workspace, the CVS/ folders will be removed from the destination.
              -

              - -


              - In order for the CVS/ folders to be marked as private, you will need - to delete the projects in your workspace and check them out from the repository - again. Failure to do so will simply result in CVS/ folders showing up in - the UI.
              -

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020312 – March 12, 2002

              - -

              Build submission for Integration Build 20020312

              - -

              What's new in this build

              - -

              The CVS plug-ins are now turned on by default. The old - VCM plug-ins are still included in the build but are turned off by default.
              - More performance improvements for the decorators.

              - -

              The actions in the Sync view have been changed. A summary:

              - -


              - Incoming mode:
              -         Update from Repository -(operates ONLY on incoming nodes that are not conflicting)
              -         Override and Update (operates - on conflicts)
              - Outgoing mode:
              -         Commit (operates only -on outgoing nodes that are not conflicting)
              -         Override and Commit (operates - on conflicts)
              - Both mode:
              -         Update from Repository -(operates ONLY on incoming nodes that are not conflicting)
              -         Override and Update (operates - on conflicts *and* on outgoing
              - changes)
              -         Commit (operates only -on outgoing nodes that are not conflicting)
              -         Override and Commit (operates - on conflicts *and* on incoming
              - changes)

              - -

              - -


              -

              - -

              A preference was added that allows the user to more -accurately determine how files are compared.

              - -

              A new action was added to the merge view which allows - the user to correctly merge conflicting files automatically (previously - we had a bug which prevented this).

              - -


              - Resolved 54 bugs.

              - -


              - - Click here to see the bugs that were fixed.

              - -


              -

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020305 – March 5, 2002

              - -

              Build submission for Integration Build 20020305

              - -

              What's new in this drop

              - -

              CVS Decorators have been greatly improved - images are - now cached and disposed.

              - -

              Resolved 74 bugs, fixing 47.

              - -


              - - Click here to see the bugs that were fixed.

              - -


              - All Team plug-ins are turned off by default. If you wish to -use Team support,

              - -
                -
              1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
              2. -
              3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
              4. -
              5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
              6. -
              7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
              8. -
              9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
              10. - -
              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020226 – February 26, 2002

              - -

              Build submission for Integration Build 20020226

              - -

              What's new in this drop

              - -

              Added :ext: support, similar to the support that was - in 1.0. See the CVS->Ext Connection Method preferences page to configure - ext support.

              - -


              - Fixed 25 bugs.

              - -


              - - Click here to see the bugs that were fixed.

              - -


              - All Team plug-ins are turned off by default. If you wish to -use Team support,

              - -
                -
              1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
              2. -
              3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
              4. -
              5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
              6. -
              7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
              8. -
              9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
              10. - -
              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build I20020214 – February 14, 2002

              - -

              Build submission for Integration Build 20020214

              - -

              What's new in this drop

              - -

              Bug fixes:

              - -

              Outgoing changes show up in Merge editor (9746)

              - -

              Incoming additions from another branch have wrong timestamp - (9748)

              - -

              Bin folders show up as outgoing additions! (9788)

              - -

              Create  branch dialog - says "Name must not be null" for a project version, even if the version - option is disabled (9691)

              - -

              Should not ignore managed resources (9502)

              - -

              Directory named core ignored!!! (9486)

              - -

              Change in semantics to validateEdit (9802)

              - -

               <>

              - -

              All Team plug-ins are turned off by default. If you wish -to use Team support,

              - -
                -
              1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
              2. -
              3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
              4. -
              5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
              6. -
              7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
              8. -
              9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
              10. - -
              - -

               <>

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build V2_0_6 – February 12, 2002

              - -

              Build submission for Integration Build 20020212

              - -

              What's new in this drop

              - -

              48 bugs fixed.

              - -

              Global ignore facility added.

              - -

              Extensive sync view rewrite. Workflow has been improved, - and in incoming/outgoing mode the user can override the direction of - any change. Auto-merging of conflicts is now supported as well.

              - -

              User can add files/directories to .cvsignore automatically - from the sync view or navigator by right clicking and selecting “Ignore”.

              - -

              Many bug fixes and improvements.

              - -

               <>

              - -

              All Team plug-ins are turned off by default. If you wish -to use Team support,

              - -
                -
              1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
              2. -
              3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
              4. -
              5. Rename plugins/org.eclipse.team.core/plugin.xml.off - to plugins/org.eclipse.team.core/plugin.xml
              6. -
              7. Rename plugins/org.eclipse.team.cvs.core/plugin.xml.off - to plugins/org.eclipse.team.cvs.core/plugin.xml
              8. -
              9. Rename plugins/org.eclipse.team.cvs.ssh/plugin.xml.off - to plugins/org.eclipse.team.cvs.ssh/plugin.xml
              10. - -
              - -

               <>

              - -

              Eclipse Platform Build Notes – CVS Support

              - -

              CVS build V2_0_2 – January 15, 2002

              - -

              Build submission for Integration Build 20020115

              - -

              What's new in this drop

              - -

              This is the initial release for the CVS support plug-ins.

              - -

               <>

              - -

              The plug-ins are turned off by default. If you wish to -use CVS support,

              - -
                -
              1. Rename plugins/org.eclipse.team.ui/plugin.xml.off - to plugins/org.eclipse.team.ui/plugin.xml
              2. -
              3. Rename plugins/org.eclipse.team.cvs.ui/plugin.xml.off - to plugins/org.eclipse.team.cvs.ui/plugin.xml
              4. - -
              - -

               <>

              - -

              Please report any problems to the VCM team, and use the -VCM component for bug tracking.

              - -

               <>

              - -

              The following features are operating near their 1.0 level -of functionality:

              - -
                -
              • The Synchronize -view
              • -
              • The Resource History - view
              • -
              • The Repositories - view
              • - -
              - -

               <>

              - -

              The following features differ from the 1.0 functionality:

              - -
                -
              • Decorators. To -see version history in the Navigator, use Window->Decorators->CVS
              • -
              • CVS metadata. The - metadata now resides in CVS/ folders in every shared folder. These - folders are hidden by default in the Navigator. If you copy entire - directories from within the Navigator, you MUST remove the CVS/ - directories from the target after copying, otherwise CVS operations - will behave unexpectedly.
              • - -
              - -

              - -

              Run - this query to determine which bugs have been fixed since -January 7 th. If you wish to narrow the search, edit the -query and change the dates.

              - - -
              - - diff --git a/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm b/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm deleted file mode 100644 index c59811321..000000000 --- a/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Legal Notices - - - -

              -Notices

              -(c) Copyright IBM Corp. 2000, 2001. All Rights Reserved. - - diff --git a/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif b/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif deleted file mode 100644 index 61cef4852..000000000 Binary files a/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html b/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html deleted file mode 100644 index 5426e6995..000000000 --- a/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - Eclipse CVS Core Extension Points - - - -

              Eclipse CVS Core

              -The extension points declared by this plug-in are for internal use only. - -

              Copyright IBM Corp. 2000, 2002.  All Rights Reserved. - - diff --git a/bundles/org.eclipse.team.cvs.core/plugin.properties b/bundles/org.eclipse.team.cvs.core/plugin.properties deleted file mode 100644 index 8dfac4eeb..000000000 --- a/bundles/org.eclipse.team.cvs.core/plugin.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -providerName=Eclipse.org -pluginName=CVS Team Provider Core -cvsNature=CVS Team Nature \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml deleted file mode 100644 index 878a11c8f..000000000 --- a/bundles/org.eclipse.team.cvs.core/plugin.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd b/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd deleted file mode 100644 index 07c2359c8..000000000 --- a/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - This extension point is internal use only - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.0 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - This extension point is for internal use only - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd b/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd deleted file mode 100644 index 0faa3b477..000000000 --- a/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - This extension point allows additional CVS connection methods to be pluged in. It is for internal use. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An implementation of <samp>IConnectionMethod</samp> - - - - - - - - - - - - - - - This extension point is internal use only - - - - - - - - - - - - - - - - - - - 1.0 - - - - - - - - - Following is an example of a connectionmethods extension: - -<p> -<pre> - <extension id="pserver" point="org.eclipse.team.cvs.core.connectionmethods"> - <adapter> - <run class="org.eclipse.team.internal.ccvs.core.connection.PServerConnectionMethod"> - <parameter name="trace" value="false"> - </parameter> - </run> - </adapter> - </extension> -</pre> -</p> - - - - - - - - - This extension point is internal use only - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd b/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd deleted file mode 100644 index cff041f74..000000000 --- a/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - This extension point is for internal use only - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2.0 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - This extension point is for internal use only - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - Copyright (c) 2004 IBM Corporation and others. -All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - - - - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java deleted file mode 100644 index c1cfd9036..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * Model for a CVS Annotate block. - */ -public class CVSAnnotateBlock { - - String revision = ""; //$NON-NLS-1$ - String user = ""; //$NON-NLS-1$ - int startLine = 0; - int endLine = 0; - int sourceOffset = 0; - boolean valid = false; - - /** - * @return - */ - public boolean isValid() { - return valid; - } - - /** - * @return index of line where source starts. - */ - public int getSourceOffset() { - return sourceOffset; - } - - /** - * @return int the last source line of the receiver - */ - public int getEndLine() { - return endLine; - } - - /** - * @param line - */ - public void setEndLine(int line) { - endLine = line; - } - - /** - * @return the revision the receiver occured in. - */ - public String getRevision() { - return revision; - } - - /** - * @return the first source line number of the receiver - */ - public int getStartLine() { - return startLine; - } - - - /** - * Parase a CVS Annotate output line and instantiate the receiver - * @param line a CVS Annotate output line - */ - public CVSAnnotateBlock(String line, int lineNumber) { - super(); - - startLine = lineNumber; - endLine = lineNumber; - - int index = line.indexOf(' '); - if (index == -1) { - return; - } - revision = line.substring(0, index); - - index = line.indexOf("(", index); //$NON-NLS-1$ - if (index == -1) { - return; - } - - int index2 = line.indexOf(' ', index); - if (index2 == -1) { - return; - } - - user = line.substring(index + 1, index2); - - index = line.indexOf(":", index2); //$NON-NLS-1$ - if (index == -1) { - return; - } - - sourceOffset = index + 2; - valid = true; - } - - /** - * Used by the default LabelProvider to display objects in a List View - */ - public String toString() { - int delta = endLine - startLine + 1; - String line = Policy.bind("CVSAnnotateBlock.4"); //$NON-NLS-1$ - if (delta == 1) { - line = Policy.bind("CVSAnnotateBlock.5"); //$NON-NLS-1$ - } - return Policy.bind("CVSAnnotateBlock.6", new Object[] { //$NON-NLS-1$ - user, - revision, - String.valueOf(delta), - line - }); - } - - /** - * Answer true if the receiver contains the given line number, false otherwse. - * @param i a line number - * @return true if receiver contains a line number. - */ - public boolean contains(int i) { - return (i >= startLine && i <= endLine); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java deleted file mode 100644 index 4b578ce2f..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.variants.IResourceVariantTree; -import org.eclipse.team.core.variants.SessionResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree; -import org.eclipse.team.internal.ccvs.core.syncinfo.MultiTagResourceVariantTree; - -/** - * This subscriber is used when comparing the local workspace with its - * corresponding remote. - */ -public class CVSCompareSubscriber extends CVSSyncTreeSubscriber implements ISubscriberChangeListener { - - public static final String ID = "org.eclipse.team.cvs.ui.compare-participant"; //$NON-NLS-1$ - public static final String ID_MODAL = "org.eclipse.team.cvs.ui.compare-participant-modal"; //$NON-NLS-1$ - - public static final String QUALIFIED_NAME = CVSProviderPlugin.ID + ".compare"; //$NON-NLS-1$ - private static final String UNIQUE_ID_PREFIX = "compare-"; //$NON-NLS-1$ - - private IResource[] resources; - private CVSResourceVariantTree tree; - - public CVSCompareSubscriber(IResource[] resources, CVSTag tag) { - super(getUniqueId(), Policy.bind("CVSCompareSubscriber.2", tag.getName()), Policy.bind("CVSCompareSubscriber.3")); //$NON-NLS-1$ //$NON-NLS-2$ - this.resources = resources; - tree = new CVSResourceVariantTree(new SessionResourceVariantByteStore(), tag, getCacheFileContentsHint()); - initialize(); - } - - public CVSCompareSubscriber(IResource[] resources, CVSTag[] tags, String name) { - super(getUniqueId(), Policy.bind("CVSCompareSubscriber.2", name), Policy.bind("CVSCompareSubscriber.3")); //$NON-NLS-1$ //$NON-NLS-2$ - resetRoots(resources, tags); - initialize(); - } - - /** - * @param resources - * @param tags - */ - public void resetRoots(IResource[] resources, CVSTag[] tags) { - if (this.resources != null) { - List removed = new ArrayList(); - for (int i = 0; i < this.resources.length; i++) { - IResource resource = this.resources[i]; - removed.add(new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, resource)); - } - this.resources = new IResource[0]; - fireTeamResourceChange((ISubscriberChangeEvent[]) removed.toArray(new ISubscriberChangeEvent[removed.size()])); - if (tree != null) { - tree.dispose(); - tree = null; - } - } - this.resources = resources; - MultiTagResourceVariantTree multiTree = new MultiTagResourceVariantTree(new SessionResourceVariantByteStore(), getCacheFileContentsHint()); - for (int i = 0; i < tags.length; i++) { - multiTree.addResource(resources[i], tags[i]); - } - tree = multiTree; - } - - private void initialize() { - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this); - } - - public void dispose() { - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().removeListener(this); - tree.dispose(); - } - - private static QualifiedName getUniqueId() { - String uniqueId = Long.toString(System.currentTimeMillis()); - return new QualifiedName(QUALIFIED_NAME, UNIQUE_ID_PREFIX + uniqueId); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache() - */ - protected IResourceVariantTree getBaseTree() { - // No base cache needed since it's a two way compare - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache() - */ - protected IResourceVariantTree getRemoteTree() { - return tree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.TeamSubscriber#isThreeWay() - */ - public boolean isThreeWay() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.TeamSubscriber#roots() - */ - public IResource[] roots() { - return resources; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.subscribers.TeamDelta[]) - */ - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - List outgoingDeltas = new ArrayList(deltas.length); - for (int i = 0; i < deltas.length; i++) { - ISubscriberChangeEvent delta = deltas[i]; - if ((delta.getFlags() & ISubscriberChangeEvent.ROOT_REMOVED) != 0) { - IResource resource = delta.getResource(); - outgoingDeltas.addAll(Arrays.asList(handleRemovedRoot(resource))); - } else if ((delta.getFlags() & ISubscriberChangeEvent.SYNC_CHANGED) != 0) { - IResource resource = delta.getResource(); - try { - if (isSupervised(resource)) { - outgoingDeltas.add(new SubscriberChangeEvent(this, delta.getFlags(), resource)); - } - } catch (TeamException e) { - // Log and ignore - CVSProviderPlugin.log(e); - } - } - } - - fireTeamResourceChange((SubscriberChangeEvent[]) outgoingDeltas.toArray(new SubscriberChangeEvent[outgoingDeltas.size()])); - } - - private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot) { - // Determine if any of the roots of the compare are affected - List removals = new ArrayList(resources.length); - for (int j = 0; j < resources.length; j++) { - IResource root = resources[j]; - if (removedRoot.getFullPath().isPrefixOf(root.getFullPath())) { - // The root is no longer managed by CVS - removals.add(root); - try { - tree.flushVariants(root, IResource.DEPTH_INFINITE); - } catch (TeamException e) { - CVSProviderPlugin.log(e); - } - } - } - if (removals.isEmpty()) { - return new SubscriberChangeEvent[0]; - } - - // Adjust the roots of the subscriber - List newRoots = new ArrayList(resources.length); - newRoots.addAll(Arrays.asList(resources)); - newRoots.removeAll(removals); - resources = (IResource[]) newRoots.toArray(new IResource[newRoots.size()]); - - // Create the deltas for the removals - SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()]; - for (int i = 0; i < deltas.length; i++) { - deltas[i] = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, (IResource)removals.get(i)); - } - return deltas; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource) - */ - public boolean isSupervised(IResource resource) throws TeamException { - if (super.isSupervised(resource)) { - if (!resource.exists() && !getRemoteTree().hasResourceVariant(resource)) { - // Exclude conflicting deletions - return false; - } - for (int i = 0; i < resources.length; i++) { - IResource root = resources[i]; - if (root.getFullPath().isPrefixOf(resource.getFullPath())) { - return true; - } - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getCacheFileContentsHint() - */ - protected boolean getCacheFileContentsHint() { - return true; - } - - public CVSTag getTag() { - return tree.getTag(ResourcesPlugin.getWorkspace().getRoot()); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - if(this == other) return true; - if(! (other instanceof CVSCompareSubscriber)) return false; - CVSCompareSubscriber s = (CVSCompareSubscriber)other; - CVSResourceVariantTree tree1 = (CVSResourceVariantTree)getRemoteTree(); - CVSResourceVariantTree tree2 = (CVSResourceVariantTree)s.getRemoteTree(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - CVSTag tag1 = tree1.getTag(root); - CVSTag tag2 = tree2.getTag(root); - if (tag1 == null || tag2 == null) return false; - return tag1.equals(tag2) && rootsEqual(s); - } - - /** - * Prime the remote tree with the sync info from the local workspace. - * This is done to ensure that we don't get a huge nimber of outgoing - * changes before the first refresh. - * - */ - public void primeRemoteTree() throws CVSException { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - cvsResource.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - byte[] bytes = file.getSyncBytes(); - if (bytes != null) { - try { - tree.getByteStore().setBytes(file.getIResource(), bytes); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - } - public void visitFolder(ICVSFolder folder) throws CVSException { - // No need to copy sync info for folders since - // CVS resource variant tree will get missing - // folder info from the local resources - folder.acceptChildren(this); - } - }); - } - } - - /** - * Return the tag associated with the given root resource - * or null if there is only a single tag - * for the subscriber. - * @param root the root resource - * @return the tag associated with the given root resource - */ - public CVSTag getTag(IResource root) { - return tree.getTag(root); - } - - /** - * Return true if the tag against which each - * root is compared may differ. - * @return whether the tag on each root may differ. - */ - public boolean isMultipleTagComparison() { - return getTag() == null; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java deleted file mode 100644 index b7dd96b7b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; - -/** - * Core validator that will load the UI validator only if a prompt is needed - */ -public class CVSCoreFileModificationValidator implements ICVSFileModificationValidator { - - IFileModificationValidator uiValidator; - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IFileModificationValidator#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - public IStatus validateEdit(IFile[] files, Object context) { - IFile[] unmanagedReadOnlyFiles = getUnmanagedReadOnlyFiles(files); - if (unmanagedReadOnlyFiles.length > 0) { - IStatus status = setWritable(unmanagedReadOnlyFiles); - if (!status.isOK()) { - return status; - } - } - IFile[] readOnlyFiles = getManagedReadOnlyFiles(files); - if (readOnlyFiles.length == 0) return Status.OK_STATUS; - return edit(readOnlyFiles, context); - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IFileModificationValidator#validateSave(org.eclipse.core.resources.IFile) - */ - public IStatus validateSave(IFile file) { - if (!needsCheckout(file)) { - if (file.isReadOnly()) { - setWritable(new IFile[] { file } ); - } - return Status.OK_STATUS; - } - return edit(new IFile[] {file}, (Object)null); - } - - /** - * Method for editing a set of files. Is overriden by the - * UI to prompt the user. Default behavior is to try and load the - * UI validator and, failing that, to edit without - * prompting. - * @param readOnlyFiles - * @param context - * @return - */ - protected IStatus edit(IFile[] readOnlyFiles, Object context) { - synchronized(this) { - if (uiValidator == null) { - uiValidator = getPluggedInValidator(); - } - } - if (uiValidator != null) { - return uiValidator.validateEdit(readOnlyFiles, context); - } else { - try { - performEdit(readOnlyFiles, new NullProgressMonitor()); - } catch (CVSException e) { - return e.getStatus(); - } - return Status.OK_STATUS; - } - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator#validateMoveDelete(org.eclipse.core.resources.IFile[], org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validateMoveDelete(IFile[] files, IProgressMonitor monitor) { - IFile[] readOnlyFiles = getManagedReadOnlyFiles(files); - if (readOnlyFiles.length == 0) return Status.OK_STATUS; - - try { - performEdit(readOnlyFiles, monitor); - return Status.OK_STATUS; - } catch (CVSException e) { - return e.getStatus(); - } - } - - protected CVSTeamProvider getProvider(IFile[] files) { - CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(files[0].getProject(), CVSProviderPlugin.getTypeId()); - return provider; - } - - protected void performEdit(IFile[] files, IProgressMonitor monitor) throws CVSException { - getProvider(files).edit(files, false /* recurse */, true /* notify server */, ICVSFile.NO_NOTIFICATION, monitor); - } - - private boolean needsCheckout(IFile file) { - try { - if (file.isReadOnly()) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - boolean managed = cvsFile.isManaged(); - return managed; - } - } catch (CVSException e) { - // Log the exception and assume we don't need a checkout - CVSProviderPlugin.log(e); - } - return false; - } - - protected IStatus setWritable(final IFile[] files) { - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - ResourceAttributes attributes = file.getResourceAttributes(); - if (attributes != null) { - attributes.setReadOnly(false); - } - try { - file.setResourceAttributes(attributes); - } catch (CoreException e) { - return CVSException.wrapException(e).getStatus(); - } - } - return Status.OK_STATUS; - } - - private IFile[] getManagedReadOnlyFiles(IFile[] files) { - List readOnlys = new ArrayList(); - for (int i = 0; i < files.length; i++) { - IFile iFile = files[i]; - if (needsCheckout(iFile)) { - readOnlys.add(iFile); - } - } - return (IFile[]) readOnlys.toArray(new IFile[readOnlys.size()]); - } - - protected IFile[] getUnmanagedReadOnlyFiles(IFile[] files) { - List readOnlys = new ArrayList(); - for (int i = 0; i < files.length; i++) { - IFile iFile = files[i]; - if (iFile.isReadOnly() && !needsCheckout(iFile)) { - readOnlys.add(iFile); - } - } - return (IFile[]) readOnlys.toArray(new IFile[readOnlys.size()]); - } - - private static IFileModificationValidator getPluggedInValidator() { - IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_FILE_MODIFICATION_VALIDATOR).getExtensions(); - if (extensions.length == 0) - return null; - IExtension extension = extensions[0]; - IConfigurationElement[] configs = extension.getConfigurationElements(); - if (configs.length == 0) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSAdapter.noConfigurationElement", new Object[] {extension.getUniqueIdentifier()}), null);//$NON-NLS-1$ - return null; - } - try { - IConfigurationElement config = configs[0]; - return (IFileModificationValidator) config.createExecutableExtension("run");//$NON-NLS-1$ - } catch (CoreException ex) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSAdapter.unableToInstantiate", new Object[] {extension.getUniqueIdentifier()}), ex);//$NON-NLS-1$ - return null; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java deleted file mode 100644 index 9a3e93f5d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.TeamException; - -/** - * A checked expection representing a failure in the CVS plugin. - *

              - * CVS exceptions contain a status object describing the cause of - * the exception. - *

              - * - * @see IStatus - */ -public class CVSException extends TeamException { - - private static final long serialVersionUID = 1L; - - public CVSException(CoreException e) { - super(e); - } - - public CVSException(int severity, int code, String message, Throwable e) { - super(new CVSStatus(severity, code, message, e)); - } - - public CVSException(int severity, int code, String message) { - this(severity, code, message, null); - } - - public CVSException(String message) { - super(new CVSStatus(IStatus.ERROR, UNABLE, message, null)); - } - - public CVSException(String message, Throwable e) { - this(IStatus.ERROR, UNABLE, message, e); - } - - public CVSException(IStatus status) { - super(status); - } - - /* - * Static helper methods for creating exceptions - */ - public static CVSException wrapException(IResource resource, String message, IOException e) { - // NOTE: we should record the resource somehow - // We should also inlcude the IO message - return new CVSException(new CVSStatus(IStatus.ERROR, IO_FAILED, message, e)); - } - - /* - * Static helper methods for creating exceptions - */ - public static CVSException wrapException(IResource resource, String message, CoreException e) { - return new CVSException(new CVSStatus(IStatus.ERROR, e.getStatus().getCode(), message, e)); - } - - /* - * Static helper methods for creating exceptions - */ - public static CVSException wrapException(Exception e) { - Throwable t = e; - if (e instanceof InvocationTargetException) { - Throwable target = ((InvocationTargetException) e).getTargetException(); - if (target instanceof CVSException) { - return (CVSException) target; - } - t = target; - } - return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, t.getMessage() != null ? t.getMessage() : "", t)); //$NON-NLS-1$ - } - - public static CVSException wrapException(CoreException e) { - if (e instanceof CVSException) { - return (CVSException)e; - } - return new CVSException(e); - } - - public CoreException toCoreException() { - IStatus status = getStatus(); - return new CoreException(new Status(status.getSeverity(), status.getPlugin(), 0, status.getMessage(), this)); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java deleted file mode 100644 index 188aff8a2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoFilter; -import org.eclipse.team.core.variants.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * A CVSMergeSubscriber is responsible for maintaining the remote trees for a merge into - * the workspace. The remote trees represent the CVS revisions of the start and end - * points (version or branch) of the merge. - * - * This subscriber stores the remote handles in the resource tree sync info slot. When - * the merge is cancelled this sync info is cleared. - * - * A merge can persist between workbench sessions and thus can be used as an - * ongoing merge. - * - * TODO: Is the merge subscriber interested in workspace sync info changes? - * TODO: Do certain operations (e.g. replace with) invalidate a merge subscriber? - * TODO: How to ensure that sync info is flushed when merge roots are deleted? - */ -public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResourceChangeListener, ISubscriberChangeListener { - - private final class MergeBaseTree extends CVSResourceVariantTree { - // The merge synchronizer has been kept so that those upgrading - // from 3.0 M8 to 3.0 M9 so not lose there ongoing merge state - private PersistantResourceVariantByteStore mergedSynchronizer; - private MergeBaseTree(ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint, String syncKeyPrefix) { - super(cache, tag, cacheFileContentsHint); - mergedSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + "0merged")); //$NON-NLS-1$ - } - public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - // Only refresh the base of a resource once as it should not change - List unrefreshed = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (!hasResourceVariant(resource)) { - unrefreshed.add(resource); - } - } - if (unrefreshed.isEmpty()) { - monitor.done(); - return new IResource[0]; - } - IResource[] refreshed = super.refresh((IResource[]) unrefreshed.toArray(new IResource[unrefreshed.size()]), depth, monitor); - return refreshed; - } - public IResourceVariant getResourceVariant(IResource resource) throws TeamException { - // Use the merged bytes for the base if there are some - byte[] mergedBytes = mergedSynchronizer.getBytes(resource); - if (mergedBytes != null) { - byte[] parentBytes = getByteStore().getBytes(resource.getParent()); - if (parentBytes != null) { - return RemoteFile.fromBytes(resource, mergedBytes, parentBytes); - } - } - return super.getResourceVariant(resource); - } - - /** - * Mark the resource as merged by making it's base equal the remote - */ - public void merged(IResource resource, byte[] remoteBytes) throws TeamException { - if (remoteBytes == null) { - getByteStore().deleteBytes(resource); - } else { - getByteStore().setBytes(resource, remoteBytes); - } - } - - /** - * Return true if the remote has already been merged - * (i.e. the base equals the remote). - */ - public boolean isMerged(IResource resource, byte[] remoteBytes) throws TeamException { - byte[] mergedBytes = getByteStore().getBytes(resource); - return Util.equals(mergedBytes, remoteBytes); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree#dispose() - */ - public void dispose() { - mergedSynchronizer.dispose(); - super.dispose(); - } - } - - public static final String ID = "org.eclipse.team.cvs.ui.cvsmerge-participant"; //$NON-NLS-1$ - public static final String ID_MODAL = "org.eclipse.team.cvs.ui.cvsmerge-participant-modal"; //$NON-NLS-1$ - private static final String UNIQUE_ID_PREFIX = "merge-"; //$NON-NLS-1$ - - private CVSTag start, end; - private List roots; - private CVSResourceVariantTree remoteTree; - private MergeBaseTree baseTree; - - public CVSMergeSubscriber(IResource[] roots, CVSTag start, CVSTag end) { - this(getUniqueId(), roots, start, end); - } - - private static QualifiedName getUniqueId() { - String uniqueId = Long.toString(System.currentTimeMillis()); - return new QualifiedName(ID, "CVS" + UNIQUE_ID_PREFIX + uniqueId); //$NON-NLS-1$ - } - - public CVSMergeSubscriber(QualifiedName id, IResource[] roots, CVSTag start, CVSTag end) { - super(id, Policy.bind("CVSMergeSubscriber.2", start.getName(), end.getName()), Policy.bind("CVSMergeSubscriber.4")); //$NON-NLS-1$ //$NON-NLS-2$ - this.start = start; - this.end = end; - this.roots = new ArrayList(Arrays.asList(roots)); - initialize(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSWorkspaceSubscriber#initialize() - */ - private void initialize() { - QualifiedName id = getId(); - String syncKeyPrefix = id.getLocalName(); - PersistantResourceVariantByteStore remoteSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + end.getName())); - remoteTree = new CVSResourceVariantTree(remoteSynchronizer, getEndTag(), getCacheFileContentsHint()) { - public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - // Override refresh to compare file contents - monitor.beginTask(null, 100); - try { - IResource[] refreshed = super.refresh(resources, depth, monitor); - compareWithRemote(refreshed, Policy.subMonitorFor(monitor, 50)); - return refreshed; - } finally { - monitor.done(); - } - } - }; - PersistantResourceVariantByteStore baseSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + start.getName())); - baseTree = new MergeBaseTree(baseSynchronizer, getStartTag(), getCacheFileContentsHint(), syncKeyPrefix); - - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this); - } - - protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException { - CVSMergeSyncInfo info = new CVSMergeSyncInfo(local, base, remote, this); - info.init(); - return info; - } - - public void merged(IResource[] resources) throws TeamException { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - internalMerged(resource); - } - fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources)); - } - - private void internalMerged(IResource resource) throws TeamException { - byte[] remoteBytes = getRemoteByteStore().getBytes(resource); - baseTree.merged(resource, remoteBytes); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.TeamSubscriber#cancel() - */ - public void cancel() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - remoteTree.dispose(); - baseTree.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.TeamSubscriber#roots() - */ - public IResource[] roots() { - return (IResource[]) roots.toArray(new IResource[roots.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource) - */ - public boolean isSupervised(IResource resource) throws TeamException { - return getBaseTree().hasResourceVariant(resource) || getRemoteTree().hasResourceVariant(resource); - } - - public CVSTag getStartTag() { - return start; - } - - public CVSTag getEndTag() { - return end; - } - - /* - * What to do when a root resource for this merge changes? - * Deleted, Move, Copied - * Changed in a CVS way (tag changed, revision changed...) - * Contents changed by user - * @see IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - IResourceDelta delta = event.getDelta(); - if(delta != null) { - delta.accept(new IResourceDeltaVisitor() { - public boolean visit(IResourceDelta delta) throws CoreException { - IResource resource = delta.getResource(); - - if (resource.getType()==IResource.PROJECT) { - IProject project = (IProject)resource; - if (!project.isAccessible()) { - return false; - } - if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { - return false; - } - if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) { - return false; - } - } - - if (roots.contains(resource)) { - if (delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.MOVED_TO) { - cancel(); - } - // stop visiting children - return false; - } - // keep visiting children - return true; - } - }); - } - } catch (CoreException e) { - CVSProviderPlugin.log(e.getStatus()); - } - } - - /** - * Return whether the given resource has been merged with its - * corresponding remote. - * @param resource the local resource - * @return boolean - * @throws TeamException - */ - public boolean isMerged(IResource resource) throws TeamException { - byte[] remoteBytes = getRemoteByteStore().getBytes(resource); - return baseTree.isMerged(resource, remoteBytes); - } - - /* - * Currently only the workspace subscriber knows when a project has been deconfigured. We will listen for these events - * and remove the root then forward to merge subscriber listeners. - * (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.subscribers.TeamDelta[]) - */ - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - for (int i = 0; i < deltas.length; i++) { - ISubscriberChangeEvent delta = deltas[i]; - switch(delta.getFlags()) { - case ISubscriberChangeEvent.ROOT_REMOVED: - IResource resource = delta.getResource(); - if(roots.remove(resource)) { - fireTeamResourceChange(new ISubscriberChangeEvent[] {delta}); - } - break; - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache() - */ - protected IResourceVariantTree getBaseTree() { - return baseTree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache() - */ - protected IResourceVariantTree getRemoteTree() { - return remoteTree; - } - - protected boolean getCacheFileContentsHint() { - return true; - } - - /* - * Mark as merged any local resources whose contents match that of the remote resource. - */ - private void compareWithRemote(IResource[] refreshed, IProgressMonitor monitor) throws CVSException, TeamException { - // For any remote changes, if the revision differs from the local, compare the contents. - if (refreshed.length == 0) return; - SyncInfoFilter.ContentComparisonSyncInfoFilter contentFilter = - new SyncInfoFilter.ContentComparisonSyncInfoFilter(); - monitor.beginTask(null, refreshed.length * 100); - for (int i = 0; i < refreshed.length; i++) { - IResource resource = refreshed[i]; - if (resource.getType() == IResource.FILE) { - ICVSFile local = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - byte[] localBytes = local.getSyncBytes(); - byte[] remoteBytes = getRemoteByteStore().getBytes(resource); - if (remoteBytes != null - && localBytes != null - && local.exists() - && !ResourceSyncInfo.getRevision(remoteBytes).equals(ResourceSyncInfo.getRevision(localBytes)) - && contentFilter.select(getSyncInfo(resource), Policy.subMonitorFor(monitor, 100))) { - // The contents are equals so mark the file as merged - internalMerged(resource); - } - } - } - monitor.done(); - } - - - private PersistantResourceVariantByteStore getRemoteByteStore() { - return (PersistantResourceVariantByteStore)((CVSResourceVariantTree)getRemoteTree()).getByteStore(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - if(this == other) return true; - if(! (other instanceof CVSMergeSubscriber)) return false; - CVSMergeSubscriber s = (CVSMergeSubscriber)other; - return getEndTag().equals(s.getEndTag()) && - getStartTag().equals(s.getStartTag()) && rootsEqual(s); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java deleted file mode 100644 index 14914f06a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.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.team.internal.ccvs.core; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.core.variants.*; - -public class CVSMergeSyncInfo extends CVSSyncInfo { - - public CVSMergeSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, Subscriber subscriber) { - super(local, base, remote, subscriber); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncInfo#handleDeletionConflicts(int) - */ - protected int handleDeletionConflicts(int kind) { - // (see bug 40053). - if(kind == (SyncInfo.CONFLICTING | SyncInfo.DELETION | SyncInfo.PSEUDO_CONFLICT)) { - return SyncInfo.IN_SYNC; - } - return kind; - } - - protected int calculateKind() throws TeamException { - // Report merged resources as in-sync - if (((CVSMergeSubscriber)getSubscriber()).isMerged(getLocal())) { - return IN_SYNC; - } - - int kind = super.calculateKind(); - - // Report outgoing resources as in-sync - if((kind & DIRECTION_MASK) == OUTGOING) { - return IN_SYNC; - } - - return kind; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncInfo#makeOutgoing(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus makeOutgoing(IProgressMonitor monitor) throws TeamException { - // Make the resource outgoing by marking it as merged with the subscriber - CVSMergeSubscriber subscriber = (CVSMergeSubscriber)getSubscriber(); - subscriber.merged(new IResource[] {getLocal() }); - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java deleted file mode 100644 index 5da4877a2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java +++ /dev/null @@ -1,519 +0,0 @@ -/********************************************************************** - Copyright (c) 2004 Dan Rubel and others. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Common Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/cpl-v10.html - - Contributors: - - Dan Rubel - initial API and implementation - - **********************************************************************/ - -package org.eclipse.team.internal.ccvs.core; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.team.core.ProjectSetCapability; -import org.eclipse.team.core.ProjectSetSerializationContext; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.client.Checkout; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Request; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; -import org.eclipse.team.internal.ccvs.core.resources.RemoteModule; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; - -/** - * An object for serializing and deserializing - * of references to CVS based projects. Given a project, it can produce a - * UTF-8 encoded String which can be stored in a file. - * Given this String, it can load a project into the workspace. - * - * @since 3.0 - */ -public class CVSProjectSetCapability extends ProjectSetCapability { - - /** - * Override superclass implementation to return an array of project references. - * - * @see ProjectSetSerializer#asReference(IProject[], ProjectSetSerializationContext, IProgressMonitor) - */ - public String[] asReference( - IProject[] projects, - ProjectSetSerializationContext context, - IProgressMonitor monitor) - throws TeamException { - - String[] result = new String[projects.length]; - for (int i = 0; i < projects.length; i++) - result[i] = asReference(projects[i]); - return result; - } - - /** - * Answer a string representing the specified project - * - * @param project the project (not null) - * @return the project reference (not null) - * @throws CVSException - */ - private String asReference(IProject project) throws TeamException { - StringBuffer buffer = new StringBuffer(); - buffer.append("1.0,"); //$NON-NLS-1$ - - CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project); - CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot(); - CVSRepositoryLocation location = CVSRepositoryLocation.fromString(root.getRemoteLocation().getLocation()); - location.setUserMuteable(true); - String repoLocation = location.getLocation(); - buffer.append(repoLocation); - buffer.append(","); //$NON-NLS-1$ - - ICVSFolder folder = root.getLocalRoot(); - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - String module = syncInfo.getRepository(); - buffer.append(module); - buffer.append(","); //$NON-NLS-1$ - - String projectName = folder.getName(); - buffer.append(projectName); - CVSTag tag = syncInfo.getTag(); - if (tag != null) { - if (tag.getType() != CVSTag.DATE) { - buffer.append(","); //$NON-NLS-1$ - String tagName = tag.getName(); - buffer.append(tagName); - } - } - return buffer.toString(); - } - - /** - * Override superclass implementation to load the referenced projects into the workspace. - * - * @see org.eclipse.team.core.ProjectSetSerializer#addToWorkspace(java.lang.String[], org.eclipse.team.core.ProjectSetSerializationContext, org.eclipse.core.runtime.IProgressMonitor) - */ - public IProject[] addToWorkspace( - String[] referenceStrings, - ProjectSetSerializationContext context, - IProgressMonitor monitor) - throws TeamException { - - monitor = Policy.monitorFor(monitor); - Policy.checkCanceled(monitor); - - // Confirm the projects to be loaded - Map infoMap = new HashMap(referenceStrings.length); - IProject[] projects = asProjects(referenceStrings, infoMap); - projects = confirmOverwrite(context, projects); - if (projects == null) - return new IProject[0]; - - // Load the projects - return checkout(projects, infoMap, monitor); - } - - /** - * Translate the reference strings into projects to be loaded - * and build a mapping of project to project load information. - * - * @param referenceStrings project references - * @param infoMap a mapping of project to project load information - * @return the projects to be loaded - */ - private IProject[] asProjects(String[] referenceStrings, Map infoMap) throws CVSException { - Collection result = new ArrayList(); - for (int i = 0; i < referenceStrings.length; i++) { - StringTokenizer tokenizer = new StringTokenizer(referenceStrings[i], ","); //$NON-NLS-1$ - String version = tokenizer.nextToken(); - // If this is a newer version, then ignore it - if (!version.equals("1.0")) //$NON-NLS-1$ - continue; - LoadInfo info = new LoadInfo(tokenizer); - IProject proj = info.getProject(); - result.add(proj); - infoMap.put(proj, info); - } - return (IProject[]) result.toArray(new IProject[result.size()]); - } - - /** - * Checkout projects from the CVS repository - * - * @param projects the projects to be loaded from the repository - * @param infoMap a mapping of project to project load information - * @param monitor the progress monitor (not null) - */ - private IProject[] checkout( - IProject[] projects, - Map infoMap, - IProgressMonitor monitor) - throws TeamException { - - monitor.beginTask("", 1000 * projects.length); //$NON-NLS-1$ - List result = new ArrayList(); - try { - for (int i = 0; i < projects.length; i++) { - if (monitor.isCanceled()) - break; - IProject project = projects[i]; - LoadInfo info = (LoadInfo) infoMap.get(project); - if (info != null && info.checkout(new SubProgressMonitor(monitor, 1000))) - result.add(project); - } - } - finally { - monitor.done(); - } - return (IProject[])result.toArray(new IProject[result.size()]); - } - - /** - * Internal class for adding projects to the workspace - */ - class LoadInfo { - private final ICVSRepositoryLocation repositoryLocation; - private final String module; - private final IProject project; - private final CVSTag tag; - - /** - * Construct a new instance wrappering the specified project reference - * - * @param projRef the project reference - */ - LoadInfo(StringTokenizer tokenizer) throws CVSException { - String repo = tokenizer.nextToken(); - repositoryLocation = getRepositoryLocationFromString(repo); - module = tokenizer.nextToken(); - String projectName = tokenizer.nextToken(); - project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (tokenizer.hasMoreTokens()) { - String tagName = tokenizer.nextToken(); - tag = new CVSTag(tagName, CVSTag.BRANCH); - } - else { - tag = null; - } - } - - /** - * Answer the project referenced by this object. - * The project may or may not already exist. - * - * @return the project (not null) - */ - private IProject getProject() { - return project; - } - - /** - * Checkout the project specified by this reference. - * - * @param monitor project monitor - * @return true if loaded, else false - * @throws TeamException - */ - boolean checkout(IProgressMonitor monitor) throws TeamException { - if (repositoryLocation == null) - return false; - CVSProjectSetCapability.checkout( - repositoryLocation, - project, - module, - tag, - monitor); - return true; - } - } - - /** - * Extract the CVS repository location information from the specified string - * - * @param repo the repository location as a string - * @return the CVS repository information - * @throws CVSException - */ - private static ICVSRepositoryLocation getRepositoryLocationFromString(String repo) throws CVSException { - // create the new location - ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo); - if (newLocation.getUsername() == null || newLocation.getUsername().length() == 0) { - // look for an existing location that matched - ICVSRepositoryLocation[] locations = CVSProviderPlugin.getPlugin().getKnownRepositories(); - for (int i = 0; i < locations.length; i++) { - ICVSRepositoryLocation location = locations[i]; - if (location.getMethod() == newLocation.getMethod() - && location.getHost().equals(newLocation.getHost()) - && location.getPort() == newLocation.getPort() - && location.getRootDirectory().equals(newLocation.getRootDirectory())) - return location; - } - } - // No existing location was found so add this location to the list of known repositories - KnownRepositories.getInstance().addRepository(newLocation, true); - return newLocation; - } - - /** - * Checkout a CVS module. - * - * The provided project represents the target project. Any existing contents - * may or may not get overwritten. If project is null then a project - * will be created based on the provided sourceModule. If soureModule is null, - * then the project name will be used as the module to - * check out. If both are absent, an exception is thrown. - * - * Resources existing in the local file system at the target project location but now - * known to the workbench will be overwritten. - * - * After the successful completion of this method, the project will exist - * and be open. - */ - public static void checkout( - ICVSRepositoryLocation repository, - IProject project, - String sourceModule, - CVSTag tag, - IProgressMonitor monitor) - throws TeamException { - - if (sourceModule == null) - sourceModule = project.getName(); - checkout(new ICVSRemoteFolder[] { new RemoteFolder(null, repository, sourceModule, tag)}, - new IProject[] { project }, monitor); - } - - /** - * Checkout the remote resources into the local workspace. Each resource will - * be checked out into the corresponding project. If the corresponding project is - * null or if projects is null, the name of the remote resource is used as the name of the project. - * - * Resources existing in the local file system at the target project location but now - * known to the workbench will be overwritten. - */ - public static void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, final IProgressMonitor monitor) throws TeamException { - final TeamException[] eHolder = new TeamException[1]; - try { - IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor pm) throws CoreException { - try { - pm.beginTask(null, 1000 * resources.length); - - // Get the location of the workspace root - ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()); - - for (int i=0;i"org.eclipse.team.cvs.core.nature"). - * The presence of this nature on a project indicates that it is - * CVS-capable. - * - * @see org.eclipse.core.resources.IProject#hasNature - */ - private static final String NATURE_ID = ID + ".cvsnature"; //$NON-NLS-1$ - - // File used to idicate if the workbench was shut down properly or not - private static final String CRASH_INDICATION_FILE = ".running"; //$NON-NLS-1$ - private boolean crash; - - public synchronized CVSWorkspaceSubscriber getCVSWorkspaceSubscriber() { - if (cvsWorkspaceSubscriber == null) { - cvsWorkspaceSubscriber = new CVSWorkspaceSubscriber( - CVS_WORKSPACE_SUBSCRIBER_ID, - Policy.bind("CVSProviderPlugin.20"), //$NON-NLS-1$ - Policy.bind("CVSProviderPlugin.21")); //$NON-NLS-1$ - } - return cvsWorkspaceSubscriber; - } - - /** - * @return - */ - public boolean isConfirmMoveTagEnabled() { - return confirmMoveTagEnabled; - } - - /** - * @param confirmMoveTag - */ - public void setConfirmMoveTagEnabled(boolean confirmMoveTag) { - this.confirmMoveTagEnabled = confirmMoveTag; - } - - /** - * Constructor for CVSProviderPlugin. - * @param descriptor - */ - public CVSProviderPlugin() { - super(); - instance = this; - } - - /** - * Convenience method for logging CoreExceptions to the plugin log - */ - public static void log(CoreException e) { - log(e.getStatus().getSeverity(), e.getMessage(), e); - } - - /** - * Log the given exception along with the provided message and severity indicator - */ - public static void log(int severity, String message, Throwable e) { - log(new Status(severity, ID, 0, message, e)); - } - - /** - * Log the given status. Do not use this method for the IStatus from a CoreException. - * Uselog(CoreException) instead so the stack trace is not lost. - */ - public static void log(IStatus status) { - getPlugin().getLog().log(status); - } - - /** - * Returns the singleton plug-in instance. - * - * @return the plugin instance - */ - public static CVSProviderPlugin getPlugin() { - return instance; - } - - /** - * Answers the repository provider type id for the cvs plugin - */ - public static String getTypeId() { - return NATURE_ID; - } - - /** - * Sets the file transfer compression level. (if supported) - * Valid levels are: 0 (disabled), 1 (worst/fastest) - 9 (best/slowest) - */ - public void setCompressionLevel(int level) { - compressionLevel = level; - } - - /** - * Gets the file transfer compression level. - */ - public int getCompressionLevel() { - return compressionLevel; - } - - /** - * Sets the default keyword substitution mode for text files. - */ - public void setDefaultTextKSubstOption(KSubstOption ksubst) { - defaultTextKSubstOption = ksubst; - } - - - /** - * Gets the default keyword substitution mode for text files. - */ - public KSubstOption getDefaultTextKSubstOption() { - return defaultTextKSubstOption; - } - - /** - * Should the CVS adapter prune empty directories - */ - public boolean getPruneEmptyDirectories() { - return pruneEmptyDirectories; - } - - /** - * Set whether the CVS adapter should prune empty directories - */ - public void setPruneEmptyDirectories(boolean prune) { - pruneEmptyDirectories = prune; - } - - /** - * Get the communications timeout value in seconds - */ - public int getTimeout() { - return communicationsTimeout; - } - - /** - * Set the timeout value for communications to a value in seconds. - * The value must be greater than or equal 0. If is it 0, there is no timeout. - */ - public void setTimeout(int timeout) { - this.communicationsTimeout = Math.max(0, timeout); - } - - /** - * Set the quietness option to use with cvs commands. - * Can be "", "-q" or "-Q" - */ - public void setQuietness(QuietOption option) { - this.quietness = option; - } - - /** - * Get the quietness option for commands - */ - public QuietOption getQuietness() { - return quietness; - } - - /** - * Set the console listener for commands. - * @param consoleListener the listener - */ - public void setConsoleListener(IConsoleListener consoleListener) { - ConsoleListeners.getInstance().addListener(consoleListener); - } - - /** - * @see Plugin#start(BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - Policy.localize("org.eclipse.team.internal.ccvs.core.messages"); //$NON-NLS-1$ - - // load the state which includes the known repositories - loadOldState(); - crash = createCrashFile(); - - // Initialize CVS change listeners. Note tha the report type is important. - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - addDeleteMoveListener = new BuildCleanupListener(); - fileModificationManager = new FileModificationManager(); - metaFileSyncListener = new SyncFileChangeListener(); - workspace.addResourceChangeListener(addDeleteMoveListener, IResourceChangeEvent.POST_BUILD); - workspace.addResourceChangeListener(metaFileSyncListener, IResourceChangeEvent.POST_CHANGE); - workspace.addResourceChangeListener(fileModificationManager, IResourceChangeEvent.POST_CHANGE); - fileModificationManager.registerSaveParticipant(); - - getCVSWorkspaceSubscriber(); - } - - /** - * @see Plugin#stop(BundleContext) - */ - public void stop(BundleContext context) throws Exception { - try { - savePluginPreferences(); - - // remove listeners - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.removeResourceChangeListener(metaFileSyncListener); - workspace.removeResourceChangeListener(fileModificationManager); - workspace.removeResourceChangeListener(addDeleteMoveListener); - - // remove all of this plugin's save participants. This is easier than having - // each class that added itself as a participant to have to listen to shutdown. - workspace.removeSaveParticipant(this); - - deleteCrashFile(); - } finally { - super.stop(context); - } - } - - /** - * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences() - */ - protected void initializeDefaultPluginPreferences(){ - Preferences store = getPluginPreferences(); - store.setDefault(READ_ONLY, false); - } - - /** - * Gets the cvsRshCommand. - * @return Returns a String - */ - public String getCvsRshCommand() { - return cvsRshCommand; - } - - /** - * Sets the cvsRshCommand. - * @param cvsRshCommand The cvsRshCommand to set - */ - public void setCvsRshCommand(String cvsRshCommand) { - this.cvsRshCommand = cvsRshCommand; - } - - /** - * Returns the cvsRshParameters. - * @return String - */ - public String getCvsRshParameters() { - return cvsRshParameters; - } - - /** - * Sets the cvsRshParameters. - * @param cvsRshParameters The cvsRshParameters to set - */ - public void setCvsRshParameters(String cvsRshParameters) { - this.cvsRshParameters = cvsRshParameters; - } - - /** - * Gets the cvsServer. - * @return Returns a String - */ - public String getCvsServer() { - return cvsServer; - } - - /** - * Sets the cvsServer. - * @param cvsServer The cvsServer to set - */ - public void setCvsServer(String cvsServer) { - this.cvsServer = cvsServer; - } - - /** - * Gets the etchAbsentDirectories. - * @return Returns a boolean - */ - public boolean getFetchAbsentDirectories() { - return fetchAbsentDirectories; - } - - public boolean getRepositoriesAreBinary() { - return repositoriesAreBinary; - } - - /** - * Sets the fetchAbsentDirectories. - * @param etchAbsentDirectories The etchAbsentDirectories to set - */ - public void setFetchAbsentDirectories(boolean fetchAbsentDirectories) { - this.fetchAbsentDirectories = fetchAbsentDirectories; - } - - public boolean getPromptOnFileDelete() { - return promptOnFileDelete; - } - - public void setPromptOnFileDelete(boolean prompt) { - promptOnFileDelete = prompt; - } - - public void setRepositoriesAreBinary(boolean binary) { - repositoriesAreBinary = binary; - } - - public boolean getPromptOnFolderDelete() { - return promptOnFolderDelete; - } - - public void setPromptOnFolderDelete(boolean prompt) { - promptOnFolderDelete = prompt; - } - - public static void broadcastDecoratorEnablementChanged(final boolean enabled) { - ICVSDecoratorEnablementListener[] listeners; - synchronized(decoratorEnablementListeners) { - listeners = (ICVSDecoratorEnablementListener[]) decoratorEnablementListeners.toArray(new ICVSDecoratorEnablementListener[decoratorEnablementListeners.size()]); - } - for (int i = 0; i < listeners.length; i++) { - final ICVSDecoratorEnablementListener listener = listeners[i]; - ISafeRunnable code = new ISafeRunnable() { - public void run() throws Exception { - listener.decoratorEnablementChanged(enabled); - } - public void handleException(Throwable e) { - // don't log the exception....it is already being logged in Platform#run - } - }; - Platform.run(code); - } - } - - /** - * Gets the replaceUnmanaged. - * @return Returns a boolean - */ - public boolean isReplaceUnmanaged() { - return replaceUnmanaged; - } - - /** - * Sets the replaceUnmanaged. - * @param replaceUnmanaged The replaceUnmanaged to set - */ - public void setReplaceUnmanaged(boolean replaceUnmanaged) { - this.replaceUnmanaged = replaceUnmanaged; - } - - - /** - * Register to receive notification of repository creation and disposal - */ - public void addRepositoryListener(ICVSListener listener) { - KnownRepositories.getInstance().addRepositoryListener(listener); - } - - /** - * Register to receive notification of enablement of sync info decoration requirements. This - * can be useful for providing lazy initialization of caches that are only required for decorating - * resource with CVS information. - */ - public void addDecoratorEnablementListener(ICVSDecoratorEnablementListener listener) { - synchronized(decoratorEnablementListeners) { - decoratorEnablementListeners.add(listener); - } - } - - /** - * De-register a listener - */ - public void removeRepositoryListener(ICVSListener listener) { - KnownRepositories.getInstance().removeRepositoryListener(listener); - } - - /** - * De-register the decorator enablement listener. - */ - public void removeDecoratorEnablementListener(ICVSDecoratorEnablementListener listener) { - synchronized(decoratorEnablementListeners) { - decoratorEnablementListeners.remove(listener); - } - } - - /** - * Return a list of the know repository locations. This is left - * here to isolate the RelEng tools plugin from changes in CVS core. - */ - public ICVSRepositoryLocation[] getKnownRepositories() { - return KnownRepositories.getInstance().getRepositories(); - } - - private void loadOldState() { - try { - IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation().append(REPOSITORIES_STATE_FILE); - File file = pluginStateLocation.toFile(); - if (file.exists()) { - try { - DataInputStream dis = new DataInputStream(new FileInputStream(file)); - readOldState(dis); - dis.close(); - // The file is no longer needed as the state is - // persisted in the user settings - file.delete(); - } catch (IOException e) { - throw new TeamException(new Status(Status.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSProvider.ioException"), e)); //$NON-NLS-1$ - } - } - } catch (TeamException e) { - Util.logError(Policy.bind("CVSProvider.errorLoading"), e);//$NON-NLS-1$ - } - } - - private void readOldState(DataInputStream dis) throws IOException, CVSException { - KnownRepositories instance = KnownRepositories.getInstance(); - int count = dis.readInt(); - if (count >= 0) { - // this is the version 1 format of the state file - for (int i = 0; i < count; i++) { - ICVSRepositoryLocation location = instance.getRepository(dis.readUTF()); - instance.addRepository(location, false /* no need to broadcast on startup */); - } - } else if (count == REPOSITORIES_STATE_FILE_VERSION_2) { - count = dis.readInt(); - for (int i = 0; i < count; i++) { - ICVSRepositoryLocation location = instance.getRepository(dis.readUTF()); - instance.addRepository(location, false /* no need to broadcast on startup */); - // Read the next field which is no longer used - dis.readUTF(); - } - } else { - Util.logError(Policy.bind("CVSProviderPlugin.unknownStateFileVersion", new Integer(count).toString()), null); //$NON-NLS-1$ - } - } - - public static boolean isText(IFile file) { - if (CVSProviderPlugin.getPlugin().getRepositoriesAreBinary()) return false; - return Team.getType(file) == Team.TEXT; - } - - /** - * Gets the determineVersionEnabled. - * @return boolean - */ - public boolean isDetermineVersionEnabled() { - return determineVersionEnabled; - } - - /** - * Sets the determineVersionEnabled. - * @param determineVersionEnabled The determineVersionEnabled to set - */ - public void setDetermineVersionEnabled(boolean determineVersionEnabled) { - this.determineVersionEnabled = determineVersionEnabled; - } - - /** - * Returns the fileModificationManager. - * @return FileModificationManager - */ - public FileModificationManager getFileModificationManager() { - return fileModificationManager; - } - - /** - * @return boolean - */ - public boolean isWatchEditEnabled() { - return getPluginPreferences().getBoolean(CVSProviderPlugin.READ_ONLY); - } - - public void setDebugProtocol(boolean value) { - Policy.DEBUG_CVS_PROTOCOL = value; - } - - public boolean isDebugProtocol() { - return Policy.DEBUG_CVS_PROTOCOL; - } - - /* - * Create the crash indicator file. This method returns true if the file - * already existed, indicating that a crash occurred on the last invokation of - * the platform. - */ - private boolean createCrashFile() { - IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation(); - File crashFile = pluginStateLocation.append(CRASH_INDICATION_FILE).toFile(); - if (crashFile.exists()) { - return true; - } - try { - crashFile.createNewFile(); - } catch (IOException e) { - CVSProviderPlugin.log(IStatus.ERROR, e.getMessage(), e); - } - return false; - } - - private void deleteCrashFile() { - IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation(); - File crashFile = pluginStateLocation.append(CRASH_INDICATION_FILE).toFile(); - crashFile.delete(); - } - - public boolean crashOnLastRun() { - return crash; - } - - /** - * Return the CVS preferences node in the instance scope - */ - public org.osgi.service.prefs.Preferences getInstancePreferences() { - IPreferencesService service = Platform.getPreferencesService(); - IEclipsePreferences root = service.getRootNode(); - return root.node(InstanceScope.SCOPE).node(getBundle().getSymbolicName()); - } - - /** - * @return Returns the usePlatformLineend. - */ - public boolean isUsePlatformLineend() { - return usePlatformLineend; - } - /** - * @param usePlatformLineend The usePlatformLineend to set. - */ - public void setUsePlatformLineend(boolean usePlatformLineend) { - this.usePlatformLineend = usePlatformLineend; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java deleted file mode 100644 index 93120962d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.IResourceVariantComparator; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * CVSRevisionNumberCompareCriteria - */ - public class CVSRevisionNumberCompareCriteria implements IResourceVariantComparator { - - private boolean isThreeWay; - - public CVSRevisionNumberCompareCriteria(boolean isThreeWay) { - this.isThreeWay = isThreeWay; - } - - /* (non-Javadoc) - * @see ComparisonCriteria#compare(Object, Object, IProgressMonitor) - */ - public boolean compare(Object e1, Object e2) { - if(e1 instanceof IResource && e2 instanceof ICVSRemoteResource) { - return compare((IResource)e1, (ICVSRemoteResource)e2); - } else if(e1 instanceof ICVSRemoteResource && e2 instanceof ICVSRemoteResource) { - return compare((ICVSRemoteResource)e1, (ICVSRemoteResource)e2); - } - return false; - } - - /** - * @see RemoteSyncElement#timestampEquals(IResourceVariant, IResourceVariant) - */ - protected boolean compare(ICVSRemoteResource e1, ICVSRemoteResource e2) { - if(e1.isContainer()) { - if(e2.isContainer()) { - return true; - } - return false; - } - return e1.equals(e2); - } - - /** - * @see RemoteSyncElement#timestampEquals(IResource, IResourceVariant) - */ - protected boolean compare(IResource e1, ICVSRemoteResource e2) { - if(e1.getType() != IResource.FILE) { - if(e2.isContainer()) { - return true; - } - return false; - } - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1); - try { - byte[] syncBytes1 = cvsFile.getSyncBytes(); - byte[] syncBytes2 = ((ICVSRemoteFile)e2).getSyncBytes(); - - if(syncBytes1 != null) { - if(ResourceSyncInfo.isDeletion(syncBytes1) || ResourceSyncInfo.isMerge(syncBytes1) || cvsFile.isModified(null)) { - return false; - } - return ResourceSyncInfo.getRevision(syncBytes1).equals(ResourceSyncInfo.getRevision(syncBytes2)); - } - return false; - } catch(CVSException e) { - CVSProviderPlugin.log(e); - return false; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.IComparisonCriteria#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.subscribers.ISubscriberResource) - */ - public boolean compare(IResource local, IResourceVariant remote) { - return compare(local, (ICVSRemoteResource)remote); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.IComparisonCriteria#compare(org.eclipse.team.core.subscribers.ISubscriberResource, org.eclipse.team.core.subscribers.ISubscriberResource) - */ - public boolean compare(IResourceVariant base, IResourceVariant remote) { - return compare((ICVSRemoteResource)base, (ICVSRemoteResource)remote); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISubscriberResourceComparator#isThreeWay() - */ - public boolean isThreeWay() { - return isThreeWay; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java deleted file mode 100644 index 6d06d5728..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import org.eclipse.core.runtime.Status; - -public class CVSStatus extends Status { - - /*** Status codes ***/ - public static final int SERVER_ERROR = -10; - public static final int NO_SUCH_TAG = -11; - public static final int CONFLICT = -12; - public static final int ERROR_LINE = -14; // generic uninterpreted E line from the server - public static final int TAG_ALREADY_EXISTS = -15; - public static final int COMMITTING_SYNC_INFO_FAILED = -16; - public static final int DOES_NOT_EXIST = -17; - public static final int FOLDER_NEEDED_FOR_FILE_DELETIONS = -18; - public static final int CASE_VARIANT_EXISTS = -19; - public static final int UNSUPPORTED_SERVER_VERSION = -20; - public static final int SERVER_IS_CVSNT = -21; - public static final int SERVER_IS_UNKNOWN = -22; - public static final int PROTOCOL_ERROR = -23; - public static final int ERROR_LINE_PARSE_FAILURE = -24; - public static final int FAILED_TO_CACHE_SYNC_INFO = -25; - public static final int UNMEGERED_BINARY_CONFLICT = -26; - public static final int INVALID_LOCAL_RESOURCE_PATH = -27; - public static final int RESPONSE_HANDLING_FAILURE = -28; - - // Path for resource related status - private ICVSFolder commandRoot; - - public CVSStatus(int severity, int code, String message, Throwable t) { - super(severity, CVSProviderPlugin.ID, code, message, t); - } - - public CVSStatus(int severity, int code, String message) { - this(severity, code, message, null); - } - - public CVSStatus(int severity, int code, ICVSFolder commandRoot, String message) { - this(severity, code, message, null); - this.commandRoot = commandRoot; - } - - public CVSStatus(int severity, String message, Throwable t) { - this(severity, 0, message, t); - } - - public CVSStatus(int severity, String message) { - this(severity, severity, message, null); - } - /** - * @see IStatus#getMessage() - */ - public String getMessage() { - String message = super.getMessage(); - if (commandRoot != null) { - message = Policy.bind("CVSStatus.messageWithRoot", commandRoot.getName(), message); //$NON-NLS-1$ - } - return message; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java deleted file mode 100644 index cfe297641..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java +++ /dev/null @@ -1,371 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.core.variants.*; -import org.eclipse.team.core.variants.ResourceVariantTreeSubscriber; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.resources.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * CVSSyncInfo - */ -public class CVSSyncInfo extends SyncInfo { - - /* - * Codes that are used in returned IStatus - */ - private static final int INVALID_RESOURCE_TYPE = 1; - private static final int INVALID_SYNC_KIND = 2; - private static final int PARENT_NOT_MANAGED = 3; - private static final int REMOTE_DOES_NOT_EXIST = 4; - private static final int SYNC_INFO_CONFLICTS = 5; - private Subscriber subscriber; - - public CVSSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, Subscriber subscriber) { - super(local, base, remote, ((ResourceVariantTreeSubscriber)subscriber).getResourceComparator()); - this.subscriber = subscriber; - } - - public Subscriber getSubscriber() { - return subscriber; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.SyncInfo#computeSyncKind(org.eclipse.core.runtime.IProgressMonitor) - */ - protected int calculateKind() throws TeamException { - // special handling for folders, the generic sync algorithm doesn't work well - // with CVS because folders are not in namespaces (e.g. they exist in all versions - // and branches). - IResource local = getLocal(); - if(local.getType() != IResource.FILE) { - int folderKind = SyncInfo.IN_SYNC; - ICVSRemoteFolder remote = (ICVSRemoteFolder)getRemote(); - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local); - boolean isCVSFolder = false; - try { - isCVSFolder = cvsFolder.isCVSFolder(); - } catch (CVSException e) { - // Assume the folder is not a CVS folder - } - if(!local.exists()) { - if(remote != null) { - if (isCVSFolder) { - // TODO: This assumes all CVS folders are in-sync even if they have been pruned! - folderKind = SyncInfo.IN_SYNC; - } else { - folderKind = SyncInfo.INCOMING | SyncInfo.ADDITION; - } - } else { - // ignore conflicting deletion to keep phantom sync info - } - } else { - if(remote == null) { - if(isCVSFolder) { - // TODO: This is not really an incoming deletion - // The folder will be pruned once any children are commited - folderKind = SyncInfo.IN_SYNC; - //folderKind = SyncInfo.INCOMING | SyncInfo.DELETION; - } else { - folderKind = SyncInfo.OUTGOING | SyncInfo.ADDITION; - } - } else if(!isCVSFolder) { - folderKind = SyncInfo.CONFLICTING | SyncInfo.ADDITION; - } else { - // folder exists both locally and remotely and are considered in sync, however - // we aren't checking the folder mappings to ensure that they are the same. - } - } - return folderKind; - } - - // 1. Run the generic sync calculation algorithm, then handle CVS specific - // sync cases. - int kind = super.calculateKind(); - - // 2. Set the CVS specific sync type based on the workspace sync state provided - // by the CVS server. - IResourceVariant remote = getRemote(); - if(remote!=null && (kind & SyncInfo.PSEUDO_CONFLICT) == 0) { - RemoteResource cvsRemote = (RemoteResource)remote; - int type = cvsRemote.getWorkspaceSyncState(); - switch(type) { - // the server compared both text files and decided that it cannot merge - // them without line conflicts. - case Update.STATE_CONFLICT: - return kind | SyncInfo.MANUAL_CONFLICT; - - // the server compared both text files and decided that it can safely merge - // them without line conflicts. - case Update.STATE_MERGEABLE_CONFLICT: - return kind | SyncInfo.AUTOMERGE_CONFLICT; - } - } - - // 3. unmanage delete/delete conflicts and return that they are in sync - kind = handleDeletionConflicts(kind); - - return kind; - } - - /* - * If the resource has a delete/delete conflict then ensure that the local is unmanaged so that the - * sync info can be properly flushed. - */ - protected int handleDeletionConflicts(int kind) { - if(kind == (SyncInfo.CONFLICTING | SyncInfo.DELETION | SyncInfo.PSEUDO_CONFLICT)) { - try { - IResource local = getLocal(); - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(local); - if(!cvsResource.isFolder() && cvsResource.isManaged()) { - cvsResource.unmanage(null); - } - return SyncInfo.IN_SYNC; - } catch(CVSException e) { - CVSProviderPlugin.log(e); - return SyncInfo.CONFLICTING | SyncInfo.DELETION; - } - } - return kind; - } - - /* - * Update the sync info of the local resource in such a way that the local changes can be committed. - * @return IStatus - * For folders, the makeInSYnc method is called and the return codes mentioned there apply - * for folders. - */ - public IStatus makeOutgoing(IProgressMonitor monitor) throws TeamException { - - // For folders, there is no outgoing, only in-sync - if (getLocal().getType() == IResource.FOLDER) { - return makeInSync(); - } - int syncKind = getKind(); - boolean incoming = (syncKind & DIRECTION_MASK) == INCOMING; - boolean outgoing = (syncKind & DIRECTION_MASK) == OUTGOING; - - ICVSResource local = CVSWorkspaceRoot.getCVSResourceFor(getLocal()); - RemoteResource remote = (RemoteResource)getRemote(); - ResourceSyncInfo origInfo = local.getSyncInfo(); - MutableResourceSyncInfo info = null; - if(origInfo!=null) { - info = origInfo.cloneMutable(); - } - - if (outgoing) { - // The sync info is alright, it's already outgoing! - return Status.OK_STATUS; - } else if (incoming) { - // We have an incoming change, addition, or deletion that we want to ignore - if (local.exists()) { - // We could have an incoming change or deletion - if (remote == null) { - info.setAdded(); - } else { - // Otherwise change the revision to the remote revision and dirty the file - info.setRevision(remote.getSyncInfo().getRevision()); - info.setTimeStamp(null); - } - } else { - // We have an incoming add, turn it around as an outgoing delete - info = remote.getSyncInfo().cloneMutable(); - info.setDeleted(true); - } - } else if (local.exists()) { - // We have a conflict and a local resource! - if (getRemote() != null) { - if (getBase() != null) { - // We have a conflicting change, Update the local revision - info.setRevision(remote.getSyncInfo().getRevision()); - } else { - try { - // We have conflictin additions. - // We need to fetch the contents of the remote to get all the relevant information (timestamp, permissions) - // The most important thing we get is the keyword substitution mode which must be right to perform the commit - remote.getStorage(Policy.monitorFor(monitor)).getContents(); - info = remote.getSyncInfo().cloneMutable(); - } catch (CoreException e) { - TeamException.asTeamException(e); - } - } - } else if (getBase() != null) { - // We have a remote deletion. Make the local an addition - info.setAdded(); - } else { - // There's a local, no base and no remote. We can't possible have a conflict! - Assert.isTrue(false); - } - } else { - // We have a conflict and there is no local! - if (getRemote() != null) { - // We have a local deletion that conflicts with remote changes. - info.setRevision(remote.getSyncInfo().getRevision()); - info.setDeleted(true); - } else { - // We have conflicting deletions. Clear the sync info - info = null; - return Status.OK_STATUS; - } - } - if(info!=null) { - FolderSyncInfo parentInfo = local.getParent().getFolderSyncInfo(); - if (parentInfo == null) { - return new CVSStatus(IStatus.ERROR, PARENT_NOT_MANAGED, Policy.bind("CVSSyncInfo.9", getLocal().getFullPath().toString())); //$NON-NLS-1$ - } - info.setTag(parentInfo.getTag()); - } - ((ICVSFile)local).setSyncInfo(info, ICVSFile.UNKNOWN); - return Status.OK_STATUS; - } - - /* - * Update the sync info of the local resource in such a way that the remote resource can be loaded - * ignore any local changes. - */ - public void makeIncoming(IProgressMonitor monitor) throws TeamException { - // To make outgoing deletions incoming, the local will not exist but - // it is still important to unmanage (e.g. delete all meta info) for the - // deletion. - CVSWorkspaceRoot.getCVSResourceFor(getLocal()).unmanage(monitor); - } - - /* - * Load the resource and folder sync info into the local from the remote - * - * This method can be used on incoming folder additions to set the folder sync info properly - * without hitting the server again. It also applies to conflicts that involves unmanaged - * local resources. - * - * @return an IStatus with the following severity and codes - *
                - *
              • IStatus.WARNING - *
                  - *
                • INVALID_RESOURCE_TYPE - makeInSync only works on folders - *
                • INVALID_SYNC_KIND - sync direction must be incoming or conflicting - *
                - *
              • IStatus.ERROR - *
                  - *
                • PARENT_NOT_MANAGED - the local parent of the resource is not under CVS control - *
                • SYNC_INFO_CONFLICTS - Sync info already exists locally and differs from the info - * in the remote handle. - *
                • REMOTE_DOES_NOT_EXIST - There is no local sync info and there is no remote handle - *
                - *
              - */ - public IStatus makeInSync() throws CVSException { - - // Only works on folders - if (getLocal().getType() == IResource.FILE) { - return new CVSStatus(IStatus.WARNING, INVALID_RESOURCE_TYPE, Policy.bind("CVSSyncInfo.7", getLocal().getFullPath().toString())); //$NON-NLS-1$ - } - - // Only works on outgoing and conflicting changes - boolean outgoing = (getKind() & DIRECTION_MASK) == OUTGOING; - if (outgoing) { - return new CVSStatus(IStatus.WARNING, INVALID_SYNC_KIND, Policy.bind("CVSSyncInfo.8", getLocal().getFullPath().toString())); //$NON-NLS-1$ - } - - // The parent must be managed - ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor((IContainer)getLocal()); - if (getLocal().getType() == IResource.FOLDER && ! local.getParent().isCVSFolder()) - return new CVSStatus(IStatus.ERROR, PARENT_NOT_MANAGED, Policy.bind("CVSSyncInfo.9", getLocal().getFullPath().toString())); //$NON-NLS-1$ - - // Ensure that the folder exists locally - if (! local.exists()) { - local.mkdir(); - } - - // If the folder already has CVS info, check that the remote and local match - RemoteFolder remote = (RemoteFolder)getRemote(); - if((local.isManaged() || getLocal().getType() == IResource.PROJECT) && local.isCVSFolder()) { - // If there's no remote, assume everything is OK - if (remote == null) return Status.OK_STATUS; - // Verify that the root and repository are the same - FolderSyncInfo remoteInfo = remote.getFolderSyncInfo(); - FolderSyncInfo localInfo = local.getFolderSyncInfo(); - if ( ! localInfo.getRoot().equals(remoteInfo.getRoot())) { - return new CVSStatus(IStatus.ERROR, SYNC_INFO_CONFLICTS, Policy.bind("CVSRemoteSyncElement.rootDiffers", new Object[] {local.getName(), remoteInfo.getRoot(), localInfo.getRoot()}));//$NON-NLS-1$ - } else if ( ! localInfo.getRepository().equals(remoteInfo.getRepository())) { - return new CVSStatus(IStatus.ERROR, SYNC_INFO_CONFLICTS, Policy.bind("CVSRemoteSyncElement.repositoryDiffers", new Object[] {local.getName(), remoteInfo.getRepository(), localInfo.getRepository()}));//$NON-NLS-1$ - } - // The folders are in sync so just return - return Status.OK_STATUS; - } - - // The remote must exist if the local is not managed - if (remote == null) { - return new CVSStatus(IStatus.ERROR, REMOTE_DOES_NOT_EXIST, Policy.bind("CVSSyncInfo.10", getLocal().getFullPath().toString())); //$NON-NLS-1$ - } - - // Since the parent is managed, this will also set the resource sync info. It is - // impossible for an incoming folder addition to map to another location in the - // repo, so we assume that using the parent's folder sync as a basis is safe. - // It is also impossible for an incomming folder to be static. - FolderSyncInfo remoteInfo = remote.getFolderSyncInfo(); - FolderSyncInfo localInfo = local.getParent().getFolderSyncInfo(); - local.setFolderSyncInfo(new FolderSyncInfo(remoteInfo.getRepository(), remoteInfo.getRoot(), localInfo.getTag(), false)); - return Status.OK_STATUS; - } - - public String toString() { - IResourceVariant base = getBase(); - IResourceVariant remote = getRemote(); - StringBuffer result = new StringBuffer(super.toString()); - result.append("Local: "); //$NON-NLS-1$ - result.append(getLocal().toString()); - result.append(" Base: "); //$NON-NLS-1$ - if (base == null) { - result.append("none"); //$NON-NLS-1$ - } else { - result.append(base.toString()); - } - result.append(" Remote: "); //$NON-NLS-1$ - if (remote == null) { - result.append("none"); //$NON-NLS-1$ - } else { - result.append(remote.toString()); - } - return result.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.SyncInfo#getContentIdentifier() - */ - public String getLocalContentIdentifier() { - try { - IResource local = getLocal(); - if (local != null && local.getType() == IResource.FILE) { - // it's a file, return the revision number if we can find one - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) local); - ResourceSyncInfo info = cvsFile.getSyncInfo(); - if (info != null) { - return info.getRevision(); - } - } - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return null; - } - return null; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java deleted file mode 100644 index 101a791f9..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.IResourceVariantComparator; -import org.eclipse.team.core.variants.ResourceVariantTreeSubscriber; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; - -/** - * This class provides common funtionality for three way sychronizing - * for CVS. - */ -public abstract class CVSSyncTreeSubscriber extends ResourceVariantTreeSubscriber { - - public static final String SYNC_KEY_QUALIFIER = "org.eclipse.team.cvs"; //$NON-NLS-1$ - - private IResourceVariantComparator comparisonCriteria; - - private QualifiedName id; - private String name; - private String description; - - CVSSyncTreeSubscriber(QualifiedName id, String name, String description) { - this.id = id; - this.name = name; - this.description = description; - this.comparisonCriteria = new CVSRevisionNumberCompareCriteria(isThreeWay()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getId() - */ - public QualifiedName getId() { - return id; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getName() - */ - public String getName() { - return name; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getDescription() - */ - public String getDescription() { - return description; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource) - */ - public SyncInfo getSyncInfo(IResource resource) throws TeamException { - if (!isSupervised(resource)) return null; - if(resource.getType() == IResource.FILE || !isThreeWay()) { - return super.getSyncInfo(resource); - } else { - // In CVS, folders do not have a base. Hence, the remote is used as the base. - IResourceVariant remoteResource = getRemoteTree().getResourceVariant(resource); - return getSyncInfo(resource, remoteResource, remoteResource); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#isSupervised(org.eclipse.core.resources.IResource) - */ - public boolean isSupervised(IResource resource) throws TeamException { - try { - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()); - if (provider == null) return false; - // TODO: what happens for resources that don't exist? - // TODO: is it proper to use ignored here? - ICVSResource cvsThing = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (cvsThing.isIgnored()) { - // An ignored resource could have an incoming addition (conflict) - return getRemoteTree().hasResourceVariant(resource); - } - return true; - } catch (TeamException e) { - // If there is no resource in coe this measn there is no local and no remote - // so the resource is not supervised. - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - return false; - } - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.TeamSubscriber#getDefaultComparisonCriteria() - */ - public IResourceVariantComparator getResourceComparator() { - return comparisonCriteria; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant, org.eclipse.team.core.synchronize.IResourceVariant) - */ - protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException { - CVSSyncInfo info = new CVSSyncInfo(local, base, remote, this); - info.init(); - return info; - } - - /* - * Indicate whether file contents should be cached on a refresh - */ - protected boolean getCacheFileContentsHint() { - return false; - } - - /* - * Indicate whether the subscriber is two-way or three-way - */ - protected boolean isThreeWay() { - return true; - } - - protected boolean rootsEqual(Subscriber other) { - Set roots1 = new HashSet(Arrays.asList(other.roots())); - Set roots2 = new HashSet(Arrays.asList(roots())); - if(roots1.size() != roots2.size()) return false; - return roots2.containsAll(roots1); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java deleted file mode 100644 index 0d9cab395..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; -import org.eclipse.core.runtime.IStatus; - -/** - * A tag in CVS gives a label to a collection of revisions. The labels can represent a version, a branch, - * or a date. - */ -public class CVSTag { - - public final static int HEAD = 0; - public final static int BRANCH = 1; - public final static int VERSION = 2; - public final static int DATE = 3; - - public static final CVSTag DEFAULT = new CVSTag(); - public static final CVSTag BASE = new CVSTag("BASE", VERSION); //$NON-NLS-1$ - - protected String name; - protected int type; - - private static final String DATE_TAG_NAME_FORMAT = "dd MMM yyyy HH:mm:ss Z";//$NON-NLS-1$ - private static final SimpleDateFormat tagNameFormat = new SimpleDateFormat(DATE_TAG_NAME_FORMAT, Locale.US); - protected static synchronized String dateToTagName(Date date){ - tagNameFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$ - return tagNameFormat.format(date); //$NON-NLS-1$ - } - protected static Date tagNameToDate(String name){ - if (name == null) return null; - try { - return tagNameFormat.parse(name); - } catch (ParseException e) { - CVSProviderPlugin.log(new CVSException("Tag name " + name + " is not of the expected format " + DATE_TAG_NAME_FORMAT, e)); //$NON-NLS-1$ //$NON-NLS-2$ - return null; - } - } - - public CVSTag() { - this("HEAD", HEAD); //$NON-NLS-1$ - } - - public CVSTag(String name, int type) { - this.name = name; - this.type = type; - } - //Write a date in local date tag format - public CVSTag(Date date) { - this(dateToTagName(date), DATE); - } - - public boolean equals(Object other) { - if(other == this) return true; - if (!(other instanceof CVSTag)) return false; - - CVSTag tag = ((CVSTag)other); - if (getType() != tag.getType()) return false; - if (!getName().equals(tag.getName())) return false; - return true; - } - - public String getName() { - return name; - } - - public int getType() { - // TODO: getType() will not return accurate types for Tags retrieved from the local CVS Entries file. See Bug: 36758 - return type; - } - - public int hashCode() { - return name.hashCode(); - } - - public int compareTo(CVSTag other) { - if(getType() == DATE && other.getType()== DATE){ - Date date1 = asDate(); - Date date2 = other.asDate(); - if(date1 == null || date2 == null)return -1; - return date1.compareTo(date2); - } - return getName().compareTo(other.getName()); - } - - public static boolean equalTags(CVSTag tag1, CVSTag tag2) { - if (tag1 == null) tag1 = CVSTag.DEFAULT; - if (tag2 == null) tag2 = CVSTag.DEFAULT; - return tag1.equals(tag2); - } - - public static IStatus validateTagName(String tagName) { - if (tagName == null) - return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.nullName")); //$NON-NLS-1$ - if (tagName.equals("")) //$NON-NLS-1$ - return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.emptyName")); //$NON-NLS-1$ - if (!Character. isLetter(tagName.charAt(0))) - return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.beginName")); //$NON-NLS-1$ - - for (int i = 0; i < tagName.length(); i++) { - char c = tagName.charAt(i); - if ( Character.isSpaceChar(c) || c == '$' || c == ',' || c == '.' || c == ':' || c == ';' || c == '@' || c == '|') - return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.badCharName")); //$NON-NLS-1$ - } - return new CVSStatus(CVSStatus.OK, Policy.bind("ok")); //$NON-NLS-1$ - } - - /** - * Return the date this tag represents or null - * if the tag is not of type DATE. - * @return the date of the tag or null - */ - public Date asDate(){ - return tagNameToDate(name); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java deleted file mode 100644 index 2763a5ed5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java +++ /dev/null @@ -1,1013 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.io.*; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.resources.team.ResourceRuleFactory; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.client.listeners.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.core.util.*; -import org.eclipse.team.internal.core.streams.CRLFtoLFInputStream; -import org.eclipse.team.internal.core.streams.LFtoCRLFInputStream; - -/** - * This class acts as both the ITeamNature and the ITeamProvider instances - * required by the Team core. - * - * The current stat of this class and it's plugin is EXPERIMENTAL. - * As such, it is subject to change except in it's conformance to the - * TEAM API which it implements. - * - * Questions: - * - * How should a project/reource rename/move effect the provider? - * - * Currently we always update with -P. Is this OK? - * - A way to allow customizable options would be nice - * - * Is the -l option valid for commit and does it work properly for update and commit? - * - * Do we need an IUserInteractionProvider in the CVS core - * - prompt for user info (caching could be separate) - * - get release comments - * - prompt for overwrite of unmanaged files - * - * Need a mechanism for communicating meta-information (provided by Team?) - * - * Should pass null when there are no options for a cvs command - * - * We currently write the files to disk and do a refreshLocal to - * have them appear in Eclipse. This may be changed in the future. - */ -public class CVSTeamProvider extends RepositoryProvider { - - private static final ResourceRuleFactory RESOURCE_RULE_FACTORY = new ResourceRuleFactory() { - public ISchedulingRule validateEditRule(IResource[] resources) { - if (resources.length == 0) - return null; - //optimize rule for single file - if (resources.length == 1) - return resources[0].isReadOnly() ? parent(resources[0]) : null; - //need a lock on the parents of all read-only files - HashSet rules = new HashSet(); - for (int i = 0; i < resources.length; i++) - if (resources[i].isReadOnly()) - rules.add(parent(resources[i])); - if (rules.isEmpty()) - return null; - if (rules.size() == 1) - return (ISchedulingRule) rules.iterator().next(); - ISchedulingRule[] ruleArray = (ISchedulingRule[]) rules - .toArray(new ISchedulingRule[rules.size()]); - return new MultiRule(ruleArray); - } - }; - - private static final boolean IS_CRLF_PLATFORM = Arrays.equals( - System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$ - - public static final IStatus OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, Policy.bind("ok"), null); //$NON-NLS-1$ - - private static final int UNIFIED_FORMAT = 0; - private static final int CONTEXT_FORMAT = 1; - private static final int STANDARD_FORMAT = 2; - - private CVSWorkspaceRoot workspaceRoot; - private IProject project; - - private static MoveDeleteHook moveDeleteHook= new MoveDeleteHook(); - private static IFileModificationValidator fileModificationValidator; - - // property used to indicate whether new directories should be discovered for the project - private final static QualifiedName FETCH_ABSENT_DIRECTORIES_PROP_KEY = - new QualifiedName("org.eclipse.team.cvs.core", "fetch_absent_directories"); //$NON-NLS-1$ //$NON-NLS-2$ - // property used to indicate whether the project is configured to use Watch/edit - private final static QualifiedName WATCH_EDIT_PROP_KEY = - new QualifiedName("org.eclipse.team.cvs.core", "watch_edit"); //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * No-arg Constructor for IProjectNature conformance - */ - public CVSTeamProvider() { - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#deconfigure() - */ - public void deconfigure() { - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.RepositoryProvider#deconfigured() - */ - public void deconfigured() { - // when a nature is removed from the project, notify the synchronizer that - // we no longer need the sync info cached. This does not affect the actual CVS - // meta directories on disk, and will remain unless a client calls unmanage(). - try { - EclipseSynchronizer.getInstance().deconfigure(getProject(), null); - internalSetWatchEditEnabled(null); - internalSetFetchAbsentDirectories(null); - } catch(CVSException e) { - // Log the exception and let the disconnect continue - CVSProviderPlugin.log(e); - } - ResourceStateChangeListeners.getListener().projectDeconfigured(getProject()); - } - /** - * @see IProjectNature#getProject() - */ - public IProject getProject() { - return project; - } - - /** - * @see IProjectNature#setProject(IProject) - */ - public void setProject(IProject project) { - this.project = project; - try { - this.workspaceRoot = new CVSWorkspaceRoot(project); - // Ensure that the project has CVS info - if (workspaceRoot.getLocalRoot().getFolderSyncInfo() == null) { - CVSProviderPlugin.log(new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTeamProvider.noFolderInfo", project.getName())))); //$NON-NLS-1$ - } - } catch (CVSException e) { - // Ignore exceptions here. They will be surfaced elsewhere - } - } - - /** - * Diff the resources with the repository and write the output to the provided - * PrintStream in a form that is usable as a patch. The patch is rooted at the - * project. - */ - public void diff(IResource resource, LocalOption[] options, PrintStream stream, - IProgressMonitor progress) throws TeamException { - - boolean includeNewFiles = false; - boolean doNotRecurse = false; - int format = STANDARD_FORMAT; - - // Determine the command root and arguments arguments list - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - ICVSFolder commandRoot; - String[] arguments; - if (cvsResource.isFolder()) { - commandRoot = (ICVSFolder)cvsResource; - arguments = new String[] {Session.CURRENT_LOCAL_FOLDER}; - } else { - commandRoot = cvsResource.getParent(); - arguments = new String[] {cvsResource.getName()}; - } - - Session s = new Session(workspaceRoot.getRemoteLocation(), commandRoot); - progress.beginTask(null, 100); - try { - s.open(Policy.subMonitorFor(progress, 20), false /* read-only */); - Command.DIFF.execute(s, - Command.NO_GLOBAL_OPTIONS, - options, - arguments, - new DiffListener(stream), - Policy.subMonitorFor(progress, 80)); - } finally { - s.close(); - progress.done(); - } - - // Append our diff output to the server diff output. - // Our diff output includes new files and new files in new directories. - - for (int i = 0; i < options.length; i++) { - LocalOption option = options[i]; - if (option.equals(Diff.INCLUDE_NEWFILES)) { - includeNewFiles = true; - } else if (option.equals(Diff.DO_NOT_RECURSE)) { - doNotRecurse = true; - } else if (option.equals(Diff.UNIFIED_FORMAT)) { - format = UNIFIED_FORMAT; - } else if (option.equals(Diff.CONTEXT_FORMAT)) { - format = CONTEXT_FORMAT; - } - } - - if (includeNewFiles) { - newFileDiff(commandRoot, stream, doNotRecurse, format); - } - } - - /** - * This diff adds new files and directories to the stream. - * @param resource - * @param stream - * @param doNotRecurse - * @param format - * @throws CVSException - */ - private void newFileDiff(final ICVSFolder resource, final PrintStream stream, final boolean doNotRecurse, final int format) throws CVSException { - resource.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - if (!(file.isIgnored() || file.isManaged())) { - addFileToDiff(resource, file, stream, format); - } - } - public void visitFolder(ICVSFolder folder) throws CVSException { - // Even if we are not supposed to recurse we still need to go into - // the root directory. - if (!folder.exists() || folder.isIgnored() || (doNotRecurse && !folder.equals(resource))) { - return; - } else { - folder.acceptChildren(this); - } - } - }); - } - - private void addFileToDiff(ICVSFolder cmdRoot, ICVSFile file, PrintStream stream, int format) throws CVSException { - - String nullFilePrefix = ""; //$NON-NLS-1$ - String newFilePrefix = ""; //$NON-NLS-1$ - String positionInfo = ""; //$NON-NLS-1$ - String linePrefix = ""; //$NON-NLS-1$ - - String pathString = file.getRelativePath(cmdRoot); - - BufferedReader fileReader = new BufferedReader(new InputStreamReader(file.getContents())); - int lines = 0; - try { - while (fileReader.readLine() != null) { - lines++; - } - fileReader.close(); - - switch (format) { - case UNIFIED_FORMAT : - nullFilePrefix = "--- "; //$NON-NLS-1$ - newFilePrefix = "+++ "; //$NON-NLS-1$ - positionInfo = "@@ -0,0 +1," + lines + " @@" ; //$NON-NLS-1$ //$NON-NLS-2$ - linePrefix = "+"; //$NON-NLS-1$ - break; - - case CONTEXT_FORMAT : - nullFilePrefix = "*** "; //$NON-NLS-1$ - newFilePrefix = "--- "; //$NON-NLS-1$ - positionInfo = "--- 1," + lines + " ----"; //$NON-NLS-1$ //$NON-NLS-2$ - linePrefix = "+ "; //$NON-NLS-1$ - break; - - default : - positionInfo = "0a1," + lines; //$NON-NLS-1$ - linePrefix = "> "; //$NON-NLS-1$ - break; - } - - fileReader = new BufferedReader(new InputStreamReader(file.getContents())); - - stream.println("Index: " + pathString); //$NON-NLS-1$ - stream.println("==================================================================="); //$NON-NLS-1$ - stream.println("RCS file: " + pathString); //$NON-NLS-1$ - stream.println("diff -N " + pathString); //$NON-NLS-1$ - - if (lines > 0) { - - if (format != STANDARD_FORMAT) { - stream.println(nullFilePrefix + "/dev/null 1 Jan 1970 00:00:00 -0000"); //$NON-NLS-1$ - // Technically this date should be the local file date but nobody really cares. - stream.println(newFilePrefix + pathString + " 1 Jan 1970 00:00:00 -0000"); //$NON-NLS-1$ - } - - if (format == CONTEXT_FORMAT) { - stream.println("***************"); //$NON-NLS-1$ - stream.println("*** 0 ****"); //$NON-NLS-1$ - } - - stream.println(positionInfo); - - for (int i = 0; i < lines; i++) { - stream.print(linePrefix); - stream.println(fileReader.readLine()); - } - } - } catch (IOException e) { - throw CVSException.wrapException(file.getIResource(), Policy.bind("CVSTeamProvider.errorAddingFileToDiff", pathString), e); //$NON-NLS-1$ - } finally { - try { - fileReader.close(); - } catch (IOException e1) { - } - } - } - - /** - * Return the remote location to which the receiver's project is mapped. - */ - public ICVSRepositoryLocation getRemoteLocation() throws CVSException { - try { - return workspaceRoot.getRemoteLocation(); - } catch (CVSException e) { - // If we can't get the remote location, we should disconnect since nothing can be done with the provider - try { - RepositoryProvider.unmap(project); - } catch (TeamException ex) { - CVSProviderPlugin.log(ex); - } - // We need to trigger a decorator refresh - throw e; - } - } - - /* - * @see ITeamProvider#isDirty(IResource) - */ - public boolean isDirty(IResource resource) { - Assert.isTrue(false); - return false; - } - - public CVSWorkspaceRoot getCVSWorkspaceRoot() { - return workspaceRoot; - } - - /* - * Generate an exception if the resource is not a child of the project - */ - private void checkIsChild(IResource resource) throws CVSException { - if (!isChildResource(resource)) - throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, - Policy.bind("CVSTeamProvider.invalidResource", //$NON-NLS-1$ - new Object[] {resource.getFullPath().toString(), project.getName()}), - null)); - } - - /* - * Get the arguments to be passed to a commit or update - */ - private String[] getValidArguments(IResource[] resources, LocalOption[] options) throws CVSException { - List arguments = new ArrayList(resources.length); - for (int i=0;i - * Applies the following rules in order:
              - *
                - *
              • If a file is not managed, skips it.
              • - *
              • If a file is not changing modes, skips it.
              • - *
              • If a file is being changed from binary to text, corrects line delimiters - * then commits it, then admins it.
              • - *
              • If a file is added, changes the resource sync information locally.
              • - *
              • Otherwise commits the file (with FORCE to create a new revision), then admins it.
              • - *
              - * All files that are admin'd are committed with FORCE to prevent other developers from - * casually trying to commit pending changes to the repository without first checking out - * a new copy. This is not a perfect solution, as they could just as easily do an UPDATE - * and not obtain the new keyword sync info. - *

              - * - * @param changeSet a map from IFile to KSubstOption - * @param monitor the progress monitor - * @return a status code indicating success or failure of the operation - * - * @throws TeamException - */ - public IStatus setKeywordSubstitution(final Map /* from IFile to KSubstOption */ changeSet, - final String comment, - IProgressMonitor monitor) throws TeamException { - final IStatus[] result = new IStatus[] { ICommandOutputListener.OK }; - workspaceRoot.getLocalRoot().run(new ICVSRunnable() { - public void run(final IProgressMonitor monitor) throws CVSException { - final Map /* from KSubstOption to List of String */ filesToAdmin = new HashMap(); - final List /* of ICVSResource */ filesToCommit = new ArrayList(); - final Collection /* of ICVSFile */ filesToCommitAsText = new HashSet(); // need fast lookup - final boolean useCRLF = IS_CRLF_PLATFORM && (CVSProviderPlugin.getPlugin().isUsePlatformLineend()); - - /*** determine the resources to be committed and/or admin'd ***/ - for (Iterator it = changeSet.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - IFile file = (IFile) entry.getKey(); - KSubstOption toKSubst = (KSubstOption) entry.getValue(); - - // only set keyword substitution if resource is a managed file - checkIsChild(file); - ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file); - if (! mFile.isManaged()) continue; - - // only set keyword substitution if new differs from actual - byte[] syncBytes = mFile.getSyncBytes(); - KSubstOption fromKSubst = ResourceSyncInfo.getKeywordMode(syncBytes); - if (toKSubst.equals(fromKSubst)) continue; - - // change resource sync info immediately for an outgoing addition - if (ResourceSyncInfo.isAddition(syncBytes)) { - mFile.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, toKSubst), ICVSFile.UNKNOWN); - continue; - } - - // nothing do to for deletions - if (ResourceSyncInfo.isDeletion(syncBytes)) continue; - - // file exists remotely so we'll have to commit it - if (fromKSubst.isBinary() && ! toKSubst.isBinary()) { - // converting from binary to text - cleanLineDelimiters(file, useCRLF, new NullProgressMonitor()); // XXX need better progress monitoring - // remember to commit the cleaned resource as text before admin - filesToCommitAsText.add(mFile); - } - // force a commit to bump the revision number - makeDirty(file); - filesToCommit.add(mFile); - // remember to admin the resource - List list = (List) filesToAdmin.get(toKSubst); - if (list == null) { - list = new ArrayList(); - filesToAdmin.put(toKSubst, list); - } - list.add(mFile); - } - - /*** commit then admin the resources ***/ - // compute the total work to be performed - int totalWork = filesToCommit.size() + 1; - for (Iterator it = filesToAdmin.values().iterator(); it.hasNext();) { - List list = (List) it.next(); - totalWork += list.size(); - totalWork += 1; // Add 1 for each connection that needs to be made - } - if (totalWork != 0) { - monitor.beginTask(Policy.bind("CVSTeamProvider.settingKSubst"), totalWork); //$NON-NLS-1$ - try { - // commit files that changed from binary to text - // NOTE: The files are committed as text with conversions even if the - // resource sync info still says "binary". - if (filesToCommit.size() != 0) { - Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */); - session.open(Policy.subMonitorFor(monitor, 1), true /* open for modification */); - try { - String keywordChangeComment = comment; - if (keywordChangeComment == null || keywordChangeComment.length() == 0) - keywordChangeComment = Policy.bind("CVSTeamProvider.changingKeywordComment"); //$NON-NLS-1$ - result[0] = Command.COMMIT.execute( - session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { Commit.DO_NOT_RECURSE, Commit.FORCE, - Commit.makeArgumentOption(Command.MESSAGE_OPTION, keywordChangeComment) }, - (ICVSResource[]) filesToCommit.toArray(new ICVSResource[filesToCommit.size()]), - filesToCommitAsText, - null, - Policy.subMonitorFor(monitor, filesToCommit.size())); - } finally { - session.close(); - } - - // if errors were encountered, abort - if (! result[0].isOK()) return; - } - - // admin files that changed keyword substitution mode - // NOTE: As confirmation of the completion of a command, the server replies - // with the RCS command output if a change took place. Rather than - // assume that the command succeeded, we listen for these lines - // and update the local ResourceSyncInfo for the particular files that - // were actually changed remotely. - for (Iterator it = filesToAdmin.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - final KSubstOption toKSubst = (KSubstOption) entry.getKey(); - final List list = (List) entry.getValue(); - // do it - Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */); - session.open(Policy.subMonitorFor(monitor, 1), true /* open for modification */); - try { - result[0] = Command.ADMIN.execute( - session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { toKSubst }, - (ICVSResource[]) list.toArray(new ICVSResource[list.size()]), - new AdminKSubstListener(toKSubst), - Policy.subMonitorFor(monitor, list.size())); - } finally { - session.close(); - } - // if errors were encountered, abort - if (! result[0].isOK()) return; - } - } finally { - monitor.done(); - } - } - } - }, Policy.monitorFor(monitor)); - return result[0]; - } - - /** - * This method translates the contents of a file from binary into text (ASCII). - * Fixes the line delimiters in the local file to reflect the platform's - * native encoding. Performs CR/LF -> LF or LF -> CR/LF conversion - * depending on the platform but does not affect delimiters that are - * already correctly encoded. - */ - public static void cleanLineDelimiters(IFile file, boolean useCRLF, IProgressMonitor progress) - throws CVSException { - try { - // convert delimiters in memory - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - InputStream is = new BufferedInputStream(file.getContents()); - try { - // Always convert CR/LF into LFs - is = new CRLFtoLFInputStream(is); - if (useCRLF) { - // For CR/LF platforms, translate LFs to CR/LFs - is = new LFtoCRLFInputStream(is); - } - for (int b; (b = is.read()) != -1;) bos.write(b); - bos.close(); - } finally { - is.close(); - } - // write file back to disk with corrected delimiters if changes were made - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - file.setContents(bis, false /*force*/, false /*keepHistory*/, progress); - } catch (CoreException e) { - throw CVSException.wrapException(file, Policy.bind("CVSTeamProvider.cleanLineDelimitersException"), e); //$NON-NLS-1$ - } catch (IOException e) { - throw CVSException.wrapException(file, Policy.bind("CVSTeamProvider.cleanLineDelimitersException"), e); //$NON-NLS-1$ - } - } - - /* - * Marks a file as dirty. - */ - private static void makeDirty(IFile file) throws CVSException { - ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file); - ResourceSyncInfo origInfo = mFile.getSyncInfo(); - MutableResourceSyncInfo info = origInfo.cloneMutable(); - info.setTimeStamp(null);/*set the sync timestamp to null to trigger dirtyness*/ - mFile.setSyncInfo(info, ICVSFile.UNKNOWN); - } - - /* - * @see RepositoryProvider#getID() - */ - public String getID() { - return CVSProviderPlugin.getTypeId(); - } - - /* - * @see RepositoryProvider#getMoveDeleteHook() - */ - public IMoveDeleteHook getMoveDeleteHook() { - return moveDeleteHook; - } - - /* - * Return the currently registered Move/Delete Hook - */ - public static MoveDeleteHook getRegisteredMoveDeleteHook() { - return moveDeleteHook; - } - - /** - * @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator() - */ - public IFileModificationValidator getFileModificationValidator() { - if (CVSTeamProvider.fileModificationValidator == null) { - CVSTeamProvider.fileModificationValidator = new CVSCoreFileModificationValidator(); - } - return CVSTeamProvider.fileModificationValidator; - } - - /** - * Checkout (cvs edit) the provided resources so they can be modified locally and committed. - * This will make any read-only resources in the list writable and will notify the server - * that the file is being edited. This notification may be done immediately or at some - * later point depending on whether contact with the server is possble at the time of - * invocation or the value of the notify server parameter. - * - * The recurse parameter is equivalent to the cvs local options -l (true) and - * -R (false). The notifyServer parameter can be used to defer server contact - * until the next command. This may be approrpiate if no shell or progress monitor is available - * to the caller. The notification bit field indicates what temporary watches are to be used while - * the file is being edited. The possible values that can be ORed together are ICVSFile.EDIT, - * ICVSFile.UNEDIT and ICVSFile.COMMIT. There pre-ORed convenience values ICVSFile.NO_NOTIFICATION - * and ICVSFile.NOTIFY_ON_ALL are also available. - * - * @param resources the resources to be edited - * @param recurse indicates whether to recurse (-R) or not (-l) - * @param notifyServer indicates whether to notify the server now, if possible, - * or defer until the next command. - * @param notification the temporary watches. - * @param progress progress monitor to provide progress indication/cancellation or null - * @exception CVSException if this method fails. - * @since 2.1 - * - * @see CVSTeamProvider#unedit - */ - public void edit(IResource[] resources, boolean recurse, boolean notifyServer, final int notification, IProgressMonitor progress) throws CVSException { - notifyEditUnedit(resources, recurse, notifyServer, new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - if (file.isReadOnly()) - file.edit(notification, Policy.monitorFor(null)); - } - public void visitFolder(ICVSFolder folder) throws CVSException { - // nothing needs to be done here as the recurse will handle the traversal - } - }, null /* no scheduling rule */, progress); - } - - /** - * Unedit the given resources. Any writtable resources will be reverted to their base contents - * and made read-only and the server will be notified that the file is no longer being edited. - * This notification may be done immediately or at some - * later point depending on whether contact with the server is possble at the time of - * invocation or the value of the notify server parameter. - * - * The recurse parameter is equivalent to the cvs local options -l (true) and - * -R (false). The notifyServer parameter can be used to defer server contact - * until the next command. This may be approrpiate if no shell or progress monitor is available - * to the caller. - * - * @param resources the resources to be unedited - * @param recurse indicates whether to recurse (-R) or not (-l) - * @param notifyServer indicates whether to notify the server now, if possible, - * or defer until the next command. - * @param progress progress monitor to provide progress indication/cancellation or null - * @exception CVSException if this method fails. - * @since 2.1 - * - * @see CVSTeamProvider#edit - */ - public void unedit(IResource[] resources, boolean recurse, boolean notifyServer, IProgressMonitor progress) throws CVSException { - notifyEditUnedit(resources, recurse, notifyServer, new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - if (!file.isReadOnly()) - file.unedit(Policy.monitorFor(null)); - } - public void visitFolder(ICVSFolder folder) throws CVSException { - // nothing needs to be done here as the recurse will handle the traversal - } - }, getProject() /* project scheduling rule */, progress); - } - - /* - * This method captures the common behavior between the edit and unedit methods. - */ - private void notifyEditUnedit(final IResource[] resources, final boolean recurse, final boolean notifyServer, final ICVSResourceVisitor editUneditVisitor, ISchedulingRule rule, IProgressMonitor monitor) throws CVSException { - final CVSException[] exception = new CVSException[] { null }; - IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - final ICVSResource[] cvsResources = getCVSArguments(resources); - - // mark the files locally as being checked out - try { - for (int i = 0; i < cvsResources.length; i++) { - cvsResources[i].accept(editUneditVisitor, recurse); - } - } catch (CVSException e) { - exception[0] = e; - return; - } - - // send the noop command to the server in order to deliver the notifications - if (notifyServer) { - monitor.beginTask(null, 100); - Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true); - try { - try { - session.open(Policy.subMonitorFor(monitor, 10), true /* open for modification */); - } catch (CVSException e1) { - // If the connection cannot be opened, just exit normally. - // The notifications will be sent when a connection can be made - return; - } - Command.NOOP.execute( - session, - Command.NO_GLOBAL_OPTIONS, - Command.NO_LOCAL_OPTIONS, - cvsResources, - null, - Policy.subMonitorFor(monitor, 90)); - } catch (CVSException e) { - exception[0] = e; - } finally { - session.close(); - monitor.done(); - } - } - } - }; - try { - ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, 0, Policy.monitorFor(monitor)); - } catch (CoreException e) { - if (exception[0] == null) { - throw CVSException.wrapException(e); - } else { - CVSProviderPlugin.log(CVSException.wrapException(e)); - } - } - if (exception[0] != null) { - throw exception[0]; - } - } - - /** - * Gets the etchAbsentDirectories. - * @return Returns a boolean - */ - public boolean getFetchAbsentDirectories() throws CVSException { - try { - String property = getProject().getPersistentProperty(FETCH_ABSENT_DIRECTORIES_PROP_KEY); - if (property == null) return CVSProviderPlugin.getPlugin().getFetchAbsentDirectories(); - return Boolean.valueOf(property).booleanValue(); - } catch (CoreException e) { - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.errorGettingFetchProperty", project.getName()), e)); //$NON-NLS-1$ - } - } - - /** - * Sets the fetchAbsentDirectories. - * @param etchAbsentDirectories The etchAbsentDirectories to set - */ - public void setFetchAbsentDirectories(boolean fetchAbsentDirectories) throws CVSException { - internalSetFetchAbsentDirectories(fetchAbsentDirectories ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); - } - - public void internalSetFetchAbsentDirectories(String fetchAbsentDirectories) throws CVSException { - try { - getProject().setPersistentProperty(FETCH_ABSENT_DIRECTORIES_PROP_KEY, fetchAbsentDirectories); - } catch (CoreException e) { - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.errorSettingFetchProperty", project.getName()), e)); //$NON-NLS-1$ - } - } - - /** - * @see org.eclipse.team.core.RepositoryProvider#canHandleLinkedResources() - */ - public boolean canHandleLinkedResources() { - return true; - } - - /** - * @see org.eclipse.team.core.RepositoryProvider#validateCreateLink(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IPath) - */ - public IStatus validateCreateLink(IResource resource, int updateFlags, IPath location) { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(resource.getParent().getFolder(new Path(resource.getName()))); - try { - if (cvsFolder.isCVSFolder()) { - // There is a remote folder that overlaps with the link so disallow - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.overlappingRemoteFolder", resource.getFullPath().toString())); //$NON-NLS-1$ - } else { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(resource.getParent().getFile(new Path(resource.getName()))); - if (cvsFile.isManaged()) { - // there is an outgoing file deletion that overlaps the link so disallow - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.overlappingFileDeletion", resource.getFullPath().toString())); //$NON-NLS-1$ - } - } - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return e.getStatus(); - } - - return super.validateCreateLink(resource, updateFlags, location); - } - - /** - * Get the editors of the resources by calling the cvs editors command. - * - * @author Gregor Kohlwes - * @param resources - * @param progress - * @return IEditorsInfo[] - * @throws CVSException - */ - public EditorsInfo[] editors( - IResource[] resources, - IProgressMonitor progress) - throws CVSException { - - // Build the local options - LocalOption[] commandOptions = new LocalOption[] { - }; - progress.worked(10); - // Build the arguments list - String[] arguments = getValidArguments(resources, commandOptions); - - // Build the listener for the command - EditorsListener listener = new EditorsListener(); - - // Check if canceled - if (progress.isCanceled()) { - return new EditorsInfo[0]; - } - // Build the session - Session session = - new Session( - workspaceRoot.getRemoteLocation(), - workspaceRoot.getLocalRoot()); - - // Check if canceled - if (progress.isCanceled()) { - return new EditorsInfo[0]; - } - progress.beginTask(null, 100); - try { - // Opening the session takes 20% of the time - session.open(Policy.subMonitorFor(progress, 20), false /* read-only */); - - if (!progress.isCanceled()) { - // Execute the editors command - Command.EDITORS.execute( - session, - Command.NO_GLOBAL_OPTIONS, - commandOptions, - arguments, - listener, - Policy.subMonitorFor(progress, 80)); - } - } finally { - session.close(); - progress.done(); - } - // Return the infos about the editors - return listener.getEditorsInfos(); - } - - /** - * Return the commit comment template that was provided by the server. - * - * @return String - * @throws CVSException - */ - public String getCommitTemplate() throws CVSException { - ICVSFolder localFolder = getCVSWorkspaceRoot().getLocalRoot(); - ICVSFile templateFile = CVSWorkspaceRoot.getCVSFileFor( - SyncFileWriter.getTemplateFile( - (IContainer)localFolder.getIResource())); - if (!templateFile.exists()) return null; - InputStream in = new BufferedInputStream(templateFile.getContents()); - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int b; - do { - b = in.read(); - if (b != -1) - out.write((byte)b); - } while (b != -1); - out.close(); - return new String(out.toString()); - } catch (IOException e) { - throw CVSException.wrapException(e); - } finally { - try { - in.close(); - } catch (IOException e) { - // Since we already have the contents, just log this exception - CVSProviderPlugin.log(CVSException.wrapException(e)); - } - } - } - - /** - * Return true if the project is configured to use watch/edit. A project will use - * watch/edit if it was checked out when the global preference to use watch/edit is - * turned on. - * @return boolean - */ - public boolean isWatchEditEnabled() throws CVSException { - IProject project = getProject(); - try { - String property = (String)project.getSessionProperty(WATCH_EDIT_PROP_KEY); - if (property == null) { - property = project.getPersistentProperty(WATCH_EDIT_PROP_KEY); - if (property == null) { - // The persistant property for the project was never set (i.e. old project) - // Use the global preference to determine if the project is using watch/edit - return CVSProviderPlugin.getPlugin().isWatchEditEnabled(); - } else { - project.setSessionProperty(WATCH_EDIT_PROP_KEY, property); - } - } - return Boolean.valueOf(property).booleanValue(); - } catch (CoreException e) { - if (project.isAccessible()) { - // We only care if the project still exists - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.errorGettingWatchEdit", project.getName()), e)); //$NON-NLS-1$ - } - } - return false; - } - - public void setWatchEditEnabled(boolean enabled) throws CVSException { - internalSetWatchEditEnabled(enabled ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); - } - - private void internalSetWatchEditEnabled(String enabled) throws CVSException { - try { - IProject project = getProject(); - project.setPersistentProperty(WATCH_EDIT_PROP_KEY, enabled); - project.setSessionProperty(WATCH_EDIT_PROP_KEY, enabled); - } catch (CoreException e) { - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("CVSTeamProvider.errorSettingWatchEdit", project.getName()), e)); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.RepositoryProvider#getRuleFactory() - */ - public IResourceRuleFactory getRuleFactory() { - return RESOURCE_RULE_FACTORY; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java deleted file mode 100644 index ff4575a87..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.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.team.internal.ccvs.core; - -import org.eclipse.team.core.ProjectSetCapability; -import org.eclipse.team.core.RepositoryProviderType; - - -/** - * This class represents the CVS Provider's capabilities in the absence of a - * particular project. - */ - -public class CVSTeamProviderType extends RepositoryProviderType { - - /** - * @see org.eclipse.team.core.RepositoryProviderType#supportsProjectSetImportRelocation() - */ - public boolean supportsProjectSetImportRelocation() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability() - */ - public ProjectSetCapability getProjectSetCapability() { - return new CVSProjectSetCapability(); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java deleted file mode 100644 index 4f66a026d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.subscribers.ISubscriberChangeEvent; -import org.eclipse.team.core.subscribers.SubscriberChangeEvent; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.IResourceVariantTree; -import org.eclipse.team.core.variants.PersistantResourceVariantByteStore; -import org.eclipse.team.core.variants.ResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTreeBuilder; -import org.eclipse.team.internal.ccvs.core.syncinfo.CVSBaseResourceVariantTree; -import org.eclipse.team.internal.ccvs.core.syncinfo.CVSDescendantResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree; -import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners; - -/** - * CVSWorkspaceSubscriber - */ -public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IResourceStateChangeListener { - - private CVSResourceVariantTree baseTree, remoteTree; - - // qualified name for remote sync info - private static final String REMOTE_RESOURCE_KEY = "remote-resource-key"; //$NON-NLS-1$ - - CVSWorkspaceSubscriber(QualifiedName id, String name, String description) { - super(id, name, description); - - // install sync info participant - ResourceVariantByteStore baseSynchronizer = new CVSBaseResourceVariantTree(); - baseTree = new CVSResourceVariantTree(baseSynchronizer, null, getCacheFileContentsHint()) { - public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { - // TODO Ensure that file contents are cached for modified local files - try { - monitor.beginTask(null, 100); - return new IResource[0]; - } finally { - monitor.done(); - } - } - }; - CVSDescendantResourceVariantByteStore remoteSynchronizer = new CVSDescendantResourceVariantByteStore( - baseSynchronizer, - new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, REMOTE_RESOURCE_KEY))); - remoteTree = new CVSResourceVariantTree(remoteSynchronizer, null, getCacheFileContentsHint()); - - ResourceStateChangeListeners.getListener().addResourceStateChangeListener(this); - } - - /* - * Return the list of projects shared with a CVS team provider. - * - * [Issue : this will have to change when folders can be shared with - * a team provider instead of the current project restriction] - * (non-Javadoc) - * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#roots() - */ - public IResource[] roots() { - List result = new ArrayList(); - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - if(project.isOpen()) { - RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if(provider != null) { - result.add(project); - } - } - } - return (IProject[]) result.toArray(new IProject[result.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[]) - */ - public void resourceSyncInfoChanged(IResource[] changedResources) { - internalResourceSyncInfoChanged(changedResources, true); - } - - private void internalResourceSyncInfoChanged(IResource[] changedResources, boolean canModifyWorkspace) { - getRemoteByteStore().handleResourceChanges(changedResources, canModifyWorkspace); - fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#externalSyncInfoChange(org.eclipse.core.resources.IResource[]) - */ - public void externalSyncInfoChange(IResource[] changedResources) { - internalResourceSyncInfoChanged(changedResources, false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceModified(org.eclipse.core.resources.IResource[]) - */ - public void resourceModified(IResource[] changedResources) { - // This is only ever called from a delta POST_CHANGE - // which causes problems since the workspace tree is closed - // for modification and we flush the sync info in resourceSyncInfoChanged - - // Since the listeners of the Subscriber will also listen to deltas - // we don't need to propogate this. - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectConfigured(org.eclipse.core.resources.IProject) - */ - public void projectConfigured(IProject project) { - SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_ADDED, project); - fireTeamResourceChange(new SubscriberChangeEvent[] {delta}); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectDeconfigured(org.eclipse.core.resources.IProject) - */ - public void projectDeconfigured(IProject project) { - try { - getRemoteTree().flushVariants(project, IResource.DEPTH_INFINITE); - } catch (TeamException e) { - CVSProviderPlugin.log(e); - } - SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, project); - fireTeamResourceChange(new SubscriberChangeEvent[] {delta}); - } - - public void setRemote(IResource resource, IResourceVariant remote, IProgressMonitor monitor) throws TeamException { - // TODO: This exposes internal behavior to much - IResource[] changedResources = - ((CVSResourceVariantTree)getRemoteTree()).collectChanges(resource, remote, IResource.DEPTH_INFINITE, monitor); - if (changedResources.length != 0) { - fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache() - */ - protected IResourceVariantTree getBaseTree() { - return baseTree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache() - */ - protected IResourceVariantTree getRemoteTree() { - return remoteTree; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#collectOutOfSync(org.eclipse.core.resources.IResource[], int, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void collectOutOfSync(IResource[] resources, int depth, final SyncInfoSet set, final IProgressMonitor monitor) { - monitor.beginTask(null, IProgressMonitor.UNKNOWN); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - try { - if (!isSupervised(resource)) { - return; - } - } catch (TeamException e) { - // fallthrough and try to collect sync info - CVSProviderPlugin.log(e); - } - try { - resource.accept(new IResourceVisitor() { - public boolean visit(IResource innerResource) throws CoreException { - try { - Policy.checkCanceled(monitor); - if (innerResource.getType() != IResource.FILE) { - monitor.subTask(Policy.bind("CVSWorkspaceSubscriber.1", innerResource.getFullPath().toString())); //$NON-NLS-1$ - } - if (isOutOfSync(innerResource, monitor)) { - SyncInfo info = getSyncInfo(innerResource); - if (info != null && info.getKind() != 0) { - set.add(info); - } - } - } catch (TeamException e) { - set.addError(new TeamStatus( - IStatus.ERROR, CVSProviderPlugin.ID, ITeamStatus.RESOURCE_SYNC_INFO_ERROR, - Policy.bind("CVSWorkspaceSubscriber.2", innerResource.getFullPath().toString(), e.getMessage()), e, innerResource)); //$NON-NLS-1$ - } - return true; - } - }, depth, true /* include phantoms */); - } catch (CoreException e) { - set.addError(new TeamStatus( - IStatus.ERROR, CVSProviderPlugin.ID, ITeamStatus.SYNC_INFO_SET_ERROR, - e.getMessage(), e, ResourcesPlugin.getWorkspace().getRoot())); - } - } - monitor.done(); - } - - /* internal use only */ boolean isOutOfSync(IResource resource, IProgressMonitor monitor) throws TeamException { - return (hasIncomingChange(resource) || hasOutgoingChange(resource, monitor)); - } - - private boolean hasIncomingChange(IResource resource) throws TeamException { - return getRemoteByteStore().isVariantKnown(resource); - } - - private boolean hasOutgoingChange(IResource resource, IProgressMonitor monitor) throws CVSException { - if (resource.getType() == IResource.PROJECT || resource.getType() == IResource.ROOT) { - // a project (or the workspace root) cannot have outgoing changes - return false; - } - int state = EclipseSynchronizer.getInstance().getModificationState(resource.getParent()); - if (state == ICVSFile.CLEAN) { - // if the parent is known to be clean then the resource must also be clean - return false; - } - if (resource.getType() == IResource.FILE) { - // A file is an outgoing change if it is modified - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - return file.isModified(monitor); - } else { - // A folder is an outgoing change if it is not a CVS folder and not ignored - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource); - return !folder.isCVSFolder() && !folder.isIgnored(); - } - } - - /* - * TODO: Should not need to access this here - */ - private CVSDescendantResourceVariantByteStore getRemoteByteStore() { - return (CVSDescendantResourceVariantByteStore)((CVSResourceVariantTree)getRemoteTree()).getByteStore(); - } - - /** - * Update the remote tree to the base - * @param folder - */ - public void updateRemote(CVSTeamProvider provider, ICVSFolder folder, IProgressMonitor monitor) throws TeamException { - try { - monitor.beginTask(null, 100); - IResource resource = folder.getIResource(); - if (resource != null) { - ICVSResource tree = RemoteFolderTreeBuilder.buildBaseTree( - (CVSRepositoryLocation)provider.getRemoteLocation(), - folder, - null, - Policy.subMonitorFor(monitor, 50)); - setRemote(resource, (IResourceVariant)tree, Policy.subMonitorFor(monitor, 50)); - } - } finally { - monitor.done(); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java deleted file mode 100644 index 2c9022a67..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; - -/** - * Utilities to handle time stamps in a cvs client. - */ -public class DateUtil { - - private static final String ENTRY_TIMESTAMP_FORMAT= "EEE MMM dd HH:mm:ss yyyy";//$NON-NLS-1$ - private static final String ENTRY_TIMESTAMP_TIME_ZONE= "GMT";//$NON-NLS-1$ - private static final Locale ENTRY_TIMESTAMP_LOCALE= Locale.US; - - private static final String MODTIME_TIMESTAMP_FORMAT= "dd MMM yyyy HH:mm:ss zz";//$NON-NLS-1$ - private static final Locale MODTIME_TIMESTAMP_LOCALE= Locale.US; - - private static final String LOG_TIMESTAMP_FORMAT= "yyyy/MM/dd HH:mm:ss zzz";//$NON-NLS-1$ - private static final Locale LOG_TIMESTAMP_LOCALE= Locale.US; - - private static final String HISTORY_TIMESTAMP_FORMAT= "yyyy-MM-dd HH:mm zzzz";//$NON-NLS-1$ - private static final Locale HISTORY_TIMESTAMP_LOCALE= Locale.US; - - /** - * Converts a time stamp as sent from a cvs server for a "log" command into a - * Date. - */ - public static Date convertFromLogTime(String modTime) { - SimpleDateFormat format= new SimpleDateFormat(LOG_TIMESTAMP_FORMAT, - LOG_TIMESTAMP_LOCALE); - try { - return format.parse(modTime); - } catch (ParseException e) { - // fallback is to return null - return null; - } - } - /** - * Converts a modifcation time stamp as send from a cvs server into a - * Date. The format of the modification time stamp is defined - * in the document CVS Client/Server for CVS 1.11 section 5.6 Dates - */ - public static Date convertFromModTime(String modTime) { - SimpleDateFormat format= new SimpleDateFormat(MODTIME_TIMESTAMP_FORMAT, - MODTIME_TIMESTAMP_LOCALE); - try { - return format.parse(modTime); - } catch (ParseException e) { - // fallback is to return null - return null; - } - } - /** - * Converts a history time stamp as sent from a cvs server into a - * Date. - */ - public static Date convertFromHistoryTime(String historyTime) { - SimpleDateFormat format= new SimpleDateFormat(HISTORY_TIMESTAMP_FORMAT, - HISTORY_TIMESTAMP_LOCALE); - try { - return format.parse(historyTime); - } catch (ParseException e) { - // fallback is to return null - return null; - } - } - /** - * Converts a date into an entry time format as specified in the document - * Version Management with CVS for CVS 1.10.6 page 14. Note that the - * time format is always in GMT also not specified in the document. - */ - public static String toEntryFormat(Date date) { - SimpleDateFormat format= new SimpleDateFormat(ENTRY_TIMESTAMP_FORMAT, - ENTRY_TIMESTAMP_LOCALE); - format.setTimeZone(TimeZone.getTimeZone(ENTRY_TIMESTAMP_TIME_ZONE)); - return format.format(date); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java deleted file mode 100644 index 7612f9446..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -/** - * Instances of EditorsInfo represent information for a CVS resurce that results - * from the cvs editors command. - * - * @author Gregor Kohlwes - */ - -public class EditorsInfo { - public EditorsInfo() { - } - - private String userName; - private String fileName; - private String dateString; - private String computerName; - - - /** - * Returns the userName. - * @return String - */ - public String getUserName() { - return userName; - } - - /** - * Sets the userName. - * @param userName The userName to set - */ - public void setUserName(String userName) { - this.userName = userName; - } - - /** - * Returns the dateString. - * @return String - */ - public String getDateString() { - return dateString; - } - - /** - * Returns the fileName. - * @return String - */ - public String getFileName() { - return fileName; - } - - /** - * Sets the dateString. - * @param dateString The dateString to set - */ - public void setDateString(String dateString) { - this.dateString = dateString; - } - - /** - * Sets the fileName. - * @param fileName The fileName to set - */ - public void setFileName(String fileName) { - this.fileName = fileName; - } - - /** - * Returns the computerName. - * @return String - */ - public String getComputerName() { - return computerName; - } - - /** - * Sets the computerName. - * @param computerName The computerName to set - */ - public void setComputerName(String computerName) { - this.computerName = computerName; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java deleted file mode 100644 index 935cc0d25..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -/** - * A decorator enablement listener is notified of changes to the enablement - * of CVS state decorators. - *

              - * Clients may implement this interface. - *

              - * @see CVSProviderPlugin#addDecoratorEnablementListener(ICVSDecoratorEnablementListener) - */ -public interface ICVSDecoratorEnablementListener { - /** - * Called when CVS decoration is enabled or disabled. Implementers can use the - * decorator enablement change as a chance to create or destroy cached CVS information - * that would help decorate CVS elements. - * - * @param enabled a flag indicating the enablement state of the decorators. - */ - void decoratorEnablementChanged(boolean enabled); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java deleted file mode 100644 index e6a6cea5b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.util.Date; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * The CVS analog of a file. CVS files have access to synchronization information - * that describes their association with the CVS repository. CVS files also provide - * mechanisms for sending and receiving content. - * - * @see ICVSResource - */ -public interface ICVSFile extends ICVSResource, ICVSStorage { - - // Constants used to indicate the type of updated response from the server - public static final int UPDATED = 1; - public static final int MERGED = 2; - public static final int UPDATE_EXISTING = 3; - public static final int CREATED = 4; - - // Constants used to indicate temporary watches - public static final int NO_NOTIFICATION = 0; - public static final int NOTIFY_ON_EDIT = 1; - public static final int NOTIFY_ON_UNEDIT = 2; - public static final int NOTIFY_ON_COMMIT = 4; - public static final int NOTIFY_ON_ALL = NOTIFY_ON_EDIT | NOTIFY_ON_UNEDIT | NOTIFY_ON_COMMIT; - - // Constants used to indicate modification state when setting sync info - public static final int UNKNOWN = 0; - public static final int CLEAN = 1; - public static final int DIRTY = 2; - - /** - * Answers the workspace synchronization information for this resource. This would - * typically include information from the Entries file that is used to track - * the base revisions of local CVS resources. - * - * @return the synchronization information for this resource, or null - * if the resource does not have synchronization information available. - */ - public byte[] getSyncBytes() throws CVSException; - - /** - * Called to set the workspace synchronization information for a resource. To - * clear sync information call unmanage. The sync info will - * become the persisted between workbench sessions. - * - * Note: This method makes use of a ResourceSyncInfo object which has the parsed - * contents of the resource sync info. Clients can manipulate the values using - * MutableResourceSyncInfo and then set the sync info using this method. - * - * @param info the resource synchronization to associate with this resource. - */ - public void setSyncInfo(ResourceSyncInfo info, int modificationState) throws CVSException; - - /** - * Called to set the workspace synchronization information for a resource. To - * clear sync information call unmanage. The sync info will - * become the persisted between workbench sessions. - * - * Note: This method sets the sync info to the bytes provided as-is. It is the caller's - * responsibility to ensure that these bytes are of the proper format. Use with caution. - * - * @param info the resource synchronization to associate with this resource. - */ - public void setSyncBytes(byte[] syncBytes, int modificationState) throws CVSException; - - /** - * Sets the file to read-only (true) or writable (false). - * - * This method is used by the command framework and should not be used by other clients. - * Other clients should use edit and unedit instead as they - * will report the change to the server if appropriate. - */ - void setReadOnly(boolean readOnly) throws CVSException; - - /** - * Answers whether the file is read-only or not. If a file is read-only, edit - * should be invoked to make the file editable. - */ - boolean isReadOnly() throws CVSException; - - /** - * Sets the file to be executable (ture) or not executable - * (false) if the platform supports it. - */ - public void setExecutable(boolean executable) throws CVSException; - - /** - * Answers whether the file is executable or not. - * - * @returns false if the platform doesn't support the executable flag. - */ - public boolean isExecutable() throws CVSException; - - /** - * Copy the resource to another file in the same directory - * - * This method is used by the command framework and should not be used by other clients. - */ - void copyTo(String filename) throws CVSException; - - /** - * Answers the current timestamp for this file with second precision. - * - * This method is used by the command framework and should not be used by other clients. - */ - Date getTimeStamp(); - - /** - * If the date is null then the current time is used. After setTimeStamp is - * invoked, it is assumed that the file is CLEAN. If this is not the case, it is the clients - * responsibility to invoke setSyncBytes() with the appropriate modification state. - * - * This method is used by the command framework and should not be used by other clients. - */ - void setTimeStamp(Date date) throws CVSException; - - /** - * Answers true if the file has changed since it was last updated - * from the repository, if the file does not exist, or is not managed. And false - * if it has not changed. - */ - boolean isModified(IProgressMonitor monitor) throws CVSException; - - /** - * Answers the revision history for this file. This is similar to the - * output of the log command. - */ - public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException; - - /** - * Mark the file as checked out to allow local editing (analogous to "cvs edit"). - * If this method is invoked when isCheckedOut() returns false, - * a notification message that will be sent to the server on the next connection - * If isCheckedOut() returns true then nothing is done. - * - * @param notifications the set of operations for which the local user would like notification - * while the local file is being edited. - */ - public void edit(int notifications, IProgressMonitor monitor) throws CVSException; - - /** - * Undo a checkout of the file (analogous to "cvs unedit"). - * If this method is invoked when isCheckedOut() returns true, - * a notification message that will be sent to the server on the next connection - * If isCheckedOut() returns false then nothing is done. - */ - public void unedit(IProgressMonitor monitor) throws CVSException; - - /** - * This method is invoked by the checked-in handler after the file - * has been committed. - * @param entryLine the entry line recieved from the server (can be null) - * @param commit whether the checkin is comming from a cvs commit or not - */ - public void checkedIn(String entryLine, boolean commit) throws CVSException; - - /** - * Answer any pending notification information associated with the receiver. - * - * This method is used by the command framework and should not be used by other clients. - */ - public NotifyInfo getPendingNotification() throws CVSException; - - /** - * Indicate to the file that the pending notification was successfully communicated to the server. - * - * This method is used by the command framework and should not be used by other clients. - */ - public void notificationCompleted() throws CVSException; - - /** - * Indicate whether the file has been "cvs edit"ed. This is determined by - * looking in the CVS/Base folder for a file of the same name as the - * file (i.e. no files are read so the method can be called by time critical - * code like menu enablement). - * - * @return boolean - */ - public boolean isEdited() throws CVSException; - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java deleted file mode 100644 index a45887e9b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileModificationValidator; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public interface ICVSFileModificationValidator extends IFileModificationValidator { - - public IStatus validateMoveDelete(IFile[] files, IProgressMonitor monitor); - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java deleted file mode 100644 index b636adc78..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; - -/** - * The CVS analog of a directory. CVS folders have access to synchronization information - * that describes the association between the folder and the remote repository. - * - * @see ICVSResource - * @see ICVSFile - */ -public interface ICVSFolder extends ICVSResource { - - public static final int FILE_MEMBERS = 1; - public static final int FOLDER_MEMBERS = 2; - public static final int IGNORED_MEMBERS = 4; - public static final int UNMANAGED_MEMBERS = 8; - public static final int MANAGED_MEMBERS = 16; - public static final int EXISTING_MEMBERS = 32; - public static final int PHANTOM_MEMBERS = 64; - public static final int ALL_MEMBERS = FILE_MEMBERS - | FOLDER_MEMBERS - | IGNORED_MEMBERS - | UNMANAGED_MEMBERS - | MANAGED_MEMBERS - | EXISTING_MEMBERS - | PHANTOM_MEMBERS; - public static final int ALL_EXISTING_MEMBERS = FILE_MEMBERS - | FOLDER_MEMBERS - | IGNORED_MEMBERS - | UNMANAGED_MEMBERS - | MANAGED_MEMBERS - | EXISTING_MEMBERS; - public static final int ALL_UNIGNORED_MEMBERS = FILE_MEMBERS - | FOLDER_MEMBERS - | UNMANAGED_MEMBERS - | MANAGED_MEMBERS - | EXISTING_MEMBERS - | PHANTOM_MEMBERS; - - /** - * Answers and array of ICVSResource elements that are immediate - * children of this remote resource, in no particular order. The server may be contacted. - * - * @param monitor a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - * - * @return array of immediate children of this remote resource. - */ - public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException; - - /** - * Answer the immediate children of the resource that are known - * at the time of invocation. The server is never contacted. - * The flags indicate the type of members to be included. - * Here are the rules for specifying just one flag: - * - * a) FILE_MEMBERS and FOLDER_MEMBERS will return managed - * and unmanaged resource of the corresponding type - * b) IGNORED_MEMBERS, MANAGED_RESOURCES and UNMANAGED_RESOURCES - * will return files and folders of the given type - * c) EXISTING_MEMBERS and PHANTOM_MEMBERS will return existing - * and phatom resource of the corresponding type - * - * Note: Unmanaged resources are those that are neither managed or ignored. - * - * If all of the flags from either group a), group b) or group c) - * are not present, the same rule for default types applies. - * For example, - * - FILE_MEMBERS | FOLDER_MEMBERS will return all managed - * and unmanaged, existing and phantom files and folders. - * - IGNORED_MEMBERS | UNMANAGED_MEMBERS will return all - * ignored or unmanaged, existing or phantom files and folders - * If a flag from each group is present, the result is the - * union of the sets. For example, - * - FILE_MEMBERS | IGNORED_MEMBERS | EXISTING_MEMBERS will return all - * existing ignored files. - */ - public ICVSResource[] members(int flags) throws CVSException; - - /** - * Answers a child folder of this resource with the given name or null if - * the given folder does not have a child with that name. - */ - public ICVSFolder getFolder(String name) throws CVSException; - - /** - * Answers a child file of this resource with the given name or null if - * the given folder does not have a child with that name. - */ - public ICVSFile getFile(String name) throws CVSException; - - /** - * Return the child resource at the given path relative to - * the receiver. - */ - public ICVSResource getChild(String path) throws CVSException; - - /** - * Create the folder if it did not exist before. Does only - * work if the direct subfolder did exist. - * - * @throws CVSException if for some reason it was not possible to create the folder - */ - public void mkdir() throws CVSException; - - /** - * Answers the folder's synchronization information or null if the folder - * is not a CVS folder. - *

              - * To modify the folder sync info the caller must call setFolderSyncInfo with - * new sync information.

              - */ - public FolderSyncInfo getFolderSyncInfo() throws CVSException; - - /** - * Set the folder sync information for this folder. Setting the folder information - * to null is not supported. The only mechanism for removing an existing - * CVS folder is to delete the resource. - */ - public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException; - - /** - * Accepts the visitor on all files and all subFolder in the folder. Files are - * visited first, then all the folders.. - */ - public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException; - - /** - * Answers true if the folder has valid CVS synchronization information and - * false otherwise. - * - * Note: This method does not throw an exception so this method does not differentiate - * between a folder not be shared with CVS and a folder that is shared but whose sync info has - * become corrupt. Use getFolderSyncInfo() to differentiate between these situations. - * - * Also Note: A folder that is a CVS folder may not exist in the workspace. The purpose of - * such a folder is to act as a remotely existing folder that does not exist locally. - * This is normally done in order to remember outgoing file deletions when a parent - * folder is deleted. - * Creating the folder will result in a folder that is mapped to a remote folder. - */ - public boolean isCVSFolder() throws CVSException; - - /** - * Runs the given action as an atomic cvs local workspace operation - * rooted at this cvs folder. - *

              - * After running a method that modifies cvs resource state in the - * local workspace, registered listeners receive after-the-fact - * notification in the form of a resource state change event. In addition, - * any resource state information persistance is batched. - * This method allows clients to call a number of - * methods that modify resources and only have resource - * change event notifications reported at the end of the entire - * batch. - *

              - *

              - * If this method is called in the dynamic scope of another such - * call, this method simply runs the action. - *

              - * - * @param job the action to perform - * @param monitor a progress monitor, or null if progress - * reporting and cancellation are not desired - * @exception CVSException if the operation failed. - */ - public void run(ICVSRunnable job, IProgressMonitor monitor) throws CVSException; -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java deleted file mode 100644 index 7bde4aed5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - - -public interface ICVSListener { - public void repositoryAdded(ICVSRepositoryLocation root); - public void repositoryRemoved(ICVSRepositoryLocation root); -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java deleted file mode 100644 index 9cdc9be65..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.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.team.internal.ccvs.core; - - -import java.io.InputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - - /** - * This interface represents a file in a repository. - * Instances of this interface can be used to fetch the contents - * of the remote file. - * - * In the future, additional information should be available (tags, revisions, etc.) - * - * Clients are not expected to implement this interface. - */ -public interface ICVSRemoteFile extends ICVSRemoteResource, ICVSFile { - - /** - * Returns a stream over the contents of this remote element. - * - * @param progress a progress monitor to indicate the duration of the operation, or - * null if progress reporting is not required. - */ - public InputStream getContents(IProgressMonitor progress) throws TeamException; - - /** - * Get the log entry for the revision the remote file represents. - * This method will return null until after the getContents(IProgressMonitor) - * method is called (i.e. the call to getContents also fetches the entry. - */ - public ILogEntry getLogEntry(IProgressMonitor monitor) throws TeamException; - - /** - * Get all the log entries of the remote file - */ - public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException; - - /** - * Get the revision of the remote file (e.g. 1.1) - * - * The revision depends on any tagging associated with the remote parent used - * to access the file. - */ - public String getRevision() throws TeamException; -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java deleted file mode 100644 index 7d92ede5a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; - - /** - * This interface represents a remote folder in a repository. It provides - * access to the members (remote files and folders) of a remote folder - * - * Clients are not expected to implement this interface. - */ -public interface ICVSRemoteFolder extends ICVSRemoteResource, ICVSFolder { - - // This constant is the name of the folder at the root of a repository - public static final String REPOSITORY_ROOT_FOLDER_NAME = ""; //$NON-NLS-1$ - - /** - * Return the context of this handle. The returned tag can be a branch or - * version tag. - */ - public CVSTag getTag(); - - /** - * Return the local options that are used to determine how memebers are retrieved. - * - * Interesting options are: - * Checkout.ALIAS - * Command.DO_NOT_RECURSE - */ - public LocalOption[] getLocalOptions(); - - /** - * Indicates whether the remote folder can be expanded. - * - * This is a temporary (hopefully) means of indicating certain types of folders - * (i.e. module definitions) that are not expandable due to lack of mdoule expansion. - * They can still be checked out. - */ - public boolean isExpandable(); - - /** - * Indicates whether the remote folder is an actual remote folder is a - * module defined in the CVSROOT/modules file (or some other module - * definition). - */ - public boolean isDefinedModule(); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java deleted file mode 100644 index aa089b17d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java +++ /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 - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; - -/** - * The interface represents a resource that exists in a CVS repository. - * It purpose is to provide information about the remote resource from - * the repository. - * - * Clients are not expected to implement this interface. - */ -public interface ICVSRemoteResource extends ICVSResource, IAdaptable { - - /** - * Answers if the remote element may have children. - * - * @return true if the remote element may have children and - * false otherwise. - */ - public boolean isContainer(); - - /** - * Return the repository - */ - public ICVSRepositoryLocation getRepository(); - - /** - * Returns the parent of this remote resource or null if the - * remote resource does not have a parent. - */ - public ICVSRemoteResource getRemoteParent(); - - /** - * Does the remote resource represented by this handle exist on the server. This - * method may contact the server and be long running. - */ - public boolean exists(IProgressMonitor monitor) throws TeamException; - - /** - * Answers the repository relative path of this remote folder. - */ - public String getRepositoryRelativePath(); - - /** - * Compares two objects for equality; for cvs remote resources, equality is defined in - * terms of their handles: same cvs resource type, equal relative paths, and - * for files, identical revision numbers. Remote resources are not equal to objects other - * than cvs remote resources. - * - * @param other the other object - * @return an indication of whether the objects are equals - */ - public boolean equals(Object other); - - /** - * Allows a client to change the context of a remote resource handle. For - * example, if a remote resource was created with the HEAD context (e.g. can - * be used to browse the main branch) use this method to change the - * context to another branch tag or to a version tag. - */ - public ICVSRemoteResource forTag(CVSTag tagName); - - /** - * Tag the remote resources referenced by the receiver (using rtag) - */ - public IStatus tag(CVSTag tag, LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException; - - /** - * TODO: Temporary - * @param progress - * @return - */ - public ICVSRemoteResource[] members(IProgressMonitor progress) throws TeamException; - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java deleted file mode 100644 index d466553b7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * This interface provides access to the specific portions of - * the repository location string for use by connection methods - * and the user authenticator. - * - * It is not intended to implemented by clients. - * - * @see IUserAuthenticator - * @see IConnectionMethod - */ -public interface ICVSRepositoryLocation extends IAdaptable { - - /** - * port value which indicates to a connection method to use the default port - */ - public static int USE_DEFAULT_PORT = 0; - - /** - * Return the connection method for making the connection - */ - public IConnectionMethod getMethod(); - - /** - * Returns the host where the repository is located - */ - public String getHost(); - - /** - * Returns the port to connect to or USE_DEFAULT_PORT if - * the connection method is to use its default port. - */ - public int getPort(); - - /** - * Returns the root directory of the repository. - */ - public String getRootDirectory(); - - /** - * Returns the string representing the receiver. This string - * should contain enough information to recreate the receiver. - */ - public String getLocation(); - - /** - * Returns the immediate children of this location. If tag is null the - * HEAD branch is assumed. - * - * If modules is true, then the module definitions from the CVSROOT/modules file are returned. - * Otherwise, the root level projects are returned. - * - * @param tag the context in which to return the members (e.g. branch or version). - */ - public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException; - - /** - * Returns a handle to a remote file at this repository location using the given tag as the - * context. The corresponding remote file may not exist or may be a folder. - */ - public ICVSRemoteFile getRemoteFile(String remotePath, CVSTag tag); - - /** - * Returns a handle to a remote folder at this repository location using the given tag as the - * context. The corresponding remote folder may not exist or may be a file. - */ - public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag); - - /** - * encoding for commit comments. - */ - public String getEncoding(); - - /** - * Return the conection timeout value in milliseconds. - * A value of 0 means there is no timeout value. - */ - public int getTimeout(); - - /** - * Return the username - */ - public String getUsername(); - - /** - * Returns the user information for the location. - */ - public IUserInfo getUserInfo(boolean allowModificationOfUsername); - - /** - * Flush any cahced user information related to the repository location - */ - public void flushUserInfo(); - - /** - * Validate that the receiver can be used to connect to a repository. - * An exception is thrown if connection fails - * - * @param monitor the progress monitor used while validating - */ - public void validateConnection(IProgressMonitor monitor) throws CVSException; - - /** - * Set the option to allow the user settings to be cached between sessions. - * @since 3.0 - */ - public void setAllowCaching(boolean allowCaching); - - /** - * Returns if the user info for this location is cached - */ - public boolean getUserInfoCached(); - - /** - * Sets the user information used for this location - */ - public void setUsername(String username); - - /** - * Sets the user information used for this location - */ - public void setPassword(String password); - - /** - * Returns the plugged-in authenticator for this location. - * @since 3.0 - */ - public IUserAuthenticator getUserAuthenticator(); - - /** - * Sets the plugged-in authenticator for this location. This is a hook - * for testing. - * @since 3.0 - */ - public void setUserAuthenticator(IUserAuthenticator authenticator); - - /** - * Sets encoding for commit messages. - * @since 3.0 - */ - public void setEncoding(String encoding); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java deleted file mode 100644 index 5bd769057..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * The CVS analog of file system files and directories. These are handles to - * state maintained by a CVS client. That is, the CVS resource does not - * actually contain data but rather represents CVS state and behavior. You are - * free to manipulate handles for CVS resources that do not exist but be aware - * that some methods require that an actual resource be available. - *

              - * The CVS client has been designed to work on these handles uniquely. As such, the - * handle could be to a remote resource or a local resource and the client could - * perform CVS operations ignoring the actual location of the resources.

              - * - * @see ICVSFolder - * @see ICVSFile - */ -public interface ICVSResource { - - /** - * Answers the name of the resource. - * - * @return the name of the resource this handle represents. It can never - * be null. - */ - public String getName(); - - /** - * Answers if this resource has CVS synchronization information associated - * with it. - * - * @return true if the resource is - */ - public boolean isManaged() throws CVSException; - - /** - * Unmanage the given resource by purging any CVS synchronization associated with the - * resource. The only way a resource can become managed is by running the - * appropriate CVS commands (e.g. add/commit/update). - */ - public void unmanage(IProgressMonitor monitor) throws CVSException; - - /** - * Answer whether the resource could be ignored because it is in the one of the - * ignore lists maintained by CVS. Even if a resource is ignored, it can still be - * added to a repository, at which time it should never be ignored by the CVS - * client. - * - * @return true if this resource is listed in one of the ignore - * files maintained by CVS and false otherwise. - */ - public boolean isIgnored() throws CVSException; - - /** - * Add the following pattern to the file's parent ignore list - * - * XXX This should really be a method of ICVSFolder - */ - public void setIgnoredAs(String pattern) throws CVSException; - - /** - * Answers if the handle is a file or a folder handle. - * - * @return true if this is a folder handle and false if - * it is a file handle. - */ - public boolean isFolder(); - - /** - * Answers if the resource identified by this handle exists. - * - * @return true if the resource represented by this handle - * exists and false false otherwise. - */ - public boolean exists() throws CVSException; - - /** - * Answers the underlying IResource for the cvs resource (or null if there - * is not a corresponding local resource). - * - * @return the IResource that corresponds to the CVS resource - */ - public IResource getIResource() throws CVSException; - - /** - * Answers the local relative path from the given ancestor to the receiver. - * This method will return a path for files that are themselves not added - * to CVS control but who have an ancestor that is under CVS control. - * - * @return the ancestor relative path for this resource. - */ - public String getRelativePath(ICVSFolder ancestor) throws CVSException; - - /** - * Return the repository relative path of the remote resource. Return - * null if the resource is not under CVS control. - * - * @return - * @throws CVSException - */ - public String getRepositoryRelativePath() throws CVSException; - - /** - * Get the absolute remote location of a resource. This method is used by - * the CVS command infrastructure during command execution. The root is used - * in situations where the resource is not under CVS control. The remote - * path that the resource would have if it was is determined by recursively - * searching the resource's parent until a managed folder is found. The - * provided root is used to stop the recursive search if no managed parent - * is found. - * - * @param root the root folder of the command. - * - * @return the remote location. - */ - public String getRemoteLocation(ICVSFolder root) throws CVSException; - - /** - * Answers the workspace synchronization information for this resource. This would - * typically include information from the Entries file that is used to track - * the base revisions of local CVS resources. - * - * @return the synchronization information for this resource, or null - * if the resource does not have synchronization information available. - */ - public ResourceSyncInfo getSyncInfo() throws CVSException; - - /** - * Deletes the resource represented by the handle. - */ - public void delete() throws CVSException; - - /** - * Give the folder that contains this resource. If the resource is not managed - * then the result of the operation is not specified. - * - * @return a handle to the parent of this resource. - */ - public ICVSFolder getParent(); - - /** - * Accept a vistor to this resource. - */ - public void accept(ICVSResourceVisitor visitor) throws CVSException; - - /** - * Accept a visitor to this resource. The recurse parameter corresponds to the CVS - * -l (do not recurse) and -R (recurse) options. If recurse is false, only the resource - * and it's children are visited. Otherwise, the resource and all it's decendants are - * visited. - */ - public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException; - - /** - * Method isModified. - * @return boolean - */ - public boolean isModified(IProgressMonitor monitor) throws CVSException; -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java deleted file mode 100644 index 28cc5cd29..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - - - -/** - * Interface for an visitor of the IManagedResources. - */ -public interface ICVSResourceVisitor { - public void visitFile(ICVSFile file) throws CVSException; - public void visitFolder(ICVSFolder folder) throws CVSException; -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java deleted file mode 100644 index 378147b8a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A runnable which executes as a batch operation within a specific cvs local - * workspace. - * The ICVSRunnable interface should be implemented by any class whose - * instances are intended to be run by IWorkspace.run. - *

              - * Clients may implement this interface. - *

              - * @see - */ -public interface ICVSRunnable { - /** - * Runs the operation reporting progress to and accepting - * cancellation requests from the given progress monitor. - *

              - * Implementors of this method should check the progress monitor - * for cancellation when it is safe and appropriate to do so. The cancellation - * request should be propagated to the caller by throwing - * OperationCanceledException. - *

              - * - * @param monitor a progress monitor, or null if progress - * reporting and cancellation are not desired - * @exception CoreException if this operation fails. - */ - public void run(IProgressMonitor monitor) throws CVSException; -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java deleted file mode 100644 index af87c02a7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * This interface is used by the Session to transfer file contents. - * It is used for regular files in a local sandbox as well as special files - * such as the CVS/Template file. - */ -public interface ICVSStorage { - - /** - * Return the name for this ICVSStorage. - * @return - */ - String getName(); - - /** - * Set the contents of the file to the contents of the provided input stream. - * - * This method is used by the command framework and should not be used by other clients. - * Other clients should set the contents of the underlying IFile which - * can be obtained using getIResource(). - * - * @param responseType the type of reponse that was received from the server - * - * UPDATED - could be a new file or an existing file - * MERGED - merging remote changes with local changes. Failure could result in loss of local changes - * CREATED - contents for a file that doesn't exist locally - * UPDATE_EXISTING - Replacing a local file with no local changes with remote changes. - */ - public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException; - - /** - * Answers the size of the file. - */ - long getSize(); - - /** - * Gets an input stream for reading from the file. - * It is the responsibility of the caller to close the stream when finished. - */ - InputStream getContents() throws CVSException; - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java deleted file mode 100644 index 6bb199784..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -/** - * Implementators of this class can act as factories for creating connections to a CVS server - * with the desired custom communication protocol. Providers of CVS connection methods must implement - * this interface and register the implementation with the extension point: - * - * org.eclipse.team.cvs.core.connectionmethods - * - * The createConnection() method will be invoked by the CVS client when the user - * is attempting to make a connection to the server using the connection name which matches - * the String returned by getName() (e.g. "pserver", "ext", etc.). - */ -public interface IConnectionMethod { - - /** - * Returns the name of this connection method (e.g."local", "ext"). - */ - public String getName(); - - /** - * Creates a new server connection using the given repository root - * (which includes the user name) and the given password. - */ - public IServerConnection createConnection(ICVSRepositoryLocation location, String password); - - /** - * Some connection method may persist the physical connection to the server - * through several IServerConnections. For example, when making several - * successive connections to the same location using SSH2, it would be very - * expensive to re-connect, re-negotiate and re-authenticate for each - * operation; therefore the SSH2 connection method will create one SSH - * session and open several channels (one for each IServerConnection - * created), and keep the session open until disconnect() is called. - *

              - * This method actually closes any connection to the indicated location. - *

              - */ - public void disconnect(ICVSRepositoryLocation location); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java deleted file mode 100644 index 339c51476..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.util.Date; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Instances of ILogEntry represent an entry for a CVS file that results - * from the cvs log command. - * - * Clients are not expected to implement this interface - */ -public interface ILogEntry extends IAdaptable { - - /** - * Get the revision for the entry - */ - public String getRevision(); - - /** - * Get the author of the revision - */ - public String getAuthor(); - - /** - * Get the date the revision was committed - */ - public Date getDate(); - - /** - * Get the comment for the revision - */ - public String getComment(); - - /** - * Get the state - */ - public String getState(); - - /** - * Get the tags associated with the revision - */ - public CVSTag[] getTags(); - - /** - * Get the remote file for this entry - */ - public ICVSRemoteFile getRemoteFile(); - - /** - * Does the log entry represent a deletion (stat = "dead") - */ - public boolean isDeletion(); -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java deleted file mode 100644 index b47e3a7f5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.util.EventListener; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; - -/** - * A resource state change listener is notified of changes to resources - * regarding their team state. - *

              - * Clients may implement this interface. - *

              - * @see ITeamManager#addResourceStateChangeListener(IResourceStateChangeListener) - */ -public interface IResourceStateChangeListener extends EventListener{ - - /** - * Notifies this listener that some resource sync info state changes have - * already happened. For example, a resource's base revision may have - * changed. The resource tree is open for modification when this method is - * invoked, so markers can be created, etc. - *

              - * Note: This method is called by the CVS core; it is not intended to be - * called directly by clients. - *

              - * - * @param changedResources that have sync info state changes - * - * [Note: The changed state event is purposely vague. For now it is only - * a hint to listeners that they should query the provider to determine the - * resources new sync info.] - */ - public void resourceSyncInfoChanged(IResource[] changedResources); - - /** - * Notifies this listener that the resource sync info may have been changed - * by an external tool. It is not always easy to differentiate external - * changes from intenal ones. Therefore, the changed resources may include - * some whose sync info was changed internally. This method is called - * from a POST_CHANGE delta listener so the workspace cannot be modified. - * - * @param changeResources that have sync info state changes - */ - public void externalSyncInfoChange(IResource[] changedResources); - - /** - * Notifies this listener that the resource's have been modified. This - * doesn't necessarily mean that the resource state isModified. The listener - * must check the state. - *

              - * Note: This method is called by CVS team core; it is not intended to be - * called directly by clients. - *

              - * - * @param changedResources that have changed state - * @param changeType the type of state change. - */ - public void resourceModified(IResource[] changedResources); - - /** - * Notifies this listener that the project has just been configured - * to be a CVS project. - *

              - * Note: This method is called by the CVS core; it is not intended to be - * called directly by clients. - *

              - * - * @param project The project that has just been configured - */ - public void projectConfigured(IProject project); - - /** - * Notifies this listener that the project has just been deconfigured - * and no longer has the CVS nature. - *

              - * Note: This method is called by the CVS core; it is not intended to be - * called directly by clients. - *

              - * - * @param project The project that has just been configured - */ - public void projectDeconfigured(IProject project); - -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java deleted file mode 100644 index 7ecfc3055..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; -/** -* CVS supports different connection methods for communicating between a client and the server. -* Furthermore, custom connection methods can be added. Connection methods are added -* to the CVS client as an IConnectionMethod, which can be used to create connections of -* type IServerConnection. -* -* @see IConnectionMethod -*/ -public interface IServerConnection { - /** - * Open a connection to the CVS server. - * - * Throw CVSAuthenticationException if the username or password is invalid. - * Throw IOExceptions for other failures. - */ - public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException; - /** - * Close the connection - * - * Throw IOException on failures - */ - public void close() throws IOException; - /** - * Get the input stream to receive responses from the server - */ - public InputStream getInputStream(); - /** - * Get the output stream to send requests to the server - */ - public OutputStream getOutputStream(); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java deleted file mode 100644 index eb0b15fc9..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Atsuhiko Yamanaka, JCraft,Inc. - adding promptForKeyboradInteractive method - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - -/** - * IUserAuthenticators are used to ensure that the user - * is validated for access to a given repository. The - * user is prompted for a username and password as - * appropriate for the given repository type. - */ -public interface IUserAuthenticator { - - /** - * Button id for an "Ok" button (value 0). - */ - public int OK_ID = 0; - - /** - * Button id for a "Cancel" button (value 1). - */ - public int CANCEL_ID = 1; - - /** - * Button id for a "Yes" button (value 2). - */ - public int YES_ID = 2; - - /** - * Button id for a "No" button (value 3). - */ - public int NO_ID = 3; - - /** - * Constant for a prompt with no type (value 0). - */ - public final static int NONE = 0; - - /** - * Constant for an error prompt (value 1). - */ - public final static int ERROR = 1; - - /** - * Constant for an information prompt (value 2). - */ - public final static int INFORMATION = 2; - - /** - * Constant for a question prompt (value 3). - */ - public final static int QUESTION = 3; - - /** - * Constant for a warning dialog (value 4). - */ - public final static int WARNING = 4; - - /** - * Authenticates the user for access to a given repository. - * The obtained values for user name and password will be placed - * into the supplied user info object. Implementors are allowed to - * save user names and passwords. The user should be prompted for - * user name and password if there is no saved one, or if retry - * is true. - * - * @param location The repository location to authenticate the user for or null - * if this authentication is not for a CVS repository location. - * @param info The object to place user validation information into. - * @param retry true if a previous attempt to log in failed. - * @param message An optional message to display if, e.g., previous authentication failed. - * @return true if the validation was successful, and false otherwise. - */ - public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String message) throws CVSException; - - /** - * Prompts the user for a number values using text fields. The labels are provided in - * the prompt array. Implementors will return the entered values, or null if - * the user cancel the prompt. - * - * @param location The repository location to authenticate the user for or null - * if this authentication is not for a CVS repository location. - * @param destination The destination in the format like username@hostname:port - * @param name A name about this dialog. - * @param instruction A message for the instruction. - * @param prompt Labels for text fields. - * @param echo the array to show which fields are secret. - * @return the entered values, or null if the user canceled. - * - * @since 3.0 - */ - public String[] promptForKeyboradInteractive(ICVSRepositoryLocation location, String destination, String name, String instruction, String[] prompt, boolean[] echo) throws CVSException; - - /** - * Prompts the authenticator for additional information regarding this authentication - * request. A default implementation of this method should return the defaultResponse, - * whereas alternate implementations could prompt the user with a dialog. - * - * @param location the repository location for this authentication or null - * if this authentication is not for a CVS repository location. - * @param promptType one of the following values: - *
                - *
              • NONE for a unspecified prompt type
              • - *
              • ERROR for an error prompt
              • - *
              • INFORMATION for an information prompt
              • - *
              • QUESTION for a question prompt
              • - *
              • WARNING for a warning prompt
              • - *
              - * @param title the prompt title that could be displayed to the user - * @param message the prompt - * @param promptResponses the possible responses to the prompt - * @param defaultResponse the default response to the prompt - * @return the response to the prompt - * - * @since 3.0 - */ - public int prompt(ICVSRepositoryLocation location, int promptType, String title, String message, int[] promptResponses, int defaultResponseIndex); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java deleted file mode 100644 index be8a9f26e..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -/** - * Instances of this class represent a username password pair. - * Both values can be set and the username can be retrieved. - * However, it is possible that the username is not mutable. - * Users must check before trying to set the username. - * - * Clients are not expected to implement this interface - */ -public interface IUserInfo { - /** - * Get the username for this user. - */ - public String getUsername(); - /** - * Return true if the username is mutable. If not, setUsername should not be called. - */ - public boolean isUsernameMutable(); - /** - * Sets the password for this user. - */ - public void setPassword(String password); - /** - * Sets the username for this user. This should not be called if - * isUsernameMutable() returns false. - */ - public void setUsername(String username); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java deleted file mode 100644 index 1e69d5b76..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core; - - -import java.io.PrintStream; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; - -public class Policy { - protected static ResourceBundle bundle = null; - - public static PrintStream recorder; - - //debug constants - public static boolean DEBUG_METAFILE_CHANGES = false; - public static boolean DEBUG_CVS_PROTOCOL = false; - public static boolean DEBUG_THREADING = false; - public static boolean DEBUG_DIRTY_CACHING = false; - public static boolean DEBUG_SYNC_CHANGE_EVENTS = false; - - static { - //init debug options - if (CVSProviderPlugin.getPlugin().isDebugging()) { - DEBUG_METAFILE_CHANGES = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/metafiles"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_CVS_PROTOCOL = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/cvsprotocol"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_THREADING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/threading"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_DIRTY_CACHING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/dirtycaching"));//$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_SYNC_CHANGE_EVENTS = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/syncchangeevents"));//$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - */ - public static String bind(String id, String binding1, String binding2) { - return bind(id, new String[] { binding1, binding2 }); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Progress monitor helpers - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - } - public static IProgressMonitor monitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } - - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks, style); - } - - public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new InfiniteSubProgressMonitor(monitor, ticks); - } - - public static boolean isDebugProtocol() { - return DEBUG_CVS_PROTOCOL || recorder != null; - } - - public static void printProtocolLine(String line) { - printProtocol(line, true); - } - - public static void printProtocol(String string, boolean newLine) { - if (DEBUG_CVS_PROTOCOL) { - System.out.print(string); - if (newLine) { - System.out.println(); - } - } - if (recorder != null) { - recorder.print(string); - if (newLine) { - recorder.println(); - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java deleted file mode 100644 index a8ce18820..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -/** - * Superclass for commands that do not change the structure on - * the local working copy (it can change the content of the files).
              - * Most of the subclasses are asking the server for response in - * message format (log, status) - */ -abstract class AbstractMessageCommand extends Command { - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Send all folders that are already managed to the server - new FileStructureVisitor(session, false, false).visit(session, resources, monitor); - return resources; - } - -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java deleted file mode 100644 index 966986724..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * An ICVSResourceVisitor that is superclass to all ICVSResourceVisitor's used - * by Command and it's subclasses. - * Provides helper methods to send files and folders with modifications - * to the server. - * - * This class does not perform a beginTask of done on the provided monitor. - * It is used only to signal worl and subTask. - */ -abstract class AbstractStructureVisitor implements ICVSResourceVisitor { - - protected Session session; - private ICVSFolder lastFolderSent; - protected IProgressMonitor monitor; - protected boolean sendQuestionable; - protected boolean sendModifiedContents; - private boolean sendBinary; - - public AbstractStructureVisitor(Session session, boolean sendQuestionable, boolean sendModifiedContents) { - this(session, sendQuestionable, sendModifiedContents, true); - } - - public AbstractStructureVisitor(Session session, boolean sendQuestionable, boolean sendModifiedContents, boolean sendBinary) { - this.session = session; - this.sendQuestionable = sendQuestionable; - this.sendModifiedContents = sendModifiedContents; - this.sendBinary = sendBinary; - } - - /** - * Helper method to indicate if a directory has already been sent to the server - */ - protected boolean isLastSent(ICVSFolder folder) { - return folder.equals(lastFolderSent); - } - - /** - * Helper method to record if a directory has already been sent to the server - */ - protected void recordLastSent(ICVSFolder folder) { - lastFolderSent = folder; - } - - /** - * Helper which indicates if a folder is an orphaned subtree. - * That is, a directory which contains a CVS subdirectory but is - * not managed by its parent. The root directory of the session - * is not considered orphaned even if it is not managed by its - * parent. - */ - protected boolean isOrphanedSubtree(ICVSFolder mFolder) throws CVSException { - return mFolder.isCVSFolder() && ! mFolder.isManaged() && ! mFolder.equals(session.getLocalRoot()) && mFolder.getParent().isCVSFolder(); - } - - /** - * Send the folder relative to the root to the server. Send all - * appropiate modifier like Sticky, Questionable, Static-directory. - *
              - * Folders will only be sent once. - */ - protected void sendFolder(ICVSFolder mFolder) throws CVSException { - - Policy.checkCanceled(monitor); - - boolean exists = mFolder.exists(); - FolderSyncInfo info = mFolder.getFolderSyncInfo(); - boolean isCVSFolder = info != null; - - // We are only interested in folders that exist or are CVS folders - // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions - if ( ! exists && ! isCVSFolder) return; - - // Do not send the same folder twice - if (isLastSent(mFolder)) return; - - // Do not send virtual directories - if (isCVSFolder && info.isVirtualDirectory()) { - return; - } - - String localPath = mFolder.getRelativePath(session.getLocalRoot()); - - monitor.subTask(Policy.bind("AbstractStructureVisitor.sendingFolder", Util.toTruncatedPath(mFolder, session.getLocalRoot(), 3))); //$NON-NLS-1$ - - // Deal with questionable directories - boolean isQuestionable = exists && (! isCVSFolder || isOrphanedSubtree(mFolder)); - if (isQuestionable) { - if (sendQuestionable) { - // We need to make sure the parent folder was sent - sendFolder(mFolder.getParent()); - session.sendQuestionable(mFolder); - } - return; - } - - // Send the directory to the server - String remotePath = mFolder.getRemoteLocation(session.getLocalRoot()); - if (remotePath == null) { - throw new CVSException(Policy.bind("AbstractStructureVisitor.noRemote")); //$NON-NLS-1$ - } - session.sendDirectory(localPath, remotePath); - - // Send any directory properties to the server - if (info != null) { - - if (info.getIsStatic()) { - session.sendStaticDirectory(); - } - - CVSEntryLineTag tag = info.getTag(); - - if (tag != null && tag.getType() != CVSTag.HEAD) { - session.sendSticky(tag.toEntryLineFormat(false)); - } - } - - // Record that we sent this folder - recordLastSent(mFolder); - - monitor.worked(1); - } - - /** - * Send the information about the file to the server. - * - * If the file is modified, its contents are sent as well. - */ - protected void sendFile(ICVSFile mFile) throws CVSException { - - Policy.checkCanceled(monitor); - - // Send the parent folder if it hasn't been sent already - sendFolder(mFile.getParent()); - - // Send the file's entry line to the server - byte[] syncBytes = mFile.getSyncBytes(); - boolean isManaged = syncBytes != null; - - if (isManaged) { - sendPendingNotification(mFile); - } else { - // If the file is not managed, send a questionable to the server if the file exists locally - // A unmanaged, locally non-existant file results from the explicit use of the file name as a command argument - if (sendQuestionable) { - if (mFile.exists()) { - session.sendQuestionable(mFile); - } - return; - } - // else we are probably doing an import so send the file contents below - } - - // Determine if we need to send the contents. - boolean sendContents = mFile.exists() && mFile.isModified(monitor); - if (ResourceSyncInfo.isDeletion(syncBytes)) { - sendEntryLineToServer(mFile, syncBytes); - } else if (sendContents) { - // Perform the send of modified contents in a sheduling rule to ensure that - // the contents are not modified while we are sending them - IResource resource = mFile.getIResource(); - try { - if (resource != null) - Platform.getJobManager().beginRule(resource, monitor); - - sendEntryLineToServer(mFile, syncBytes); - if (mFile.exists() && mFile.isModified(null)) { - boolean binary = ResourceSyncInfo.isBinary(syncBytes); - if (sendModifiedContents) { - session.sendModified(mFile, binary, sendBinary, monitor); - } else { - session.sendIsModified(mFile, binary, monitor); - } - } else { - session.sendUnchanged(mFile); - } - } finally { - if (resource != null) - Platform.getJobManager().endRule(resource); - } - } else { - sendEntryLineToServer(mFile, syncBytes); - session.sendUnchanged(mFile); - } - - monitor.worked(1); - } - - private void sendEntryLineToServer(ICVSFile mFile, byte[] syncBytes) throws CVSException { - if (syncBytes != null) { - String syncBytesToServer = ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp()); - session.sendEntry(syncBytes, syncBytesToServer); - } - } - - protected void sendPendingNotification(ICVSFile mFile) throws CVSException { - NotifyInfo notify = mFile.getPendingNotification(); - if (notify != null) { - sendFolder(mFile.getParent()); - session.sendNotify(mFile.getParent(), notify); - } - } - - /** - * This method is used to visit a set of ICVSResources. Using it ensures - * that a common parent between the set of resources is only sent once - */ - public void visit(Session session, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException { - - // Sort the resources to avoid sending the same directory multiple times - List resourceList = new ArrayList(resources.length); - resourceList.addAll(Arrays.asList(resources)); - final ICVSFolder localRoot = session.getLocalRoot(); - Collections.sort(resourceList, new Comparator() { - public int compare(Object object1, Object object2) { - ICVSResource resource1 = (ICVSResource)object1; - ICVSResource resource2 = (ICVSResource)object2; - try { - String path1 = resource1.getParent().getRelativePath(localRoot); - String path2 = resource2.getParent().getRelativePath(localRoot); - int pathCompare = path1.compareTo(path2); - if (pathCompare == 0) { - if (resource1.isFolder() == resource2.isFolder()) { - return resource1.getName().compareTo(resource2.getName()); - } else if (resource1.isFolder()) { - return 1; - } else { - return -1; - } - } else { - return pathCompare; - } - } catch (CVSException e) { - return resource1.getName().compareTo(resource2.getName()); - } - } - }); - - // Create a progress monitor suitable for the visit - int resourceHint = 64; - monitor.beginTask(null, resourceHint); - this.monitor = Policy.infiniteSubMonitorFor(monitor, resourceHint); - try { - // Visit all the resources - this.monitor.beginTask(null, resourceHint); - session.setSendFileTitleKey(getSendFileTitleKey()); - for (int i = 0; i < resourceList.size(); i++) { - ((ICVSResource)resourceList.get(i)).accept(this); - } - } finally { - monitor.done(); - } - } - - protected String getSendFileTitleKey() { - return "AbstractStructureVisitor.sendingFile"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java deleted file mode 100644 index 157584c3c..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -public class Add extends Command { - /*** Local options: specific to add ***/ - - protected Add() { } - protected String getRequestId() { - return "add"; //$NON-NLS-1$ - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Check that all the arguments can give you an - // repo that you will need while traversing the - // file-structure - for (int i = 0; i < resources.length; i++) { - Assert.isNotNull(resources[i].getRemoteLocation(session.getLocalRoot())); - } - - // Get a vistor and use it on every resource we should - // work on - AddStructureVisitor visitor = new AddStructureVisitor(session); - visitor.visit(session, resources, monitor); - return resources; - } - - /** - * If the add succeeded then folders have to be initialized with the - * sync info - */ - protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, - IStatus status) throws CVSException { - - if (status.getCode() == CVSStatus.SERVER_ERROR) { - return status; - } - - for (int i = 0; i < resources.length; i++) { - if (resources[i].isFolder()) { - ICVSFolder mFolder = (ICVSFolder) resources[i]; - FolderSyncInfo info = mFolder.getParent().getFolderSyncInfo(); - if (info == null) { - status = mergeStatus(status, new CVSStatus(CVSStatus.ERROR, Policy.bind("Add.invalidParent", mFolder.getRelativePath(session.getLocalRoot())))); //$NON-NLS-1$ - } else { - String repository = info.getRepository() + "/" + mFolder.getName(); //$NON-NLS-1$ - mFolder.setFolderSyncInfo(new FolderSyncInfo(repository, info.getRoot(), info.getTag(), info.getIsStatic())); - } - } - } - return status; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#getDefaultCommandOutputListener() - */ - protected ICommandOutputListener getDefaultCommandOutputListener() { - return new CommandOutputListener() { - public IStatus errorLine(String line, - ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - if (serverMessage.startsWith("use `cvs commit' to add")) //$NON-NLS-1$ - return OK; - if (serverMessage.startsWith("scheduling file") && serverMessage.endsWith("for addition")) //$NON-NLS-1$ //$NON-NLS-2$ - return OK; - } - return super.errorLine(line, location, commandRoot, monitor); - } - }; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java deleted file mode 100644 index 033daa40d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * This visitor is used by the Add command to ensure that the parent - * folder is sent along with the added resource. - */ -class AddStructureVisitor extends AbstractStructureVisitor { - - public AddStructureVisitor(Session session) { - super(session, false, true); - } - - /** - * @see ICVSResourceVisitor#visitFile(IManagedFile) - */ - public void visitFile(ICVSFile mFile) throws CVSException { - - // Send the parent folder - sendFolder(mFile.getParent()); - - // Sends the Is-modified request if it is supported, otherwise - // the file contents are sent as binary. The server does not - // need the contents at this stage so this should not be a problem. - session.sendIsModified(mFile, true, monitor); - - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder mFolder) throws CVSException { - - Assert.isNotNull(mFolder); - - // Send the parent folder - sendFolder(mFolder.getParent()); - - // Send the directory - String localPath = mFolder.getRelativePath(session.getLocalRoot()); - String remotePath = mFolder.getRemoteLocation(session.getLocalRoot()); - session.sendDirectory(localPath, remotePath); - - // Record that we sent this folder - recordLastSent(mFolder); - } - -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java deleted file mode 100644 index f4e5dd2c6..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -public class Admin extends AbstractMessageCommand { - /*** Local options: specific to admin ***/ - - protected Admin() { } - protected String getRequestId() { - return "admin"; //$NON-NLS-1$ - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java deleted file mode 100644 index ff813c717..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -/** - * The CVS Annotate Command. - * Answers a resource with each line annotated with the revision the line - * was added/changed and the user making the change. - */ -public class Annotate extends AbstractMessageCommand { - - public static final Object FORCE_BINARY_ANNOTATE = new LocalOption("-F"); //$NON-NLS-1$ - - protected Annotate() { } - - protected String getRequestId() { - return "annotate"; //$NON-NLS-1$ - } - - // Local options specific to Annotate - revision (can be tag or revision) - public static LocalOption makeRevisionOption(String revision) { - return new LocalOption("-r" + revision, null); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java deleted file mode 100644 index e81e91cf0..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.io.*; - -class ByteCountOutputStream extends OutputStream { - - private long size = 0; - - public void write(int b) throws IOException { - size++; - } - public long getSize() { - return size; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java deleted file mode 100644 index d4aac1251..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.io.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; - -/** - * Stream which detects CRLF in text file contents recieved from the server - */ -public class CRLFDetectInputStream extends FilterInputStream { - - private boolean previousCR; - private String filename; - private boolean reported = false; - - protected CRLFDetectInputStream(InputStream in, ICVSStorage file) { - super(in); - try { - this.filename = getFileName(file); - } catch (CVSException e) { - this.filename = file.getName(); - } - } - - private String getFileName(ICVSStorage storage) throws CVSException { - String fileName; - if (storage instanceof ICVSFile) { - ICVSFile file = (ICVSFile)storage; - fileName = file.getRepositoryRelativePath(); - if (fileName == null) { - IResource resource = file.getIResource(); - if (resource == null) { - fileName = file.getName(); - } else { - // Use the resource path if there is one since the remote pat - fileName = file.getIResource().getFullPath().toString(); - } - } - } else { - fileName = storage.getName(); - } - return fileName; - } - - /** - * Wraps the underlying stream's method. - * Translates CR/LF sequences to LFs transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred will be zero - * @throws IOException if an i/o error occurs - */ - public int read() throws IOException { - int next = in.read(); - if (next != -1) { - testForCRLF((byte)next); - } - return next; - } - - /** - * Wraps the underlying stream's method. - * Translates CR/LF sequences to LFs transparently. - * @throws InterruptedIOException if the operation was interrupted before all of the - * bytes specified have been skipped, bytesTransferred may be non-zero - * @throws IOException if an i/o error occurs - */ - public int read(byte[] buffer, int off, int len) throws IOException { - int count = super.read(buffer, off, len); - for (int i = off; i < count; i++) { - testForCRLF(buffer[i]); - } - return count; - } - - /** - * Test the byte to see if a CRLF sequence was read - */ - private void testForCRLF(byte next) { - if (reported) return; - if (previousCR && next == '\n') { - CVSProviderPlugin.log(IStatus.WARNING, Policy.bind("CRLFDetectInputStream.0", filename), null); //$NON-NLS-1$ - reported = true; - } - previousCR = (next == '\r'); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java deleted file mode 100644 index f5ba4b829..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Handles a "Checked-in" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Checked-in ??? \n
              - *   [...]
              - * 
              - * Then - *

              - */ -class CheckedInHandler extends ResponseHandler { - public String getResponseID() { - return "Checked-in"; //$NON-NLS-1$ - } - - public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryFile = session.readLine(); - String entryLine = session.readLine(); - - // clear file update modifiers - session.setModTime(null); - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - ICVSFile mFile = mParent.getFile(fileName); - - // Marked the local file as checked-in - monitor.subTask(Policy.bind("CheckInHandler.checkedIn", Util.toTruncatedPath((ICVSResource)mFile, session.getLocalRoot(), 3))); //$NON-NLS-1$ - mFile.checkedIn(entryLine, session.getCurrentCommand() instanceof Commit); - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java deleted file mode 100644 index 148e775fe..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.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.team.internal.ccvs.core.client; - - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.ModuleDefinitionsListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.resources.RemoteModule; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -public class Checkout extends Command { - /*** Local options: specific to checkout ***/ - public static final LocalOption DO_NOT_SHORTEN = new LocalOption("-N"); //$NON-NLS-1$ - public static final LocalOption FETCH_MODULE_ALIASES = new LocalOption("-c"); //$NON-NLS-1$ - public static LocalOption makeDirectoryNameOption(String moduleName) { - return new LocalOption("-d", moduleName); //$NON-NLS-1$ - } - - /*** Default command output listener ***/ - private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new UpdateListener(null); - - /** Command options found in the CVSROOT/modules file */ - public static LocalOption ALIAS = new LocalOption("-a"); //$NON-NLS-1$ - public static LocalOption makeStatusOption(String status) { - return new LocalOption("-s", status); //$NON-NLS-1$ - } - - protected Checkout() { } - protected String getRequestId() { - return "co"; //$NON-NLS-1$ - } - - protected ICommandOutputListener getDefaultCommandOutputListener() { - return DEFAULT_OUTPUT_LISTENER; - } - - protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, - String[] arguments) throws CVSException { - - // We shouldn't have any arguments if we're fetching the module definitions - if (arguments.length < 1 && ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) throw new IllegalArgumentException(); - - // We can determine the local directories using either the -d option or the module expansions - Option dOption = findOption(localOptions, "-d"); //$NON-NLS-1$ - if (dOption != null) { - // Should we append the expansions to the -d argument? - return new ICVSResource[] {session.getLocalRoot().getFolder(dOption.argument)}; - } - String[] modules = session.getModuleExpansions(); - ICVSResource[] resources = new ICVSResource[modules.length]; - for (int i = 0; i < resources.length; i++) { - resources[i] = session.getLocalRoot().getFolder(modules[i]); - } - return resources; - } - - /** - * Start the Checkout command: - * Send the module that is going to be checked-out to the server - * by reading the name of the resource given - * (This has to change to we give it the name of the modul and the - * Checkout creates everything for us) - */ - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // We need a folder to put the project(s) we checkout into - Assert.isTrue(session.getLocalRoot().isFolder()); - - // Send the information about the local workspace resources to the server - List resourcesToSend = new ArrayList(resources.length); - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - if (resource.exists() && resource.isFolder() && ((ICVSFolder)resource).isCVSFolder()) { - resourcesToSend.add(resource); - } - } - if ( ! resourcesToSend.isEmpty()) { - resources = (ICVSResource[]) resourcesToSend.toArray(new ICVSResource[resourcesToSend.size()]); - new FileStructureVisitor(session, true, true).visit(session, resources, monitor); - } else { - monitor.beginTask(null, 100); - monitor.done(); - } - return resources; - } - - protected void sendLocalWorkingDirectory(Session session) throws CVSException { - session.sendConstructedRootDirectory(); - } - - /** - * On sucessful finish, prune empty directories if - * the -P option was specified (or is implied by -D or -r) - */ - protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, - IStatus status) throws CVSException { - // If we didn't succeed, don't do any post processing - if (status.getCode() == CVSStatus.SERVER_ERROR) { - return status; - } - - // If we are retrieving the modules file, ignore other options - if (FETCH_MODULE_ALIASES.isElementOf(localOptions)) return status; - - // If we are pruning (-P) or getting a sticky copy (-D or -r), then prune empty directories - if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions) || - (findOption(localOptions, "-D") != null) || //$NON-NLS-1$ - (findOption(localOptions, "-r") != null)) { //$NON-NLS-1$ - - // Prune empty directories - new PruneFolderVisitor().visit(session, resources); - } - - return status; - } - - /** - * Override execute to perform a expand-modules before the checkout - */ - protected IStatus doExecute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener, - IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); - - if ( ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) { - // Execute the expand-modules command. - // This will put the expansions in the session for later retrieval - IStatus status = Request.EXPAND_MODULES.execute(session, arguments, Policy.subMonitorFor(monitor, 10)); - if (status.getCode() == CVSStatus.SERVER_ERROR) - return status; - - // If -d is not included in the local options, then send -N (do not shorten directory paths) - // to the server (as is done by other cvs clients) - if (findOption(localOptions, "-d") == null) { //$NON-NLS-1$ - if ( ! DO_NOT_SHORTEN.isElementOf(localOptions)) { - LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1]; - newLocalOptions[0] = DO_NOT_SHORTEN; - System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length); - localOptions = newLocalOptions; - } - } - } - - return super.doExecute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90)); - } - - /** - * Perform a checkout to get the module expansions defined in the CVSROOT/modules file - */ - public RemoteModule[] getRemoteModules(Session session, CVSTag tag, IProgressMonitor monitor) - throws CVSException { - - ModuleDefinitionsListener moduleDefinitionListener = new ModuleDefinitionsListener(); - - IStatus status = super.execute(session, NO_GLOBAL_OPTIONS, new LocalOption[] {FETCH_MODULE_ALIASES}, NO_ARGUMENTS, - moduleDefinitionListener, monitor); - - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - - return RemoteModule.createRemoteModules(moduleDefinitionListener.getModuleExpansions(), session.getCVSRepositoryLocation(), tag); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java deleted file mode 100644 index 803f10e35..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; - -/** - * This checkout will overwrite any resources even for created responses - */ -public class CheckoutWithOverwrite extends Checkout { - - /** - * This class overrides the "Created" handler but uses the "Updated" - * behavior which will overwrite existing files. - */ - public class CreatedResponseHandler extends UpdatedHandler { - public CreatedResponseHandler() { - super(UpdatedHandler.HANDLE_UPDATED); - } - public String getResponseID() { - return "Created"; //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus doExecute( - Session session, - GlobalOption[] globalOptions, - LocalOption[] localOptions, - String[] arguments, - ICommandOutputListener listener, - IProgressMonitor monitor) - throws CVSException { - - ResponseHandler newCreated = new CreatedResponseHandler(); - ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID()); - session.registerResponseHandler(newCreated); - try { - return super.doExecute( - session, - globalOptions, - localOptions, - arguments, - listener, - monitor); - } finally { - session.registerResponseHandler(oldCreated); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java deleted file mode 100644 index 1d2984f98..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java +++ /dev/null @@ -1,764 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; - -/** - * Abstract base class for command requests. - * Provides a framework for implementing command execution. - */ -public abstract class Command extends Request { - /*** Command singleton instances ***/ - public final static Add ADD = new Add(); - public final static Admin ADMIN = new Admin(); - public final static Annotate ANNOTATE = new Annotate(); - public final static Checkout CHECKOUT = new CheckoutWithOverwrite(); - public final static Commit COMMIT = new Commit(); - public final static Diff DIFF = new Diff(); - public final static RDiff RDIFF = new RDiff(); - public final static Editors EDITORS = new Editors(); - public final static Import IMPORT = new Import(); - public final static Log LOG = new Log(); - public final static Remove REMOVE = new Remove(); - public final static Status STATUS = new Status(); - public final static Tag TAG = new Tag(); - // The CUSTOM_TAG command has special handling for added and removed resources. - // This behavior supports branching with local changes in the workspace - public final static Tag CUSTOM_TAG = new Tag(true); - public final static RTag RTAG = new RTag(); - public final static Update UPDATE = new Update(); - public final static Update REPLACE = new UpdateWithOverwrite(); - public final static SyncUpdate SYNCUPDATE = new SyncUpdate(); - public final static Version VERSION = new Version(); - public final static NOOPCommand NOOP = new NOOPCommand(); - - // Empty argument array - public final static String[] NO_ARGUMENTS = new String[0]; - - /*** Global options ***/ - // Empty global option array - public static final GlobalOption[] NO_GLOBAL_OPTIONS = new GlobalOption[0]; - // Do not change file contents - public static final GlobalOption DO_NOT_CHANGE = new GlobalOption("-n"); //$NON-NLS-1$ - // Do not record this operation into CVS command history - public static final GlobalOption DO_NOT_LOG = new GlobalOption("-l"); //$NON-NLS-1$ - // Make new working files read-only - public static final GlobalOption MAKE_READ_ONLY = new GlobalOption("-r"); //$NON-NLS-1$ - // Trace command execution - public static final GlobalOption TRACE_EXECUTION = new GlobalOption("-t"); //$NON-NLS-1$ - - /*** Global options: quietness ***/ - // Don't be quiet (normal verbosity) - public static final QuietOption VERBOSE = new QuietOption(""); //$NON-NLS-1$ - // Be somewhat quiet (suppress informational messages) - public static final QuietOption PARTLY_QUIET = new QuietOption("-q"); //$NON-NLS-1$ - // Be really quiet (silent but for serious problems) - public static final QuietOption SILENT = new QuietOption("-Q"); //$NON-NLS-1$ - - /*** Local options: common to many commands ***/ - // Empty local option array - public static final LocalOption[] NO_LOCAL_OPTIONS = new LocalOption[0]; - // valid for: annotate checkout commit diff export log rdiff remove rtag status tag update - public static final LocalOption DO_NOT_RECURSE = new LocalOption("-l"); //$NON-NLS-1$ - // valid for: checkout export update - public static final LocalOption PRUNE_EMPTY_DIRECTORIES = new LocalOption("-P"); //$NON-NLS-1$ - // valid for: checkout export update - public static final LocalOption MESSAGE_OPTION = new LocalOption("-m"); //$NON-NLS-1$ - - /*** Local options: keyword substitution mode ***/ - // valid for: add admin checkout export import update - private static final Map ksubstOptionMap = new HashMap(); - public static final KSubstOption KSUBST_BINARY = new KSubstOption("-kb"); //$NON-NLS-1$ - public static final KSubstOption KSUBST_TEXT = new KSubstOption("-ko"); //$NON-NLS-1$ - public static final KSubstOption KSUBST_TEXT_EXPAND = new KSubstOption("-kkv"); //$NON-NLS-1$ - public static final KSubstOption KSUBST_TEXT_EXPAND_LOCKER = new KSubstOption("-kkvl"); //$NON-NLS-1$ - public static final KSubstOption KSUBST_TEXT_VALUES_ONLY = new KSubstOption("-kv"); //$NON-NLS-1$ - public static final KSubstOption KSUBST_TEXT_KEYWORDS_ONLY = new KSubstOption("-kk"); //$NON-NLS-1$ - - /*** Default command output listener ***/ - protected static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new CommandOutputListener(); - - /** - * Prevents client code from instantiating us. - */ - protected Command() { } - - /** - * Provides the default command output listener which is used to accumulate errors. - * - * Subclasses can override this method in order to properly interpret information - * received from the server. - */ - protected ICommandOutputListener getDefaultCommandOutputListener() { - return DEFAULT_OUTPUT_LISTENER; - } - - /** - * Sends the command's arguments to the server. - * [template method] - *

              - * The default implementation sends all arguments. Subclasses may override - * this method to provide alternate behaviour. - *

              - * - * @param session the CVS session - * @param arguments the arguments that were supplied by the caller of execute() - */ - protected void sendArguments(Session session, String[] arguments) throws CVSException { - for (int i = 0; i < arguments.length; ++i) { - session.sendArgument(arguments[i]); - } - } - - /** - * Describes the local resource state to the server prior to command execution. - * [template method] - *

              - * Commands must override this method to inform the server about the state of - * local resources using the Entries, Modified, Unchanged, and Questionable - * requests as needed. - *

              - *

              - * This method should return the resources that are of interest to the - * Command#commandFinished() method. In most cases, it - * is the same resources that are provided but in some cases (e.g. Commit) - * the resources to be passed to the above method are different. - *

              - * - * @param session the CVS session - * @param globalOptions the global options for the command - * @param localOptions the local options for the command - * @param resources the resource arguments for the command - * @param monitor the progress monitor - * @return ICVSResource[] - */ - protected abstract ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException; - - /** - * Cleans up after command execution. - * [template method] - *

              - * The default implementation is a no-op. Subclasses may override this - * method to follow up command execution on the server with clean up - * operations on local resources. - *

              - * - * @param session the CVS session - * @param globalOptions the global options for the command - * @param localOptions the local options for the command - * @param resources the resource arguments for the command - * @param monitor the progress monitor - * @param status the status accumulated so far. If the code == CVSStatus.SERVER_ERROR - * then the command failed - * @return status the status past in plus any additional status accumulated during the finish - */ - protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, - IStatus status) throws CVSException { - return status; - } - - /** - * Sends the local working directory path prior to command execution. - * [template method] - *

              - * The default implementation sends the paths of local root directory - * (assuming it exists). Subclasses may override this method to provide - * alternate behaviour. - *

              - * - * @param session the CVS session - */ - protected void sendLocalWorkingDirectory(Session session) throws CVSException { - ICVSFolder localRoot = session.getLocalRoot(); - if (localRoot.isCVSFolder()) { - session.sendLocalRootDirectory(); - } else { - session.sendConstructedRootDirectory(); - } - } - - /** - * Computes an array of ICVSResources corresponding to command arguments. - * [template method] - *

              - * The default implementation assumes that all arguments supplied to the - * command represent resources in the local root that are to be manipulated. - * Subclasses must override this method if this assumption does not hold. - *

              - * @param session the CVS session - * @param localOptions the command local options - * @param arguments the command arguments - * @return the resource arguments for the command - */ - protected ICVSResource[] computeWorkResources(Session session, - LocalOption[] localOptions, String[] arguments) throws CVSException { - ICVSFolder localRoot = session.getLocalRoot(); - - if (arguments.length == 0) { - // As a convenience, passing no arguments to the CVS command - // implies the command will operate on the local root folder. - return new ICVSResource[] { localRoot }; - } else { - // Assume all arguments represent resources that are descendants - // of the local root folder. - ICVSResource[] resources = new ICVSResource[arguments.length]; - for (int i = 0; i < arguments.length; i++) { - ICVSResource resource = localRoot.getChild(arguments[i]); - // file does not exist, it could have been deleted. It doesn't matter - // which type we return since only the name of the resource is used - // and sent to the server. - if(resource==null) { - if(localRoot.getName().length()==0) { - // Return a folder because it is the safest choice when - // localRoot is a handle to the IWorkspaceRoot! - resource = localRoot.getFolder(arguments[i]); - } else { - resource = localRoot.getFile(arguments[i]); - } - } - resources[i] = resource; - } - return resources; - } - } - - /** - * Send an array of Resources. - * - * @see Command#sendFileStructure(ICVSResource,IProgressMonitor,boolean,boolean,boolean) - */ - protected void sendFileStructure(Session session, ICVSResource[] resources, - boolean emptyFolders, IProgressMonitor monitor) throws CVSException { - checkResourcesManaged(resources); - - new FileStructureVisitor(session, emptyFolders, true).visit(session, resources, monitor); - } - - /** - * Checks that all work resources are managed. - * - * @param resources the resource arguments for the command - * @throws CVSException if some resources are not managed - */ - protected void checkResourcesManaged(ICVSResource[] resources) throws CVSException { - for (int i = 0; i < resources.length; ++i) { - ICVSFolder folder; - if (resources[i].isFolder()) { - folder = (ICVSFolder) resources[i]; - } - else { - folder = resources[i].getParent(); - } - if (folder==null || (!folder.isCVSFolder() && folder.exists())) { - throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$ - } - } - } - - /** - * Executes a CVS command. - *

              - * Dispatches the commands, retrieves the results, and determines whether or - * not an error occurred. A listener may be supplied to capture message text - * that would normally be written to the standard error and standard output - * streams of a command line CVS client. - *

              - * @param session the open CVS session - * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS - * @param localOptions the array of local options, or NO_LOCAL_OPTIONS - * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS - * @param listener the command output listener, or null to discard all messages - * @param monitor the progress monitor - * @return a status code indicating success or failure of the operation - * @throws CVSException if a fatal error occurs (e.g. connection timeout) - */ - public final IStatus execute(final Session session, final GlobalOption[] globalOptions, - final LocalOption[] localOptions, final String[] arguments, final ICommandOutputListener listener, - IProgressMonitor pm) throws CVSException { - final IStatus[] status = new IStatus[1]; - ICVSRunnable job = new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - // update the global and local options - GlobalOption[] gOptions = filterGlobalOptions(session, globalOptions); - LocalOption[] lOptions = filterLocalOptions(session, gOptions, localOptions); - - // print the invocation string to the console - if (session.isOutputToConsole() || Policy.isDebugProtocol()) { - IPath commandRootPath; - IResource resource = session.getLocalRoot().getIResource(); - if (resource == null) { - commandRootPath = Path.EMPTY; - } else { - commandRootPath = resource.getFullPath(); - } - String line = constructCommandInvocationString(commandRootPath, gOptions, lOptions, arguments); - ConsoleListeners.getInstance().commandInvoked(session, line); - if (Policy.isDebugProtocol()) Policy.printProtocolLine("CMD> " + line); //$NON-NLS-1$ - } - - // run the command - try { - session.setCurrentCommand(Command.this); - status[0] = doExecute(session, gOptions, lOptions, arguments, listener, monitor); - notifyConsoleOnCompletion(session, status[0], null); - } catch (CVSException e) { - notifyConsoleOnCompletion(session, null, e); - throw e; - } catch (RuntimeException e) { - notifyConsoleOnCompletion(session, null, e); - throw e; - } - } - }; - if (isWorkspaceModification()) { - session.getLocalRoot().run(job, pm); - } else { - job.run(pm); - } - return status[0]; - } - - /** - * Return whether this command modifies the workspace. - * If true is returned, a scheduling rule on - * the session local root is obtained. Otherwise, no - * scheduling rule is obtained. By default, true - * is returned - * @return whether this command modifies the workspace - */ - protected boolean isWorkspaceModification() { - return true; - } - - private void notifyConsoleOnCompletion(Session session, IStatus status, Exception exception) { - ConsoleListeners.getInstance().commandCompleted(session, status, exception); - if (Policy.isDebugProtocol()) { - if (status != null) Policy.printProtocolLine("RESULT> " + status.toString()); //$NON-NLS-1$ - else Policy.printProtocolLine("RESULT> " + exception.toString()); //$NON-NLS-1$ - } - } - - protected IStatus doExecute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener, - IProgressMonitor monitor) throws CVSException { - ICVSResource[] resources = null; - /*** setup progress monitor ***/ - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - Policy.checkCanceled(monitor); - try { - /*** prepare for command ***/ - // clear stale command state from previous runs - session.setNoLocalChanges(DO_NOT_CHANGE.isElementOf(globalOptions)); - session.setModTime(null); - - /*** initiate command ***/ - // send global options - for (int i = 0; i < globalOptions.length; i++) { - globalOptions[i].send(session); - } - Policy.checkCanceled(monitor); - // send local options - for (int i = 0; i < localOptions.length; i++) { - localOptions[i].send(session); - } - Policy.checkCanceled(monitor); - // compute the work resources - resources = computeWorkResources(session, localOptions, arguments); - Policy.checkCanceled(monitor); - // send local working directory state contributes 48% of work - resources = sendLocalResourceState(session, globalOptions, localOptions, - resources, Policy.infiniteSubMonitorFor(monitor, 48)); - Policy.checkCanceled(monitor); - // send arguments - sendArguments(session, arguments); - // send local working directory path - sendLocalWorkingDirectory(session); - - // if no listener was provided, use the command's default in order to get error reporting - if (listener == null) listener = getDefaultCommandOutputListener(); - - /*** execute command and process responses ***/ - // Processing responses contributes 50% of work. - IStatus status = executeRequest(session, listener, Policy.subMonitorFor(monitor, 50)); - - // Finished adds last 2% of work. - status = commandFinished(session, globalOptions, localOptions, resources, Policy.subMonitorFor(monitor, 2), - status); - return status; - } finally { - monitor.done(); - } - } - - /** - * Constucts the CVS command invocation string corresponding to the arguments. - * - * @param globalOptions the global options - * @param localOption the local options - * @param arguments the arguments - * @return the command invocation string - */ - private String constructCommandInvocationString(IPath commandRootPath, GlobalOption[] globalOptions, - LocalOption[] localOptions, String[] arguments) { - StringBuffer commandLine = new StringBuffer("cvs"); //$NON-NLS-1$ - for (int i = 0; i < globalOptions.length; ++i) { - String option = globalOptions[i].toString(); - if (option.length() == 0) continue; - commandLine.append(' '); - commandLine.append(option); - } - commandLine.append(' '); - commandLine.append(getRequestId()); - for (int i = 0; i < localOptions.length; ++i) { - String option = localOptions[i].toString(); - if (option.length() == 0) continue; - commandLine.append(' '); - commandLine.append(option); - } - for (int i = 0; i < arguments.length; ++i) { - if (arguments[i].length() == 0) continue; - commandLine.append(" \""); //$NON-NLS-1$ - IPath completePath = commandRootPath; - if (!arguments[i].equals(Session.CURRENT_LOCAL_FOLDER)) { - completePath = completePath.append(arguments[i]); - } - commandLine.append(completePath.toString()); - commandLine.append('"'); //$NON-NLS-1$ - } - return commandLine.toString(); - } - - /** - * Superclass for all CVS command options - */ - protected static abstract class Option { - protected String option, argument; - protected Option(String option, String argument) { - this.option = option; - this.argument = argument; - } - /** - * Determines if this option is an element of an array of options - * @param array the array of options - * @return true iff the array contains this option - */ - public boolean isElementOf(Option[] array) { - return findOption(array, option) != null; - } - /** - * Returns the option part of the option - */ - String getOption() { - return option; - } - /** - * Compares two options for equality. - * @param other the other option - */ - public boolean equals(Object other) { - if (this == other) return true; - if (other instanceof Option) { - Option otherOption = (Option) other; - return option.equals(otherOption.option); - } - return false; - } - /** - * Sends the option to a CVS server - * @param session the CVS session - */ - public abstract void send(Session session) throws CVSException; - /* - * To make debugging a tad easier. - */ - public String toString() { - if (argument != null && argument.length() != 0) { - return option + " \"" + argument + '"'; //$NON-NLS-1$ - } else { - return option; - } - } - } - /** - * Option subtype for global options that are common to all commands. - */ - public static class GlobalOption extends Option { - protected GlobalOption(String option) { - super(option, null); - } - public void send(Session session) throws CVSException { - session.sendGlobalOption(option); - } - /** - * Add the given global option to the end of the provided list - * - * @param newOption - * @param options - * @return GlobalOption[] - */ - protected GlobalOption[] addToEnd(GlobalOption[] options) { - GlobalOption[] globalOptions = new GlobalOption[options.length + 1]; - System.arraycopy(options, 0, globalOptions, 0, options.length); - globalOptions[globalOptions.length - 1] = this; - return globalOptions; - } - } - /** - * Option subtype for global quietness options. - */ - public static final class QuietOption extends GlobalOption { - private QuietOption(String option) { - super(option); - } - public void send(Session session) throws CVSException { - if (option.length() != 0) super.send(session); - } - } - /** - * Option subtype for local options that vary from command to command. - */ - public static class LocalOption extends Option { - protected LocalOption(String option) { - super(option, null); - } - protected LocalOption(String option, String argument) { - super(option, argument); - } - public void send(Session session) throws CVSException { - session.sendArgument(option); - if (argument != null) session.sendArgument(argument); - } - } - /** - * Options subtype for keyword substitution options. - */ - public static class KSubstOption extends LocalOption { - private boolean isUnknownMode; - private KSubstOption(String option) { - this(option, false); - } - private KSubstOption(String option, boolean isUnknownMode) { - super(option); - this.isUnknownMode = isUnknownMode; - ksubstOptionMap.put(option, this); - } - /** - * Gets the KSubstOption instance for the specified mode. - * - * @param mode the mode, e.g. -kb - * @return an instance for that mode - */ - public static KSubstOption fromMode(String mode) { - if (mode.length() == 0) mode = "-kkv"; // use default //$NON-NLS-1$ - KSubstOption option = (KSubstOption) ksubstOptionMap.get(mode); - if (option == null) option = new KSubstOption(mode, true); - return option; - } - /** - * Gets the KSubstOption instance for the specified file. - * - * @param file the file to get the option for - * @return an instance for that mode - */ - public static KSubstOption fromFile(IFile file) { - if (CVSProviderPlugin.isText(file)) - return getDefaultTextMode(); - return KSUBST_BINARY; - } - /** - * Returns an array of all valid modes. - */ - public static KSubstOption[] getAllKSubstOptions() { - return (KSubstOption[]) ksubstOptionMap.values().toArray(new KSubstOption[ksubstOptionMap.size()]); - } - /** - * Returns the entry line mode string for this instance. - */ - public String toMode() { - if (KSUBST_TEXT_EXPAND.equals(this)) return ""; //$NON-NLS-1$ - return getOption(); - } - /** - * Returns true if the substitution mode requires no data translation - * during file transfer. - */ - public boolean isBinary() { - return KSUBST_BINARY.equals(this); - } - /** - * Returns a short localized text string describing this mode. - */ - public String getShortDisplayText() { - if (isUnknownMode) return Policy.bind("KSubstOption.unknown.short", option); //$NON-NLS-1$ - return Policy.bind("KSubstOption." + option + ".short"); //$NON-NLS-1$ //$NON-NLS-2$ - } - /** - * Returns a long localized text string describing this mode. - */ - public String getLongDisplayText() { - if (isUnknownMode) return Policy.bind("KSubstOption.unknown.long", option); //$NON-NLS-1$ - return Policy.bind("KSubstOption." + option + ".long"); //$NON-NLS-1$ //$NON-NLS-2$ - } - /** - * Return the text mode that will be used by default - */ - public static KSubstOption getDefaultTextMode() { - return CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - } - } - - /** - * Makes a -m log message option. - * Valid for: add commit import - */ - public static LocalOption makeArgumentOption(LocalOption option, String argument) { - if(argument == null) { - argument = ""; //$NON-NLS-1$ - } - return new LocalOption(option.getOption(), argument); //$NON-NLS-1$ - } - - /** - * Makes a -r or -D option for a tag. - * Valid for: checkout export history rdiff update - */ - public static LocalOption makeTagOption(CVSTag tag) { - int type = tag.getType(); - switch (type) { - case CVSTag.BRANCH: - case CVSTag.VERSION: - return new LocalOption("-r", tag.getName()); //$NON-NLS-1$ - case CVSTag.DATE: - return new LocalOption("-D", tag.getName()); //$NON-NLS-1$ - default: - // tag must not be HEAD - throw new IllegalArgumentException(Policy.bind("Command.invalidTag")); //$NON-NLS-1$ - } - } - - /** - * Find a specific option in an array of options - * @param array the array of options - * @param option the option string to search for - * @return the first element matching the option string, or null if none - */ - public static Option findOption(Option[] array, String option) { - for (int i = 0; i < array.length; ++i) { - if (array[i].getOption().equals(option)) return array[i]; - } - return null; - } - - /** - * Collect all arguments of a specific option from an array of options - * @param array the array of options - * @param option the option string to search for - * @return an array of all arguments of belonging to matching options - */ - protected static String[] collectOptionArguments(Option[] array, String option) { - List /* of String */ list = new ArrayList(); - for (int i = 0; i < array.length; ++i) { - if (array[i].getOption().equals(option)) { - list.add(array[i].argument); - } - } - return (String[]) list.toArray(new String[list.size()]); - } - - /** - * Allows commands to filter the set of global options to be sent. - * This method invokes the method of the same name on the session - * itself in order to get any session wide or globally set options. - * Subclasses that override this method should call the superclass. - * - * @param session the session - * @param globalOptions the global options, read-only - * @return the filtered global options - */ - protected GlobalOption[] filterGlobalOptions(Session session, GlobalOption[] globalOptions) { - return session.filterGlobalOptions(globalOptions); - } - - /** - * Allows commands to filter the set of local options to be sent. - * Subclasses that override this method should call the superclass. - * - * @param session the session - * @param globalOptions the global options, read-only - * @param localOptions the local options, read-only - * @return the filtered local options - */ - protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) { - return localOptions; - } - - /** - * Execute a CVS command on an array of ICVSResource. This method simply converts - * the ICVSResource to String paths relative to the local root of the session and - * invokes execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor). - *

              - * @param session the open CVS session - * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS - * @param localOptions the array of local options, or NO_LOCAL_OPTIONS - * @param arguments the array of ICVSResource to be operated on - * @param listener the command output listener, or null to discard all messages - * @param monitor the progress monitor - * @return a status code indicating success or failure of the operation - * @throws CVSException if a fatal error occurs (e.g. connection timeout) - * - * @see Command#execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor) - */ - public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] arguments, - ICommandOutputListener listener, IProgressMonitor pm) throws CVSException { - - String[] stringArguments = convertArgumentsForOpenSession(arguments, session); - return execute(session, globalOptions, localOptions, stringArguments, listener, pm); - } - - protected String[] convertArgumentsForOpenSession(ICVSResource[] arguments, Session openSession) throws CVSException { - // Convert arguments - List stringArguments = new ArrayList(arguments.length); - for (int i = 0; i < arguments.length; i++) { - stringArguments.add(arguments[i].getRelativePath(openSession.getLocalRoot())); - } - return (String[]) stringArguments.toArray(new String[stringArguments.size()]); - } - - /** - * Method mergeStatus. - * @param status - * @param cVSStatus - * @return IStatus - */ - protected IStatus mergeStatus(IStatus accumulatedStatus, IStatus newStatus) { - if (accumulatedStatus.isMultiStatus()) { - ((MultiStatus)accumulatedStatus).merge(newStatus); - return accumulatedStatus; - } - if (accumulatedStatus.isOK()) return newStatus; - if (newStatus.isOK()) return accumulatedStatus; - MultiStatus result = new MultiStatus(CVSProviderPlugin.ID, CVSStatus.INFO, - new IStatus[] {accumulatedStatus, newStatus}, - Policy.bind("Command.warnings", Policy.bind("Command." + getRequestId())), null); //$NON-NLS-1$ //$NON-NLS-2$ - return result; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java deleted file mode 100644 index e510598d7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; - -public class CommandOutputListener implements ICommandOutputListener { - - /* - * Failure string that is returned from the server when pserver is used and the root directory - * is not readable. The problem can be fixed by making the directory readable or by using -f in - * the pserver configuration file. We will ignore the error since it does not affect the command. - */ - public static final String ROOT_CVSIGNORE_READ_FAILURE = "cvs server: cannot open /root/.cvsignore: Permission denied"; //$NON-NLS-1$ - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - return OK; - } - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String protocolError = getProtocolError(line, location); - if (protocolError != null) { - return new CVSStatus(CVSStatus.ERROR, CVSStatus.PROTOCOL_ERROR, commandRoot, protocolError); - } - if (line.equals(ROOT_CVSIGNORE_READ_FAILURE) || getServerMessage(ROOT_CVSIGNORE_READ_FAILURE, location).equals(getServerMessage(line, location))) { - // Don't report this as an error since it does not affect the command - return new CVSStatus(CVSStatus.WARNING, CVSStatus.ERROR_LINE, commandRoot, line); - } - return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, commandRoot, line); - } - - /** - * Return the portion of the line that describes the error if the error line - * is a protocol error or null if the line is not a protocol error. - * - * @param line the error line received from the server - * @param location the repository location - * @return String the potocol error or null - */ - protected String getProtocolError(String line, ICVSRepositoryLocation location) { - if (line.startsWith("Protocol error:")) { //$NON-NLS-1$ - return line; - } - return null; - } - - public String getServerMessage(String line, ICVSRepositoryLocation location) { - return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_PREFIX); - } - - public String getServerAbortedMessage(String line, ICVSRepositoryLocation location) { - return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_ABORTED_PREFIX); - } - - public String getServerRTagMessage(String line, ICVSRepositoryLocation location) { - return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, RTAG_PREFIX); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java deleted file mode 100644 index 7f0e8de7d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.Collection; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; - -public class Commit extends Command { - /*** Local options: specific to commit ***/ - // Forces a file to be committed even if it has not been modified; implies -l. - // NOTE: This option is not fully supported -- a file will not be sent - // unless it is dirty. The primary use is to resend a file that may - // or may not be changed (e.g. could depend on CR/LF translations, etc...) - // and force the server to create a new revision and reply Checked-in. - public static final LocalOption FORCE = new LocalOption("-f"); //$NON-NLS-1$ - - protected Commit() { } - protected String getRequestId() { - return "ci"; //$NON-NLS-1$ - } - - /** - * Send all files under the workingFolder as changed files to - * the server. - */ - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Get the folders we want to work on - checkResourcesManaged(resources); - - // Send all changed files to the server - ModifiedFileSender visitor = new ModifiedFileSender(session); - visitor.visit(session, resources, monitor); - - // Send the changed files as arguments (because this is what other cvs clients do) - ICVSFile[] changedFiles = visitor.getModifiedFiles(); - for (int i = 0; i < changedFiles.length; i++) { - session.sendArgument(changedFiles[i].getRelativePath(session.getLocalRoot())); - } - return changedFiles; - } - - /** - * On successful finish, prune empty directories if the -P or -D option was specified. - */ - protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, - IStatus status) throws CVSException { - // If we didn't succeed, don't do any post processing - if (status.getCode() == CVSStatus.SERVER_ERROR) { - return status; - } - - // If pruning is enable, prune empty directories after a commit - if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { //$NON-NLS-1$ - new PruneFolderVisitor().visit(session, resources); - } - - // Reset the timestamps of any committed files that are still dirty. - // Only do so if there were no E messages from the server - if (status.isOK()) { - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - if (!resource.isFolder()) { - ICVSFile cvsFile = (ICVSFile)resources[i]; - if (cvsFile.exists() && cvsFile.isModified(null)) { - status = mergeStatus(status, clearModifiedState(cvsFile)); - } - } - } - } - return status; - } - - protected IStatus clearModifiedState(ICVSFile cvsFile) throws CVSException { - byte[] info = cvsFile.getSyncBytes(); - if (info == null) { - // There should be sync info. Log the problem - return new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0, Policy.bind("Commit.syncInfoMissing", cvsFile.getIResource().getFullPath().toString()), null); //$NON-NLS-1$ - } - cvsFile.checkedIn(null, true /* commit in progress */); - return new Status(IStatus.INFO, CVSProviderPlugin.ID, 0, Policy.bind("Commit.timestampReset", cvsFile.getIResource().getFullPath().toString()), null); //$NON-NLS-1$; - } - - /** - * We do not want to send the arguments here, because we send - * them in sendRequestsToServer (special handling). - */ - protected void sendArguments(Session session, String[] arguments) throws CVSException { - } - - public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, - ICVSResource[] arguments, Collection filesToCommitAsText, - ICommandOutputListener listener, IProgressMonitor pm) throws CVSException { - - session.setTextTransferOverride(filesToCommitAsText); - try { - return super.execute(session, globalOptions, localOptions, arguments, listener, pm); - } finally { - session.setTextTransferOverride(null); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java deleted file mode 100644 index fb3b29b98..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener; - -/** - * Class which forwards CVS console output to 1 or more - * registered console listeners. - */ -public class ConsoleListeners implements IConsoleListener { - - private static ConsoleListeners instance = new ConsoleListeners(); - private Set listeners = new HashSet(); - - /** - * Return the console listeners - * @return the console listeners - */ - public static ConsoleListeners getInstance() { - return instance; - } - - public void addListener(IConsoleListener listener) { - synchronized(listeners) { - listeners.add(listener); - } - } - - public void removeListener(IConsoleListener listener) { - synchronized(listeners) { - listeners.remove(listener); - } - } - - private IConsoleListener[] getListeners() { - synchronized(listeners) { - return (IConsoleListener[]) listeners.toArray(new IConsoleListener[listeners.size()]); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandInvoked(java.lang.String) - */ - public void commandInvoked(final Session session, final String line) { - if (listeners.isEmpty()) return; - IConsoleListener[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IConsoleListener listener = listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exception logged by Platform - } - public void run() throws Exception { - listener.commandInvoked(session, line); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#messageLineReceived(java.lang.String) - */ - public void messageLineReceived(final Session session, final String line, final IStatus status) { - if (listeners.isEmpty()) return; - IConsoleListener[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IConsoleListener listener = listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exception logged by Platform - } - public void run() throws Exception { - listener.messageLineReceived(session, line, status); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#errorLineReceived(java.lang.String) - */ - public void errorLineReceived(final Session session, final String line, final IStatus status) { - if (listeners.isEmpty()) return; - IConsoleListener[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IConsoleListener listener = listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exception logged by Platform - } - public void run() throws Exception { - listener.errorLineReceived(session, line, status); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandCompleted(org.eclipse.core.runtime.IStatus, java.lang.Exception) - */ - public void commandCompleted(final Session session, final IStatus status, final Exception exception) { - if (listeners.isEmpty()) return; - IConsoleListener[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IConsoleListener listener = listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exception logged by Platform - } - public void run() throws Exception { - listener.commandCompleted(session, status, exception); - } - }); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java deleted file mode 100644 index 67f042950..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Handles a "Copy-file" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Copy-file myproject/ \n
              - *   /u/cvsroot/myproject/oldfile.txt \n
              - *   newfile.txt
              - *   [...]
              - * 
              - * Then we copy (or optionally rename) the local file "oldfile.txt" in - * folder "myproject" to "newfile.txt". This response is used to create - * a backup copy of an existing file before merging in new changes. - *

              - */ -class CopyHandler extends ResponseHandler { - public String getResponseID() { - return "Copy-file"; //$NON-NLS-1$ - } - - public void handle(Session session, String localDir, - IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryFile = session.readLine(); - String newFile = session.readLine(); - if (session.isNoLocalChanges() || ! session.isCreateBackups()) return; - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - ICVSFile mFile = mParent.getFile(fileName); - - Assert.isTrue(mParent.exists()); - Assert.isTrue(mFile.exists() && mFile.isManaged()); - - // rename the file - mFile.copyTo(newFile); - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java deleted file mode 100644 index dc32ec188..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; - -/** - * Runs the CVS diff command. - */ -public class Diff extends Command { - /*** Local options: specific to diff ***/ - public static final LocalOption UNIFIED_FORMAT = new LocalOption("-u"); //$NON-NLS-1$ - public static final LocalOption CONTEXT_FORMAT = new LocalOption("-c"); //$NON-NLS-1$ - public static final LocalOption INCLUDE_NEWFILES = new LocalOption("-N"); //$NON-NLS-1$ - public static final LocalOption BRIEF = new LocalOption("--brief"); //$NON-NLS-1$ - - protected Diff() { } - protected String getRequestId() { - return "diff"; //$NON-NLS-1$ - } - - /** - * Overwritten to throw the CVSDiffException if the server returns an error, because it just does - * so when there is a difference between the checked files. - */ - protected IStatus doExecute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, - String[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) throws CVSException { - try { - return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor); - } catch (CVSServerException e) { - if (e.containsErrors()) throw e; - return e.getStatus(); - } - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - checkResourcesManaged(resources); - DiffStructureVisitor visitor = new DiffStructureVisitor(session); - visitor.visit(session, resources, monitor); - return resources; - } - - protected String getServerErrorMessage() { - return Policy.bind("Diff.serverError"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java deleted file mode 100644 index 3dcf82cb3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * The diff command needs to send a file structure to the server that differs somewhat from the canonical - * format sent by other commands. Instead of sending new files as questionables this class sends - * new files as modified and fakes them being added. The contents are sent to the server and are - * included in the returned diff report. - */ -class DiffStructureVisitor extends FileStructureVisitor { - - public DiffStructureVisitor(Session session) { - super(session, false, true); - } - - /** - * Send unmanaged files as modified with a default entry line. - */ - protected void sendFile(ICVSFile mFile) throws CVSException { - byte[] info = mFile.getSyncBytes(); - if (info==null) { - return; - } - - // Send the parent folder if it hasn't been sent already - sendFolder(mFile.getParent()); - Policy.checkCanceled(monitor); - session.sendEntry(info, null); - - if (!mFile.exists()) { - return; - } - - if (mFile.isModified(null)) { - session.sendModified(mFile, ResourceSyncInfo.isBinary(info), monitor); - } else { - session.sendUnchanged(mFile); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java deleted file mode 100644 index 15fdbc653..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -/** - * - * The editors command - * - * @author Gregor Kohlwes - */ -public class Editors extends AbstractMessageCommand { - - /** - * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId() - */ - protected String getRequestId() { - return "editors"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification() - */ - protected boolean isWorkspaceModification() { - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java deleted file mode 100644 index 55364fd36..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; - -public class ExpandModules extends Request { - protected ExpandModules() { } - protected String getRequestId() { - return "expand-modules"; //$NON-NLS-1$ - } - - public IStatus execute(Session session, String[] modules, IProgressMonitor monitor) throws CVSException { - // Reset the module expansions before the responses arrive - session.resetModuleExpansion(); - for (int i = 0; i < modules.length; ++i) { - session.sendArgument(modules[i]); - } - return executeRequest(session, Command.DEFAULT_OUTPUT_LISTENER, monitor); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java deleted file mode 100644 index 6e10dcb30..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -/** - * Visitor to send the local file structure to the CVS Server. - * - * Files are sent as Unchanged or Modified. - * Folders are sent if they contain files unless sendEmptyFolders is true - * in which case all folders are sent. - * - * @param sendEmptyFolders sends the folder-entrie even if there is no file - to send in it - */ - -class FileStructureVisitor extends AbstractStructureVisitor { - - private boolean sendEmptyFolders; - - public FileStructureVisitor(Session session, boolean sendEmptyFolders, boolean sendModifiedContents) { - this(session, sendEmptyFolders, sendModifiedContents, true); - } - - public FileStructureVisitor(Session session, boolean sendEmptyFolders, boolean sendModifiedContents, boolean sendBinary) { - super(session, true, sendModifiedContents, sendBinary); - this.sendEmptyFolders = sendEmptyFolders; - } - - /** - * @see ICVSResourceVisitor#visitFile(IManagedFile) - */ - public void visitFile(ICVSFile mFile) throws CVSException { - sendFile(mFile); - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder mFolder) throws CVSException { - - if (sendEmptyFolders) { - // If we want to send empty folder, that just send it when - // we come to it - sendFolder(mFolder); - } - - boolean exists = mFolder.exists(); - boolean isCVSFolder = mFolder.isCVSFolder(); - - // We are only interested in CVS folders - // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions - if ( ! isCVSFolder) return; - - if (exists && isOrphanedSubtree(mFolder)) { - return; - } - - // Send files, then the questionable folders, then the managed folders - ICVSResource[] children = mFolder.members(ICVSFolder.ALL_UNIGNORED_MEMBERS); - sendFiles(children); - sendQuestionableFolders(children); - sendManagedFolders(children); - } - - /** - * Method sendManagedFolders. - * @param children - */ - private void sendManagedFolders(ICVSResource[] children) throws CVSException { - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if (resource.isFolder() && resource.isManaged()) { - resource.accept(this); - } - } - } - - /** - * Method sendQuestionableFolders. - * @param children - */ - private void sendQuestionableFolders(ICVSResource[] children) throws CVSException { - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if (resource.isFolder() && ! resource.isManaged()) { - resource.accept(this); - } - } - } - - /** - * Method sendFiles. - * @param children - */ - private void sendFiles(ICVSResource[] children) throws CVSException { - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if (!resource.isFolder()) { - resource.accept(this); - } - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java deleted file mode 100644 index e654bf075..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; - - -public class Import extends Command { - /*** Local options: specific to import ***/ - public static LocalOption makeBinaryWrapperOption(String pattern) { - return new LocalOption("-W", pattern + " -k 'b'"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - protected Import() { } - protected String getRequestId() { - return "import"; //$NON-NLS-1$ - } - - protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, - String[] arguments) throws CVSException { - if (arguments.length < 3) throw new IllegalArgumentException(); - return new ICVSResource[0]; - } - - protected IStatus doExecute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener, - IProgressMonitor monitor) throws CVSException { - - // If the branch option is not provided, a default value of 1.1.1 is used. - // This is done to maintain reference client compatibility - if (findOption(localOptions, "-b") == null) { //$NON-NLS-1$ - LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1]; - newLocalOptions[0] = new LocalOption("-b", "1.1.1"); //$NON-NLS-1$ //$NON-NLS-2$ - System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length); - localOptions = newLocalOptions; - } - return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor); - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - ICVSResourceVisitor visitor = new ImportStructureVisitor(session, - collectOptionArguments(localOptions, "-W"), monitor); //$NON-NLS-1$ - session.getLocalRoot().accept(visitor); - return resources; - } - - protected void sendLocalWorkingDirectory(Session session) throws CVSException { - session.sendConstructedRootDirectory(); - } - -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java deleted file mode 100644 index df7265f5c..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.Team; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher; - -/** - * The ImportStructureVisitor sends the content of the folder it is - * used on to the server. It constructs the locations of the resources - * because the resources do not yet have a remote-location.
              - * It can also ignore certain files and decides wether to send - * a file in binary or text mode due to a specification that is passed - * as a "wrapper" argument. - */ -class ImportStructureVisitor implements ICVSResourceVisitor { - - private static final String KEYWORD_OPTION = "-k"; //$NON-NLS-1$ - private static final String QUOTE = "'"; //$NON-NLS-1$ - - protected Session session; - protected IProgressMonitor monitor; - - private FileNameMatcher ignoreMatcher; - private FileNameMatcher wrapMatcher; - - /** - * Constructor for ImportStructureVisitor. - * @param requestSender - * @param mRoot - * @param monitor - */ - public ImportStructureVisitor(Session session, - String[] wrappers, IProgressMonitor monitor) { - - this.session = session; - this.monitor = Policy.infiniteSubMonitorFor(monitor, 512); - wrapMatcher = initWrapMatcher(wrappers); - } - - - /** - * Inits the wrapMatcher, that is responsible to find out - * whether a file is to be send as a binary (on an import) - * or not. - * - * Takes wrappers of this format: - * *.class -k 'o' - * - * and inits the FileNameMatcher to give - * -ko back if you call it with match("somename.class") - * - * ignores all wrappers, that do not contain -k - */ - private FileNameMatcher initWrapMatcher(String[] wrappers) { - - FileNameMatcher wrapMatcher; - - if (wrappers == null) { - return null; - } - - wrapMatcher = new FileNameMatcher(); - - for (int i = 0; i < wrappers.length; i++) { - - if (wrappers[i].indexOf(KEYWORD_OPTION) == -1) { - continue; - } - - StringTokenizer st = new StringTokenizer(wrappers[i]); - String pattern = st.nextToken(); - String option = st.nextToken(); - // get rid of the quotes - StringTokenizer quoteSt = - new StringTokenizer(st.nextToken(),QUOTE); - option += quoteSt.nextToken(); - - wrapMatcher.register(pattern,option); - } - - return wrapMatcher; - } - - /** - * @see ICVSResourceVisitor#visitFile(IManagedFile) - */ - public void visitFile(ICVSFile mFile) throws CVSException { - if (ignoreMatcher != null && ignoreMatcher.match(mFile.getName())) { - return; - } - - boolean binary = Team.getType((IFile)mFile.getIResource()) == Team.BINARY; - if (wrapMatcher != null) { - String mode = wrapMatcher.getMatch(mFile.getName()); - if (mode != null) binary = KSubstOption.fromMode(mode).isBinary(); - } - session.sendModified(mFile, binary, monitor); - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder mFolder) throws CVSException { - - if (ignoreMatcher != null && ignoreMatcher.match(mFolder.getName())) { - return; - } - - String localPath = mFolder.getRelativePath(session.getLocalRoot()); - monitor.subTask(Policy.bind("AbstractStructureVisitor.sendingFolder", localPath)); //$NON-NLS-1$ - - session.sendConstructedDirectory(localPath); - mFolder.acceptChildren(this); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java deleted file mode 100644 index d82420872..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -public class Log extends AbstractMessageCommand { - /*** Local options: specific to log ***/ - - public static LocalOption makeRevisionOption(String revision) { - return new LocalOption("-r" + revision, null); //$NON-NLS-1$ - } - public static final LocalOption RCS_FILE_NAMES_ONLY = new LocalOption("-R"); //$NON-NLS-1$ - - public static final LocalOption NO_TAGS = new LocalOption("-N"); //$NON-NLS-1$ - - protected Log() { } - protected String getRequestId() { - return "log"; //$NON-NLS-1$ - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Send all folders that are already managed to the server - boolean sendEmptyFolders = Command.findOption(localOptions, RCS_FILE_NAMES_ONLY.getOption()) != null; - new FileStructureVisitor(session, sendEmptyFolders, false /* send modified contents */).visit(session, resources, monitor); - return resources; - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java deleted file mode 100644 index 6e7f20fc3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; - -public class MTHandler extends ResponseHandler { - - private String nextLine; - private boolean isLineAvailable; - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getInstance() - */ - ResponseHandler getInstance() { - return new MTHandler(); - } - - /** - * @see ResponseHandler#getResponseID() - */ - public String getResponseID() { - return "MT"; //$NON-NLS-1$ - } - - /** - * @see ResponseHandler#handle(Session, String, IProgressMonitor) - */ - public void handle(Session session, String argument, IProgressMonitor monitor) - throws CVSException { - - // If there was a line available from before, clear it - if (isLineAvailable()) { - startNextLine(); - } - - if (argument.charAt(0) == '+') { - // Reset any previously accumulated text - startNextLine(); - } else if (argument.charAt(0) == '-') { - // Mark the line as available in case there was no trailing newline - if (nextLine != null) { - isLineAvailable = true; - } - } else { - // Extract the tag and text from the line - String tag; - String text; - int spaceIndex = argument.indexOf(' '); - if (spaceIndex == -1) { - tag = argument; - text = null; - } else { - tag = argument.substring(0, spaceIndex); - text = argument.substring(spaceIndex + 1); - } - - // Accumulate the line and indicate if its available for use - if (tag.equals("newline")) { //$NON-NLS-1$ - isLineAvailable = true; - } else if (text != null) { - // Reset the previous line if required - if (isLineAvailable()) { - startNextLine(); - } - // Accumulate the line - if (nextLine == null) { - nextLine = text; - } else { - // The text from the sevrver contains spaces when appropriate so just append - nextLine = nextLine + text; - } - } - } - } - - /** - * Check if there is a line available. If there is, it should be fetched with - * getLine() immediatly before the next MT response is processed. - */ - public boolean isLineAvailable() { - return isLineAvailable; - } - - /** - * Get the available line. This purges the line from the handler - */ - public String getLine() { - return nextLine; - } - - private void startNextLine() { - isLineAvailable = false; - nextLine = null; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java deleted file mode 100644 index 7ccc793e4..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.text.ParseException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter; - -/** - * Handles a "Mod-time" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Mod-time 18 Oct 2001 20:21:13 -0330\n
              - *   [...]
              - * 
              - * Then we parse and remember the date for use in subsequent - * file transfer responses such as Updated. - *

              - */ -class ModTimeHandler extends ResponseHandler { - public String getResponseID() { - return "Mod-time"; //$NON-NLS-1$ - } - - public void handle(Session session, String timeStamp, - IProgressMonitor monitor) throws CVSException { - try { - session.setModTime(CVSDateFormatter.serverStampToDate(timeStamp)); - } catch (ParseException e) { - throw new CVSException(Policy.bind("ModTimeHandler.invalidFormat", timeStamp), e); //$NON-NLS-1$ - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java deleted file mode 100644 index 7496408cc..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; - -/** - * Visit the CVS file structure, only sending files if they are modified. - */ -class ModifiedFileSender extends FileStructureVisitor { - - private final Set modifiedFiles; - - public ModifiedFileSender(Session session) { - super(session, false, true); - modifiedFiles = new HashSet(); - } - - /** - * Override sendFile to only send modified files - */ - protected void sendFile(ICVSFile mFile) throws CVSException { - // Only send the file if its modified - if (mFile.isManaged() && mFile.isModified(null)) { - super.sendFile(mFile); - modifiedFiles.add(mFile); - } - } - - protected String getSendFileTitleKey() { - return null; - } - - /** - * Return all the files that have been send to the server - */ - public ICVSFile[] getModifiedFiles() { - return (ICVSFile[]) modifiedFiles.toArray(new ICVSFile[modifiedFiles.size()]); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java deleted file mode 100644 index f4797416a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; - -public class ModuleExpansionHandler extends ResponseHandler { - - /* - * @see ResponseHandler#getResponseID() - */ - public String getResponseID() { - return "Module-expansion";//$NON-NLS-1$ - } - - /* - * @see ResponseHandler#handle(Session, String, IProgressMonitor) - */ - public void handle(Session session, String expansion, IProgressMonitor monitor) - throws CVSException { - - session.addModuleExpansion(expansion); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java deleted file mode 100644 index f2cc644de..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -/** - * Noop command that sends edit notifications to the server. - */ -public class NOOPCommand extends Command { - - /** - * @see org.eclipse.team.internal.ccvs.core.client.Command#sendLocalResourceState(Session, GlobalOption[], LocalOption[], ICVSResource[], IProgressMonitor) - */ - protected ICVSResource[] sendLocalResourceState( - Session session, - GlobalOption[] globalOptions, - LocalOption[] localOptions, - ICVSResource[] resources, - IProgressMonitor monitor) - throws CVSException { - - // The noop visitor will send any pending notifications - new NOOPVisitor(session).visit(session, resources, monitor); - return resources; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId() - */ - protected String getRequestId() { - return "noop"; //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.Command#sendArguments(Session, String[]) - */ - protected void sendArguments(Session session, String[] arguments)throws CVSException { - // don't send any arguments - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification() - */ - protected boolean isWorkspaceModification() { - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java deleted file mode 100644 index c16a3ae50..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -/** - * Send the contents of the CVS/Notify files to the server - */ -public class NOOPVisitor extends AbstractStructureVisitor { - - public NOOPVisitor(Session session) { - // Only send non-empty folders - super(session, false, false); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor#visitFile(ICVSFile) - */ - public void visitFile(ICVSFile file) throws CVSException { - sendPendingNotification(file); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder folder) throws CVSException { - if (folder.isCVSFolder()) { - folder.acceptChildren(this); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java deleted file mode 100644 index 2b143e9f1..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -public class NewEntryHandler extends ResponseHandler { - - /* - * @see ResponseHandler#getResponseID() - */ - public String getResponseID() { - return "New-entry"; //$NON-NLS-1$ - } - - /* - * @see ResponseHandler#handle(Session, String, IProgressMonitor) - */ - public void handle(Session session, String localDir, IProgressMonitor monitor) - throws CVSException { - - // read additional data for the response - String repositoryFile = session.readLine(); - String entryLine = session.readLine(); - - // Clear the recorded mod-time - session.setModTime(null); - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - ICVSFile mFile = mParent.getFile(fileName); - - ResourceSyncInfo fileInfo = mFile.getSyncInfo(); - MutableResourceSyncInfo newInfo = fileInfo.cloneMutable(); - newInfo.setEntryLine(entryLine); - mFile.setSyncInfo(newInfo, ICVSFile.UNKNOWN); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java deleted file mode 100644 index 465b7b754..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class NotifiedHandler extends ResponseHandler { - - /** - * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getResponseID() - */ - public String getResponseID() { - return "Notified"; //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#handle(Session, String, IProgressMonitor) - */ - public void handle( - Session session, - String localDir, - IProgressMonitor monitor) - throws CVSException { - - // read additional data for the response - // (which is the full repository path of the file) - String repositoryFilePath = session.readLine(); - - // clear the notify info for the file - ICVSFolder folder = session.getLocalRoot().getFolder(localDir); - ICVSFile file = folder.getFile(new Path(null, repositoryFilePath).lastSegment()); - file.notificationCompleted(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java deleted file mode 100644 index 58f2b392e..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; - -/** - * Goes recursivly through the folders checks if they are empyty - * and deletes them. Of course it is starting at the leaves of the - * recusion (the folders that do not have subfolders). - */ -public class PruneFolderVisitor implements ICVSResourceVisitor { - - private ICVSFolder localRoot; - - public PruneFolderVisitor() { - } - - /** - * This method is used to visit a set of ICVSResources. - */ - public void visit(Session s, ICVSResource[] resources) throws CVSException { - visit(s.getLocalRoot(), resources); - } - - /** - * This method is used to visit a set of ICVSResources. - */ - public void visit(ICVSFolder root, ICVSResource[] resources) throws CVSException { - localRoot = root; - - // Visit the resources - Set prunableParents = new HashSet(); - for (int i = 0; i < resources.length; i++) { - ICVSResource cvsResource = resources[i]; - // prune the resource and it's children when appropriate - cvsResource.accept(this); - // if the resource doesn't exists, attempt to prune it's parent - if (!cvsResource.exists()) - prunableParents.add(cvsResource.getParent()); - } - for (Iterator iter = prunableParents.iterator(); iter.hasNext();) { - ICVSFolder cvsFolder = (ICVSFolder)iter.next(); - pruneFolderAndParentsIfAppropriate(cvsFolder); - } - } - /** - * @see ICVSResourceVisitor#visitFile(IManagedFile) - */ - public void visitFile(ICVSFile file) throws CVSException { - // nothing to do here - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder folder) throws CVSException { - // First prune any empty children - folder.acceptChildren(this); - // Then prune the folder if it is empty - pruneFolderIfAppropriate(folder); - } - - private void pruneFolderIfAppropriate(ICVSFolder folder) throws CVSException { - // Only prune managed folders that are not the root of the operation - if (folder.exists() && folder.isManaged() - && ! folder.equals(getLocalRoot()) - && folder.members(ICVSFolder.ALL_EXISTING_MEMBERS).length == 0) { - - // Delete the folder but keep a phantom for local folders - folder.delete(); - } - } - - private ICVSFolder getLocalRoot() { - return localRoot; - } - - /** - * Attemp to prunt the given folder. If the folder is pruned, attempt to prune it's parent. - */ - private void pruneFolderAndParentsIfAppropriate(ICVSFolder folder) throws CVSException { - pruneFolderIfAppropriate(folder); - if (!folder.exists()) { - ICVSFolder parent = folder.getParent(); - pruneFolderAndParentsIfAppropriate(parent); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java deleted file mode 100644 index de27da825..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.team.internal.ccvs.core.CVSTag; - -public class RDiff extends RemoteCommand { - - /*** Local options: specific to rdiff ***/ - public static final LocalOption SUMMARY = new LocalOption("-s", null); //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId() - */ - protected String getRequestId() { - return "rdiff"; //$NON-NLS-1$ - } - - /** - * Makes a -r or -D option for a tag. - * Valid for: checkout export history rdiff update - */ - public static LocalOption makeTagOption(CVSTag tag) { - if (tag == null) tag = CVSTag.DEFAULT; - int type = tag.getType(); - switch (type) { - case CVSTag.BRANCH: - case CVSTag.VERSION: - case CVSTag.HEAD: - return new LocalOption("-r", tag.getName()); //$NON-NLS-1$ - case CVSTag.DATE: - return new LocalOption("-D", tag.getName()); //$NON-NLS-1$ - default: - // Unknow tag type!!! - throw new IllegalArgumentException(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java deleted file mode 100644 index fff45a343..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.Date; - -import org.eclipse.team.internal.ccvs.core.CVSTag; - -/** - * The "cvs rlog..." command - */ -public class RLog extends RemoteCommand { - - /*** Local options: specific to rlog ***/ - public static final LocalOption NO_TAGS = new LocalOption("-N"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final LocalOption ONLY_INCLUDE_CHANGES = new LocalOption("-S"); //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Makes a -r option for rlog. Here are the currently supported options: - * - * tag1 tag2 result - * ==== ==== ================================= - * date date datedate (all revisions of date or later) - * branch tag tag: (all revisions from tag to the end of branchs tip) - * - * Valid for: rlog - */ - public static LocalOption makeTagOption(CVSTag tag1, CVSTag tag2) { - int type1 = tag1.getType(); - int type2 = tag2.getType(); - - if(type1 == type2) { - switch (type1) { - case CVSTag.HEAD: - case CVSTag.BRANCH: - // A range of branches - all revisions on all the branches in that range. - case CVSTag.VERSION: - // Revisions from tag1 to tag2 (they must be on the same branch). - return new LocalOption("-r" + tag1.getName() + ":" + tag2.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$ - case CVSTag.DATE: - // Selects revisions created between DATE1 and DATE2. If DATE1 is after DATE2, use > instead; otherwise, no log messages are retrieved. - Date date1 = tag1.asDate(); - Date date2 = tag2.asDate(); - String operator = "<"; //$NON-NLS-1$ - if(date1.compareTo(date2) > 0) { - operator = ">"; //$NON-NLS-1$ - } - return new LocalOption("-d", tag1.getName() + operator + tag2.getName()); //$NON-NLS-1$ - default: - // Unknow tag type!!! - throw new IllegalArgumentException(); - } - } - - if((type1 == CVSTag.BRANCH || type1 == CVSTag.HEAD) && type2 == CVSTag.DATE) { - return new LocalOption("-d", ">" + tag2.getName()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - if((type1 == CVSTag.BRANCH || type1 == CVSTag.HEAD) && type2 == CVSTag.VERSION) { - return new LocalOption("-r" + tag2.getName() + ":", null); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // defaults - switch (type1) { - case CVSTag.HEAD: - case CVSTag.BRANCH: - // All revisions on this branch - case CVSTag.VERSION: - // revisions in this tag - return new LocalOption("-r" + tag1.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$ - case CVSTag.DATE: - // Revisions at this date tag - return new LocalOption("-d", tag1.getName()); //$NON-NLS-1$ //$NON-NLS-2$ - default: - // Unknow tag type!!! - throw new IllegalArgumentException(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId() - */ - protected String getRequestId() { - return "rlog"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java deleted file mode 100644 index 2dd9a204c..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.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.team.internal.ccvs.core.client; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener; - -public class RTag extends RemoteCommand { - /*** Local options: specific to tag ***/ - public static final LocalOption CREATE_BRANCH = Tag.CREATE_BRANCH; - public static final LocalOption CLEAR_FROM_REMOVED = new LocalOption("-a", null); //$NON-NLS-1$ - public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$ - public static final LocalOption FORCE_BRANCH_REASSIGNMENT = new LocalOption("-B", null); //$NON-NLS-1$ - - /*** Default command output listener ***/ - private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener(); - - /** - * Makes a -r or -D option for a tag. - * Valid for: checkout export history rdiff update - */ - public static LocalOption makeTagOption(CVSTag tag) { - int type = tag.getType(); - switch (type) { - case CVSTag.BRANCH: - case CVSTag.VERSION: - case CVSTag.HEAD: - return new LocalOption("-r", tag.getName()); //$NON-NLS-1$ - case CVSTag.DATE: - return new LocalOption("-D", tag.getName()); //$NON-NLS-1$ - default: - // Unknow tag type!!! - throw new IllegalArgumentException(); - } - } - - protected String getRequestId() { - return "rtag"; //$NON-NLS-1$ - } - - protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, - String[] arguments) throws CVSException { - if (arguments.length < 2) throw new IllegalArgumentException(); - return super.computeWorkResources(session, localOptions, arguments); - } - - public IStatus execute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, CVSTag sourceTag, CVSTag tag, String[] arguments, - IProgressMonitor monitor) throws CVSException { - - if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) { - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("Tag.notVersionOrBranchError"))); //$NON-NLS-1$ - } - - // Add the source tag to the local options - List modifiedLocalOptions = new ArrayList(localOptions.length + 1); - if (sourceTag==null) sourceTag = CVSTag.DEFAULT; - modifiedLocalOptions.addAll(Arrays.asList(localOptions)); - modifiedLocalOptions.add(makeTagOption(sourceTag)); - - // Add the CREATE_BRANCH option for a branch tag - if (tag.getType() == CVSTag.BRANCH) { - if ( ! CREATE_BRANCH.isElementOf(localOptions)) { - modifiedLocalOptions.add(CREATE_BRANCH); - } - } - - // Add the tag name to the start of the arguments - String[] newArguments = new String[arguments.length + 1]; - newArguments[0] = tag.getName(); - System.arraycopy(arguments, 0, newArguments, 1, arguments.length); - - return execute(session, globalOptions, - (LocalOption[]) modifiedLocalOptions.toArray(new LocalOption[modifiedLocalOptions.size()]), - newArguments, null, monitor); - } - - public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, - CVSTag sourceTag, CVSTag tag, ICVSRemoteResource[] arguments, IProgressMonitor monitor) - throws CVSException { - - String[] stringArguments = convertArgumentsForOpenSession(arguments, session); - - return execute(session, globalOptions, localOptions, sourceTag, tag, stringArguments, monitor); - } - - protected ICommandOutputListener getDefaultCommandOutputListener() { - return DEFAULT_OUTPUT_LISTENER; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java deleted file mode 100644 index 71596f294..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -/** - * This class acts as a super class for those CVS commands that do not send up the local file structure - */ -public abstract class RemoteCommand extends Command { - - protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, - String[] arguments) throws CVSException { - return new ICVSResource[0]; - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // do nothing - monitor.beginTask(null, 100); - monitor.done(); - return resources; - } - - protected void sendLocalWorkingDirectory(Session session) throws CVSException { - // do nothing - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#convertArgumentsForOpenSession(org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.team.internal.ccvs.core.client.Session) - */ - protected String[] convertArgumentsForOpenSession( - ICVSResource[] arguments, - Session openSession) - throws CVSException { - - // Convert arguments - List stringArguments = new ArrayList(arguments.length); - for (int i = 0; i < arguments.length; i++) { - ICVSResource resource = arguments[i]; - String remotePath; - if (isDefinedModule(resource)) { - remotePath = resource.getName(); - } else { - remotePath = resource.getRepositoryRelativePath(); - - } - stringArguments.add(remotePath); - } - return (String[]) stringArguments.toArray(new String[stringArguments.size()]); - } - - private boolean isDefinedModule(ICVSResource resource) { - return resource instanceof ICVSRemoteFolder && ((ICVSRemoteFolder)resource).isDefinedModule(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java deleted file mode 100644 index 75a587ad7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -public class Remove extends Command { - /*** Local options: specific to remove ***/ - - protected Remove() { } - protected String getRequestId() { - return "remove"; //$NON-NLS-1$ - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Send all modified files to the server - // XXX Does the command line client send all modified files? - new ModifiedFileSender(session).visit(session, resources, monitor); - return resources; - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java deleted file mode 100644 index 78f34a266..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * Handles a "Remove-entry" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Remove-entry ??? \n
              - *   [...]
              - * 
              - * Then - *

              - */ - -/** - * It removes the file from both the entries of the parent-folder. - * This happen, when the folder has allready been removed locally - * what happens on a checkin that includes a removed file. - */ -class RemoveEntryHandler extends ResponseHandler { - public String getResponseID() { - return "Remove-entry"; //$NON-NLS-1$ - } - - public void handle(Session session, String localDir, - IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryFile = session.readLine(); - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - ICVSFile mFile = mParent.getFile(fileName); - if (mFile.exists()) { - CVSProviderPlugin.log(new CVSException(Policy.bind("RemoveEntryHandler.2", mFile.getRepositoryRelativePath()))); //$NON-NLS-1$ - } else { - mFile.unmanage(null); - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java deleted file mode 100644 index 943262f32..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; - -/** - * Handles a "Removed" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Removed ??? \n
              - *   [...]
              - * 
              - * Then - *

              - */ - -/** - * It removes the file from both the entries of the parent-folder - * and from the local filesystem. - */ -class RemovedHandler extends ResponseHandler { - public String getResponseID() { - return "Removed"; //$NON-NLS-1$ - } - - public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException { - - // read additional data for the response - String repositoryFile = session.readLine(); - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - ICVSFile mFile = mParent.getFile(fileName); - - if ( ! mFile.isManaged()) { - throw new CVSException(Policy.bind("RemovedHandler.invalid", new Path(null, localDir).append(fileName).toString())); //$NON-NLS-1$ - } - - // delete then unmanage the file - try { - if (mFile.isReadOnly()) mFile.setReadOnly(false); - mFile.delete(); - mFile.unmanage(null); - } catch (CVSException e) { - session.handleResponseError(new CVSStatus(IStatus.ERROR, CVSStatus.RESPONSE_HANDLING_FAILURE, Policy.bind("RemovedHandler.0", getPath(mFile)), e)); //$NON-NLS-1$ - } - } - - private String getPath(ICVSFile file) { - try { - IResource resource = file.getIResource(); - if (resource != null) { - return resource.getFullPath().toString(); - } - } catch (CVSException e) { - // Ignore - } - try { - return file.getRepositoryRelativePath(); - } catch (CVSException e1) { - return file.getName(); - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java deleted file mode 100644 index 91c75fba8..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; - -/** - * Abstract base class for requests that are to be sent to the server. - */ -public abstract class Request { - public static final ExpandModules EXPAND_MODULES = new ExpandModules(); - public static final ValidRequests VALID_REQUESTS = new ValidRequests(); - - /*** Response handler map ***/ - private static final Map responseHandlers = new HashMap(); - - private static void initializeHandlerCache() { - synchronized(responseHandlers) { - registerResponseHandler(new CheckedInHandler()); - registerResponseHandler(new CopyHandler()); - registerResponseHandler(new ModTimeHandler()); - registerResponseHandler(new NewEntryHandler()); - registerResponseHandler(new RemovedHandler()); - registerResponseHandler(new RemoveEntryHandler()); - registerResponseHandler(new StaticHandler(true)); - registerResponseHandler(new StaticHandler(false)); - registerResponseHandler(new StickyHandler(true)); - registerResponseHandler(new StickyHandler(false)); - registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATED)); - registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATE_EXISTING)); - registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_CREATED)); - registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_MERGED)); - registerResponseHandler(new ValidRequestsHandler()); - registerResponseHandler(new ModuleExpansionHandler()); - registerResponseHandler(new MTHandler()); - registerResponseHandler(new NotifiedHandler()); - registerResponseHandler(new TemplateHandler()); - } - } - private static void registerResponseHandler(ResponseHandler handler) { - synchronized(responseHandlers) { - responseHandlers.put(handler.getResponseID(), handler); - } - } - - /** - * This method is invoked by Session to get a mutable copy of the - * global list of acceptable response handlers. - * - * @return a map of reponse handlers - */ - protected static Map getReponseHandlerMap() { - synchronized(responseHandlers) { - if (responseHandlers.isEmpty()) { - initializeHandlerCache(); - } - Map copy = new HashMap(); - for (Iterator iter = responseHandlers.values().iterator(); iter.hasNext();) { - ResponseHandler handler = (ResponseHandler) iter.next(); - copy.put(handler.getResponseID(), handler.getInstance()); - - } - return copy; - } - } - /** - * Prevents client code from instantiating us. - */ - protected Request() { } - - /** - * Returns the string used to invoke this request on the server. - * [template method] - * - * @return the request identifier string - */ - protected abstract String getRequestId(); - - /** - * Executes a request and processes the responses. - * - * @param session the open CVS session - * @param listener the command output listener, or null to discard all messages - * @param monitor the progress monitor - * @return a status code indicating success or failure of the operation - */ - protected IStatus executeRequest(Session session, ICommandOutputListener listener, - IProgressMonitor monitor) throws CVSException { - // send request - session.sendRequest(getRequestId()); - - // This number can be tweaked if the monitor is judged to move too - // quickly or too slowly. After some experimentation this is a good - // number for both large projects (it doesn't move so quickly as to - // give a false sense of speed) and smaller projects (it actually does - // move some rather than remaining still and then jumping to 100). - final int TOTAL_WORK = 300; - monitor.beginTask(Policy.bind("Command.receivingResponses"), TOTAL_WORK); //$NON-NLS-1$ - int halfWay = TOTAL_WORK / 2; - int currentIncrement = 4; - int nextProgress = currentIncrement; - int worked = 0; - - // If the session is connected to a CVSNT server (1.11.1.1), we'll need to do some special handling for - // some errors. Unfortunately, CVSNT 1.11.1.1 will drop the connection after so some functionality is - // still effected - boolean isCVSNT = session.isCVSNT(); - - session.clearErrors(); - for (;;) { - // update monitor work amount - if (--nextProgress <= 0) { - monitor.worked(1); - worked++; - if (worked >= halfWay) { - // we have passed the current halfway point, so double the - // increment and reset the halfway point. - currentIncrement *= 2; - halfWay += (TOTAL_WORK - halfWay) / 2; - } - // reset the progress counter to another full increment - nextProgress = currentIncrement; - } - Policy.checkCanceled(monitor); - - // retrieve a response line - String response = session.readLine(); - int spacePos = response.indexOf(' '); - String argument; - if (spacePos != -1) { - argument = response.substring(spacePos + 1); - response = response.substring(0, spacePos); - } else argument = ""; //$NON-NLS-1$ - - // handle completion responses - if (response.equals("ok")) { //$NON-NLS-1$ - break; - } else if (response.equals("error") || (isCVSNT && response.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$ - argument = argument.trim(); - boolean serious = false; - if (argument.length() == 0) { - argument = getServerErrorMessage(); - } else { - argument = Policy.bind("Command.seriousServerError", argument); //$NON-NLS-1$ - if (!session.hasErrors()) { - session.addError(new CVSStatus(CVSStatus.ERROR, CVSStatus.SERVER_ERROR, argument)); - } - serious = true; - } - - if (!session.hasErrors()) { - session.addError(new CVSStatus(CVSStatus.ERROR, CVSStatus.SERVER_ERROR, Policy.bind("Command.noMoreInfoAvailable")));//$NON-NLS-1$ - } - IStatus status = new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, - session.getErrors(), - argument, null); - if (serious) { - throw new CVSServerException(status); - } else { - // look for particularly bad errors in the accumulated statii - IStatus[] errors = session.getErrors(); - for (int i = 0; i < errors.length; i++) { - IStatus s = errors[i]; - if (s.getCode() == CVSStatus.PROTOCOL_ERROR) { - throw new CVSServerException(status); - } - } - } - return status; - // handle message responses - } else if (response.equals("MT")) { //$NON-NLS-1$ - // Handle the MT response - MTHandler handler = (MTHandler) session.getResponseHandler(response); - if (handler != null) { - handler.handle(session, argument, monitor); - } else { - throw new CVSException(new org.eclipse.core.runtime.Status(IStatus.ERROR, - CVSProviderPlugin.ID, CVSException.IO_FAILED, - Policy.bind("Command.unsupportedResponse", response, argument), null)); //$NON-NLS-1$ - } - // If a line is available, pass it on to the message listener - // and console as if it were an M response - if (handler.isLineAvailable()) { - String line = handler.getLine(); - IStatus status = listener.messageLine(line, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor); - session.addError(status); // The session ignores OK status - ConsoleListeners.getInstance().messageLineReceived(session, line, status); - - } - } else if (response.equals("M")) { //$NON-NLS-1$ - IStatus status = listener.messageLine(argument, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor); - session.addError(status); // The session ignores OK status - ConsoleListeners.getInstance().messageLineReceived(session, argument, status); - } else if (response.equals("E")) { //$NON-NLS-1$ - IStatus status = listener.errorLine(argument, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor); - session.addError(status); // The session ignores OK status - ConsoleListeners.getInstance().errorLineReceived(session, argument, status); - // handle other responses - } else { - ResponseHandler handler = session.getResponseHandler(response); - if (handler != null) { - handler.handle(session, argument, monitor); - } else { - throw new CVSException(new org.eclipse.core.runtime.Status(IStatus.ERROR, - CVSProviderPlugin.ID, CVSException.IO_FAILED, - Policy.bind("Command.unsupportedResponse", response, argument), null)); //$NON-NLS-1$ - } - } - } - if (!session.hasErrors()) { - return ICommandOutputListener.OK; - } else { - return new MultiStatus(CVSProviderPlugin.ID, CVSStatus.INFO, - session.getErrors(), - Policy.bind("Command.warnings", Policy.bind("Command." + getRequestId())), null); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /* - * Provide the message that is used for the status that is generated when the server - * reports as error. - */ - protected String getServerErrorMessage() { - return Policy.bind("Command.serverError", Policy.bind("Command." + getRequestId())); //$NON-NLS-1$ //$NON-NLS-2$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java deleted file mode 100644 index bbd8a7dfb..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Handles server responses that arise as a result of issuing a request - * (usually a command) to a CVS server. The processing of each such - * response is deferred to subclasses. - */ -public abstract class ResponseHandler { - /** - * Returns the text string of the server response handled by this object. - * @return the id - */ - public abstract String getResponseID(); - - /** - * Handles a server response. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              -	 *   [...]
              -	 *   Clear-sticky myDirectory \n
              -	 *   /u/cvsroot/myDirectory \n
              -	 *   [...]
              -	 * 
              - * Then the handle method of the ResponseHandler - * for Clear-sticky will be invoked with argument - * set to "myDirectory". It must then read the remaining - * response data from the connection ("/u/cvsroot/myDirectory" - * including the newline) and take any necessary action. - *

              - * Note: The type and quantity of additional data that must be read - * from the connection varies on a per-response basis. - *

              - * @param session the Session used for CVS communication - * @param argument the argument supplied with the response - * @param monitor the progress monitor for the current CVS command - */ - public abstract void handle(Session session, String argument, - IProgressMonitor monitor) throws CVSException; - - /** - * Creates a new CVS folder. - * @param localDir the local path of the folder relative to root - * @param repositoryDir the remote path of the folder relative to the repository - * @return the new folder - */ - protected static ICVSFolder createFolder( - Session session, - String localDir, - String repositoryDir) throws CVSException { - - ICVSFolder folder = session.getLocalRoot().getFolder(localDir); - if (!folder.exists() - && (!CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() - || !folder.getParent().isCVSFolder())) { - // Only create the folder if pruning is disabled or the - // folder's parent is not a CVS folder (which occurs on checkout). - // When pruning is enabled, the folder will be lazily created - // when it contains a file (see getExistingFolder) - folder.mkdir(); - } - if (! folder.isCVSFolder()) { - folder.setFolderSyncInfo(new FolderSyncInfo( - Util.getRelativePath(session.getRepositoryRoot(), repositoryDir), - session.getCVSRepositoryLocation().getLocation(), - null, false)); - } - return folder; - } - - protected ICVSFolder getExistingFolder(Session session, String localDir) throws CVSException { - ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); - if (! mParent.exists()) { - // First, check if the parent is a phantom - IContainer container = (IContainer)mParent.getIResource(); - if (container != null) { - try { - // Create all the parents as need - recreatePhatomFolders(mParent); - } catch (CVSException e) { - if (!handleInvalidResourceName(session, mParent, e)) { - throw e; - } - } - } - } - return mParent; - } - - /** - * Method recreatePhatomFolders. - * @param mParent - */ - private void recreatePhatomFolders(ICVSFolder folder) throws CVSException { - ICVSFolder parent = folder.getParent(); - if (!parent.exists()) { - recreatePhatomFolders(parent); - } - folder.mkdir(); - } - - /** - * Return as instance that can be used by an open session. Subclasses that contain - * session related state must override this message to return a copy of themselves. - */ - /* package */ ResponseHandler getInstance() { - return this; - } - - protected boolean handleInvalidResourceName(Session session, ICVSResource resource, CVSException e) { - int code = e.getStatus().getCode(); - if (code == IResourceStatus.INVALID_VALUE - || code == IResourceStatus.INVALID_RESOURCE_NAME - || code == IResourceStatus.RESOURCE_NOT_FOUND - || code == IResourceStatus.RESOURCE_EXISTS - || code == IResourceStatus.RESOURCE_WRONG_TYPE - || code == IResourceStatus.CASE_VARIANT_EXISTS - || code == IResourceStatus.PATH_OCCUPIED) { - - try { - IResource local = resource.getIResource(); - String path; - if (local == null) { - path = resource.getRepositoryRelativePath(); - } else { - path = local.getFullPath().toString(); - } - IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.INVALID_LOCAL_RESOURCE_PATH, Policy.bind("ResponseHandler.0", path, e.getMessage()), e); //$NON-NLS-1$ - session.handleResponseError(status); - } catch (CVSException e1) { - CVSProviderPlugin.log(e1); - } - return true; - } - return false; - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java deleted file mode 100644 index e0fdd4950..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java +++ /dev/null @@ -1,1011 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.io.*; -import java.util.*; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption; -import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.Connection; -import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.*; -import org.eclipse.team.internal.core.streams.*; - -/** - * Maintains CVS communication state for the lifetime of a connection - * to a remote repository. This class covers the initialization, use, - * and eventual shutdown of a dialogue between a CVS client and a - * remote server. This dialogue may be monitored through the use of - * a console. - * - * Initially the Session is in a CLOSED state during which communication - * with the server cannot take place. Once OPENED, any number of commands - * may be issued serially to the server, one at a time. When finished, the - * Session MUST be CLOSED once again to prevent eventual local and/or - * remote resource exhaustion. The session can either be discarded, or - * re-opened for use with the same server though no state is persisted from - * previous connections except for console attributes. - * - * CVSExceptions are thrown only as a result of unrecoverable errors. Once - * this happens, commands must no longer be issued to the server. If the - * Session is in the OPEN state, it is still the responsibility of the - * caller to CLOSE it before moving on. - */ -public class Session { - public static final String CURRENT_LOCAL_FOLDER = "."; //$NON-NLS-1$ - public static final String CURRENT_REMOTE_FOLDER = ""; //$NON-NLS-1$ - public static final String SERVER_SEPARATOR = "/"; //$NON-NLS-1$ - - // default file transfer buffer size (in bytes) - private static final int TRANSFER_BUFFER_SIZE = 8192; - // update progress bar in increments of this size (in bytes) - // no incremental progress shown for files smaller than this size - private static final int TRANSFER_PROGRESS_INCREMENT = 32768; - - private static final boolean IS_CRLF_PLATFORM = Arrays.equals( - System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$ - - private CVSRepositoryLocation location; - private ICVSFolder localRoot; - private boolean outputToConsole; - private Connection connection = null; - private String validRequests = null; - private Date modTime = null; - private boolean noLocalChanges = false; - private boolean createBackups = true; - private int compressionLevel = 0; - private List expansions; - private Collection /* of ICVSFile */ textTransferOverrideSet = null; - - // state need to indicate whether - private boolean ignoringLocalChanges = false; - - // The resource bundle key that provides the file sending message - private String sendFileTitleKey; - private Map responseHandlers; - - // List of errors accumulated while the command is executing - private List errors = new ArrayList(); - - private Command currentCommand; - - /** - * Creates a new CVS session, initially in the CLOSED state. - * By default, command output is directed to the console. - * - * @param location the CVS repository location used for this session - * @param localRoot represents the current working directory of the client - */ - public Session(ICVSRepositoryLocation location, ICVSFolder localRoot) { - this(location, localRoot, true); - } - - /** - * Creates a new CVS session, initially in the CLOSED state. - * - * @param location the CVS repository location used for this session - * @param localRoot represents the current working directory of the client - * @param outputToConsole if true, command output is directed to the console - */ - public Session(ICVSRepositoryLocation location, ICVSFolder localRoot, boolean outputToConsole) { - this.location = (CVSRepositoryLocation) location; - this.localRoot = localRoot; - this.outputToConsole = outputToConsole; - } - - /* - * Add a module expansion receivered from the server. - * This is only used by the ModuleExpansionsHandler - */ - protected void addModuleExpansion(String expansion) { - expansions.add(expansion); - } - - /* - * Add a module expansion receivered from the server. - * This is only used by the ExpandModules command - */ - protected void resetModuleExpansion() { - if (expansions == null) - expansions = new ArrayList(); - else - expansions.clear(); - } - - /** - * Opens, authenticates and initializes a connection to the server specified - * for the remote location. - * - * @param monitor the progress monitor - * @throws IllegalStateException if the Session is not in the CLOSED state - */ - public void open(IProgressMonitor monitor) throws CVSException { - open(monitor, true /* write access*/); - } - - public void open(IProgressMonitor monitor, boolean writeAccess) throws CVSException { - if (connection != null) throw new IllegalStateException(); - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - boolean opened = false; - - try { - connection = getLocationForConnection(writeAccess).openConnection(Policy.subMonitorFor(monitor, 50)); - - // If we're connected to a CVSNT server or we don't know the platform, - // accept MT. Otherwise don't. - boolean useMT = ! (location.getServerPlatform() == CVSRepositoryLocation.CVS_SERVER); - if ( ! useMT) { - removeResponseHandler("MT"); //$NON-NLS-1$ - } - - // tell the server the names of the responses we can handle - connection.writeLine("Valid-responses " + makeResponseList()); //$NON-NLS-1$ - // Flush in order to recieve the valid requests - connection.flush(); - - // ask for the set of valid requests - IStatus status = Request.VALID_REQUESTS.execute(this, Policy.subMonitorFor(monitor, 40)); - if (!status.isOK()) { - throw new CVSException(status); - } - - // set the root directory on the server for this connection - connection.writeLine("Root " + getRepositoryRoot()); //$NON-NLS-1$ - - // enable compression - compressionLevel = CVSProviderPlugin.getPlugin().getCompressionLevel(); - if (compressionLevel != 0 && isValidRequest("gzip-file-contents")) { //$NON-NLS-1$ - // Enable the use of CVS 1.8 per-file compression mechanism. - // The newer Gzip-stream request seems to be problematic due to Java's - // GZIPInputStream tendency to block on read() rather than to return a - // partially filled buffer. The latter option would be better since it - // can make more effective use of the code dictionary, if it can be made - // to work... - connection.writeLine("gzip-file-contents " + Integer.toString(compressionLevel)); //$NON-NLS-1$ - } else { - compressionLevel = 0; - } - - // get the server platform if it is unknown - if (CVSProviderPlugin.getPlugin().isDetermineVersionEnabled() && location.getServerPlatform() == CVSRepositoryLocation.UNDETERMINED_PLATFORM) { - Command.VERSION.execute(this, location, Policy.subMonitorFor(monitor, 10)); - } - opened = true; - } finally { - if (connection != null && ! opened) { - close(); - } - monitor.done(); - } - } - - /* - * Return the location to be used for this connection - */ - private CVSRepositoryLocation getLocationForConnection(boolean writeAccess) { - return location; - } - - /** - * Closes a connection to the server. - * - * @throws IllegalStateException if the Session is not in the OPEN state - */ - public void close() { - if (connection != null) { - connection.close(); - connection = null; - validRequests = null; - } - } - - /** - * Determines if the server supports the specified request. - * - * @param request the request string to verify - * @return true iff the request is supported - */ - public boolean isValidRequest(String request) { - return (validRequests == null) || - (validRequests.indexOf(" " + request + " ") != -1); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public boolean isCVSNT() { - if (location.getServerPlatform() == CVSRepositoryLocation.UNDETERMINED_PLATFORM) { - return location.getRootDirectory().indexOf(':') == 1; - } else { - return location.getServerPlatform() == CVSRepositoryLocation.CVSNT_SERVER; - } - } - - /** - * Returns the local root folder for this session. - *

              - * Generally speaking, specifies the "current working directory" at - * the time of invocation of an equivalent CVS command-line client. - *

              - * - * @return the local root folder - */ - public ICVSFolder getLocalRoot() { - return localRoot; - } - - /** - * Return the list of module expansions communicated from the server. - * - * The modules expansions are typically a directory path of length 1 - * but can be of greater length on occasion. - */ - public String[] getModuleExpansions() { - if (expansions == null) return new String[0]; - return (String[]) expansions.toArray(new String[expansions.size()]); - } - - /** - * Returns the repository root folder for this session. - *

              - * Specifies the unqualified path to the CVS repository root folder - * on the server. - *

              - * - * @return the repository root folder - */ - public String getRepositoryRoot() { - return location.getRootDirectory(); - } - - /** - * Returns an object representing the CVS repository location for this session. - * - * @return the CVS repository location - */ - public ICVSRepositoryLocation getCVSRepositoryLocation() { - return location; - } - - /** - * Receives a line of text minus the newline from the server. - * - * @return the line of text - */ - public String readLine() throws CVSException { - return connection.readLine(); - } - - /** - * Sends a line of text followed by a newline to the server. - * - * @param line the line of text - */ - public void writeLine(String line) throws CVSException { - connection.writeLine(line); - } - - /** - * Sends an argument to the server. - *

              e.g. sendArgument("Hello\nWorld\n Hello World") sends: - *

              -	 *   Argument Hello \n
              -	 *   Argumentx World \n
              -	 *   Argumentx Hello World \n
              -	 * 

              - * - * @param arg the argument to send - */ - public void sendArgument(String arg) throws CVSException { - connection.write("Argument "); //$NON-NLS-1$ - int oldPos = 0; - for (;;) { - int pos = arg.indexOf('\n', oldPos); - if (pos == -1) break; - connection.writeLine(stripTrainingCR(arg.substring(oldPos, pos))); - connection.write("Argumentx "); //$NON-NLS-1$ - oldPos = pos + 1; - } - connection.writeLine(stripTrainingCR(arg.substring(oldPos))); - } - - /* - * Remove any trailing CR from the string - */ - private String stripTrainingCR(String string) { - if (string.endsWith("\r")) { //$NON-NLS-1$ - return string.substring(0, string.length() - 1); - } - return string; - } - - /** - * Sends a request to the server and flushes any output buffers. - * - * @param requestId the string associated with the request to be executed - */ - public void sendRequest(String requestId) throws CVSException { - connection.writeLine(requestId); - connection.flush(); - } - - /** - * Sends an Is-modified request to the server without the file contents. - *

              e.g. if a file called "local_file" was modified, sends: - *

              -	 *   Is-modified local_file \n
              -	 * 

              - * This request is an optimized form of the Modified request and may not - * be supported by all servers. Hence, if it is not supported, a Modified - * request is sent instead along with the file's contents. According to - * the CVS protocol specification, this request is only safe for use with - * some forms of: admin, annotate, diff, editors, log, watch-add, watch-off, - * watch-on, watch-remove, and watchers.
              - * It may be possible to use this for: add, export, remove and status.
              - * Do not use with co, ci, history, init, import, release, rdiff, rtag, or update. - *

              - * Note: The most recent Directory request must have specified the file's - * parent folder. - *

              - * - * @param file the file that was modified - * @see #sendModified - */ - public void sendIsModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor) - throws CVSException { - if (isValidRequest("Is-modified")) { //$NON-NLS-1$ - connection.writeLine("Is-modified " + file.getName()); //$NON-NLS-1$ - } else { - sendModified(file, isBinary, monitor); - } - } - - /** - * Sends a Static-directory request to the server. - *

              - * Indicates that the directory specified in the most recent Directory request - * is static. No new files will be checked out into this directory unless - * explicitly requested. - *

              - */ - public void sendStaticDirectory() throws CVSException { - connection.writeLine("Static-directory"); //$NON-NLS-1$ - } - - /** - * Sends a Directory request to the server with a constructed path. - *

              - * It may be necessary at times to guess the remote path of a directory since - * it does not exist yet. In this case we construct a remote path based on the - * local path by prepending the local path with the repository root. This may - * not work in the presence of modules, so only use it for creating new projects. - *

              - * Note: A CVS repository root can end with a trailing slash. The CVS server - * expects that the repository root sent contain this extra slash. Including - * the foward slash in addition to the absolute remote path makes for a string - * containing two consecutive slashes (e.g. /home/cvs/repo//projecta/a.txt). - * This is valid in the CVS protocol. - *

              - */ - public void sendConstructedDirectory(String localDir) throws CVSException { - sendDirectory(localDir, getRepositoryRoot() + "/" + localDir); //$NON-NLS-1$ - } - - /** - * Sends a Directory request to the server. - *

              e.g. sendDirectory("local_dir", "remote_dir") sends: - *

              -	 *   Directory local_dir
              -	 *   repository_root/remote_dir
              -	 * 

              - * - * @param localDir the path of the local directory relative to localRoot - * @param remoteDir the path of the remote directory relative to repositoryRoot - */ - public void sendDirectory(String localDir, String remoteDir) throws CVSException { - if (localDir.length() == 0) localDir = CURRENT_LOCAL_FOLDER; //$NON-NLS-1$ - connection.writeLine("Directory " + localDir); //$NON-NLS-1$ - connection.writeLine(remoteDir); - } - - /** - * Sends a Directory request for the localRoot. - */ - public void sendLocalRootDirectory() throws CVSException { - sendDirectory(CURRENT_LOCAL_FOLDER, localRoot.getRemoteLocation(localRoot)); //$NON-NLS-1$ - } - - /** - * Sends a Directory request for the localRoot with a constructed path. - *

              - * Use this when creating a new project that does not exist in the repository. - *

              - * @see #sendConstructedDirectory - */ - public void sendConstructedRootDirectory() throws CVSException { - sendConstructedDirectory(""); //$NON-NLS-1$ - } - - /** - * Sends an Entry request to the server. - *

              - * Indicates that a file is managed (but it may not exist locally). Sends - * the file's entry line to the server to indicate the version that was - * previously checked out. - *

              - * Note: The most recent Directory request must have specified the file's - * parent folder. - *

              - * - * @param entryLine the formatted entry line of the managed file. - */ - public void sendEntry(byte[] syncBytes, String serverTimestamp) throws CVSException { - connection.write("Entry "); //$NON-NLS-1$ - if (serverTimestamp == null) { - serverTimestamp = ""; //$NON-NLS-1$ - } - int start = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', 0, 3); - if (start == -1) { - // something is wrong with the entry line so just send it as is - // and let the server report the error. - connection.writeLine(new String(syncBytes)); - return; - } - int end = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', start + 1, 1); - if (end == -1) { - // something is wrong with the entry line so just send it as is - // and let the server report the error. - connection.writeLine(new String(syncBytes)); - return; - } - connection.write(new String(syncBytes, 0, start + 1)); - connection.write(serverTimestamp); - connection.writeLine(new String(syncBytes, end, syncBytes.length - end)); - } - - /** - * Sends a global options to the server. - *

              e.g. sendGlobalOption("-n") sends: - *

              -	 *   Global_option -n \n
              -	 * 

              - * - * @param option the global option to send - */ - public void sendGlobalOption(String option) throws CVSException { - connection.writeLine("Global_option " + option); //$NON-NLS-1$ - } - - /** - * Sends an Unchanged request to the server. - *

              e.g. if a file called "local_file" was not modified, sends: - *

              -	 *   Unchanged local_file \n
              -	 * 

              - * Note: The most recent Directory request must have specified the file's - * parent folder. - *

              - * - * @param file the file that was not modified - */ - public void sendUnchanged(ICVSFile file) throws CVSException { - connection.writeLine("Unchanged " + file.getName()); //$NON-NLS-1$ - } - - /** - * Sends the Notify request to the server - */ - public void sendNotify(ICVSFolder parent, NotifyInfo info) - throws CVSException { - - String filename = info.getName(); - connection.writeLine("Notify " + filename); //$NON-NLS-1$ - connection.writeLine(info.getServerLine(parent)); - } - - /** - * Sends a Questionable request to the server. - *

              - * Indicates that a file exists locally but is unmanaged. Asks the server - * whether or not the file should be ignored in subsequent CVS operations. - * The reply to the request occurs in the form of special M-type message - * responses prefixed with '?' when the next command is executed. - *

              - * Note: The most recent Directory request must have specified the file's - * parent folder. - *

              - * - * @param resource the local file or folder - */ - public void sendQuestionable(ICVSResource resource) throws CVSException { - connection.writeLine("Questionable " + resource.getName()); //$NON-NLS-1$ - } - - /** - * Sends a Sticky tag request to the server. - *

              - * Indicates that the directory specified in the most recent Directory request - * has a sticky tag or date, and sends the tag's contents. - *

              - * - * @param tag the sticky tag associated with the directory - */ - public void sendSticky(String tag) throws CVSException { - connection.writeLine("Sticky " + tag); //$NON-NLS-1$ - } - - /** - * Sends a Modified request to the server along with the file contents. - *

              e.g. if a file called "local_file" was modified, sends: - *

              -	 *   Modified local_file \n
              -	 *   file_permissions \n
              -	 *   file_size \n
              -	 *   [... file_contents ...]
              -	 * 

              - * Under some circumstances, Is-modified may be used in place of this request.
              - * Do not use with history, init, import, rdiff, release, rtag, or update. - *

              - * Note: The most recent Directory request must have specified the file's - * parent folder. - *

              - * - * @param file the file that was modified - * @param isBinary if true the file is sent without translating line delimiters - * @param monitor the progress monitor - * @see #sendIsModified - */ - public void sendModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor) - throws CVSException { - sendModified(file, isBinary, true, monitor); - } - - public void sendModified(ICVSFile file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor) - throws CVSException { - - String filename = file.getName(); - connection.writeLine("Modified " + filename); //$NON-NLS-1$ - // send the default permissions for now - if (file.isExecutable()) { - connection.writeLine(ResourceSyncInfo.getDefaultExecutablePermissions()); - } else { - connection.writeLine(ResourceSyncInfo.getDefaultPermissions()); - } - sendFile(file, isBinary, sendBinary, monitor); - } - - /** - * Sends a file to the remote CVS server, possibly translating line delimiters. - *

              - * Line termination sequences are automatically converted to linefeeds only - * (required by the CVS specification) when sending non-binary files. This - * may alter the actual size and contents of the file that is sent. - *

              - * Note: Non-binary files must be small enough to fit in available memory. - *

              - * @param file the file to be sent - * @param isBinary is true if the file should be sent without translation - * @param monitor the progress monitor - */ - public void sendFile(ICVSFile file, boolean isBinary, IProgressMonitor monitor) throws CVSException { - sendFile(file, isBinary, true, monitor); - } - - public void sendFile(ICVSStorage file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor) throws CVSException { - // check overrides - if (textTransferOverrideSet != null && - textTransferOverrideSet.contains(file)) isBinary = false; - - // update progress monitor - final String title = Policy.bind(getSendFileTitleKey(), new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$ - monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$ - try { - InputStream in = null; - long length; - try { - if (isBinary && !sendBinary) { - byte[] bytes = "hello".getBytes(); //$NON-NLS-1$ - sendUncompressedBytes(new ByteArrayInputStream(bytes), bytes.length); - return; - } - - if (compressionLevel == 0) { - in = file.getContents(); - if (!isBinary && IS_CRLF_PLATFORM){ - // uncompressed text - byte[] buffer = new byte[TRANSFER_BUFFER_SIZE]; - in = new CRLFtoLFInputStream(in); - ByteCountOutputStream counter = new ByteCountOutputStream(); - try { - for (int count; (count = in.read(buffer)) != -1;) counter.write(buffer, 0, count); - } finally { - counter.close(); - } - in.close(); - length = counter.getSize(); - in = new CRLFtoLFInputStream(file.getContents()); - } else { - // uncompressed binary - length = file.getSize(); - } - in = new ProgressMonitorInputStream(in, length, TRANSFER_PROGRESS_INCREMENT, monitor) { - protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) { - if (bytesRead == 0) return; - Assert.isTrue(bytesRead <= bytesTotal); - monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$ - new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })); - } - }; - sendUncompressedBytes(in, length); - } else { - monitor.subTask(Policy.bind("Session.calculatingCompressedSize", Util.toTruncatedPath(file, localRoot, 3))); //$NON-NLS-1$ - in = file.getContents(); - byte[] buffer = new byte[TRANSFER_BUFFER_SIZE]; - ByteCountOutputStream counter = new ByteCountOutputStream(); - OutputStream zout = new GZIPOutputStream(counter); - if (!isBinary && IS_CRLF_PLATFORM) in = new CRLFtoLFInputStream(in); - try { - for (int count; (count = in.read(buffer)) != -1;) zout.write(buffer, 0, count); - } finally { - zout.close(); - } - in.close(); - in = file.getContents(); - in = new ProgressMonitorInputStream(in, file.getSize(), TRANSFER_PROGRESS_INCREMENT, monitor) { - protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) { - if (bytesRead == 0) return; - Assert.isTrue(bytesRead <= bytesTotal); - monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$ - new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })); - } - }; - if (!isBinary && IS_CRLF_PLATFORM) in = new CRLFtoLFInputStream(in); - sendCompressedBytes(in, counter.getSize()); - } - } finally { - if (in != null) in.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Send the contents of the input stream to CVS. - * Length must equal the number of bytes that will be transferred - * across the wire, that is, the compressed file size. - */ - private void sendCompressedBytes(InputStream in, long length) throws IOException, CVSException { - String sizeLine = "z" + Long.toString(length); //$NON-NLS-1$ - writeLine(sizeLine); - OutputStream out = connection.getOutputStream(); - GZIPOutputStream zo = new GZIPOutputStream(out); - byte[] buffer = new byte[TRANSFER_BUFFER_SIZE]; - for (int count; - (count = in.read(buffer)) != -1;) - zo.write(buffer, 0, count); - zo.finish(); - } - - /* - * Send the contents of the input stream to CVS. - * Length must equal the number of bytes that will be transferred - * across the wire. - */ - private void sendUncompressedBytes(InputStream in, long length) throws IOException, CVSException { - OutputStream out = connection.getOutputStream(); - String sizeLine = Long.toString(length); - writeLine(sizeLine); - byte[] buffer = new byte[TRANSFER_BUFFER_SIZE]; - for (int count; (count = in.read(buffer)) != -1;) out.write(buffer, 0, count); - } - - - - - /** - * Receives a file from the remote CVS server, possibly translating line delimiters. - *

              - * Line termination sequences are automatically converted to platform format - * only when receiving non-binary files. This may alter the actual size and - * contents of the file that is received. - *

              - * Translation is performed on-the-fly, so the file need not fit in available memory. - *

              - * @param file the file to be received - * @param isBinary is true if the file should be received without translation - * @param responseType one of the ICVSFile updated types (UPDATED, CREATED, MERGED, UPDATE_EXISTING) - * indicating what repsonse type provided the file contents - * @param monitor the progress monitor - */ - public void receiveFile(ICVSStorage file, boolean isBinary, int responseType, IProgressMonitor monitor) - throws CVSException { - // check overrides - if (textTransferOverrideSet != null && - textTransferOverrideSet.contains(file)) isBinary = false; - - // update progress monitor - final String title = Policy.bind("Session.receiving", new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$ - monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$ - // get the file size from the server - long size; - boolean compressed = false; - String sizeLine = null; - try { - sizeLine = readLine(); - if (sizeLine.charAt(0) == 'z') { - compressed = true; - sizeLine = sizeLine.substring(1); - } - size = Long.parseLong(sizeLine, 10); - } catch (NumberFormatException e) { - // In some cases, the server will give us an error line here - if (sizeLine != null && sizeLine.startsWith("E")) { //$NON-NLS-1$ - handleErrorLine(sizeLine.substring(1).trim(), org.eclipse.core.runtime.Status.OK_STATUS); - return; - } else { - throw new CVSException(Policy.bind("Session.badInt"), e); //$NON-NLS-1$ - } - } - // create an input stream that spans the next 'size' bytes from the connection - InputStream in = new SizeConstrainedInputStream(connection.getInputStream(), size, true /*discardOnClose*/); - // setup progress monitoring - in = new ProgressMonitorInputStream(in, size, TRANSFER_PROGRESS_INCREMENT, monitor) { - protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) { - if (bytesRead == 0) return; - monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$ - new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })); - } - }; - // if compression enabled, decompress on the fly - if (compressed) { - try { - in = new GZIPInputStream(in); - } catch (IOException e) { - throw CVSException.wrapException(e); - } - } - // if not binary, translate line delimiters on the fly - if (! isBinary) { - // switch from LF to CRLF if appropriate - if (IS_CRLF_PLATFORM && CVSProviderPlugin.getPlugin().isUsePlatformLineend()) { - // auto-correct for CRLF line-ends that come from the server - in = new CRLFtoLFInputStream(in); - // convert LF to CRLF - in = new LFtoCRLFInputStream(in); - } else { - // be nice and warn about text files that contain CRLF - in = new CRLFDetectInputStream(in, file); - } - } - // write the file locally - file.setContents(in, responseType, true, new NullProgressMonitor()); - } - - /** - * Stores the value of the last Mod-time response encountered. - * Valid only for the duration of a single CVS command. - */ - void setModTime(Date modTime) { - this.modTime = modTime; - } - - /** - * Returns the stored value of the last Mod-time response, - * or null if there was none while processing the current command. - */ - Date getModTime() { - return modTime; - } - - /** - * Stores true if the -n global option was specified for the current command. - * Valid only for the duration of a single CVS command. - */ - void setNoLocalChanges(boolean noLocalChanges) { - this.noLocalChanges = noLocalChanges; - } - - /** - * Returns true if the -n global option was specified for the current command, - * false otherwise. - */ - boolean isNoLocalChanges() { - return noLocalChanges; - } - - /** - * Callback hook for the ValidRequestsHandler to specify the set of valid - * requests for this session. - */ - void setValidRequests(String validRequests) { - this.validRequests = " " + validRequests + " "; //$NON-NLS-1$ //$NON-NLS-2$ - } - - public boolean isOutputToConsole() { - return outputToConsole; - } - - /** - * Stores a flag as to whether .# files will be created. (Default is true) - * @param createBackups if true, creates .# files at the server's request - */ - void setCreateBackups(boolean createBackups) { - this.createBackups = createBackups; - } - - /** - * Returns a flag as to whether .# files will be created. - */ - boolean isCreateBackups() { - return createBackups; - } - - /** - * Gets the sendFileTitleKey. - * @return Returns a String - */ - String getSendFileTitleKey() { - if (sendFileTitleKey == null) - return "Session.sending"; //$NON-NLS-1$ - return sendFileTitleKey; - } - - /** - * Sets the sendFileTitleKey. - * @param sendFileTitleKey The sendFileTitleKey to set - */ - public void setSendFileTitleKey(String sendFileTitleKey) { - this.sendFileTitleKey = sendFileTitleKey; - } - - /** - * Remembers a set of files that must be transferred as 'text' - * regardless of what the isBinary parameter to sendFile() is. - * - * @param textTransferOverrideSet the set of ICVSFiles to override, or null if none - */ - public void setTextTransferOverride(Collection textTransferOverrideSet) { - this.textTransferOverrideSet = textTransferOverrideSet; - } - - /** - * Filter the provided global options using parameters set on this session - * or globally. The session may add global options that correspond to user - * preferences or remove those that contradict requirements for this - * particular session. - * - * @param globalOptions the global options, read-only - * @return the filtered global options - */ - protected GlobalOption[] filterGlobalOptions(GlobalOption[] globalOptions) { - if (! Command.DO_NOT_CHANGE.isElementOf(globalOptions)) { - // Get the user preference for verbosity - QuietOption quietOption = CVSProviderPlugin.getPlugin().getQuietness(); - if (quietOption != null) { - globalOptions = quietOption.addToEnd(globalOptions); - } - // Get the user preference for read-only - if (CVSProviderPlugin.getPlugin().getPluginPreferences().getBoolean(CVSProviderPlugin.READ_ONLY)) { - if (!Command.MAKE_READ_ONLY.isElementOf(globalOptions)) { - globalOptions = Command.MAKE_READ_ONLY.addToEnd(globalOptions); - } - } - } - return globalOptions; - } - /** - * Method setIgnoringLocalChanges. - * @param b - */ - protected void setIgnoringLocalChanges(boolean b) { - ignoringLocalChanges = b; - } - /** - * Returns the ignoringLocalChanges. - * @return boolean - */ - protected boolean isIgnoringLocalChanges() { - return ignoringLocalChanges; - } - - /* - * Get the response handler map to be used for this session. The map is created by making a copy of the global - * reponse handler map. - */ - protected Map getReponseHandlers() { - if (responseHandlers == null) { - responseHandlers = Request.getReponseHandlerMap(); - } - return responseHandlers; - } - - /* - * Makes a list of all valid responses; for initializing a session. - * @return a space-delimited list of all valid response strings - */ - private String makeResponseList() { - StringBuffer result = new StringBuffer("ok error M E"); //$NON-NLS-1$ - Iterator elements = getReponseHandlers().keySet().iterator(); - while (elements.hasNext()) { - result.append(' '); - result.append((String) elements.next()); - } - - return result.toString(); - } - public void registerResponseHandler(ResponseHandler handler) { - getReponseHandlers().put(handler.getResponseID(), handler); - } - - public void removeResponseHandler(String responseID) { - getReponseHandlers().remove(responseID); - } - - public ResponseHandler getResponseHandler(String responseID) { - return (ResponseHandler)getReponseHandlers().get(responseID); - } - - /** - * Accumulate the added errors so they can be included in the status returned - * when the command execution is finished. OK status are ignored. - * @param status the status to be accumulated - */ - public void addError(IStatus status) { - if (!status.isOK()) - errors.add(status); - } - - public boolean hasErrors() { - return !errors.isEmpty(); - } - - public IStatus[] getErrors() { - return (IStatus[]) errors.toArray(new IStatus[errors.size()]); - } - - public void clearErrors() { - errors.clear(); - } - - public void setCurrentCommand(Command c) { - currentCommand = c; - } - - public Command getCurrentCommand() { - return currentCommand; - } - - /** - * Report the given error line to any listeners - * @param line the error line - * @param status the status that indicates any problems encountered parsing the line - */ - public void handleErrorLine(String line, IStatus status) { - ConsoleListeners.getInstance().errorLineReceived(this, line, status); - } - - /** - * An error has occurred while processing responses from the - * server. Place this error is the status that will be returned - * from the command and show the error in the console - * @param status the status that descibes the error - */ - public void handleResponseError(IStatus status) { - addError(status); - handleErrorLine(Policy.bind("Session.0", status.getMessage()), status); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java deleted file mode 100644 index 8f8db23e9..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Handles any "Set-static-directory" and "Clear-static-directory" responses - * from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Set-static-directory myproject/ \n
              - *   /u/cvsroot/myproject/ \n
              - *   [...]
              - * 
              - * Then we set or clear the static flag of the folder "myproject", - * automatically creating it if it does not exist locally, - *

              - */ -class StaticHandler extends ResponseHandler { - private final boolean setStaticDirectory; - - public StaticHandler(boolean setStaticDirectory) { - this.setStaticDirectory = setStaticDirectory; - } - - public String getResponseID() { - if (setStaticDirectory) { - return "Set-static-directory"; //$NON-NLS-1$ - } else { - return "Clear-static-directory"; //$NON-NLS-1$ - } - } - - public void handle(Session session, String localDir, - IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryDir = session.readLine(); - - // create the directory then set or clear the static flag - Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$ - repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1); - try { - ICVSFolder folder = createFolder(session, localDir, repositoryDir); - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - // Added to ignore sync info for workspace root - if (syncInfo == null) return; - FolderSyncInfo newInfo = new FolderSyncInfo(syncInfo.getRepository(), - syncInfo.getRoot(), syncInfo.getTag(), setStaticDirectory); - // only set the sync info if it has changed - if (!syncInfo.equals(newInfo)) - folder.setFolderSyncInfo(newInfo); - } catch (CVSException e) { - if (!handleInvalidResourceName(session, session.getLocalRoot().getFolder(localDir), e)) { - throw e; - } - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java deleted file mode 100644 index 31b2d5a63..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -public class Status extends AbstractMessageCommand { - /*** Local options: specific to status ***/ - - protected Status() { } - protected String getRequestId() { - return "status"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java deleted file mode 100644 index 69de3ba35..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Handles any "Set-sticky" and "Clear-stick" responses from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Set-sticky myproject/ \n
              - *   /u/cvsroot/myproject/ \n
              - *   Tsometag \n
              - *   [...]
              - * 
              - * Then we set or clear the sticky tag property of the folder "myproject", - * automatically creating it if it does not exist locally, - *

              - */ -class StickyHandler extends ResponseHandler { - private final boolean setSticky; - - public StickyHandler(boolean setSticky) { - this.setSticky = setSticky; - } - - public String getResponseID() { - if (setSticky) { - return "Set-sticky"; //$NON-NLS-1$ - } else { - return "Clear-sticky"; //$NON-NLS-1$ - } - } - - public void handle(Session session, String localDir, - IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryDir = session.readLine(); - String tag = null; - if (setSticky) { - tag = session.readLine(); - if (tag.length() == 0) tag = null; // FIXME: is this correct - } - - // create the directory then set or clear the sticky tag - Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$ - repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1); - try { - ICVSFolder folder = createFolder(session, localDir, repositoryDir); - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - // Added to ignore sync info for workspace root - if (syncInfo == null) return; - FolderSyncInfo newInfo = new FolderSyncInfo(syncInfo.getRepository(), - syncInfo.getRoot(), tag != null ? new CVSEntryLineTag(tag) : null, - syncInfo.getIsStatic()); - // only set the sync info if it has changed - if (!syncInfo.equals(newInfo)) - folder.setFolderSyncInfo(newInfo); - } catch (CVSException e) { - if (!handleInvalidResourceName(session, session.getLocalRoot().getFolder(localDir), e)) { - throw e; - } - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java deleted file mode 100644 index 6ac042c4b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -public class SyncUpdate extends Update { - - public SyncUpdate() { }; - - /* - * @see Command#sendFileStructure(ICVSResource,IProgressMonitor,boolean,boolean,boolean) - */ - protected void sendFileStructure(Session session, ICVSResource[] resources, - boolean emptyFolders, IProgressMonitor monitor) throws CVSException { - - checkResourcesManaged(resources); - new FileStructureVisitor(session, emptyFolders, true, false).visit(session, resources, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification() - */ - protected boolean isWorkspaceModification() { - // The sync-update will not modify the workspace - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#filterGlobalOptions(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[]) - */ - protected GlobalOption[] filterGlobalOptions(Session session, GlobalOption[] globalOptions) { - // Ensure that the DO_NOT_CHANGE (-n) global option is present - if (! Command.DO_NOT_CHANGE.isElementOf(globalOptions)) { - globalOptions = Command.DO_NOT_CHANGE.addToEnd(globalOptions); - } - return super.filterGlobalOptions(session, globalOptions); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java deleted file mode 100644 index 63176791f..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener; - -public class Tag extends Command { - /*** Local options: specific to tag ***/ - public static final LocalOption CREATE_BRANCH = new LocalOption("-b", null); //$NON-NLS-1$ - public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$ - - /*** Default command output listener ***/ - private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener(); - - // handle added and removed resources in a special way - private boolean customBehaviorEnabled; - - protected Tag(boolean customBehaviorEnabled) { - this.customBehaviorEnabled = customBehaviorEnabled; - } - - protected Tag() { - this(false); - } - - protected String getRequestId() { - return "tag"; //$NON-NLS-1$ - } - - protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, - String[] arguments) throws CVSException { - - if (arguments.length < 1) throw new IllegalArgumentException(); - String[] allButFirst = new String[arguments.length - 1]; - System.arraycopy(arguments, 1, allButFirst, 0, arguments.length - 1); - return super.computeWorkResources(session, localOptions, allButFirst); - } - - public IStatus execute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, CVSTag tag, String[] arguments, ICommandOutputListener listener, - IProgressMonitor monitor) throws CVSException { - - if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) { - throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("Tag.notVersionOrBranchError"))); //$NON-NLS-1$ - } - - // Add the CREATE_BRANCH option for a branch tag - if (tag.getType() == CVSTag.BRANCH) { - if ( ! CREATE_BRANCH.isElementOf(localOptions)) { - LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1]; - System.arraycopy(localOptions, 0, newLocalOptions, 0, localOptions.length); - newLocalOptions[newLocalOptions.length - 1] = CREATE_BRANCH; - localOptions = newLocalOptions; - } - } - - // Add the tag name to the start of the arguments - String[] newArguments = new String[arguments.length + 1]; - newArguments[0] = tag.getName(); - System.arraycopy(arguments, 0, newArguments, 1, arguments.length); - - return execute(session, globalOptions, localOptions, newArguments, listener, monitor); - } - - public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, - CVSTag tag, ICVSResource[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) - throws CVSException { - - String[] stringArguments = convertArgumentsForOpenSession(arguments, session); - - return execute(session, globalOptions, localOptions, tag, stringArguments, listener, monitor); - } - - protected ICommandOutputListener getDefaultCommandOutputListener() { - return DEFAULT_OUTPUT_LISTENER; - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Send all folders that are already managed to the server - if (customBehaviorEnabled) { - new TagFileSender(session).visit(session, resources, monitor); - } else { - new FileStructureVisitor(session, false, false).visit(session, resources, monitor); - } - return resources; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java deleted file mode 100644 index ee408f14f..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * Special visitor which handles added and removed files in a special way. - * Added resources are skipped. Deleted resources are sent as if they were not deleted. - */ -class TagFileSender extends FileStructureVisitor { - - public TagFileSender(Session session) { - super(session, false, false); - } - - /** - * Override sendFile to provide custom handling of added and deleted resources. - * Added resources are skipped. Deleted resources are sent as if they were not deleted. - */ - protected void sendFile(ICVSFile mFile) throws CVSException { - Policy.checkCanceled(monitor); - byte[] syncBytes = mFile.getSyncBytes(); - if (syncBytes != null) { - // Send the parent folder if it hasn't been sent already - sendFolder(mFile.getParent()); - // Send the file if appropriate - if (ResourceSyncInfo.isDeletion(syncBytes)) { - // makes this resource sync undeleted - syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes); - } - if (!ResourceSyncInfo.isAddition(syncBytes)) { - session.sendEntry(syncBytes, ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp())); - session.sendIsModified(mFile, ResourceSyncInfo.isBinary(syncBytes), monitor); - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java deleted file mode 100644 index 4469a4103..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.io.*; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class TemplateHandler extends ResponseHandler { - - /** - * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getResponseID() - */ - public String getResponseID() { - return "Template"; //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#handle(org.eclipse.team.internal.ccvs.core.client.Session, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) - */ - public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException { - session.readLine(); /* read the remote dir which is not needed */ - ICVSFolder localFolder = getExistingFolder(session, localDir); - IContainer container = (IContainer)localFolder.getIResource(); - ICVSStorage templateFile = null; - if (container != null) { - try { - templateFile = CVSWorkspaceRoot.getCVSFileFor(SyncFileWriter.getTemplateFile(container)); - } catch (CVSException e) { - // Log the inability to create the template file - CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR, "Could not write template file in " + container.getFullPath() + ": " + e.getMessage(), e)); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - if (container == null || templateFile == null) { - // Create a dummy storage handle to recieve the contents from the server - templateFile = new ICVSStorage() { - public String getName() { - return "Template"; //$NON-NLS-1$ - } - public void setContents( - InputStream stream, - int responseType, - boolean keepLocalHistory, - IProgressMonitor monitor) - throws CVSException { - - try { - // Transfer the contents - OutputStream out = new ByteArrayOutputStream(); - try { - byte[] buffer = new byte[1024]; - int read; - while ((read = stream.read(buffer)) >= 0) { - Policy.checkCanceled(monitor); - out.write(buffer, 0, read); - } - } finally { - out.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); //$NON-NLS-1$ - } finally { - try { - stream.close(); - } catch (IOException e1) { - // Ignore close errors - } - } - } - public long getSize() { - return 0; - } - public InputStream getContents() throws CVSException { - return new ByteArrayInputStream(new byte[0]); - } - }; - } - try { - session.receiveFile(templateFile, false, UpdatedHandler.HANDLE_UPDATED, monitor); - } catch (CVSException e) { - if (!(templateFile instanceof ICVSFile && handleInvalidResourceName(session, (ICVSFile)templateFile, e))) { - throw e; - } - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java deleted file mode 100644 index d3075e557..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener; - -public class Update extends Command { - /*** Local options: specific to update ***/ - public static final LocalOption CLEAR_STICKY = new LocalOption("-A"); //$NON-NLS-1$ - public static final LocalOption IGNORE_LOCAL_CHANGES = new LocalOption("-C"); //$NON-NLS-1$ - public static final LocalOption RETRIEVE_ABSENT_DIRECTORIES = new LocalOption("-d"); //$NON-NLS-1$ - public static final LocalOption JOIN = new LocalOption("-j"); //$NON-NLS-1$ - - /*** Default command output listener ***/ - private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new UpdateListener(null); - - /*** File information status returned from update ***/ - public static final int STATE_NONE = 0; // no state information available - public static final int STATE_ADDED_LOCAL = 1; // new file locally that was added but not comitted to server yet - public static final int STATE_UNKOWN = 2; // new file locally but not added to server - public static final int STATE_REMOTE_CHANGES = 3; // remote changes to an unmodified local file - public static final int STATE_DELETED = 4; // removed locally but still exists on the server - public static final int STATE_MODIFIED = 5; // modified locally - public static final int STATE_CONFLICT = 6; // modified locally and on the server but cannot be auto-merged - public static final int STATE_MERGEABLE_CONFLICT = 7; // modified locally and on the server but can be auto-merged - - /** - * Makes a -r or -D or -A option for a tag. - * Valid for: checkout export history rdiff update - */ - public static LocalOption makeTagOption(CVSTag tag) { - int type = tag.getType(); - switch (type) { - case CVSTag.HEAD: - return CLEAR_STICKY; - default: - return Command.makeTagOption(tag); - } - } - - protected Update() { } - protected String getRequestId() { - return "update"; //$NON-NLS-1$ - } - - protected ICommandOutputListener getDefaultCommandOutputListener() { - return DEFAULT_OUTPUT_LISTENER; - } - - protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - - // Send all folders that are already managed to the server - // even folders that are empty - sendFileStructure(session, resources, true, monitor); - return resources; - } - - /** - * Convenience method that allows the creation of .# files to be disabled. - * @param createBackups if true, creates .# files - * @see Command.execute - */ - public final IStatus execute(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener, - IProgressMonitor pm, boolean createBackups) throws CVSException { - session.setCreateBackups(createBackups); - try { - return super.execute(session, globalOptions, localOptions, arguments, listener, pm); - } finally { - session.setCreateBackups(true); - } - } - - /** - * On successful finish, prune empty directories if the -P or -D option was specified. - */ - protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, - IStatus status) throws CVSException { - // If we didn't succeed, don't do any post processing - if (status.getCode() == CVSStatus.SERVER_ERROR) { - return status; - } - - // If we are pruning (-P), then prune empty directories - // Note, the CVS spec says that Date (-D) and version (-r) updates - // should automatically prune but this is a problem for remote CVS handles - // which fetch a level at a time - if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) { //$NON-NLS-1$ - // Delete empty directories - new PruneFolderVisitor().visit(session, resources); - - } - return status; - } - - protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) { - List newOptions = new ArrayList(Arrays.asList(localOptions)); - - // Look for absent directories if enabled and the option is not already included - IResource resource = null; - RepositoryProvider provider = null; - // If there is a provider, use the providers setting - try { - resource = session.getLocalRoot().getIResource(); - if (resource != null) { - provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()); - if (provider != null) { - if (((CVSTeamProvider)provider).getFetchAbsentDirectories() && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) { - newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES); - } - } - } - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - // If there is no provider, use the global setting - if (provider == null) { - if (CVSProviderPlugin.getPlugin().getFetchAbsentDirectories() && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) { - newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES); - } - } - - // Prune empty directories if pruning is enabled and the command in not being run in non-update mode - if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() && ! PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) { - if (! DO_NOT_CHANGE.isElementOf(globalOptions)) { - newOptions.add(Update.PRUNE_EMPTY_DIRECTORIES); - } - } - localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]); - return super.filterLocalOptions(session, globalOptions, localOptions); - } - - /** - * We allow unmanaged resources as long as there parents are managed. - * - * @see Command#checkResourcesManaged(ICVSResource[]) - */ - protected void checkResourcesManaged(ICVSResource[] resources) throws CVSException { - for (int i = 0; i < resources.length; ++i) { - ICVSFolder folder; - if (resources[i].isFolder()) { - if (((ICVSFolder)resources[i]).isCVSFolder()) { - folder = (ICVSFolder)resources[i]; - } else { - folder = resources[i].getParent(); - } - } - else { - folder = resources[i].getParent(); - } - if (folder==null || (!folder.isCVSFolder() && folder.exists())) { - throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$ - } - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption, org.eclipse.team.internal.ccvs.core.client.Command.LocalOption, java.lang.String, org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus doExecute( - Session session, - GlobalOption[] globalOptions, - LocalOption[] localOptions, - String[] arguments, - ICommandOutputListener listener, - IProgressMonitor monitor) - throws CVSException { - - session.setIgnoringLocalChanges(IGNORE_LOCAL_CHANGES.isElementOf(localOptions)); - try { - return super.doExecute( - session, - globalOptions, - localOptions, - arguments, - listener, - monitor); - } finally { - session.setIgnoringLocalChanges(false); - } - - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java deleted file mode 100644 index 1af7a337b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.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 - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * This custom update command will only update files that - * are either incoming changes (Update-existing) or auto-mergable - * (Merged with no "+=" in entry line). - */ -public class UpdateMergableOnly extends Update { - - private static final String LOCAL_FILE_PATH_VARIABLE_NAME = "localFilePath"; //$NON-NLS-1$ - private static ServerMessageLineMatcher MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER; - static { - // TODO: temprary until proper lifecycle is defined - initializePatterns(); - } - public static void initializePatterns() { - try { - MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.MERGE_UPDATE_CONFLICTING_ADDITION, new String[] {LOCAL_FILE_PATH_VARIABLE_NAME}); - } catch (CVSException e) { - // This is serious as the listener will not function properly - CVSProviderPlugin.log(e); - } - } - - List skippedFiles = new ArrayList(); - - public class MergableOnlyUpdatedHandler extends UpdatedHandler { - - public MergableOnlyUpdatedHandler() { - // handle "Merged" responses - super(UpdatedHandler.HANDLE_MERGED); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.UpdatedHandler#getTargetFile(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, byte[]) - */ - protected ICVSFile getTargetFile(ICVSFolder mParent, String fileName, byte[] entryBytes) throws CVSException { - String adjustedFileName = fileName; - if (ResourceSyncInfo.isMergedWithConflicts(entryBytes)) { - // for merged-with-conflict, return a temp file - adjustedFileName = ".##" + adjustedFileName + " " + ResourceSyncInfo.getRevision(entryBytes); //$NON-NLS-1$ //$NON-NLS-2$ - skippedFiles.add(((IContainer)mParent.getIResource()).getFile(new Path(null, fileName))); - } - return super.getTargetFile(mParent, adjustedFileName, entryBytes); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.UpdatedHandler#receiveTargetFile(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.ICVSFile, java.lang.String, java.util.Date, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void receiveTargetFile( - Session session, - ICVSFile mFile, - String entryLine, - Date modTime, - boolean binary, - boolean readOnly, - boolean executable, - IProgressMonitor monitor) - throws CVSException { - - if (ResourceSyncInfo.isMergedWithConflicts(entryLine.getBytes())) { - // For merged-with-conflict, just recieve the file contents. - // Use the Updated handler type so that the file will be created or - // updated. - session.receiveFile(mFile, binary, UpdatedHandler.HANDLE_UPDATED, monitor); - // Now delete the file since it is not used - mFile.delete(); - } else { - super.receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, monitor); - } - } - } - - /** - * Override the general update listener to handle the following - * message: - * cvs server: file folder/file.ext exists, but has been added in revision TAG_NAME - * This is required because MergeSubscriber adjusts the base when an update - * occurs and we can end up in a situation where the update faile with the - * above message (see buh 58654). - */ - public class MergeUpdateListener extends UpdateListener { - public MergeUpdateListener(IUpdateMessageListener updateMessageListener) { - super(updateMessageListener); - } - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - Map variables = MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER.processServerMessage(line); - if (variables != null) { - String filePath = (String)variables.get(LOCAL_FILE_PATH_VARIABLE_NAME); - try { - ICVSResource cvsResource = commandRoot.getChild(filePath); - IResource resource = cvsResource.getIResource(); - if (resource != null && resource.getType() == IResource.FILE) { - skippedFiles.add(resource); - return OK; - } - } catch (CVSException e) { - CVSProviderPlugin.log(e); - // Fall through to let the superclass process the error line - } - } - return super.errorLine(line, location, commandRoot, monitor); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus doExecute( - Session session, - GlobalOption[] globalOptions, - LocalOption[] localOptions, - String[] arguments, - ICommandOutputListener listener, - IProgressMonitor monitor) - throws CVSException { - - MergableOnlyUpdatedHandler newHandler = new MergableOnlyUpdatedHandler(); - ResponseHandler oldHandler = session.getResponseHandler(newHandler.getResponseID()); - skippedFiles.clear(); - try { - session.registerResponseHandler(newHandler); - // Don't create backup files since merges won't be overridden - session.setCreateBackups(false); - return super.doExecute( - session, - globalOptions, - localOptions, - arguments, - new MergeUpdateListener(null), - monitor); - } finally { - session.registerResponseHandler(oldHandler); - session.setCreateBackups(true); - } - } - - public IFile[] getSkippedFiles() { - return (IFile[]) skippedFiles.toArray(new IFile[skippedFiles.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateWithOverwrite.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateWithOverwrite.java deleted file mode 100644 index 8d662ced1..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateWithOverwrite.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; - -/** - * A specialized update that will ignore unmanaged local content. - * It is the same os CheckoutWithOverwrite. - */ -public class UpdateWithOverwrite extends Update { - - /** - * This class overrides the "Created" handler but uses the "Updated" - * behavior which will overwrite existing files. - */ - public class CreatedResponseHandler extends UpdatedHandler { - public CreatedResponseHandler() { - super(UpdatedHandler.HANDLE_UPDATED); - } - public String getResponseID() { - return "Created"; //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus doExecute( - Session session, - GlobalOption[] globalOptions, - LocalOption[] localOptions, - String[] arguments, - ICommandOutputListener listener, - IProgressMonitor monitor) - throws CVSException { - - ResponseHandler newCreated = new CreatedResponseHandler(); - ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID()); - session.registerResponseHandler(newCreated); - try { - return super.doExecute( - session, - globalOptions, - localOptions, - arguments, - listener, - monitor); - } finally { - session.registerResponseHandler(oldCreated); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java deleted file mode 100644 index 3c88163d4..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.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 - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import java.util.Date; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * Handles any "Updated" and "Merged" responses - * from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Updated ???\n
              - *   [...]
              - * 
              - * Then - *

              - */ - -/** - * Does get information about the file that is updated - * and the file-content itself and puts it on the fileSystem. - * - * The difference beetween the "Updated" and the "Merged" is, that - * an "Merged" file is not going to be up-to-date after the operation. - * - * Requiers a exisiting parent-folder. - */ -public class UpdatedHandler extends ResponseHandler { - - private int handlerType; - - protected static final int HANDLE_UPDATED = ICVSFile.UPDATED; - protected static final int HANDLE_MERGED = ICVSFile.MERGED; - protected static final int HANDLE_UPDATE_EXISTING = ICVSFile.UPDATE_EXISTING; - protected static final int HANDLE_CREATED = ICVSFile.CREATED; - - private static final String READ_ONLY_FLAG = "u=rw"; //$NON-NLS-1$ - private static final String EXECUTE_FLAG = "x"; //$NON-NLS-1$ - - public UpdatedHandler(int handlerType) { - this.handlerType = handlerType; - } - - public String getResponseID() { - switch (handlerType) { - case HANDLE_UPDATED: return "Updated"; //$NON-NLS-1$ - case HANDLE_MERGED: return "Merged"; //$NON-NLS-1$ - case HANDLE_UPDATE_EXISTING: return "Update-existing"; //$NON-NLS-1$ - case HANDLE_CREATED: return "Created"; //$NON-NLS-1$ - } - return null; - } - - public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException { - // read additional data for the response - String repositoryFile = session.readLine(); - String entryLine = session.readLine(); - byte[] entryBytes = entryLine.getBytes(); - String permissionsLine = session.readLine(); - - // clear file update modifiers - Date modTime = session.getModTime(); - session.setModTime(null); - - // Get the local file - String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$ - ICVSFolder mParent = getExistingFolder(session, localDir); - ICVSFile mFile = getTargetFile(mParent, fileName, entryBytes); - - boolean binary = ResourceSyncInfo.isBinary(entryBytes); - boolean readOnly = permissionsLine.indexOf(READ_ONLY_FLAG) == -1; - boolean executable = permissionsLine.indexOf(EXECUTE_FLAG) != -1; - - try { - // The file may have been set as read-only by a previous checkout/update - if (mFile.isReadOnly()) mFile.setReadOnly(false); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } - - try { - receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, monitor); - } catch (CVSException e) { - // An error occurred while recieving the file. - // If it is due to an invalid file name, - // accumulate the error and continue. - // Otherwise, exit - if (!handleInvalidResourceName(session, mFile, e)) { - throw e; - } - } - } - - protected ICVSFile getTargetFile(ICVSFolder mParent, String fileName, byte[] entryBytes) throws CVSException { - return mParent.getFile(fileName); - } - - protected void receiveTargetFile(Session session, ICVSFile mFile, String entryLine, Date modTime, boolean binary, boolean readOnly, boolean executable, IProgressMonitor monitor) throws CVSException { - - // receive the file contents from the server - session.receiveFile(mFile, binary, handlerType, monitor); - - // Set the timestamp in the file and get it again so that we use the *real* timestamp - // in the sync info. The os may not actually set the time we provided :) - mFile.setTimeStamp(modTime); - modTime = mFile.getTimeStamp(); - ResourceSyncInfo info = new ResourceSyncInfo(entryLine, null, null); - MutableResourceSyncInfo newInfoWithTimestamp = info.cloneMutable(); - newInfoWithTimestamp.setTimeStamp(modTime); - int modificationState = ICVSFile.UNKNOWN; - if(handlerType==HANDLE_MERGED) { - newInfoWithTimestamp.setMerged(); - } else if (!session.isIgnoringLocalChanges() - && !info.isAdded() /* could be an added entry during a merge in which case it is dirty */ - && (handlerType==HANDLE_UPDATE_EXISTING || handlerType==HANDLE_CREATED)) { - // both these cases result in an unmodified file. - // reporting is handled by the FileModificationManager - modificationState = ICVSFile.CLEAN; - CVSProviderPlugin.getPlugin().getFileModificationManager().updated(mFile); - } - mFile.setSyncInfo(newInfoWithTimestamp, modificationState); - try { - if (readOnly) mFile.setReadOnly(true); - if (executable) mFile.setExecutable(true); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java deleted file mode 100644 index 4272e132a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; - -class ValidRequests extends Request { - - protected ValidRequests() { } - - protected String getRequestId() { - return "valid-requests"; //$NON-NLS-1$ - } - - public IStatus execute(Session session, IProgressMonitor monitor) throws CVSException { - return executeRequest(session, Command.DEFAULT_OUTPUT_LISTENER, monitor); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java deleted file mode 100644 index 965ce9fd7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.client.Session; - -/** - * Handles a "Valid-requests" response from the CVS server. - *

              - * Suppose as a result of performing a command the CVS server responds - * as follows:
              - *

              - *   [...]
              - *   Valid-requests ci co update Root Directory Valid-responses Argument ...\n
              - *   [...]
              - * 
              - * Then we remember the set of valid requests for this session in - * preparation for isValidRequests queries. - *

              - */ -class ValidRequestsHandler extends ResponseHandler { - public String getResponseID() { - return "Valid-requests"; //$NON-NLS-1$ - } - - public void handle(Session session, String validRequests, - IProgressMonitor monitor) throws CVSException { - // remember the set of valid requests for this session - session.setValidRequests(validRequests); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java deleted file mode 100644 index 7e888df3b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; - -/** - * Here are some of the output formats we know about: - * - * Concurrent Versions System (CVS) 1.11.1p1 (client/server) - * Concurrent Versions System (CVS) NT 1.11.1.1 (Build 27) - * Concurrent Versions System (CVSNT) 1.11.1.3 (Build 57a) (client/server) - */ -public class Version extends RemoteCommand { - - private static final String CVS_NT_PREFIX_1 = "Concurrent Versions System (CVS) NT "; //$NON-NLS-1$ - private static final String CVS_NT_PREFIX_2 = "Concurrent Versions System (CVSNT) "; //$NON-NLS-1$ - private static final String CVS_PREFIX = "Concurrent Versions System (CVS) "; //$NON-NLS-1$ - /** - * @see Request#getRequestId() - */ - protected String getRequestId() { - return "version"; //$NON-NLS-1$ - } - - public IStatus execute(Session session, final ICVSRepositoryLocation location, IProgressMonitor monitor) throws CVSException { - - // The server may not support the version request - if ( ! session.isValidRequest(getRequestId())) { - IStatus status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_UNKNOWN, Policy.bind("Version.versionNotValidRequest", location.getHost()));//$NON-NLS-1$ - ((CVSRepositoryLocation)location).setServerPlaform(CVSRepositoryLocation.UNKNOWN_SERVER); - CVSProviderPlugin.log(status); - return status; - } - - ICommandOutputListener listener = new ICommandOutputListener() { - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String knownPrefix = null; - boolean isCVSNT = false; - if (line.startsWith(CVS_NT_PREFIX_1)) { - isCVSNT = true; - knownPrefix = CVS_NT_PREFIX_1; - } else if (line.startsWith(CVS_NT_PREFIX_2)) { - isCVSNT = true; - knownPrefix = CVS_NT_PREFIX_2; - } else if (line.startsWith(CVS_PREFIX)) { - knownPrefix = CVS_PREFIX; - } - IStatus status = OK; - int serverType = CVSRepositoryLocation.CVS_SERVER; - if (knownPrefix != null) { - String versionNumber = line.substring(knownPrefix.length(), line.indexOf(' ', knownPrefix.length() + 1)); - if (versionNumber.startsWith("1.10") || versionNumber.equals("1.11") || versionNumber.equals("1.11.1")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - serverType = CVSRepositoryLocation.UNSUPPORTED_SERVER; - status = new CVSStatus(IStatus.WARNING, CVSStatus.UNSUPPORTED_SERVER_VERSION, Policy.bind("Version.unsupportedVersion", location.getHost(), versionNumber));//$NON-NLS-1$ - } else if (isCVSNT) { - serverType = CVSRepositoryLocation.CVSNT_SERVER; - } - } else { - serverType = CVSRepositoryLocation.UNKNOWN_SERVER; - status = new CVSStatus(IStatus.INFO, CVSStatus.SERVER_IS_UNKNOWN, Policy.bind("Version.unknownVersionFormat", location.getHost(), line));//$NON-NLS-1$ - } - ((CVSRepositoryLocation)location).setServerPlaform(serverType); - return status; - } - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line); - } - }; - - return execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, new String[] {}, listener, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification() - */ - protected boolean isWorkspaceModification() { - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java deleted file mode 100644 index c3dbf3348..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Used with 'admin -ksubst' to capture lines of text that are issued - * as confirmation that the remote keyword substitution mode has been - * changed. When encountered, updates the local ResourceSyncInfo for - * the file in question to reflect - * - * e.g. - * RCS file: path/filename,v - * done - * - * We don't expect to see anything special on stderr if the command succeeds. - */ -public class AdminKSubstListener extends CommandOutputListener { - private KSubstOption ksubstMode; - - public AdminKSubstListener(KSubstOption ksubstMode) { - this.ksubstMode = ksubstMode; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - if (line.startsWith("RCS file:")) { //$NON-NLS-1$ - String rcsFile = line.substring(10).trim(); - if (! rcsFile.endsWith(",v")) { //$NON-NLS-1$ - return new CVSStatus(CVSStatus.ERROR, - Policy.bind("AdminKSubstListener.expectedRCSFile", rcsFile)); //$NON-NLS-1$ - } - IPath rcsFilePath = new Path(null, Util.removeAtticSegment(rcsFile.substring(0, rcsFile.length() - 2))); - try { - ICVSFile file = findLocalFileFor(commandRoot, rcsFilePath); - //ResourceSyncInfo info = file.getSyncInfo(); - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes != null) { - // only update sync info if we have it locally - file.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, ksubstMode), ICVSFile.UNKNOWN); - } - } catch (CVSException e) { - return e.getStatus(); - } - } - return OK; - } - - private ICVSFile findLocalFileFor(ICVSFolder commandRoot, IPath rcsFilePath) throws CVSException { - - // First, look for the local file by following the remote path - FolderSyncInfo info = commandRoot.getFolderSyncInfo(); - String remoteRootLocation = info.getRemoteLocation(); - if (remoteRootLocation == null) { - throw new CVSException(new CVSStatus(CVSStatus.ERROR, - Policy.bind("AdminKSubstListener.commandRootNotManaged"))); //$NON-NLS-1$ - } - IPath remoteRootPath = new Path(null, remoteRootLocation); - if (remoteRootPath.isPrefixOf(rcsFilePath)) { - IPath relativeFilePath = rcsFilePath.removeFirstSegments(remoteRootPath.segmentCount()); - ICVSFile file = commandRoot.getFile(relativeFilePath.toString()); - if (file.isManaged() && isMatchingPath(file, rcsFilePath)) { - return file; - } - } - - // We couldn't find the file that way which means we're working in a defined module. - // Scan all folders looking for a match - ICVSFolder parent = findFolder(commandRoot, rcsFilePath.removeLastSegments(1)); - if (parent != null) { - ICVSFile file = parent.getFile(rcsFilePath.lastSegment()); - if (file.isManaged()) { - return file; - } - } - - // No file was found so return null; - throw new CVSException(new CVSStatus(CVSStatus.ERROR, - Policy.bind("AdminKSubstListener.expectedChildOfCommandRoot", //$NON-NLS-1$ - rcsFilePath.toString(), remoteRootPath.toString()))); - } - - private ICVSFolder findFolder(ICVSFolder commandRoot, IPath path) throws CVSException { - final String remotePath = path.toString(); - final ICVSFolder[] result = new ICVSFolder[] { null }; - commandRoot.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - // Nothing to do for files - } - public void visitFolder(ICVSFolder folder) throws CVSException { - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info != null && info.getRemoteLocation().equals(remotePath)) { - // We found the folder we're looking for - result[0] = folder; - } - if (result[0] == null) { - folder.acceptChildren(this); - } - } - }); - return result[0]; - } - - private boolean isMatchingPath(ICVSFile file, IPath rcsFilePath) throws CVSException { - FolderSyncInfo info = file.getParent().getFolderSyncInfo(); - return info != null - && info.getRemoteLocation().equals(rcsFilePath.removeLastSegments(1).toString()); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java deleted file mode 100644 index 37c464509..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.Policy; - -public class AnnotateListener extends CommandOutputListener { - -/** - * Handle output from the CVS Annotate command. - */ - ByteArrayOutputStream aStream = new ByteArrayOutputStream(); - List blocks = new ArrayList(); - int lineNumber; - String error; - - public String getError() { - return error; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - - CVSAnnotateBlock aBlock = new CVSAnnotateBlock(line, lineNumber++); - if (!aBlock.isValid()) { - error = line; - } - - /** - * Make sure all lines have a line terminator. - */ - try { - aStream.write(line.substring(aBlock.getSourceOffset()).getBytes()); - if (!(line.endsWith("\r") || line.endsWith("\r\n"))) { //$NON-NLS-1$ //$NON-NLS-2$ - aStream.write(System.getProperty("line.separator").getBytes()); //$NON-NLS-1$ - } - } catch (IOException e) { - } - add(aBlock); - return OK; - } - - public InputStream getContents() { - return new ByteArrayInputStream(aStream.toByteArray()); - } - - public List getCvsAnnotateBlocks() { - return blocks; - } - /** - * Add an annotate block to the receiver merging this block with the - * previous block if it is part of the same change. - * @param aBlock - */ - private void add(CVSAnnotateBlock aBlock) { - - int size = blocks.size(); - if (size == 0) { - blocks.add(aBlock); - } else { - CVSAnnotateBlock lastBlock = (CVSAnnotateBlock) blocks.get(size - 1); - if (lastBlock.getRevision().equals(aBlock.getRevision())) { - lastBlock.setEndLine(aBlock.getStartLine()); - } else { - blocks.add(aBlock); - } - } - } - - public boolean hasError() { - return (error != null); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - if(line.startsWith(Policy.bind("AnnotateListener.3"))) { //$NON-NLS-1$ - error = Policy.bind("AnnotateListener.4"); //$NON-NLS-1$ - return new CVSStatus(CVSStatus.ERROR, CVSStatus.SERVER_ERROR, commandRoot, error); - } - return super.errorLine(line, location, commandRoot, monitor); - } - - /** - * Set the contents of the listener to the provided contents. - * This is done if the contents fetched by the annotate command - * has a charater set that may have been mangled by the transfer - * @param remoteContents the actual contens of the file - */ - public void setContents(InputStream remoteContents) { - try { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int n = remoteContents.read(buffer); - while (n != -1) { - stream.write(buffer, 0, n); - n = remoteContents.read(buffer); - } - aStream = stream; - } catch (IOException e) { - // Log and continue - CVSProviderPlugin.log(CVSException.wrapException(e)); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/CompareDiffListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/CompareDiffListener.java deleted file mode 100644 index fcaa933a0..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/CompareDiffListener.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.team.internal.ccvs.core.client.listeners; - -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * This class interprets the output of "cvs diff --brief ..." in order to get the revisions - * of two compared versions of a project or folder. - */ -public class CompareDiffListener extends CommandOutputListener { - - private static ServerMessageLineMatcher LOCAL_FILE_MATCHER; - private static ServerMessageLineMatcher REMOTE_FILE_MATCHER; - private static ServerMessageLineMatcher REVISION_LINE_MATCHER; - - static { - try { - LOCAL_FILE_MATCHER = new ServerMessageLineMatcher( - "Index: (localFile:.*:localFile)", new String[] {"localFile"}); //$NON-NLS-1$ //$NON-NLS-2$ - REMOTE_FILE_MATCHER = new ServerMessageLineMatcher( - "RCS file: (remoteFile:.*:remoteFile),v", new String[] {"remoteFile"}); //$NON-NLS-1$ //$NON-NLS-2$ - REVISION_LINE_MATCHER = new ServerMessageLineMatcher( - "diff .* -r(leftRevision:.*:leftRevision) -r(rightRevision:.*:rightRevision)", new String[] {"leftRevision", "rightRevision"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } catch (CVSException e) { - // This is serious as the listener will not function properly - CVSProviderPlugin.log(e); - LOCAL_FILE_MATCHER = null; - REMOTE_FILE_MATCHER = null; - REVISION_LINE_MATCHER = null; - } - } - - private String localFilePath, remoteFilePath, leftRevision, rightRevision; - - private IFileDiffListener listener; - - public interface IFileDiffListener { - public void fileDiff( - String localFilePath, - String remoteFilePath, - String leftRevision, - String rightRevision); - } - - public CompareDiffListener(IFileDiffListener listener) { - this.listener = listener; - } - - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - // ignore any server messages - if (getServerMessage(line, location) != null) { - return OK; - } - Map map = LOCAL_FILE_MATCHER.processServerMessage(line); - if (map != null) { - localFilePath = (String)map.get("localFile"); //$NON-NLS-1$ - return OK; - } - map = REMOTE_FILE_MATCHER.processServerMessage(line); - if (map != null) { - remoteFilePath = (String)map.get("remoteFile"); //$NON-NLS-1$ - return OK; - } - map = REVISION_LINE_MATCHER.processServerMessage(line); - if (map != null) { - leftRevision = (String)map.get("leftRevision"); //$NON-NLS-1$ - rightRevision = (String)map.get("rightRevision"); //$NON-NLS-1$ - if (localFilePath == null || remoteFilePath == null) { - return new CVSStatus(IStatus.ERROR, Policy.bind("CompareDiffListener.11")); //$NON-NLS-1$ - } - listener.fileDiff(localFilePath, remoteFilePath, leftRevision, rightRevision); - localFilePath = remoteFilePath = leftRevision = rightRevision = null; - return OK; - } - // Ignore all other lines - return OK; - } - - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - // ignore server messages for now - this is used only with the diff - // request and the errors can be safely ignored. - if (getServerMessage(line, location) != null) { - return OK; - } - return super.errorLine(line, location, commandRoot, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java deleted file mode 100644 index 1637535a5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.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.team.internal.ccvs.core.client.listeners; - - -import java.io.PrintStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -public class DiffListener extends CommandOutputListener { - PrintStream patchStream; - - public DiffListener(PrintStream patchStream) { - this.patchStream = patchStream; - } - - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Ensure that the line doesn't end with a CR. - // This can happen if the remote file has CR/LF in it. - if (line.length() > 0 && line.charAt(line.length() - 1) == '\r') { - line = line.substring(0, line.length() - 1); - } - patchStream.println(line); - return OK; - } - - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - // ignore server messages for now - this is used only with the diff - // request and the errors can be safely ignored. - if (getServerMessage(line, location) != null) { - return OK; - } - return super.errorLine(line, location, commandRoot, monitor); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java deleted file mode 100644 index 096684f15..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.EditorsInfo; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - - -/** - * - * - * Listener for the Editors command - * - * @author Gregor Kohlwes - * - */ -public class EditorsListener extends CommandOutputListener { - /** - * List to store the EditorsInfos - */ - private List infos = new LinkedList(); - - /** - * Name of the current file - */ - private String fileName; - - /** - * Constructor EditorsListener. - */ - public EditorsListener() { - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // If there is a file with multiple editors - // then cvs will write the filename only - // in the first line and the following - // line will start with a Tab - if (line.startsWith("\t")) { //$NON-NLS-1$ - line = fileName + line; - } - EditorsInfo info = new EditorsInfo(); - StringTokenizer tokenizer = new StringTokenizer(line,"\t"); //$NON-NLS-1$ - int i = 0; - while(tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - switch (i) { - case 0: - info.setFileName(token); - fileName = token; - break; - case 1: - info.setUserName(token); - break; - case 2: - info.setDateString(token); - break; - case 3: - info.setComputerName(token); - break; - default : - break; - } - i++; - } - - infos.add(info); - return OK; - - } - /** - * Method getEditorsInfos. - * @return IEditorsInfo[] - */ - public EditorsInfo[] getEditorsInfos() { - return (EditorsInfo[]) infos.toArray(new EditorsInfo[infos.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java deleted file mode 100644 index 58281d8ae..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * Instances of this interface can be passed to the Command#execute methods - * and will receive notification when M or E messages are received from the server. - */ -public interface ICommandOutputListener { - - /*** Status to be returned when no error or warning occured ***/ - public static final IStatus OK = new CVSStatus(CVSStatus.OK, Policy.bind("ok")); //$NON-NLS-1$ - - public static final String SERVER_PREFIX = "server: "; //$NON-NLS-1$ - public static final String SERVER_ABORTED_PREFIX = "[server aborted]: "; //$NON-NLS-1$ - public static final String RTAG_PREFIX = "rtag: "; //$NON-NLS-1$ - - /** - * Invoked when a message line is received from the server. - *

              - * Any status other than ICommandOutputListener.OK will be accumulated - * by the command and returned. The severity of the status matches those of - * IStatus and must indicate whether this is a warning, error, or informational - * text.while the code should be one of the codes provided by CVSStatus. - * The status code must not be CVSStatus.SERVER_ERROR. - *

              - * - * @param line the line of message text sent by the server - * @param commandRoot the root directory of the command - * @param monitor the progress monitor - * @return a status indicating success or failure based on the text - */ - public IStatus messageLine(String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor); - - /** - * Invoked when an error line is received from the server. - *

              - * Any status other than ICommandOutputListener.OK will be accumulated - * by the command and returned. The severity of the status matches those of - * IStatus and must indicate whether this is a warning, error, or informational - * text.while the code should be one of the codes provided by CVSStatus. - * The status code must not be CVSStatus.SERVER_ERROR. - *

              - * - * @param line the line of error text sent by the server - * @param commandRoot the root directory of the command - * @param monitor the progress monitor - * @return a status indicating success or failure based on the text - */ - public IStatus errorLine(String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java deleted file mode 100644 index 9d1352e41..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.client.Session; - -public interface IConsoleListener { - /** - * Called when a command is invoked. - * @param session the session that the command is being executed over - * @param line the command invocation string - */ - public void commandInvoked(Session session, String line); - - /** - * Called when a line of message text has been received. - * @param session the session that the command is being executed over - * @param line the line of text - * @param status the status returned from the command message parser - */ - public void messageLineReceived(Session session, String line, IStatus status); - - /** - * Called when a line of error text has been received. - * @param session the session that the command is being executed over - * @param line the line of text - * @param status the status returned from the command message parser - */ - public void errorLineReceived(Session session, String line, IStatus status); - - /** - * Called when a command has been completed. - * @param session the session that the command is being executed over - * @param status the status code, or null if not applicable - * @param exception an exception, or null if not applicable - */ - public void commandCompleted(Session session, IStatus status, Exception exception); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java deleted file mode 100644 index 5e44de599..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ILogEntry; - -/** - * Interface for receiving log entries from the LogListener - */ -public interface ILogEntryListener { - - /** - * A log entry was received for the current file - * @param entry the received log entry. - */ - void handleLogEntryReceived(ILogEntry entry); - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java deleted file mode 100644 index a66650d77..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.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.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class contains the default server message patterns - */ -public interface IMessagePatterns { - - public static final String SERVER_MESSAGE_PREFIX = "\\w* \\w*: "; //$NON-NLS-1$ - public static final String SERVER_ABORTED_MESSAGE_PREFIX = "\\w* [\\w* aborted]: "; //$NON-NLS-1$ - - // TODO: These patterns could be more specific but this would require non-capturing - // groups which currently throw off variable matching - public static final String TAG_PATTERN = "\\w*"; //$NON-NLS-1$ - public static final String REVISION_PATTERN = ".*"; //$NON-NLS-1$ - public static final String FILE_PATH_PATTERN = ".*"; //$NON-NLS-1$ - - // TODO: It would be better if the prefix was optional but this requires the use of a capturing group which throws the group count off - public static final String RDIFF_DIRECTORY = SERVER_MESSAGE_PREFIX + "Diffing " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFolderPath"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String RDIFF_SUMMARY_FILE_DIFF = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " changed from revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision") + " to " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - public static final String RDIFF_SUMMARY_NEW_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is new; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - public static final String RDIFF_SUMMARY_DELETED_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; not included in release tag " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // This format was introduced in 1.11.7 - public static final String RDIFF_SUMMARY_DELETED_FILE2 = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - - public static final String MERGE_UPDATE_CONFLICTING_ADDITION = SERVER_MESSAGE_PREFIX + "file " + Util.getVariablePattern(FILE_PATH_PATTERN, "localFilePath") + " exists, but has been added in revision " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java deleted file mode 100644 index b7744fcab..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -public interface IStatusListener { - - public static final String FOLDER_REVISION = ""; //$NON-NLS-1$ - - /** - * Provides access to the revision of a file through the use of the Status command. - * - * @param commandRoot the root directory of the command - * @param path the absolute remote path of the resource including the repository root directory - * @param remoteRevision the remote revision of the file - */ - public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java deleted file mode 100644 index 67874f531..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -/** - * This listener is used by RemoteFolder to listener for E and M messages - * from the CVS server in order to determine the files and folders contained in a parent folder. - */ -public interface IUpdateMessageListener { - /** - * Notification that a directory (which may or may not have been reported by - * directoryInformation()) does not exist. - * - * @param commandRoot the root directory of the command - * @param path the path of the directory relative to the commandRoot - */ - public void directoryDoesNotExist(ICVSFolder commandRoot, String path); - /** - * Notification of information about a directory. - * - * @param commandRoot the root directory of the command - * @param path the path of the directory relative to the commandRoot - * @param newDirectory true if the directory does not exist locally (i.e. in the commandRoot hierarchy) - */ - public void directoryInformation(ICVSFolder commandRoot, String path, boolean newDirectory); - /** - * Notification of information about a file - * - * @param type the type of update for the file (see Update for type constants) - * @param commandRoot the root directory of the command - * @param filename the path of the file relative to the commandRoot - */ - public void fileInformation(int type, ICVSFolder parent, String filename); - /** - * Notification that a file does not exists remotely - * - * @param commandRoot the root directory of the command - * @param filename the path of the file relative to the commandRoot - */ - public void fileDoesNotExist(ICVSFolder parent, String filename); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java deleted file mode 100644 index 1d5e49960..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.util.Date; - -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; - -public class LogEntry extends PlatformObject implements ILogEntry { - - private RemoteFile file; - private String author; - private Date date; - private String comment; - private String state; - private CVSTag[] tags; - - public LogEntry(RemoteFile file, String revision, String author, Date date, String comment, String state, CVSTag[] tags) { - this.file = file.toRevision(revision); - this.author = author; - this.date = date; - this.comment = comment; - this.state = state; - this.tags = tags; - } - - /** - * @see ILogEntry#getRevision() - */ - public String getRevision() { - return file.getRevision(); - } - - /** - * @see ILogEntry#getAuthor() - */ - public String getAuthor() { - return author; - } - - /** - * @see ILogEntry#getDate() - */ - public Date getDate() { - return date; - } - - /** - * @see ILogEntry#getComment() - */ - public String getComment() { - return comment; - } - - /** - * @see ILogEntry#getState() - */ - public String getState() { - return state; - } - - /** - * @see ILogEntry#getTags() - */ - public CVSTag[] getTags() { - CVSTag[] result = new CVSTag[tags.length]; - System.arraycopy(tags, 0, result, 0, tags.length); - return result; - } - - /** - * @see ILogEntry#getRemoteFile() - */ - public ICVSRemoteFile getRemoteFile() { - return file; - } - - /** - * @see ILogEntry#isDeletion() - */ - public boolean isDeletion() { - return getState().equals("dead"); //$NON-NLS-1$ - } - -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java deleted file mode 100644 index ab505da61..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.*; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Log listener that parses the log entries returned from the - * server but delegates the handling of the entries to a subclass. - */ -public class LogListener extends CommandOutputListener { - - // Server message prefix used for error detection - private static final String NOTHING_KNOWN_ABOUT = "nothing known about "; //$NON-NLS-1$ - - // States of log accumulation. - private final int DONE = 4; - private final int COMMENT = 3; - private final int REVISION = 2; - private final int SYMBOLIC_NAMES = 1; - private final int BEGIN = 0; - - // Instance variables for accumulating Log information - private RemoteFile currentFile; - private int state = BEGIN; - private StringBuffer comment; - private String fileState; - private String revision; - private String author; - private String creationDate; - private List tagRevisions = new ArrayList(5); - private List tagNames = new ArrayList(5); - - private final ILogEntryListener listener; - - /** - * Create a log listener for receiving entries for one or more files. - */ - public LogListener(ILogEntryListener listener) { - this.listener = listener; - } - - public LogListener(RemoteFile file, ILogEntryListener listener) { - this(listener); - this.currentFile = file; - } - - private String getRelativeFilePath(ICVSRepositoryLocation location, String fileName) { - if (fileName.endsWith(",v")) { //$NON-NLS-1$ - fileName = fileName.substring(0, fileName.length() - 2); - } - fileName = Util.removeAtticSegment(fileName); - String rootDirectory = location.getRootDirectory(); - if (fileName.startsWith(rootDirectory)) { - try { - fileName = Util.getRelativePath(rootDirectory, fileName); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return null; - } - } - return fileName; - } - - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - // look for the following condition - // E cvs server: nothing known about fileName - if (serverMessage.startsWith(NOTHING_KNOWN_ABOUT)) { - return new CVSStatus(IStatus.ERROR, CVSStatus.DOES_NOT_EXIST, commandRoot, line); - } - } - return OK; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - // Fields we will find in the log for a file - // keys = String (tag name), values = String (tag revision number) */ - switch (state) { - case BEGIN: - if (line.startsWith("RCS file: ")) { //$NON-NLS-1$ - // We are starting to recieve the log for a file - String fileName = getRelativeFilePath(location, line.substring(10).trim()); - if (fileName == null) { - currentFile = null; - handleInvalidFileName(location, fileName); - } else { - if (currentFile == null || !currentFile.getRepositoryRelativePath().equals(fileName)) { - // We are starting another file - beginFile(location, fileName); - } - } - } else if (line.startsWith("symbolic names:")) { //$NON-NLS-1$ - state = SYMBOLIC_NAMES; - } else if (line.startsWith("revision ")) { //$NON-NLS-1$ - revision = line.substring(9); - state = REVISION; - } - break; - case SYMBOLIC_NAMES: - if (line.startsWith("keyword substitution:")) { //$NON-NLS-1$ - state = BEGIN; - } else { - int firstColon = line.indexOf(':'); - String tagName = line.substring(1, firstColon); - String tagRevision = line.substring(firstColon + 2); - tagNames.add(tagName); - tagRevisions.add(tagRevision); - } - break; - case REVISION: - // date: 2000/06/19 04:56:21; author: somebody; state: Exp; lines: +114 -45 - // get the creation date - int endOfDateIndex = line.indexOf(';', 6); - creationDate = line.substring(6, endOfDateIndex) + " GMT"; //$NON-NLS-1$ - - // get the author name - int endOfAuthorIndex = line.indexOf(';', endOfDateIndex + 1); - author = line.substring(endOfDateIndex + 11, endOfAuthorIndex); - - // get the file state (because this revision might be "dead") - fileState = line.substring(endOfAuthorIndex + 10, line.indexOf(';', endOfAuthorIndex + 1)); - comment = new StringBuffer(); - state = COMMENT; - break; - case COMMENT: - // skip next line (info about branches) if it exists, if not then it is a comment line. - if (line.startsWith("branches:")) break; //$NON-NLS-1$ - if (line.equals("=============================================================================") //$NON-NLS-1$ - || line.equals("----------------------------")) { //$NON-NLS-1$ - state = DONE; - break; - } - if (comment.length() != 0) comment.append('\n'); - comment.append(line); - break; - } - if (state == DONE) { - // we are only interested in tag names for this revision, remove all others. - List thisRevisionTags = new ArrayList(3); - for (int i = 0; i < tagNames.size(); i++) { - String tagName = (String) tagNames.get(i); - String tagRevision = (String) tagRevisions.get(i); - // If this is a branch tag then only include this tag with the revision - // that is the root of this branch (e.g. 1.1 is root of branch 1.1.2). - boolean isBranch = isBranchTag(tagRevision); - if (isBranch) { - int lastDot = tagRevision.lastIndexOf('.'); - if (lastDot == -1) { - CVSProviderPlugin.log(IStatus.ERROR, - Policy.bind("LogListener.invalidRevisionFormat", tagName, tagRevision), null); //$NON-NLS-1$ - } else { - if (tagRevision.charAt(lastDot - 1) == '0' && tagRevision.charAt(lastDot - 2) == '.') { - lastDot = lastDot - 2; - } - tagRevision = tagRevision.substring(0, lastDot); - } - } - if (tagRevision.equals(revision)) { - int type = isBranch ? CVSTag.BRANCH : CVSTag.VERSION; - thisRevisionTags.add(new CVSTag(tagName, type)); - } - } - Date date = DateUtil.convertFromLogTime(creationDate); - if (currentFile != null) { - LogEntry entry = new LogEntry(currentFile, revision, author, date, - comment.toString(), fileState, (CVSTag[]) thisRevisionTags.toArray(new CVSTag[0])); - addEntry(entry); - } - state = BEGIN; - } - return OK; - } - - protected void beginFile(ICVSRepositoryLocation location, String fileName) { - currentFile = RemoteFile.create(fileName, location); - tagNames.clear(); - tagRevisions.clear(); - } - - protected void addEntry(LogEntry entry) { - listener.handleLogEntryReceived(entry); - } - - protected void handleInvalidFileName(ICVSRepositoryLocation location, String badFilePath) { - CVSProviderPlugin.log(IStatus.WARNING, "Invalid file path '" + badFilePath + "' received from " + location.toString(), null); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** branch tags have odd number of segments or have - * an even number with a zero as the second last segment - * e.g: 1.1.1, 1.26.0.2 are branch revision numbers */ - protected boolean isBranchTag(String tagName) { - // First check if we have an odd number of segments (i.e. even number of dots) - int numberOfDots = 0; - int lastDot = 0; - for (int i = 0; i < tagName.length(); i++) { - if (tagName.charAt(i) == '.') { - numberOfDots++; - lastDot = i; - } - } - if ((numberOfDots % 2) == 0) return true; - if (numberOfDots == 1) return false; - - // If not, check if the second lat segment is a zero - if (tagName.charAt(lastDot - 1) == '0' && tagName.charAt(lastDot - 2) == '.') return true; - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java deleted file mode 100644 index 4de19a23b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -/* - * This class pares the output of the "cvs checkout -c" command which returns the list of modules - * defined in the CVSROOT/modules file. - */ -public class ModuleDefinitionsListener extends CommandOutputListener { - - // the last line read from the context (used to accumulate multi-line definitions) - private String lastLine = ""; //$NON-NLS-1$ - - private Map moduleMap; - - public ModuleDefinitionsListener() { - reset(); - } - - /* - * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Lines that start with a space indicate a multi line entry - if( line.charAt(0) == ' ' ) { - lastLine += line; - line = lastLine; - } - else - lastLine = line; - - // Use the module name as the key so that multi-line modules will be recorded properly - int firstSpace = line.indexOf(" "); //$NON-NLS-1$ - if (firstSpace > -1) { - String module = line.substring(0, firstSpace); - moduleMap.put(module, line); - } - return OK; - } - - public String[] getModuleExpansions() { - return (String[])moduleMap.values().toArray(new String[moduleMap.size()]); - } - - public void reset() { - this.moduleMap = new HashMap(); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java deleted file mode 100644 index 12badc099..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; - -/** - * - */ -public class ModuleExpansion { - - /** Name of the CVS module as found in the CVSROOT/modules file */ - private String moduleName; - - /** Expansion of the module name returned by the CVS server */ - private String[] expansions; - - private LocalOption[] options; - - ModuleExpansion(String moduleName, String[] expansions, LocalOption[] options) { - this.moduleName = moduleName; - this.expansions = expansions; - this.options = options; - } - - /** - * @see IModuleExpansion#getModuleName() - */ - public String getModuleName() { - return moduleName; - } - - /** - * @see IModuleExpansion#getModuleExpansionString() - */ - public String getModuleExpansionString() { - String result = expansions[0]; - for (int i=1;i moduleMappings.size()) { - // Indicate that a circular reference exists - throw new CVSException(Policy.bind("ModuleExpansion.circular", module));//$NON-NLS-1$ - } - Object mappings = moduleMappings.get(module); - if (mappings == null) { - // If there's no mapping assume it is a project name - List result = new ArrayList(); - result.add(module); - return result; - } else { - // Follow any expansion chains - return getExpansionsFor(((ModuleExpansion)mappings).expansions, moduleMappings, depth + 1); - } - } - - /** - * Resolve the module mappings using moduleMappings which maps - * module names to their ModuleExpansion - */ - public void resolveModuleReferencesUsing(Map moduleMappings) { - try { - List result = getExpansionsFor(expansions, moduleMappings, 0); - expansions = (String[])result.toArray(new String[result.size()]); - } catch (CVSException e) { - // Is this the best way to show the circular reference problem? - // Or should we just leave the expansions untouched? - List result = new ArrayList(); - result.add(e.getStatus().getMessage()); - result.addAll(Arrays.asList(expansions)); - expansions = (String[])result.toArray(new String[result.size()]); - } - } -} - - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java deleted file mode 100644 index 29d2ec260..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -/** - * This class parses the messages recieved in response to an "cvs rdiff -s ..." command - */ -public class RDiffSummaryListener extends CommandOutputListener { - - private static final String RIGHT_REVISION_VARIABLE_NAME = "rightRevision"; //$NON-NLS-1$ - private static final String LEFT_REVISION_VARIABLE_NAME = "leftRevision"; //$NON-NLS-1$ - private static final String REMOTE_FILE_PATH_VARIABLE_NAME = "remoteFilePath"; //$NON-NLS-1$ - private static final String REMOTE_FOLDER_PATH_VARIABLE_NAME = "remoteFolderPath"; //$NON-NLS-1$ - - private IFileDiffListener listener; - private static ServerMessageLineMatcher DIRECTORY_MATCHER; - private static ServerMessageLineMatcher FILE_DIFF_MATCHER; - private static ServerMessageLineMatcher NEW_FILE_MATCHER; - private static ServerMessageLineMatcher DELETED_FILE_MATCHER; - private static ServerMessageLineMatcher DELETED_FILE_MATCHER2; - - static { - // TODO: temprary until proper lifecycle is defined - initializePatterns(); - } - public static void initializePatterns() { - try { - DIRECTORY_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_DIRECTORY, new String[] {REMOTE_FOLDER_PATH_VARIABLE_NAME}); - FILE_DIFF_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_FILE_DIFF, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME}); - NEW_FILE_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_NEW_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME}); - DELETED_FILE_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME}); - DELETED_FILE_MATCHER2 = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE2, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME}); - } catch (CVSException e) { - // This is serious as the listener will not function properly - CVSProviderPlugin.log(e); - } - } - - public interface IFileDiffListener { - public void fileDiff( - String remoteFilePath, - String leftRevision, - String rightRevision); - public void newFile( - String remoteFilePath, - String rightRevision); - public void deletedFile( - String remoteFilePath, - String leftRevision); - public void directory(String remoteFolderPath); - } - - public RDiffSummaryListener(IFileDiffListener listener) { - this.listener = listener; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - Map variables = FILE_DIFF_MATCHER.processServerMessage(line); - if (variables != null) { - listener.fileDiff( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(LEFT_REVISION_VARIABLE_NAME), - (String)variables.get(RIGHT_REVISION_VARIABLE_NAME)); - return OK; - } - - variables = NEW_FILE_MATCHER.processServerMessage(line); - if (variables != null) { - listener.newFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(RIGHT_REVISION_VARIABLE_NAME)); - return OK; - } - - variables = DELETED_FILE_MATCHER.processServerMessage(line); - if (variables != null) { - listener.deletedFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - null); - return OK; - } - - variables = DELETED_FILE_MATCHER2.processServerMessage(line); - if (variables != null) { - listener.deletedFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(LEFT_REVISION_VARIABLE_NAME)); - return OK; - } - - return super.messageLine(line, location, commandRoot, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - Map variables = DIRECTORY_MATCHER.processServerMessage(line); - if (variables != null) { - listener.directory( - (String)variables.get(REMOTE_FOLDER_PATH_VARIABLE_NAME)); - return OK; - } - - return super.errorLine(line, location, commandRoot, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java deleted file mode 100644 index 3e42ee1a6..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * This class extracts matches server lines to expected patterns and extracts - * required information from the line. - */ -public class ServerMessageLineMatcher { - - protected static final Pattern VARIABLE_MATCHING_PATTERN = Pattern.compile("(\\((\\w*):.*:\\2\\))"); //$NON-NLS-1$ - - Pattern pattern; - String[] variables; - - public ServerMessageLineMatcher(String template, String[] expectedVariables) throws CVSException { - // Extract the variable names from the template - Matcher matcher = VARIABLE_MATCHING_PATTERN.matcher(template); - List variables = new ArrayList(); - while (matcher.find()) { - if (matcher.groupCount() != 2) { - throw new CVSException(Policy.bind("ServerMessageLineMatcher.5", template)); //$NON-NLS-1$ - } - variables.add(matcher.group(2)); - } - ensureMatches(template, variables, expectedVariables); - this.variables = (String[]) variables.toArray(new String[variables.size()]); - - // Modify the template so it can be used to match message lines from the server - // (i.e. remove the variable markup) - for (Iterator iter = variables.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - template = template.replaceAll(element + ":", ""); //$NON-NLS-1$ //$NON-NLS-2$ - template = template.replaceAll(":" + element, ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Ensure that the number of groups in the pattern match the number of variables - int count = 0; - int start = -1; - while ((start = template.indexOf('(', start + 1)) != -1) { - count++; - } - if (count != variables.size()) { - throw new CVSException(Policy.bind("ServerMessageLineMatcher.6", template)); //$NON-NLS-1$ - } - - // Create the pattern fir matching lines from the server - this.pattern = Pattern.compile(template); - } - - /* - * Throw an exception if the found variables do not match the expected variables - */ - private void ensureMatches(String template, List variables, String[] expectedVariables) throws CVSException { - for (int i = 0; i < expectedVariables.length; i++) { - String expected = expectedVariables[i]; - if (!variables.contains(expected)) { - throw new CVSException(Policy.bind("ServerMessageLineMatcher.7", expected, template)); //$NON-NLS-1$ - } - } - } - - public Map processServerMessage(String line) { - Matcher matcher = pattern.matcher(line); - if (!matcher.find()) return null; - Assert.isTrue(matcher.groupCount() == variables.length); - Map result = new HashMap(); - for (int i = 1; i <= matcher.groupCount(); i++) { - result.put(variables[i - 1], matcher.group(i)); - } - return result; - } - - public boolean matches(String line) { - Matcher matcher = pattern.matcher(line); - return (matcher.find()); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java deleted file mode 100644 index ef673efa8..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.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.team.internal.ccvs.core.client.listeners; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.util.Util; - -public class StatusListener extends CommandOutputListener { - private static boolean isFolder = false; - private IStatusListener statusListener; - - public StatusListener(IStatusListener statusListener) { - this.statusListener = statusListener; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // We're only concerned about file revisions. - if (line.startsWith(" Repository revision:")) { //$NON-NLS-1$ - if (!line.startsWith(" Repository revision: No revision control file")) { //$NON-NLS-1$ - int separatingTabIndex = line.indexOf('\t', 24); - String remoteRevision = line.substring(24, separatingTabIndex); - - // This is the full location on the server (e.g. /home/cvs/repo/project/file.txt) - String fileLocation = line.substring(separatingTabIndex + 1, line.length() - 2); - - // Inform the listener about the file revision - statusListener.fileStatus(commandRoot, removeAtticSegment(fileLocation), remoteRevision); - } - } - return OK; - } - - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - if (serverMessage.startsWith("conflict:")) {//$NON-NLS-1$ - // We get this because we made up an entry line to send to the server - // Therefore, we make this a warning!!! - return new CVSStatus(CVSStatus.WARNING, CVSStatus.CONFLICT, commandRoot, line); - } - if (serverMessage.startsWith("Examining")) {//$NON-NLS-1$ - isFolder = true; - return OK; - } - } - if (isFolder) { - // This used to do something but it was obviously wrong and there was no indication - // why it was needed. Therefore, I have removed the code to see if anything is effected - isFolder = false; - } - return super.errorLine(line, location, commandRoot, monitor); - } - - /** - * If the status returns that the file is in the Attic, then remove the - * Attic segment. This is because files added to a branch that are not in - * the main trunk (HEAD) are added to the Attic but cvs does magic on - * updateto put them in the correct location. - * (e.g. /project/Attic/file.txt -> /project/file.txt) - */ - private String removeAtticSegment(String path) { - return Util.removeAtticSegment(path); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java deleted file mode 100644 index 422b9699f..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -public class TagListener extends CommandOutputListener { - - /* - * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Received a warning in the form: - // W folder/file : v1 already exists on version 1.2 : NOT MOVING tag to version 1.3 - // Indicate this as an error since no tagging was done - if(line.length() >= 2 && line.charAt(0) == 'W' && line.charAt(1) == ' ') { - return new CVSStatus(CVSStatus.ERROR, CVSStatus.TAG_ALREADY_EXISTS, commandRoot, line.substring(2)); - } - - return OK; - } - - /* - * @see ICommandOutputListener#errorLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Ignore the lines: Tagging folder1/folder2 - String serverMessage = getServerMessage(line, location); - if ((serverMessage != null) && serverMessage.startsWith("Tagging")) { //$NON-NLS-1$ - return OK; - } - String rtagMessage = getServerRTagMessage(line, location); - if(rtagMessage != null && rtagMessage.startsWith("Tagging") ) { //$NON-NLS-1$ - return OK; - } - - return super.errorLine(line, location, commandRoot, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java deleted file mode 100644 index 9e3c548c5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.util.Util; - -public class UpdateListener extends CommandOutputListener { - - // Pattern matchers - private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_1; - private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_2; - - // Pattern Variables - private static final String REVISION_VARIABLE_NAME = "revision"; //$NON-NLS-1$ - private static final String LOCAL_FILE_PATH_VARIABLE_NAME = "localFilePath"; //$NON-NLS-1$ - private static final String BACKUP_FILE_VARIABLE_NAME = "backupFile"; //$NON-NLS-1$ - - static { - try { - String line1 = "revision " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, REVISION_VARIABLE_NAME) - + " from repository is now in " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.FILE_PATH_PATTERN, LOCAL_FILE_PATH_VARIABLE_NAME); - MERGED_BINARY_FILE_LINE_1 = new ServerMessageLineMatcher( - line1, - new String[] {REVISION_VARIABLE_NAME, LOCAL_FILE_PATH_VARIABLE_NAME}); - String line2 = "file from working directory is now in " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, BACKUP_FILE_VARIABLE_NAME); - MERGED_BINARY_FILE_LINE_2 = new ServerMessageLineMatcher( - line2, - new String[] {BACKUP_FILE_VARIABLE_NAME}); - - } catch (CVSException e) { - // Shouldn't happen - CVSProviderPlugin.log(e); - } - } - - IUpdateMessageListener updateMessageListener; - boolean merging = false; - boolean mergingBinary = false; - String mergedBinaryFileRevision, mergedBinaryFilePath; - - public UpdateListener(IUpdateMessageListener updateMessageListener) { - this.updateMessageListener = updateMessageListener; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - mergingBinary = false; - if (updateMessageListener == null) return OK; - if(line.startsWith("Merging differences")) { //$NON-NLS-1$ - merging = true; - } else if(line.indexOf(' ')==1) { - // We have a message that indicates the type of update. The possible messages are - // defined by the prefix constants MLP_*. - String path = line.substring(2); - char changeType = line.charAt(0); - - // calculate change type - int type = 0; - switch(changeType) { - case 'A': type = Update.STATE_ADDED_LOCAL; break; // new file locally that was added but not comitted to server yet - case '?': type = Update.STATE_UNKOWN; break; // new file locally but not added to server - case 'U': type = Update.STATE_REMOTE_CHANGES; break; // remote changes to an unmodified local file - case 'R': type = Update.STATE_DELETED; break; // removed locally but still exists on the server - case 'M': type = Update.STATE_MODIFIED; break; // modified locally - case 'C': type = Update.STATE_CONFLICT; break; // modified locally and on the server but cannot be auto-merged - case 'D': type = Update.STATE_DELETED; break; // deleted locally but still exists on server - default: type = Update.STATE_NONE; - } - - if (merging) { - // If we are merging the modified prefix is used both to show merges and - // local changes. We have to detect this case and use a more specific change - // type. - if (type == Update.STATE_MODIFIED) - type = Update.STATE_MERGEABLE_CONFLICT; - merging = false; - } - updateMessageListener.fileInformation(type, commandRoot, path); - } - return OK; - } - - /** - * This handler is used by the RemoteResource hierarchy to retrieve E messages - * from the CVS server in order to determine the folders contained in a parent folder. - * - * WARNING: This class parses the message output to determine the state of files in the - * repository. Unfortunately, these messages seem to be customizable on a server by server basis. - * - * Here's a list of responses we expect in various situations: - * - * Directory exists remotely: - * cvs server: Updating folder1/folder2 - * Directory doesn't exist remotely: - * cvs server: skipping directory folder1/folder2 - * New (or unknown) remote directory - * cvs server: New Directory folder1/folder2 - * File removed remotely - * cvs server: folder1/file.ext is no longer in the repository - * cvs server: warning: folder1/file.ext is not (any longer) pertinent - * Locally added file was added remotely as well - * cvs server: conflict: folder/file.ext created independently by second party - * File removed locally and modified remotely - * cvs server: conflict: removed file.txt was modified by second party - * File modified locally but removed remotely - * cvs server: conflict: file.txt is modified but no longer in the repository - * Ignored Messages - * cvs server: cannot open directory ... - * cvs server: nothing known about ... - * Tag error that really means there are no files in a directory - * cvs [server aborted]: no such tag - * Merge contained conflicts - * rcsmerge: warning: conflicts during merge - * Binary file conflict - * cvs server: nonmergeable file needs merge - * cvs server: revision 1.4 from repository is now in a1/a2/test - * cvs server: file from working directory is now in .#test.1.3 - */ - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - - try { - // Reset flag globally here because we have to many exit points - boolean wasMergingBinary = mergingBinary; - mergingBinary = false; - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - // Strip the prefix from the line - String message = serverMessage; - if (message.startsWith("Updating")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(9); - updateMessageListener.directoryInformation(commandRoot, path, false); - } - return OK; - } else if (message.startsWith("skipping directory")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(18).trim(); - updateMessageListener.directoryDoesNotExist(commandRoot, path); - } - return OK; - } else if (message.startsWith("New directory")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(15, message.lastIndexOf('\'')); - updateMessageListener.directoryInformation(commandRoot, path, true); - } - return OK; - } else if (message.endsWith("is no longer in the repository")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String filename = message.substring(0, message.length() - 31); - filename = stripQuotes(filename); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - return OK; - } else if (message.startsWith("conflict:")) { //$NON-NLS-1$ - /* - * We can get the following conflict warnings - * cvs server: conflict: folder/file.ext created independently by second party - * cvs server: conflict: removed file.txt was modified by second party - * cvs server: conflict: file.txt is modified but no longer in the repository - * If we get the above line, we have conflicting additions or deletions and we can expect a server error. - * We still get "C foler/file.ext" so we don't need to do anything else (except in the remotely deleted case) - */ - if (updateMessageListener != null) { - if (message.endsWith("is modified but no longer in the repository")) { //$NON-NLS-1$ - // The "C foler/file.ext" will come after this so if whould be ignored! - String filename = message.substring(10, message.length() - 44); - filename = stripQuotes(filename); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - } - return new CVSStatus(CVSStatus.WARNING, CVSStatus.CONFLICT, commandRoot, line); - } else if (message.startsWith("warning:")) { //$NON-NLS-1$ - /* - * We can get the following conflict warnings - * cvs server: warning: folder1/file.ext is not (any longer) pertinent - * If we get the above line, we have local changes to a remotely deleted file. - */ - if (updateMessageListener != null) { - if (message.endsWith("is not (any longer) pertinent")) { //$NON-NLS-1$ - String filename = message.substring(9, message.length() - 30); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - } - return new CVSStatus(CVSStatus.WARNING, CVSStatus.CONFLICT, commandRoot, line); - } else if (message.startsWith("conflicts")) { //$NON-NLS-1$ - // This line is info only. The server doesn't report an error. - return new CVSStatus(IStatus.INFO, CVSStatus.CONFLICT, commandRoot, line); - } else if (message.startsWith("nonmergeable file needs merge")) { //$NON-NLS-1$ - mergingBinary = true; - mergedBinaryFileRevision = null; - mergedBinaryFilePath = null; - return OK; - } else if (wasMergingBinary) { - Map variables = MERGED_BINARY_FILE_LINE_1.processServerMessage(message); - if (variables != null) { - mergedBinaryFileRevision = (String)variables.get(REVISION_VARIABLE_NAME); - mergedBinaryFilePath = (String)variables.get(LOCAL_FILE_PATH_VARIABLE_NAME); - mergingBinary = true; - return OK; - } - variables = MERGED_BINARY_FILE_LINE_2.processServerMessage(message); - if (variables != null) { - String backupFile = (String)variables.get(BACKUP_FILE_VARIABLE_NAME); - try { - if (mergedBinaryFileRevision != null && mergedBinaryFilePath != null) { - ICVSFile file = commandRoot.getFile(mergedBinaryFilePath); - IResource resource = file.getIResource(); - if (resource != null) { - return new CVSStatus(IStatus.ERROR, CVSStatus.UNMEGERED_BINARY_CONFLICT, - Policy.bind("UpdateListener.0", new Object[] { //$NON-NLS-1$ - resource.getFullPath().toString(), - mergedBinaryFileRevision, - resource.getFullPath().removeLastSegments(1).append(backupFile).toString()})); - } - } - } catch (CVSException e1) { - CVSProviderPlugin.log(e1); - } - return OK; - } - } - - // Fallthrough case for "cvs server" messages - if (!message.startsWith("cannot open directory") //$NON-NLS-1$ - && !message.startsWith("nothing known about")) { //$NON-NLS-1$ - return super.errorLine(line, location, commandRoot, monitor); - } - } else { - String serverAbortedMessage = getServerAbortedMessage(line, location); - if (serverAbortedMessage != null) { - // Strip the prefix from the line - String message = serverAbortedMessage; - if (message.startsWith("no such tag")) { //$NON-NLS-1$ - // This is reported from CVS when a tag is used on the update there are no files in the directory - // To get the folders, the update request should be re-issued for HEAD - return new CVSStatus(CVSStatus.WARNING, CVSStatus.NO_SUCH_TAG, commandRoot, line); - } else if (message.startsWith("Numeric join") && message.endsWith("may not contain a date specifier")) { //$NON-NLS-1$ //$NON-NLS-2$ - // This error indicates a join failed because a date tag was used - return super.errorLine(line, location, commandRoot, monitor); - } else { - return super.errorLine(line, location, commandRoot, monitor); - } - } else if (line.equals("rcsmerge: warning: conflicts during merge")) { //$NON-NLS-1$ - // There were conflicts in the merge - return new CVSStatus(CVSStatus.WARNING, CVSStatus.CONFLICT, commandRoot, line); - } - } - } catch (StringIndexOutOfBoundsException e) { - // Something went wrong in the parsing of the message. - // Return a status indicating the problem - if (CVSProviderPlugin.getPlugin().isDebugging()) { - System.out.println("Error parsing E line: " + line); //$NON-NLS-1$ - } - return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE_PARSE_FAILURE, commandRoot, line); - } - return super.errorLine(line, location, commandRoot, monitor); - } - - private String stripQuotes(String filename) { - // CVS version 12 fix - filenames are returned inside quotes - // Fixes bug 49056 - if (filename.startsWith("`") && filename.endsWith("'")) //$NON-NLS-1$ //$NON-NLS-2$ - filename = filename.substring(1,filename.length()-1); - return filename; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java deleted file mode 100644 index b686f7a30..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.Policy; - -public class CVSAuthenticationException extends CVSException { - - private static final long serialVersionUID = 1L; - - /** - * Code indicating that authentication can be retried after - * prompting the user for corrected authentication information - */ - public static final int RETRY = 1; - - /** - * Code indicating that authentication should not be reattempted. - */ - public static final int NO_RETRY = 2; - - /** - * Creates a new CVSAuthenticationException - * - * @param detail a message that describes the exception in detail. - * @param code indicates whether authentication can be retried or not - */ - public CVSAuthenticationException(String detail, int code) { - this(new CVSStatus(IStatus.ERROR, code, - Policy.bind("CVSAuthenticationException.detail", new Object[] { detail }))); //$NON-NLS-1$ - } - - /** - * Creates a new CVSAuthenticationException - * - * @param status the status result describing this exception. - */ - public CVSAuthenticationException(IStatus status) { - super(status); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java deleted file mode 100644 index 44b079b07..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import java.io.InterruptedIOException; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.Policy; - -public class CVSCommunicationException extends CVSException { - - private static final long serialVersionUID = 1L; - - /** - * Create a new CVSCommunicationException with the - * given status. - */ - private CVSCommunicationException(IStatus status) { - super(status); - } - /** - * Create a new CVSCommunicationException with the - * given message. - */ - public CVSCommunicationException(String message) { - super(message); - } - /** - * Create a new CVSCommunicationException. - * - * @param message a message describing the exception in detail. - * @param the caught exception that has caused the communication - * exception. - */ - public CVSCommunicationException(String message, Exception e) { - super(message, e); - } - /** - * Create a new CVSCommunicationException. - * - * @param the caught exception that has caused the communication - * exception. - */ - public CVSCommunicationException(Exception e) { - this(getStatusFor(e)); - } - - public static IStatus getStatusFor(Exception e) { - if (e instanceof InterruptedIOException) { - MultiStatus status = new MultiStatus(CVSProviderPlugin.ID, 0, getMessageFor(e), e); - status.add(new CVSStatus(IStatus.ERROR, Policy.bind("CVSCommunicationException.interruptCause"))); //$NON-NLS-1$ - status.add(new CVSStatus(IStatus.ERROR, Policy.bind("CVSCommunicationException.interruptSolution"))); //$NON-NLS-1$ - status.add(new CVSStatus(IStatus.ERROR, Policy.bind("CVSCommunicationException.alternateInterruptCause"))); //$NON-NLS-1$ - status.add(new CVSStatus(IStatus.ERROR, Policy.bind("CVSCommunicationException.alternateInterruptSolution"))); //$NON-NLS-1$ - return status; - } - return new CVSStatus(IStatus.ERROR, getMessageFor(e), e); - } - - public static String getMessageFor(Throwable throwable) { - String message = Policy.bind(throwable.getClass().getName(), new Object[] {throwable.getMessage()}); - if (message.equals(throwable.getClass().getName())) - message = Policy.bind("CVSCommunicationException.io", new Object[] {throwable.toString()}); //$NON-NLS-1$ - return message; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java deleted file mode 100644 index 698028300..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java +++ /dev/null @@ -1,1235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.resources.*; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -/** - * This class manages a CVS repository location. - * - * It provides the mapping between connection method name and the - * plugged in ICunnectionMethod. - * - * It parses location strings into instances. - * - * It provides a method to open a connection to the server along - * with a method to validate that connections can be made. - * - * It manages its user info using the plugged in IUserAuthenticator - * (unless a username and password are provided as part of the creation - * string, in which case, no authenticator is used). - * - * Instances must be disposed of when no longer needed in order to - * notify the authenticator so cached properties can be cleared - * - */ -public class CVSRepositoryLocation extends PlatformObject implements ICVSRepositoryLocation, IUserInfo { - - /** - * The name of the preferences node in the CVS preferences that contains - * the known repositories as its children. - */ - public static final String PREF_REPOSITORIES_NODE = "repositories"; //$NON-NLS-1$ - - /* - * The name of the node in the default scope that has the default settings - * for a repository. - */ - private static final String DEFAULT_REPOSITORY_SETTINGS_NODE = "default_repository_settings"; //$NON-NLS-1$ - - // Preference keys used to persist the state of the location - public static final String PREF_LOCATION = "location"; //$NON-NLS-1$ - public static final String PREF_SERVER_ENCODING = "encoding"; //$NON-NLS-1$ - - // server platform constants - public static final int UNDETERMINED_PLATFORM = 0; - public static final int CVS_SERVER = 1; - public static final int CVSNT_SERVER = 2; - public static final int UNSUPPORTED_SERVER = 3; - public static final int UNKNOWN_SERVER = 4; - - // static variables for extension points - private static IUserAuthenticator authenticator; - private static IConnectionMethod[] pluggedInConnectionMethods = null; - - // Locks for ensuring that authentication to a host is serialized - // so that invalid passwords do not result in account lockout - private static Map hostLocks = new HashMap(); - - private IConnectionMethod method; - private String user; - private String password; - private String host; - private int port; - private String root; - private boolean userFixed; - private boolean passwordFixed; - private boolean allowCaching; - - private int serverPlatform = UNDETERMINED_PLATFORM; - - public static final char COLON = ':'; - public static final char HOST_SEPARATOR = '@'; - public static final char PORT_SEPARATOR = '#'; - public static final boolean STANDALONE_MODE = (System.getProperty("eclipse.cvs.standalone")==null) ? //$NON-NLS-1$ - false :(new Boolean(System.getProperty("eclipse.cvs.standalone")).booleanValue()); //$NON-NLS-1$ - - // command to start remote cvs in server mode - private static final String INVOKE_SVR_CMD = "server"; //$NON-NLS-1$ - - // fields needed for caching the password - public static final String INFO_PASSWORD = "org.eclipse.team.cvs.core.password";//$NON-NLS-1$ - public static final String INFO_USERNAME = "org.eclipse.team.cvs.core.username";//$NON-NLS-1$ - public static final String AUTH_SCHEME = "";//$NON-NLS-1$ - public static final URL FAKE_URL; - - public static final String USER_VARIABLE = "{user}"; //$NON-NLS-1$ - public static final String PASSWORD_VARIABLE = "{password}"; //$NON-NLS-1$ - public static final String HOST_VARIABLE = "{host}"; //$NON-NLS-1$ - public static final String PORT_VARIABLE = "{port}"; //$NON-NLS-1$ - - private static String extProxy; //$NON-NLS-1$ - - static { - URL temp = null; - try { - temp = new URL("http://org.eclipse.team.cvs.core");//$NON-NLS-1$ - } catch (MalformedURLException e) { - // Should never fail - } - FAKE_URL = temp; - } - - /** - * Return the preferences node whose child nodes are teh know repositories - * @return a preferences node - */ - public static Preferences getParentPreferences() { - return CVSProviderPlugin.getPlugin().getInstancePreferences().node(PREF_REPOSITORIES_NODE); - } - - /** - * Return a preferences node that contains suitabel defaults for a - * repository location. - * @return a preferences node - */ - public static Preferences getDefaultPreferences() { - Preferences defaults = new DefaultScope().getNode(CVSProviderPlugin.ID).node(DEFAULT_REPOSITORY_SETTINGS_NODE); - defaults.put(PREF_SERVER_ENCODING, getDefaultEncoding()); - return defaults; - } - - private static String getDefaultEncoding() { - return System.getProperty("file.encoding", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set the proxy connection method that is to be used when a - * repository location has the ext connection method. This is - * usefull with the extssh connection method as it can be used to - * kepp the sandbox compatible with the command line client. - * @param string - */ - public static void setExtConnectionMethodProxy(String string) { - extProxy = string; - } - - /** - * Validate whether the given string is a valid registered connection method - * name. - * @param methodName the method name - * @return whether the given string is a valid registered connection method - * name - */ - public static boolean validateConnectionMethod(String methodName) { - Assert.isNotNull(methodName); - IConnectionMethod[] methods = getPluggedInConnectionMethods(); - for (int i=0;i 0) { - end = index - 1; - port = Integer.parseInt(portString); - } - } - - // Get the repository path (translating backslashes to slashes) - partId = "CVSRepositoryLocation.parsingRoot";//$NON-NLS-1$ - start = end + 1; - String root = location.substring(start).replace('\\', '/'); - - if (validateOnly) - throw new CVSException(new CVSStatus(IStatus.OK, Policy.bind("ok")));//$NON-NLS-1$ - return new CVSRepositoryLocation(method, user, password, host, port, root, null /* encoding */, (user != null), (password != null)); - } - catch (IndexOutOfBoundsException e) { - // We'll get here if anything funny happened while extracting substrings - throw new CVSException(Policy.bind(partId)); - } - catch (NumberFormatException e) { - // We'll get here if we couldn't parse a number - throw new CVSException(Policy.bind(partId)); - } - } - - /** - * Validate that the given string could be used to succesfully create - * a CVS repository location - * - * This method performs some initial checks to provide displayable - * feedback and also tries a more in-depth parse using - * fromString(String, boolean). - */ - public static IStatus validate(String location) { - - // Check some simple things that are not checked in creation - if (location == null) - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.nullLocation"));//$NON-NLS-1$ - if (location.equals(""))//$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.emptyLocation"));//$NON-NLS-1$ - if (location.endsWith(" ") || location.endsWith("\t"))//$NON-NLS-1$ //$NON-NLS-2$ - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.endWhitespace"));//$NON-NLS-1$ - if (!location.startsWith(":") || location.indexOf(COLON, 1) == -1)//$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.startOfLocation"));//$NON-NLS-1$ - - // Do some quick checks to provide geberal feedback - String formatError = Policy.bind("CVSRepositoryLocation.locationForm");//$NON-NLS-1$ - int secondColon = location.indexOf(COLON, 1); - int at = location.indexOf(HOST_SEPARATOR); - if (at != -1) { - String user = location.substring(secondColon + 1, at); - if (user.equals(""))//$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, formatError); - } else - at = secondColon; - int colon = location.indexOf(COLON, at + 1); - if (colon == -1) - return new CVSStatus(IStatus.ERROR, formatError); - String host = location.substring(at + 1, colon); - if (host.equals(""))//$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, formatError); - String path = location.substring(colon + 1, location.length()); - if (path.equals(""))//$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, formatError); - - // Do a full parse and see if it passes - try { - fromString(location, true); - } catch (CVSException e) { - // An exception is always throw. Return the status - return e.getStatus(); - } - - // Looks ok (we'll actually never get here because above - // fromString(String, boolean) will always throw an exception). - return Status.OK_STATUS; - } - - /** - * Get the plugged-in user authenticator if there is one. - * @return the plugged-in user authenticator or null - */ - public static IUserAuthenticator getAuthenticator() { - if (authenticator == null) { - authenticator = getPluggedInAuthenticator(); - } - return authenticator; - } - - /** - * Return the list of plugged-in connection methods. - * @return the list of plugged-in connection methods - */ - public static IConnectionMethod[] getPluggedInConnectionMethods() { - if(pluggedInConnectionMethods==null) { - List connectionMethods = new ArrayList(); - - if (STANDALONE_MODE) { - connectionMethods.add(new PServerConnectionMethod()); - } else { - IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_CONNECTIONMETHODS).getExtensions(); - for(int i=0; inull if none is registered with the given name. - */ - private static IConnectionMethod getPluggedInConnectionMethod(String methodName) { - Assert.isNotNull(methodName); - IConnectionMethod[] methods = getPluggedInConnectionMethods(); - for(int i=0; i0) - methodNames.append(", ");//$NON-NLS-1$ - methodNames.append(name); - } - return methodNames.toString(); - } - - /* - * Get the pluged-in authenticator from the plugin manifest. - */ - private static IUserAuthenticator getPluggedInAuthenticator() { - IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_AUTHENTICATOR).getExtensions(); - if (extensions.length == 0) - return null; - IExtension extension = extensions[0]; - IConfigurationElement[] configs = extension.getConfigurationElements(); - if (configs.length == 0) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSAdapter.noConfigurationElement", new Object[] {extension.getUniqueIdentifier()}), null);//$NON-NLS-1$ - return null; - } - try { - IConfigurationElement config = configs[0]; - return (IUserAuthenticator) config.createExecutableExtension("run");//$NON-NLS-1$ - } catch (CoreException ex) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSAdapter.unableToInstantiate", new Object[] {extension.getUniqueIdentifier()}), ex);//$NON-NLS-1$ - return null; - } - } - - /* - * Create a CVSRepositoryLocation from its composite parts. - */ - private CVSRepositoryLocation(IConnectionMethod method, String user, String password, String host, int port, String root, String encoding, boolean userFixed, boolean passwordFixed) { - this.method = method; - this.user = user; - this.password = password; - this.host = host; - this.port = port; - this.root = root; - // The username can be fixed only if one is provided - if (userFixed && (user != null)) - this.userFixed = true; - // The password can only be fixed if the username is and a password is provided - if (userFixed && passwordFixed && (password != null)) - this.passwordFixed = true; - if (encoding != null) { - setEncoding(encoding); - } - } - - /* - * Create the connection to the remote server. - * If anything fails, an exception will be thrown and must - * be handled by the caller. - */ - private Connection createConnection(String password, IProgressMonitor monitor) throws CVSException { - IConnectionMethod methodToUse = method; - if (method.getName().equals("ext") && extProxy != null && !extProxy.equals(method.getName())) { //$NON-NLS-1$ - methodToUse = getPluggedInConnectionMethod(extProxy); - } - Connection connection = new Connection(this, methodToUse.createConnection(this, password)); - connection.open(monitor); - return connection; - } - - /* - * Dispose of the receiver by clearing any cached authorization information. - * This method shold only be invoked when the corresponding adapter is shut - * down or a connection is being validated. - */ - public void dispose() { - flushCache(); - try { - if (hasPreferences()) { - internalGetPreferences().removeNode(); - getParentPreferences().flush(); - } - } catch (BackingStoreException e) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.73", getLocation(true)), e); //$NON-NLS-1$ - } - } - - /* - * Flush the keyring entry associated with the receiver - */ - private void flushCache() { - try { - Platform.flushAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME); - } catch (CoreException e) { - // No need to report this since the location is - // most likely being disposed. - // Just fail silently and continue - CVSProviderPlugin.log(e); - } - } - - /* - * @see ICVSRepositoryLocation#getHost() - */ - public String getHost() { - return host; - } - - /* - * @see IRepositoryLocation#getLocation() - * - * The username is included if it is fixed. - * The password is never included even if it is fixed. - * The port is included if it is not the default port. - */ - public String getLocation() { - return getLocation(false); - } - - public String getLocation(boolean forDisplay) { - return COLON + method.getName() + COLON + - (userFixed?(user + - ((passwordFixed && !forDisplay)?(COLON + password):"")//$NON-NLS-1$ - + HOST_SEPARATOR):"") +//$NON-NLS-1$ - host + COLON + - ((port == USE_DEFAULT_PORT)?"":(new Integer(port).toString())) + //$NON-NLS-1$ - root; - } - - /* - * @see ICVSRepositoryLocation#getMethod() - */ - public IConnectionMethod getMethod() { - return method; - } - - public boolean setMethod(String methodName) { - IConnectionMethod newMethod = getPluggedInConnectionMethod(methodName); - if (newMethod == null) - return false; - method = newMethod; - return true; - } - - /* - * @see ICVSRepositoryLocation#getPort() - */ - public int getPort() { - return port; - } - - /* - * @see ICVSRepositoryLocation#getEncoding() - */ - public String getEncoding() { - if (hasPreferences()) { - return internalGetPreferences().get(PREF_SERVER_ENCODING, getDefaultEncoding()); - } else { - return getDefaultEncoding(); - } - } - - /* - * @see ICVSRepositoryLocation#setEncoding() - */ - public void setEncoding(String encoding) { - if (encoding == null || encoding == getDefaultEncoding()) { - if (hasPreferences()) { - internalGetPreferences().remove(PREF_SERVER_ENCODING); - } - } else { - ensurePreferencesStored(); - internalGetPreferences().put(PREF_SERVER_ENCODING, encoding); - flushPreferences(); - } - } - - /* - * @see ICVSRepositoryLocation#members(CVSTag, boolean, IProgressMonitor) - */ - public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException { - try { - if (modules) { - return RemoteModule.getRemoteModules(this, tag, progress); - } else { - RemoteFolder root = new RemoteFolder(null, this, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); - ICVSRemoteResource[] resources = root.members(progress); - // There is the off chance that there is a file in the root of the repository. - // This is not supported by cvs so we need to make sure there are no files - List folders = new ArrayList(resources.length); - for (int i = 0; i < resources.length; i++) { - ICVSRemoteResource remoteResource = resources[i]; - if (remoteResource.isContainer()) { - folders.add(remoteResource); - } - } - return (ICVSRemoteResource[]) folders.toArray(new ICVSRemoteResource[folders.size()]); - } - } catch(TeamException e) { - throw new CVSException(e.getStatus()); - } - } - - /* - * @see ICVSRepositoryLocation#getRemoteFolder(String, CVSTag) - */ - public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag) { - return new RemoteFolder(null, this, remotePath, tag); - } - - /* - * @see ICVSRepositoryLocation#getRemoteFile(String, CVSTag) - */ - public ICVSRemoteFile getRemoteFile(String remotePath, CVSTag tag) { - IPath path = new Path(null, remotePath); - RemoteFolderTree remoteFolder = new RemoteFolderTree(null, this, path.removeLastSegments(1).toString(), tag); - RemoteFile remoteFile = new RemoteFile(remoteFolder, Update.STATE_ADDED_LOCAL, path.lastSegment(), null, null, tag); - remoteFolder.setChildren(new ICVSRemoteResource[] { remoteFile }); - return remoteFile; - } - - /* - * @see ICVSRepositoryLocation#getRootDirectory() - */ - public String getRootDirectory() { - return root; - } - - /* - * @see ICVSRepositoryLocation#getTimeout() - * - * For the time being, the timeout value is a system wide value - * associated with the CVSPlugin singleton. - */ - public int getTimeout() { - return CVSProviderPlugin.getPlugin().getTimeout(); - } - - /* - * @see ICVSRepositoryLocation#getUserInfo() - */ - public IUserInfo getUserInfo(boolean makeUsernameMutable) { - return new UserInfo(getUsername(), password, makeUsernameMutable ? true : isUsernameMutable()); - } - - /* - * @see ICVSRepositoryLocation#getUsername() - * @see IUserInfo#getUsername() - */ - public String getUsername() { - // If the username is mutable, get it from the cache if it's there - if (user == null && isUsernameMutable()) { - retrievePassword(); - } - return user == null ? "" : user; //$NON-NLS-1$ - } - - /* - * @see IUserInfo#isUsernameMutable() - */ - public boolean isUsernameMutable() { - return !userFixed; - } - - /* - * Open a connection to the repository represented by the receiver. - * If the username or password are not fixed, openConnection will - * use the plugged-in authenticator to prompt for the username and/or - * password if one has not previously been provided or if the previously - * supplied username and password are invalid. - * - * This method is synchronized to ensure that authentication with the - * remote server is serialized. This is needed to avoid the situation where - * multiple failed authentications occur and result in the remote account - * being locked. The CVSProviderPlugin enforces that there is one instance - * of a CVSRepositoryLocation per remote location thus this method is called - * for any connection made to this remote location. - */ - public Connection openConnection(IProgressMonitor monitor) throws CVSException { - Object hostLock; - synchronized(hostLocks) { - hostLock = hostLocks.get(getHost()); - if (hostLock == null) { - hostLock = new Object(); - hostLocks.put(getHost(), hostLock); - } - } - synchronized(hostLock) { - try { - // Allow two ticks in case of a retry - monitor.beginTask(Policy.bind("CVSRepositoryLocation.openingConnection", getHost()), 2);//$NON-NLS-1$ - ensureLocationCached(); - boolean cacheNeedsUpdate = false; - while (true) { - try { - // The following will throw an exception if authentication fails - String password = this.password; - if (password == null) { - // If the instance has no password, obtain it from the cache - password = retrievePassword(); - } - if (user == null) { - // This is possible if the cache was cleared somehow for a location with a mutable username - throw new CVSAuthenticationException(new CVSStatus(IStatus.ERROR, CVSAuthenticationException.RETRY, Policy.bind("CVSRepositoryLocation.usernameRequired"))); //$NON-NLS-1$ - } - if (password == null) - password = "";//$NON-NLS-1$ - Connection connection = createConnection(password, monitor); - if (cacheNeedsUpdate) - updateCachedLocation(); - return connection; - } catch (CVSAuthenticationException ex) { - if (ex.getStatus().getCode() == CVSAuthenticationException.RETRY) { - String message = ex.getMessage(); - IUserAuthenticator authenticator = getAuthenticator(); - if (authenticator == null) { - throw new CVSAuthenticationException(Policy.bind("Client.noAuthenticator"), CVSAuthenticationException.NO_RETRY);//$NON-NLS-1$ - } - authenticator.promptForUserInfo(this, this, message); - // The authentication iformation has been change so update the cache - cacheNeedsUpdate = true; - } else { - throw ex; - } - } - } - } finally { - monitor.done(); - } - } - } - - /* - * Ensure that this location is in the known repositories list - * and that the authentication information matches what is in the - * cache, if this instance is not the instance in the cache. - */ - private void ensureLocationCached() { - String location = getLocation(); - KnownRepositories repositories = KnownRepositories.getInstance(); - if (repositories.isKnownRepository(location)) { - try { - // The repository is already known. - // Ensure that the authentication information of this - // location matches that of the known location - setAuthenticationInformation((CVSRepositoryLocation)repositories.getRepository(location)); - } catch (CVSException e) { - // Log the exception and continue - CVSProviderPlugin.log(e); - } - } else { - // The repository is not known so record it so any authentication - // information the user may provide is remembered - repositories.addRepository(this, true /* broadcast */); - } - } - - /* - * Set the authentication information of this instance such that it matches the - * provided instances. - */ - private void setAuthenticationInformation(CVSRepositoryLocation other) { - if (other != this) { - // The instances differ so copy from the other location to this one - if (other.getUserInfoCached()) { - // The user info is cached for the other instance - // so null all the values in this instance so the - // information is obtained from the cache - this.allowCaching = true; - if (!userFixed) this.user = null; - if (!passwordFixed) this.password = null; - } else { - // The user info is not cached for the other instance so - // copy the authentication information into this instance - setAllowCaching(false); /* this will clear any cahced values */ - // Only copy the username and password if they are not fixed. - // (If they are fixed, they would be included in the location - // identifier and therefore must already match) - if (!other.userFixed) - this.user = other.user; - if (!other.passwordFixed) - this.password = other.password; - } - } - } - - /* - * The connection was sucessfully made. Update the cached - * repository location if it is a differnet instance than - * this location. - */ - private void updateCachedLocation() { - try { - CVSRepositoryLocation known = (CVSRepositoryLocation)KnownRepositories.getInstance().getRepository(getLocation()); - known.setAuthenticationInformation(this); - } catch (CVSException e) { - // Log the exception and continue - CVSProviderPlugin.log(e); - } - } - - /* - * Implementation of inherited toString() - */ - public String toString() { - return getLocation(true); - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof CVSRepositoryLocation)) return false; - return getLocation().equals(((CVSRepositoryLocation)o).getLocation()); - } - public int hashCode() { - return getLocation().hashCode(); - } - - /* - * Return the cached password from the keyring. - * Also, set the username of the receiver if the username is mutable - */ - private String retrievePassword() { - Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME); - if (map != null) { - String username = (String) map.get(INFO_USERNAME); - if (username != null && isUsernameMutable()) - setUsername(username); - String password = (String) map.get(INFO_PASSWORD); - if (password != null) { - return password; - } - } - return null; - } - /* - * @see IUserInfo#setPassword(String) - */ - public void setPassword(String password) { - if (passwordFixed) - throw new UnsupportedOperationException(); - // We set the password here but it will be cleared - // if the user info is cached using updateCache() - this.password = password; - } - - public void setUserInfo(IUserInfo userinfo) { - user = userinfo.getUsername(); - password = ((UserInfo)userinfo).getPassword(); - } - /* - * @see IUserInfo#setUsername(String) - */ - public void setUsername(String user) { - if (userFixed) - throw new UnsupportedOperationException(); - this.user = user; - } - - public void setUserMuteable(boolean muteable) { - userFixed = !muteable; - } - - public void setAllowCaching(boolean value) { - allowCaching = value; - updateCache(); - } - - public void updateCache() { - // Nothing to cache if the password is fixed - if (passwordFixed || ! allowCaching) return; - // Nothing to cache if the password is null and the user is fixed - if (password == null && userFixed) return; - if (updateCache(user, password)) { - // If the cache was updated, null the password field - // so we will obtain the password from the cache when needed - password = null; - } - ensurePreferencesStored(); - } - - /* - * Cache the user info in the keyring. Return true if the operation - * succeeded and false otherwise. If an error occurs, it will be logged. - */ - private boolean updateCache(String username, String password) { - // put the password into the Platform map - Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME); - if (map == null) { - map = new java.util.HashMap(10); - } - if (username != null) - map.put(INFO_USERNAME, username); - if (password != null) - map.put(INFO_PASSWORD, password); - try { - Platform.addAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME, map); - } catch (CoreException e) { - // We should probably wrap the CoreException here! - CVSProviderPlugin.log(e); - return false; - } - return true; - } - - /* - * Validate that the receiver contains valid information for - * making a connection. If the receiver contains valid - * information, the method returns. Otherwise, an exception - * indicating the problem is throw. - */ - public void validateConnection(IProgressMonitor monitor) throws CVSException { - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()); - Session session = new Session(this, root, false /* output to console */); - session.open(Policy.subMonitorFor(monitor, 50), false /* read-only */); - try { - IStatus status = Command.VERSION.execute(session, this, Policy.subMonitorFor(monitor, 50)); - // Log any non-ok status - if (! status.isOK()) { - CVSProviderPlugin.log(status); - } - } finally { - session.close(); - monitor.done(); - } - } catch (CVSException e) { - // If the validation failed, dispose of any cached info - dispose(); - throw e; - } - } - - /** - * Return the server platform type. It will be one of the following: - * UNDETERMINED_PLATFORM: The platform has not been determined - * CVS_SERVER: The platform is regular CVS server - * CVSNT_SERVER: The platform in CVSNT - * If UNDETERMINED_PLATFORM is returned, the platform can be determined - * using the Command.VERSION command. - */ - public int getServerPlatform() { - return serverPlatform; - } - - /** - * This method is called from Command.VERSION to set the platform type. - */ - public void setServerPlaform(int serverType) { - // Second, check the code of the status itself to see if it is NT - switch (serverType) { - case CVS_SERVER: - case CVSNT_SERVER: - case UNKNOWN_SERVER: - case UNSUPPORTED_SERVER: - serverPlatform = serverType; - break; - default: - // We had an error status with no info about the server. - // Mark it as undetermined. - serverPlatform = UNDETERMINED_PLATFORM; - } - } - - /** - * @see ICVSRepositoryLocation#flushUserInfo() - */ - public void flushUserInfo() { - flushCache(); - } - - /* - * Return the command string that is to be used by the EXT connection method. - */ - String[] getExtCommand(String password) throws IOException { - // Get the user specified connection parameters - String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand(); - String CVS_RSH_PARAMETERS = CVSProviderPlugin.getPlugin().getCvsRshParameters(); - String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer(); - if(CVS_RSH == null || CVS_SERVER == null) { - throw new IOException(Policy.bind("EXTServerConnection.varsNotSet")); //$NON-NLS-1$ - } - - // If there is only one token, assume it is the command and use the default parameters and order - if (CVS_RSH_PARAMETERS == null || CVS_RSH_PARAMETERS.length() == 0) { - if (port != USE_DEFAULT_PORT) - throw new IOException(Policy.bind("EXTServerConnection.invalidPort")); //$NON-NLS-1$ - return new String[] {CVS_RSH, host, "-l", user, CVS_SERVER, INVOKE_SVR_CMD}; //$NON-NLS-1$ - } - - // Substitute any variables for their appropriate values - CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, USER_VARIABLE, user); - CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, PASSWORD_VARIABLE, password); - CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, HOST_VARIABLE, host); - CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, PORT_VARIABLE, new Integer(port).toString()); - - // Build the command list to be sent to the OS. - List commands = new ArrayList(); - commands.add(CVS_RSH); - StringTokenizer tokenizer = new StringTokenizer(CVS_RSH_PARAMETERS); - while (tokenizer.hasMoreTokens()) { - String next = tokenizer.nextToken(); - commands.add(next); - } - commands.add(CVS_SERVER); - commands.add(INVOKE_SVR_CMD); - return (String[]) commands.toArray(new String[commands.size()]); - } - - /* - * Replace all occurances of oldString with newString - */ - private String stringReplace(String string, String oldString, String newString) { - int index = string.toLowerCase().indexOf(oldString); - if (index == -1) return string; - return stringReplace( - string.substring(0, index) + newString + string.substring(index + oldString.length()), - oldString, newString); - } - - /** - * Return the server message with the prefix removed. - * Server aborted messages typically start with - * "cvs server: ..." - * "cvs [server aborted]: ..." - * "cvs rtag: ..." - */ - public String getServerMessageWithoutPrefix(String errorLine, String prefix) { - String message = errorLine; - int firstSpace = message.indexOf(' '); - if(firstSpace != -1) { - // remove the program name and the space - message = message.substring(firstSpace + 1); - // Quick fix to handle changes in server message format (see Bug 45138) - if (prefix.startsWith("[")) { //$NON-NLS-1$ - // This is the server aborted message - // Remove the pattern "[command_name aborted]: " - int closingBracket = message.indexOf("]: "); //$NON-NLS-1$ - if (closingBracket == -1) return null; - // get what is inside the brackets - String realPrefix = message.substring(1, closingBracket); - // check that there is two words and the second word is "aborted" - int space = realPrefix.indexOf(' '); - if (space == -1) return null; - if (realPrefix.indexOf(' ', space +1) != -1) return null; - if (!realPrefix.substring(space +1).equals("aborted")) return null; //$NON-NLS-1$ - // It's a match, return the rest of the line - message = message.substring(closingBracket + 2); - if (message.charAt(0) == ' ') { - message = message.substring(1); - } - return message; - } else { - // This is the server command message - // Remove the pattern "command_name: " - int colon = message.indexOf(": "); //$NON-NLS-1$ - if (colon == -1) return null; - // get what is before the colon - String realPrefix = message.substring(0, colon); - // ensure that it is a single word - if (realPrefix.indexOf(' ') != -1) return null; - message = message.substring(colon + 1); - if (message.charAt(0) == ' ') { - message = message.substring(1); - } - return message; - } - } - // This is not a server message with the desired prefix - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#getUserAuthenticator() - */ - public IUserAuthenticator getUserAuthenticator() { - return getAuthenticator(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#setUserAuthenticator() - */ - public void setUserAuthenticator(IUserAuthenticator authenticator) { - CVSRepositoryLocation.authenticator = authenticator; - } - - /* - * Return the preferences node for this repository - */ - public Preferences getPreferences() { - if (!hasPreferences()) { - ensurePreferencesStored(); - } - return internalGetPreferences(); - } - - private Preferences internalGetPreferences() { - return getParentPreferences().node(getPreferenceName()); - } - - private boolean hasPreferences() { - try { - return getParentPreferences().nodeExists(getPreferenceName()); - } catch (BackingStoreException e) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.74", getLocation(true)), e); //$NON-NLS-1$ - return false; - } - } - - /** - * Return a unique name that identifies this location but - * does not contain any slashes (/). Also, do not use ':'. - * Although a valid path character, the initial core implementation - * didn't handle it well. - */ - private String getPreferenceName() { - return getLocation().replace('/', '%').replace(':', '%'); - } - - public void storePreferences() { - Preferences prefs = internalGetPreferences(); - // Must store at least one preference in the node - prefs.put(PREF_LOCATION, getLocation()); - flushPreferences(); - } - - private void flushPreferences() { - try { - internalGetPreferences().flush(); - } catch (BackingStoreException e) { - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("CVSRepositoryLocation.75", getLocation(true)), e); //$NON-NLS-1$ - } - } - - private void ensurePreferencesStored() { - if (!hasPreferences()) { - storePreferences(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#getUserInfoCached() - */ - public boolean getUserInfoCached() { - Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME); - if (map != null) { - String password = (String) map.get(INFO_PASSWORD); - return (password != null); - } - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java deleted file mode 100644 index a0cfa8f9d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; - -/** - * Client has received an error response from the server. - */ -public class CVSServerException extends CVSException { - - private static final long serialVersionUID = 1L; - - /** - * Return true if the exception from the cvs server is the no tag error, and false - * otherwise. - */ - public boolean isNoTagException() { - IStatus status = getStatus(); - if ( ! status.isMultiStatus()) - return false; - IStatus[] children = ((MultiStatus)status).getChildren(); - for (int i = 0; i < children.length; i++) { - if (children[i].getCode() == CVSStatus.NO_SUCH_TAG) { - return true; - } - } - return false; - } - - /** - * Return true if the exceptions status contains any error status messages - */ - public boolean containsErrors() { - IStatus status = getStatus(); - if ( ! status.isMultiStatus()) - return status.getSeverity() == IStatus.ERROR; - IStatus[] children = ((MultiStatus)status).getChildren(); - for (int i=0;i 0) { - return new CVSServerException(message, children); - } else { - return new CVSServerException(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, message, null)); - } - } - - public CVSServerException(IStatus status) { - super(status); - } - - private CVSServerException(String message, IStatus[] children) { - super(new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, children, message, null)); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java deleted file mode 100644 index 942e7692e..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.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.team.internal.ccvs.core.connection; - - -import java.io.*; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; - -/** - * A connection to talk to a cvs server. The life cycle of a connection is - * as follows: - *
                - *
              • constructor: creates a new connection object that wraps the given - * repository location and connection method. - *
              • open: opens a connection. - *
              • send a request: use write* method or use the request stream directly. - * GetRequestStream returns an output stream to directly - * talk to the server. - *
              • read responses: use read* methods or use the response stream directly. - * GetResponseStream returns an input stream to directly - * read output from the server. - *
              • close: closes the connection. A closed connection can be reopened by - * calling open again. - *
              - */ -public class Connection { - private static final byte NEWLINE= 0xA; - - private IServerConnection serverConnection; - private ICVSRepositoryLocation fCVSRoot; - private boolean fIsEstablished; - private InputStream fResponseStream; - private byte[] readLineBuffer = new byte[256]; - - public Connection(ICVSRepositoryLocation cvsroot, IServerConnection serverConnection) { - fCVSRoot = cvsroot; - this.serverConnection = serverConnection; - } - - private static byte[] append(byte[] buffer, int index, byte b) { - if (index >= buffer.length) { - byte[] newBuffer= new byte[index * 2]; - System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); - buffer= newBuffer; - } - buffer[index]= b; - return buffer; - } - /** - * Closes the connection. - */ - public void close() { - if (!isEstablished()) - return; - try { - serverConnection.close(); - } catch (IOException ex) { - // Generally, errors on close are of no interest. - // However, log them if debugging is on - if (CVSProviderPlugin.getPlugin().isDebugging()) { - CVSProviderPlugin.log(new CVSCommunicationException(Policy.bind("Connection.cannotClose"), ex));//$NON-NLS-1$ - } - } finally { - fResponseStream = null; - fIsEstablished = false; - } - } - /** - * Flushes the request stream. - */ - public void flush() throws CVSException { - if (!isEstablished()) - return; - try { - getOutputStream().flush(); - } catch(IOException e) { - throw new CVSCommunicationException(e); - } - } - - /** - * Returns the OutputStream used to send requests - * to the server. - */ - public OutputStream getOutputStream() { - if (!isEstablished()) - return null; - return serverConnection.getOutputStream(); - } - /** - * Returns the InputStream used to read responses from - * the server. - */ - public InputStream getInputStream() { - if (!isEstablished()) - return null; - if (fResponseStream == null) - fResponseStream = serverConnection.getInputStream(); - return fResponseStream; - } - - /** - * Returns true if the connection is established; - * otherwise false. - */ - public boolean isEstablished() { - return fIsEstablished; - } - - /** - * Opens the connection. - */ - public void open(IProgressMonitor monitor) throws CVSException { - if (isEstablished()) - return; - try { - serverConnection.open(monitor); - } catch (IOException e) { - throw new CVSCommunicationException(Policy.bind("Connection.0", fCVSRoot.getLocation(), CVSCommunicationException.getMessageFor(e)), e); //$NON-NLS-1$ - } - fIsEstablished= true; - } - /** - * Reads a line from the response stream. - */ - public String readLine() throws CVSException { - if (!isEstablished()) - throw new CVSCommunicationException(Policy.bind("Connection.readUnestablishedConnection"));//$NON-NLS-1$ - try { - InputStream in = getInputStream(); - int index = 0; - int r; - while ((r = in.read()) != -1) { - if (r == NEWLINE) break; - readLineBuffer = append(readLineBuffer, index++, (byte) r); - } - - String result = new String(readLineBuffer, 0, index, getEncoding(fCVSRoot)); - if (Policy.isDebugProtocol()) Policy.printProtocolLine(result); - return result; - } catch (IOException e) { - throw new CVSCommunicationException(e); - } - } - - static String readLine(ICVSRepositoryLocation location, InputStream in) throws IOException { - byte[] buffer = new byte[256]; - int index = 0; - int r; - while ((r = in.read()) != -1) { - if (r == NEWLINE) - break; - buffer = append(buffer, index++, (byte) r); - } - - String result = new String(buffer, 0, index, getEncoding(location)); - if (Policy.isDebugProtocol()) - Policy.printProtocolLine(result); - return result; - } - - //---- Helper to send strings to the server ---------------------------- - - /** - * Sends the given string to the server. - */ - public void write(String s) throws CVSException { - try { - write(s.getBytes(getEncoding(fCVSRoot)), false); - } catch (UnsupportedEncodingException e) { - throw new CVSException (e.getMessage()); - } - } - - /** - * Return the encoding for the given repository location - * @return the encoding for the given repository location - */ - public static String getEncoding(ICVSRepositoryLocation location) { - return location.getEncoding(); - } - - /** - * Sends the given string and a newline to the server. - */ - public void writeLine(String s) throws CVSException { - try { - write(s.getBytes(getEncoding(fCVSRoot)), true); - } catch (UnsupportedEncodingException e) { - throw new CVSException (e.getMessage()); - } - } - - void write (byte[] bytes, boolean newLine) throws CVSException { - write(bytes, 0, bytes.length, newLine); - } - - /** - * Low level method to write a string to the server. All write* methods are - * funneled through this method. - */ - void write(byte[] b, int off, int len, boolean newline) throws CVSException { - if (!isEstablished()) - throw new CVSCommunicationException(Policy.bind("Connection.writeUnestablishedConnection"));//$NON-NLS-1$ - - if (Policy.isDebugProtocol()) - Policy.printProtocol(new String(b, off, len), newline); - - try { - OutputStream out= getOutputStream(); - out.write(b, off, len); - if (newline) - out.write(NEWLINE); - - } catch (IOException e) { - throw new CVSCommunicationException(e); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java deleted file mode 100644 index 225dfd09b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IServerConnection; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.core.streams.PollingInputStream; -import org.eclipse.team.internal.core.streams.PollingOutputStream; -import org.eclipse.team.internal.core.streams.TimeoutInputStream; -import org.eclipse.team.internal.core.streams.TimeoutOutputStream; - -/** - * Implements a connection method which invokes an external tool to - * establish the connection to the cvs server. Authentication and starting - * of the cvs server are the responsibility of the external connection - * tool. - */ -public class ExtConnection implements IServerConnection { - - // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo) - private ICVSRepositoryLocation location; - private String password; - - // incoming from remote host - InputStream inputStream; - - // outgoing to remote host - OutputStream outputStream; - - // Process spawn to run the command - Process process; - - protected ExtConnection(ICVSRepositoryLocation location, String password) { - this.location = location; - this.password = password; - } - - /** - * Closes the connection. - */ - public void close() throws IOException { - try { - if (inputStream != null) inputStream.close(); - } finally { - inputStream = null; - try { - if (outputStream != null) outputStream.close(); - } finally { - outputStream = null; - if (process != null) process.destroy(); - } - } - } - - /** - * Returns the InputStream used to read data from the - * server. - */ - public InputStream getInputStream() { - return inputStream; - } - - /** - * Returns the OutputStream used to send data to the - * server. - */ - public OutputStream getOutputStream() { - return outputStream; - } - - /** - * Opens the connection and invokes cvs in server mode. - * - * @see Connection.open() - */ - public void open(IProgressMonitor monitor) throws IOException { - String[] command = ((CVSRepositoryLocation)location).getExtCommand(password); - boolean connected = false; - try { - process = Util.createProcess(command, monitor); - - inputStream = new PollingInputStream(new TimeoutInputStream(process.getInputStream(), - 8192 /*bufferSize*/, 1000 /*readTimeout*/, -1 /*closeTimeout*/), location.getTimeout(), monitor); - outputStream = new PollingOutputStream(new TimeoutOutputStream(process.getOutputStream(), - 8192 /*buffersize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), location.getTimeout(), monitor); - - // XXX need to do something more useful with stderr - // discard the input to prevent the process from hanging due to a full pipe - Thread thread = new DiscardInputThread(process.getErrorStream()); - connected = true; - } finally { - if (! connected) { - try { - close(); - } finally { - // Ignore any exceptions during close - } - } - } - } - - private static class DiscardInputThread extends Thread { - private InputStream in; - public DiscardInputThread(InputStream in) { - this.in = in; - } - public void run() { - try { - try { - while (in.read() != -1); - } finally { - in.close(); - } - } catch (IOException e) { - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java deleted file mode 100644 index 94c5f0de9..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import org.eclipse.team.internal.ccvs.core.*; - -public class ExtConnectionMethod implements IConnectionMethod { - /** - * @see IConnectionMethod#getName - */ - public String getName() { - return "ext"; //$NON-NLS-1$ - } - - /** - * @see IConnectionMethod#createConnection - */ - public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) { - return new ExtConnection(repositoryRoot, password); - } - - public void disconnect(ICVSRepositoryLocation location) { - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java deleted file mode 100644 index 621805564..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java +++ /dev/null @@ -1,257 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import java.io.*; -import java.net.Socket; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.core.streams.*; - -/** - * A connection used to talk to an cvs pserver. - */ -public class PServerConnection implements IServerConnection { - - public static final char NEWLINE= 0xA; - - /** default CVS pserver port */ - private static final int DEFAULT_PORT= 2401; - - /** error line indicators */ - private static final char ERROR_CHAR = 'E'; - private static final String ERROR_MESSAGE = "error 0";//$NON-NLS-1$ - private static final String NO_SUCH_USER = "no such user";//$NON-NLS-1$ - - private static final char[] SCRAMBLING_TABLE=new char[] { - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, - 114,120,53,79,96,109,72,108,70,64,76,67,116,74,68,87, - 111,52,75,119,49,34,82,81,95,65,112,86,118,110,122,105, - 41,57,83,43,46,102,40,89,38,103,45,50,42,123,91,35, - 125,55,54,66,124,126,59,47,92,71,115,78,88,107,106,56, - 36,121,117,104,101,100,69,73,99,63,94,93,39,37,61,48, - 58,113,32,90,44,98,60,51,33,97,62,77,84,80,85,223, - 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190, - 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193, - 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212, - 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246, - 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176, - 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127, - 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195, - 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152 - }; - - /** Communication strings */ - private static final String BEGIN= "BEGIN AUTH REQUEST";//$NON-NLS-1$ - private static final String END= "END AUTH REQUEST";//$NON-NLS-1$ - private static final String LOGIN_OK= "I LOVE YOU";//$NON-NLS-1$ - private static final String LOGIN_FAILED= "I HATE YOU";//$NON-NLS-1$ - - private String password; - private ICVSRepositoryLocation cvsroot; - - private Socket fSocket; - - private InputStream inputStream; - private OutputStream outputStream; - - /** - * @see Connection#doClose() - */ - public void close() throws IOException { - try { - if (inputStream != null) inputStream.close(); - } finally { - inputStream = null; - try { - if (outputStream != null) outputStream.close(); - } finally { - outputStream = null; - try { - if (fSocket != null) fSocket.close(); - } finally { - fSocket = null; - } - } - } - } - - /** - * @see Connection#doOpen() - */ - public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - - monitor.subTask(Policy.bind("PServerConnection.authenticating"));//$NON-NLS-1$ - monitor.worked(1); - - fSocket = createSocket(monitor); - boolean connected = false; - try { - this.inputStream = new BufferedInputStream(new PollingInputStream(fSocket.getInputStream(), - cvsroot.getTimeout(), monitor)); - this.outputStream = new PollingOutputStream(new TimeoutOutputStream( - fSocket.getOutputStream(), 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), - cvsroot.getTimeout(), monitor); - authenticate(); - connected = true; - } finally { - if (! connected) cleanUpAfterFailedConnection(); - } - } - - /** - * @see Connection#getInputStream() - */ - public InputStream getInputStream() { - return inputStream; - } - /** - * @see Connection#getOutputStream() - */ - public OutputStream getOutputStream() { - return outputStream; - } - - /** - * Creates a new PServerConnection for the given - * cvs root. - */ - PServerConnection(ICVSRepositoryLocation cvsroot, String password) { - this.cvsroot = cvsroot; - this.password = password; - } - /** - * Does the actual authentification. - */ - private void authenticate() throws IOException, CVSAuthenticationException { - String scrambledPassword = scramblePassword(password); - - String user = cvsroot.getUsername(); - OutputStream out = getOutputStream(); - - StringBuffer request = new StringBuffer(); - request.append(BEGIN); - request.append(NEWLINE); - request.append(cvsroot.getRootDirectory()); - request.append(NEWLINE); - request.append(user); - request.append(NEWLINE); - request.append(scrambledPassword); - request.append(NEWLINE); - request.append(END); - request.append(NEWLINE); - out.write(request.toString().getBytes()); - out.flush(); - String line = Connection.readLine(cvsroot, getInputStream()).trim(); - - // Return if we succeeded - if (LOGIN_OK.equals(line)) - return; - - // Otherwise, determine the type of error - if (line.length() == 0) { - throw new IOException(Policy.bind("PServerConnection.noResponse"));//$NON-NLS-1$ - } - - // Accumulate a message from the error (E) stream - String message = "";//$NON-NLS-1$ - String separator = ""; //$NON-NLS-1$ - while (line.length() > 0 && line.charAt(0) == ERROR_CHAR) { - if (line.length() > 2) { - message += separator + line.substring(2); - separator = " "; //$NON-NLS-1$ - } - line = Connection.readLine(cvsroot, getInputStream()); - } - - // If the last line is the login failed (I HATE YOU) message, return authentication failure - if (LOGIN_FAILED.equals(line)) { - if (message.length() == 0) { - throw new CVSAuthenticationException(Policy.bind("PServerConnection.loginRefused"), CVSAuthenticationException.RETRY);//$NON-NLS-1$ - } else { - throw new CVSAuthenticationException(message, CVSAuthenticationException.RETRY); - } - } - - // Remove leading "error 0" - if (line.startsWith(ERROR_MESSAGE)) - message += separator + line.substring(ERROR_MESSAGE.length() + 1); - else - message += separator + line; - if (message.indexOf(NO_SUCH_USER) != -1) - throw new CVSAuthenticationException(Policy.bind("PServerConnection.invalidUser", new Object[] {message}), CVSAuthenticationException.RETRY);//$NON-NLS-1$ - throw new IOException(Policy.bind("PServerConnection.connectionRefused", new Object[] { message }));//$NON-NLS-1$ - } - /* - * Called if there are exceptions when connecting. - * This method makes sure that all connections are closed. - */ - private void cleanUpAfterFailedConnection() throws IOException { - try { - if (inputStream != null) - inputStream.close(); - } finally { - try { - if (outputStream != null) - outputStream.close(); - } finally { - try { - if (fSocket != null) - fSocket.close(); - } finally { - fSocket = null; - } - } - } - - } - /** - * Creates the actual socket - */ - protected Socket createSocket(IProgressMonitor monitor) throws IOException { - // Determine what port to use - int port = cvsroot.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) - port = DEFAULT_PORT; - // Make the connection - Socket result; - try { - result= Util.createSocket(cvsroot.getHost(), port, monitor); - // Bug 36351: disable buffering and send bytes immediately - result.setTcpNoDelay(true); - } catch (InterruptedIOException e) { - // If we get this exception, chances are the host is not responding - throw new InterruptedIOException(Policy.bind("PServerConnection.socket", new Object[] {cvsroot.getHost()}));//$NON-NLS-1$ - } - result.setSoTimeout(1000); // 1 second between timeouts - return result; - } - - private String scramblePassword(String password) throws CVSAuthenticationException { - int length = password.length(); - char[] out= new char[length]; - for (int i= 0; i < length; i++) { - char value = password.charAt(i); - if( value < 0 || value > 255 ) - throwInValidCharacter(); - out[i]= SCRAMBLING_TABLE[value]; - } - return "A" + new String(out);//$NON-NLS-1$ - } - - private void throwInValidCharacter() throws CVSAuthenticationException { - throw new CVSAuthenticationException(Policy.bind("PServerConnection.invalidChars"), CVSAuthenticationException.RETRY);//$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java deleted file mode 100644 index 48e152429..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IConnectionMethod; -import org.eclipse.team.internal.ccvs.core.IServerConnection; -public class PServerConnectionMethod implements IConnectionMethod { - /** - * @see IConnectionMethod#createConnection(ICVSRepositoryLocation, String) - */ - public IServerConnection createConnection(ICVSRepositoryLocation location, String password) { - return new PServerConnection(location, password); - } - /** - * @see IConnectionMethod#getName() - */ - public String getName() { - return "pserver";//$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#disconnect(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation) - */ - public void disconnect(ICVSRepositoryLocation location) { - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java deleted file mode 100644 index 62d50b6e6..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.connection; - - -import org.eclipse.team.internal.ccvs.core.IUserInfo; - -/** - * @version 1.0 - * @author - */ -public class UserInfo implements IUserInfo { - - private String username; - private String password; - private boolean isUsernameMutable; - - protected UserInfo(String username, String password, boolean isUsernameMutable) { - this.username = username; - this.password = password; - this.isUsernameMutable = isUsernameMutable; - } - - /* - * @see IUserInfo#getUsername() - */ - public String getUsername() { - return username; - } - - protected String getPassword() { - return password; - } - - /* - * @see IUserInfo#isUsernameMutable() - */ - public boolean isUsernameMutable() { - return isUsernameMutable; - } - - /* - * @see IUserInfo#setPassword(String) - */ - public void setPassword(String password) { - this.password = password; - } - - /* - * @see IUserInfo#setUsername(String) - */ - public void setUsername(String username) { - this.username = username; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties deleted file mode 100644 index 66e52a7d8..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties +++ /dev/null @@ -1,351 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -org.eclipse.team.internal.provider.cvs.CVSException=CVS Error: {0} - -ok=ok -null=null -internal=An internal error has occurred. Consult the error log for details. - -AbstractStructureVisitor.sendingFolder=Processing {0} -AbstractStructureVisitor.sendingFile=Processing {0} -AbstractStructureVisitor.noRemote=Unable to determine remote location for resource - -AddDeleteMoveListener.deletedResource={0} has been deleted locally -AddDeleteMoveListener.Error_creating_deletion_marker_1=Error creating deletion marker -AddDeleteMoveListener.Local_addition_not_under_CVS_control_2=Local addition not under CVS control -AddDeleteMoveListener.Error_creating_addition_marker_3=Error creating addition marker -AddDeleteMoveListener.Error_updating_marker_state_4=Error updating marker state - -CVSAuthenticationException.detail=Authentication error: {0} -CVSCommunicationException.io=CVS communication error: {0} -CVSCommunicationException.interruptCause=The most likely cause of the interrupt is either an intermittent network failure or a communications timeout. -CVSCommunicationException.interruptSolution=The CVS communications timeout can be adjusted in the Team/CVS preferences. -CVSCommunicationException.alternateInterruptCause=Another possible cause is the improper configuration of the "ext" connection method. -CVSCommunicationException.alternateInterruptSolution=The "ext" connection method can be configured on the Team/CVS/EXT Connection Method preference page -CVSFileException.io=Error accessing CVS file -CVSDiffException.message=The compared files are different -CVSStatus.messageWithRoot={0}: {1} - -CVSTag.nullName=Name must not be null -CVSTag.emptyName=Name must not be empty -CVSTag.beginName=Name must start with a letter -CVSTag.badCharName=Name must not contain spaces or the characters `$,.:;@|' - -CVSWorkspaceRoot.notCVSFolder=The CVS synchronization information for {0} has become corrupt or does not exist - -java.io.IOException=I/O exception occurred: {0} -java.io.EOFException=End of file encountered: {0} -java.io.FileNotFoundException=File not found: {0} -java.io.InterruptedIOException=I/O has been interrupted. -java.net.UnknownHostException=Cannot locate host: {0} -java.net.ConnectException=Cannot connect to host: {0} -java.net.SocketException=Socket Exception: {0} -java.net.NoRouteToHostException={0} - -Connection.cannotClose=Cannot close connection -Connection.readUnestablishedConnection=Failure due to attempt to read from an unestablished connection -Connection.writeUnestablishedConnection=Failure due to attempt to write to an unestablished connection -Connection.0=Could not connect to {0}: {1} - -PServerConnection.invalidChars=Invalid characters in password -PServerConnection.hostInvalid=Invalid host -PServerConnection.loginRefused=Incorrect user name or password -PServerConnection.invalidUser={0} -PServerConnection.socket=Cannot connect to host: {0} -PServerConnection.connectionRefused=Connection refused: {0} -PServerConnection.stream=Error opening socket connection -PServerConnection.noResponse=No response from server -PServerConnection.authenticating=Authenticating using pserver - -CVSProviderPlugin.cannotUpdateDescription=Error updating project description -CVSProviderPlugin.errorDeletingCache=Error occurred deleting cache: {0} -CVSProviderPlugin.errorCreatingCache=Error occurred creating cache: {0} -CVSProviderPlugin.unknownStateFileVersion=Could not read CVS state file: unknown version '{0}'. - -CVSProvider.exception=Internal error occurred. -CVSProvider.invalidResource=Resource {0} is not a CVS resource -CVSProvider.initialImport=Initial import -CVSProvider.alreadyExists=The specified repository location already exists. -CVSProvider.rename=An I/O Exception occurred while renaming the state file {0} -CVSProvider.save=An I/O Exception occurred while saving the state file {0} -CVSProvider.ioException=I/O Exception occurred on the state file -CVSProvider.errorSaving=Error saving state -CVSProvider.errorLoading=Error loading state -CVSProvider.infoMismatch=Provided CVS information does not match that on disk for project {0} - -CVSTeamProvider.noFolderInfo=Project {0} does not contain CVS folder meta-information -CVSTeamProvider.deconfigureProblem=Error while deconfiguring CVS project {0} -CVSTeamProvider.initializationFailed=Initialization of CVS for project {0} failed -CVSTeamProvider.visitError=An error occurred while visiting resource {0} -CVSTeamProvider.invalidResource=Resource {0} is not a child of project {1} -CVSTeamProvider.checkinProblems=Problems occurred committing resources to server -CVSTeamProvider.invalidProjectState=CVS sharing information is missing from project {0} -CVSTeamProvider.typesDiffer=Error retrieving remote resource tree. Local and remote resource types differ for {0} -CVSTeamProvider.connectionInfo=Updating connection information for project {0} -CVSTeamProvider.scrubbingResource=Scrubbing {0} -CVSTeamProvider.preparingToSetKSubst=Preparing to set keyword substitution mode -CVSTeamProvider.settingKSubst=Setting keyword substitution mode -CVSTeamProvider.cleanLineDelimitersException=Exception occurred while cleaning line delimiters -CVSTeamProvider.changingKeywordComment=*** keyword substitution change *** -CVSTeamProvider.errorGettingFetchProperty=Could not get "fetch new directory" property for project ''{0}''. -CVSTeamProvider.errorSettingFetchProperty=Could not set "fetch new directory" property for project ''{0}''. -CVSTeamProvider.overlappingRemoteFolder=Cannot create linked resource ''{0}'' because a folder of the same name exists remotely. -CVSTeamProvider.overlappingFileDeletion=Cannot create linked resource ''{0}'' because a deletion for the file of that name has not been committed. -CVSTeamProvider.errorGettingWatchEdit=Could not get "watch/edit" property for project ''{0}''. -CVSTeamProvider.errorSettingWatchEdit=Could not set "watch/edit" property for project ''{0}''. -CVSTeamProvider.errorAddingFileToDiff=An I/O error occurred adding file ''{0}'' to the patch output. -CVSTeamProvider.updatingFolder=Updating {0} - -ResourceDeltaVisitor.visitError=Error while processing resource deltas - -ResponseDispatcher.serverError=The CVS server responded with an error (see the CVS console) -ResponseDispatcher.problemsReported= Errors occurred during the CVS operation -ResponseDispatcher.receiving=Receiving response - -FileProperties.invalidEntryLine=Invalid entry line: {0} - -EclipseResource.invalidResourceClass=Two different implementations of ICVSResource used - -RemoteResource.invalidResourceClass=Two different implementations of ICVSResource used -RemoteResource.invalidOperation=Invalid operation performed on remote resource -RemoteFolder.errorFetchingRevisions=Error fetching file revision numbers -RemoteFolder.invalidChild=Resource {0} is not a child of folder {1} -RemoteFolder.errorFetchingRevisions=Error fetching file revisions -RemoteFolder.errorFetchingMembers=One or more error occurred fetching the members of a remote folder -RemoteFolder.doesNotExist=Folder {0} does not exist remotely or you do not have permission to access it - -RemoteFile.noContentsReceived=No contents received from server for {0} -RemoteFile.errorRetrievingFromCache=Error occurred retrieving cached contents: {0} - -RemoteFolderTreeBuilder.buildingBase=Collecting local synchronization information -RemoteFolderTreeBuilder.0=Resource {0} is no longer mapped to CVS. -RemoteFolderTreeBuilder.receivingDelta=Receiving delta for {0} -RemoteFolderTreeBuilder.receivingRevision=Receiving revision for {0} -RemoteFolderTreeBuilder.missingParent=An error has occurred processing file ''{0} {1}'' -RemoteFolderTreeBuild.folderDeletedFromServer=Folder ''{0}'' has been deleted from the server. - -ReplaceWithBaseVisitor.replacing=Replacing ''{0}'' - -Session.badInt="Malformed file transmission received" -Session.receiving=Receiving file: {0} -Session.sending=Sending file: {0} -Session.transfer={0} ({1}K of {2}K bytes) -Session.transferNoSize={0} -Session.calculatingCompressedSize=Calculating compressed size: {0} -Session.dot_2=dot -Session.0=cvs client: {0} - -Command.receivingResponses=Receiving server response -Command.warnings=The following warnings were reported while performing the "cvs {0}" command. -Command.serverError=The server reported an error while performing the "cvs {0}" command. -Command.noMoreInfoAvailable=The server did not provide any additional information. -Command.add=add -Command.admin=admin -Command.annotate=annotate -Command.co=checkout -Command.ci=commit -Command.diff=diff -Command.editors=editors -Command.import=import -Command.log=log -Command.remove=remove -Command.status=status -Command.tag=tag -Command.rtag=rtag -Command.update=update -Command.version=version -Command.rdiff=rdiff -Command.valid-requests=valid-requests -Command.expand-modules=expand-modules -Command.unsupportedResponse=Unknown response received from cvs server: {0} {1} -Command.argumentNotManaged=Argument {0} is not managed -Command.invalidTag=HEAD is not a valid tag -Command.noOpenSession=The CVS command cannot be issued because there is no connection available -Command.seriousServerError=The server reported an error: {0} - -Commit.syncInfoMissing=The commit operation succeeded. However, committed file ''{0}'' no longer has CVS synchronization information. -Commit.timestampReset=The modification timestamp was changed for ''{0}'' but the contents match that of the server. The timstamp has been reset. - -Diff.serverError=The server reported an error while performing the "cvs diff" command which may only indicate that a difference exists. - -Tag.notVersionOrBranchError=Error applying tag: the tag provided is not a version or branch tag. - -DefaultHandler.connectionClosed=The connection to the server has been closed -ModTimeHandler.invalidFormat=The server modification time {0} is in an unknown format -Updated.numberFormat=Server did not send length of the file -UpdateListener.0=An unmergable conflict has occurred for binary file {0}. Revision {1} has been loaded and overwritten local changes have been saved in file {2} -UnsupportedHandler.message=Unsupported response received from server -RemovedHandler.invalid=Invalid removed response received from CVS server for {0} -RemovedHandler.0=An error occurred removing resource {0} -CheckInHandler.checkedIn= Receiving confirmation for file {0}. - -KSubstOption.-kb.short=Binary -KSubstOption.-kb.long=Binary (-kb) -KSubstOption.-ko.short=ASCII -ko -KSubstOption.-ko.long=ASCII without keyword substitution (-ko) -KSubstOption.-kkv.short=ASCII -kkv -KSubstOption.-kkv.long=ASCII with keyword expansion (-kkv) -KSubstOption.-kkvl.short=ASCII -kkvl -KSubstOption.-kkvl.long=ASCII with keyword expansion and locker (-kkvl) -KSubstOption.-kv.short=ASCII -kv -KSubstOption.-kv.long=ASCII with keyword replacement (-kv) -KSubstOption.-kk.short=ASCII -kk -KSubstOption.-kk.long=ASCII with keyword compression (-kk) -KSubstOption.unknown.short=Unknown {0} -KSubstOption.unknown.long=Unknown ({0}) - -AdminKSubstListener.expectedRCSFile=Expected RCS file {0} to end in ',v' -AdminKSubstListener.commandRootNotManaged=Local root for this command is not managed -AdminKSubstListener.expectedChildOfCommandRoot=Expected RCS file {0} to be a child of remote root for this command {1} -AdminKSubstListener.couldNotSetResourceSyncInfo=Could not set resource sync info for {0}: {1} - -CVSRepositoryLocation.nullLocation=Location must not be null -CVSRepositoryLocation.emptyLocation=Location must not be empty -CVSRepositoryLocation.endWhitespace=Location must not end with whitespace -CVSRepositoryLocation.locationForm=Location must have form ':methodname:[user[:password]@]host:[port]/path/to/cvsroot' -CVSRepositoryLocation.startOfLocation=Location must start with a connection method name enclosed in colons -CVSRepositoryLocation.methods=Only the following methods are supported: {0} -CVSRepositoryLocation.parsingMethod=Error in connection method specification -CVSRepositoryLocation.parsingUser=Error in user name specification -CVSRepositoryLocation.parsingPassword=Error in password specification -CVSRepositoryLocation.parsingHost=Error in host specification -CVSRepositoryLocation.parsingPort=Error in port specification -CVSRepositoryLocation.parsingRoot=Error in repository root directory specification -CVSRepositoryLocation.invalidFormat=Invalid CVS repository location format: {0} -CVSRepositoryLocation.authenticationCanceled=Authentication canceled by user -CVSRepositoryLocation.errorCaching=Error occurred while saving password for {0} -CVSRepositoryLocation.openingConnection=Opening connection to {0} -CVSRepositoryLocation.usernameRequired=A username is required to make a connection - -ProjectDescriptionContentHandler.xml=Error parsing project description file - -Util.invalidResource=Resource {1} is not relative to root {0} -Util.timeout=A timeout occurred connecting to host {0} -Util.processTimeout=A timeout occurred executing command ''{0}'' -Util.truncatedPath=...{0} - -ResourceSyncInfo.malformedSyncBytes=Malformed entry line bytes encountered: {0} -Synchronizer.reload=Examining {0} -Checking_out_from_CVS..._5=Checking out from CVS... -FileSystemSynchronizer_Error_loading_from_CVS/Entries_file_1=Error loading from CVS/Entries file -FileSystemSynchronizer_Error_loading_from_.cvsignore_file_2=Error loading from .cvsignore file -FileSystemSynchronizer_Error_loading_from_CVS/Root,Repository_files_3=Error loading from CVS/Root,Repository files -FileSystemSynchronizer_Error_reloading_sync_information_5=Error reloading sync information -Malformed_entry_line___11=Malformed entry line: -Malformed_entry_line,_missing_name___12=Malformed entry line, missing name: -Malformed_entry_line,_missing_revision___13=Malformed entry line, missing revision: -FolderSyncInfo_Maleformed_root_4=Malformed root -SyncFileUtil_Error_writing_to_Entries.log_48=Error writing to Entries.log -SyncFileUtil_Cannot_close_Entries.log_49=Cannot close Entries.log -SyncFileUtil_Error_reloading_sync_information_58=Error reloading sync information -SyncFileUtil_Error_writing_to_.cvsignore_61=Error writing to .cvsignore -SyncFileUtil_Cannot_close_.cvsignore_62=Cannot close .cvsignore -SyncFileWriter.baseNotAvailable=Could not restore the base contents of ''{0}'' from the local cache. -BaseRevInfo.malformedEntryLine=Malformed entry line ''{0}'' for base revision information file. - -FileModificationValidator.isReadOnly=File is Read Only. - -EXTServerConnection.invalidPort=A port cannot be specified for the ext connection method. -EXTServerConnection.varsNotSet=Cannot run external ext program because CVS_RSH and CVS_SERVER variables are not initialized. -EXTServerConnection.ioError=Error starting external connection program: {0}. Ensure that the path is correct and that you can connect manually using this program. - -CVSRemoteSyncElement.rootDiffers=Error mapping local folder {0} to repository {1}. It is already managed by repository {2}. -CVSRemoteSyncElement.repositoryDiffers=Error mapping local folder {0} to remote folder {1}. It is already mapped to {2}. -Util.Internal_error,_resource_does_not_start_with_root_3=Internal error, resource does not start with root - -CVSProvider.Scrubbing_local_project_1=Scrubbing local project -CVSProvider.Scrubbing_projects_1=Scrubbing projects -CVSProvider.Creating_projects_2=Creating projects - -EclipseFile_Problem_deleting_resource=Problem deleting resource: {0}. {1} -EclipseFile_Problem_accessing_resource=Problem accessing resource: {0}. {1} Perform a Refresh. -EclipseFile_Problem_creating_resource=Problem creating resource: {0}. {1} -EclipseFile_Problem_writing_resource=Problem writing resource ''{0}''. {1} -EclipseFolder_problem_creating=Problem creating folder: {0}. {1} -EclipseFolder.isModifiedProgress=Determining if {0} has outgoing changes... - -EclipseSynchronizer.UpdatingSyncEndOperation=Updating CVS synchronization information... -EclipseSynchronizer.UpdatingSyncEndOperationCancelled=Operation cancelled: updating CVS synchronization information... -EclipseSynchronizer.NotifyingListeners=Notifying of CVS changes... -EclipseSynchronizer.ErrorSettingFolderSync=Cannot set folder sync info on {0} -EclipseSynchronizer.ErrorSettingResourceSync=Cannot set resource sync info on {0} -EclipseSynchronizer.ErrorSettingIgnorePattern=Cannot set ignored pattern on {0} -EclipseSynchronizer.ErrorCommitting=Errors saving CVS synchronization information to disk. Please fix the problems listed below and then update the affected resources from the CVS repository. -EclipseSynchronizer.folderSyncInfoMissing=CVS synchronization information could not be found for folder ''{0}'' -EclipseSynchronizer.workspaceClosedForResource=Invalid attempt to modify the sync info for resource ''{0}'' - -SynchrnoizerSyncInfoCache.failedToSetSyncBytes=Could not change sync info for ''{0}'' from ''{1}'' to ''{2}'' because the workspace is locked. - -SyncFileChangeListener.errorSettingTeamPrivateFlag=Error setting team-private flag on resource - -RemoteFile.getContents=Retrieving remote file contents -RemoteFile.getLogEntries=Retrieving log entries -RemoteFolder.exists=Checking if resource exists remotely -RemoteFolder.getMembers=Retrieving children of remote folder -RemoteModule.getRemoteModules=Retrieving remote modules -RemoteModule.invalidDefinition=Invalid module definition ''{0}'' received from ''{1}''. - -PruneFolderVisitor.caseVariantsExist=The following resources could not be created. -PruneFolderVisitor.caseVariantExists=The resource ''{0}'' could not be created because another resource exists whose path differs only by case. - -Version.unsupportedVersion=Host ''{0}'' is running unsupported CVS version {1}. Although most functionality works, use version 1.11.1p1 or later for full support. -Version.unknownVersionFormat=Host ''{0}'' is running ''{1}'' which is an unknown version to the workbench. Although most functionality may work, use version 1.11.1p1 or later for full support. -Version.versionNotValidRequest=Unable to determine server version. Host ''{0}'' does not support the ''cvs version'' command. Although most functionality works, use version 1.11.1p1 or later for full support. - -LogListener.invalidRevisionFormat=Invalid revision format ''{1}'' for tag ''{0}''. -RemoteFile.Could_not_cache_remote_contents_to_disk._Caching_remote_file_in_memory_instead._1=Could not cache remote contents to disk. Caching remote file in memory instead. Exception follows. - -NotifyInfo.MalformedLine=Invalid Notify format: ''{0}'' -NotifyInfo.MalformedNotificationType=Invalid notification type in line: ''{0}'' -NotifyInfo.MalformedNotifyDate=Invalid date format in line: ''{0}'' - -ResourceSynchronizer.missingParentBytesOnGet=Synchronization bytes are missing for parent of resource ''{1}'' in synchronization partner ''{0}'' on get. -ResourceSynchronizer.missingParentBytesOnSet=Synchronization bytes are missing for parent of resource ''{1}'' in synchronization partner ''{0}'' on set. -CVSAnnotateBlock.4=lines -CVSAnnotateBlock.5=line -CVSAnnotateBlock.6={0} {1} ({2} {3}) -CVSMergeSubscriber.2=CVS Merge ''{0} to {1}'' -CVSMergeSubscriber.4=Shows the the differences between a merge source and the workspace. -CVSMergeSubscriber.13=Error restoring merge subscriber: {0} is an invalid save context. -CVSMergeSubscriber.19=Error restoring merge subscriber {0}: There are no roots in the save context. -CVSMergeSubscriber.21=Ignoring root resource {0} because it does not exist in the current workspace. -CVSMergeSubscriber.22=Error restoring merge subscriber {0}: There are no existing roots in the save context. -CVSProviderPlugin.20=CVS Workspace -CVSProviderPlugin.21=Synchronizes the CVS managed resources in your workspace with their associated remote location -CVSRevisionNumberCompareCriteria.1=Comparing revision numbers -ReentrantLock.9=An error occurred writting CVS synchronization information to disk. Some information may be lost. -CRLFDetectInputStream.0=CVS file {0} either contains invalid line endings on the server (CR/LF instead of just LF) or is a binary file that is not marked as -kb. -SynchronizerSyncInfoCache.0=Synchronization information could not be cached for {0}. The only negative effect of this may be decreased performance. -DeferredResourceChangeHandler.0=Reconciling CVS state changes -DeferredResourceChangeHandler.1=Errors occured handling ignore file (.cvsignore) changes. Some resources may not be decorated properly. -CVSWorkspaceRoot.11=The parent folder of managed file {0} does not have sync info associated with it. -RemoveEntryHandler.2=Remove-entry received and ignored from CVS server for existing file {0}. -ServerMessageLineMatcher.5=Variable in template is not of the correct format: {0} -ServerMessageLineMatcher.6=There are additional groups above those defining variables in template: {0} -ServerMessageLineMatcher.7=Expected variable {0} in {1} but it is not present. -CVSSyncInfo.7=Invalid attempt to make file {0} in-sync. This operation can only be sed on folders. -CVSSyncInfo.8=Invalid attempt to make outgoing resource {0} in-sync. This operation only applies to incoming or conflicting changes. -CVSSyncInfo.9=Cannot make {0} in-sync because its parent is not under CVS control. -CVSSyncInfo.10=Cannot make {0} in-sync because there is no corresponding remote. -CVSCompareSubscriber.2=CVS Compare ''{0}'' -CVSCompareSubscriber.3=Shows the differences between a tag and the workspace. -CompareDiffListener.11=Unsupported message sequence received while comparing using CVS diff command -CompareDiffListener.12=Unknown message format received while comparing using CVS diff command: {0} -AnnotateListener.3=Skipping binary file -AnnotateListener.4=Cannot annotate a binary file. -CVSWorkspaceSubscriber.1=Calculating synchronization state for {0} -CVSWorkspaceSubscriber.2=An error occurred calculating the synchronization state for {0}: {1} -KnownRepositories.0=Error restoring CVS repositories -CVSRepositoryLocation.73=Error clearing preferences for CVS repository location {0} -CVSRepositoryLocation.74=Error retrieving preferences for CVS repository location {0} -CVSRepositoryLocation.75=Error flushing preferences for CVS repository location {0} -SyncFileWriter.0=An invalid entry was found in the CVS/Entries file for folder {0}. The entry has been ignored. -ResponseHandler.0=Could not create resource {0}: {1} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java deleted file mode 100644 index d01829c29..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -import org.eclipse.team.internal.ccvs.core.*; - -public class CVSEntryLineTag extends CVSTag { - - /* - * This is the format of a date as it appears in the entry line. The date in an entry - * line is always in GMT. - */ - private static final String ENTRY_LINE_DATE_TAG_FORMAT = "yyyy.MM.dd.HH.mm.ss"; //$NON-NLS-1$ - - /* - * This is a formatter that will translate dates to and from text as it appears in the entry line - */ - private static SimpleDateFormat entryLineDateTagFormatter = new SimpleDateFormat(ENTRY_LINE_DATE_TAG_FORMAT, Locale.US); - - /* - * Convert the tag name as it appears as an argument to a command - * into the format that appears in the entry line of a folder or file - */ - private static String getNameInInternalFormat(CVSTag tag) { - if(tag.getType() == DATE){ - String s = ensureEntryLineFormat(tag.getName()); - if(s != null){ - return s; - } - } - return tag.getName(); - } - - /* - * Helper for converting the tag name as it appears as an argument to a command - * into the format that appears in the entry line of a folder or file - */ - private static synchronized String ensureEntryLineFormat(String text){ - if(text.length() == ENTRY_LINE_DATE_TAG_FORMAT.length()) return text; - Date date = tagNameToDate(text); - if (date == null) return text; - entryLineDateTagFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ - return entryLineDateTagFormatter.format(date); - } - - static synchronized public Date entryLineToDate(String text){ - try { - entryLineDateTagFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ - return entryLineDateTagFormatter.parse(text); - } catch (ParseException e) { - CVSProviderPlugin.log(new CVSException("Tag name " + text + " is not of the expected format " + ENTRY_LINE_DATE_TAG_FORMAT, e)); //$NON-NLS-1$ //$NON-NLS-2$ - return null; - } - } - - /* - * The parameter tag must not be null. - */ - public CVSEntryLineTag(CVSTag tag) { - super(getNameInInternalFormat(tag), tag.getType()); - } - - public CVSEntryLineTag(String entryLineTag) { - switch (entryLineTag.charAt(0)) { - case 'T' : type = BRANCH; break; - case 'N' : type = VERSION; break; - case 'D' : type = DATE; break; - default: type = HEAD; - } - name = entryLineTag.substring(1); - } - /* - * Returns the tag name - */ - public String getName() { - if (getType() == DATE) { - // Use same format as CVSTag when the name is requested - Date date = asDate(); - if(date != null){ - return dateToTagName(date); - } - } - return name; - } - /* - * Returns the tag type - */ - public int getType() { - return type; - } - - public String toEntryLineFormat(boolean useSamePrefixForBranchAndTag) { - if (type == BRANCH || (type == VERSION && useSamePrefixForBranchAndTag)) - return "T" + name;//$NON-NLS-1$ - else if (type == VERSION) - return "N" + name;//$NON-NLS-1$ - else if (type == DATE) - return "D" + name;//$NON-NLS-1$ - return "";//$NON-NLS-1$ - } - - /* - * For debugging purposes. - */ - public String toString() { - return toEntryLineFormat(false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSTag#asDate() - */ - public Date asDate() { - return entryLineToDate(name); - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java deleted file mode 100644 index 756d5f219..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java +++ /dev/null @@ -1,329 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.Request; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class provides static methods for checking out projects from a repository - * into the local workspace and for converting IResources into CVSRespources - * and sync trees. - * Instances of this class represent a local workspace root (i.e. a project). - */ -public class CVSWorkspaceRoot { - - private ICVSFolder localRoot; - - public CVSWorkspaceRoot(IContainer resource){ - this.localRoot = getCVSFolderFor(resource); - } - - /** - * Set the sharing for a project to enable it to be used with the CVSTeamProvider. - * This method ensure that the repository in the FolderSyncInfo is known and that - * the project is mapped to a CVS repository provider. It does not modify the sync - * info associated with the project's resources in any way. - */ - public static void setSharing(IProject project, FolderSyncInfo info, IProgressMonitor monitor) throws TeamException { - - // Ensure provided info matches that of the project - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); - FolderSyncInfo folderInfo = folder.getFolderSyncInfo(); - if ( ! info.equals(folderInfo)) { - throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSProvider.infoMismatch", project.getName())));//$NON-NLS-1$ - } - - // Register the project with Team - RepositoryProvider.map(project, CVSProviderPlugin.getTypeId()); - } - - /** - * Answer the list of directories that a checkout of the given resources would expand to. - * In other words, the returned strings represent the root paths that the given resources would - * be loaded into. - */ - public static String[] getExpansions(ICVSRemoteFolder[] resources, IProgressMonitor monitor) throws CVSException { - - if (resources.length == 0) return new String[0]; - - // Get the location of the workspace root - ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()); - - // Get the command arguments - String[] arguments = new String[resources.length]; - for (int i = 0; i < resources.length; i++) { - if (resources[i] instanceof RemoteModule) { - arguments[i] = ((RemoteModule)resources[i]).getName(); - } else { - arguments[i] = resources[i].getRepositoryRelativePath(); - } - } - - // Perform the Expand-Modules command - IStatus status; - Session s = new Session(resources[0].getRepository(), root); - s.open(monitor, false /* read-only */); - try { - status = Request.EXPAND_MODULES.execute(s, arguments, monitor); - } finally { - s.close(); - } - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - - return s.getModuleExpansions(); - } - - public static ICVSFolder getCVSFolderFor(IContainer resource) { - return new EclipseFolder(resource); - } - - - public static ICVSFile getCVSFileFor(IFile resource) { - return new EclipseFile(resource); - } - - - public static ICVSResource getCVSResourceFor(IResource resource) { - if (resource.getType() == IResource.FILE) - return getCVSFileFor((IFile) resource); - else - return getCVSFolderFor((IContainer) resource); - } - - public static ICVSRemoteResource getRemoteResourceFor(IResource resource) throws CVSException { - ICVSResource managed = getCVSResourceFor(resource); - return getRemoteResourceFor(managed); - } - - public static ICVSRemoteResource getRemoteResourceFor(ICVSResource resource) throws CVSException { - if (resource.isFolder()) { - ICVSFolder folder = (ICVSFolder)resource; - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - if (syncInfo != null) { - return new RemoteFolder(null, KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag()); - } - } else { - if (resource.isManaged()) { - RemoteFolder parent = (RemoteFolder)getRemoteResourceFor(resource.getParent()); - if (parent == null) { - // This could be caused by another thread changing the state in the - // instant between when we did the managed check and we obtained the - // parent handle. If this is the case, isManaged should return false - // now. If it doesn't, then we should log an error. - if (resource.isManaged()) { - CVSProviderPlugin.log(new CVSException(Policy.bind("CVSWorkspaceRoot.11", Util.getFullestPath(resource)))); //$NON-NLS-1$ - } - } else { - return RemoteFile.getBase(parent, (ICVSFile)resource); - } - } - } - return null; - } - - /* - * Helper method that uses the parent of a local resource that has no base to ensure that the resource - * wasn't added remotely by a third party - */ - private static ICVSRemoteResource getRemoteTreeFromParent(IResource resource, ICVSResource managed, CVSTag tag, IProgressMonitor progress) throws TeamException { - // If the parent isn't mapped to CVS, there's nothing we can do - ICVSFolder parent = managed.getParent(); - FolderSyncInfo syncInfo = parent.getFolderSyncInfo(); - if (syncInfo == null) { - // The parent is managed so just indicate that there is no remote - return null; - } - ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(parent.getFolderSyncInfo().getRoot()); - RemoteFolder remoteParent = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, parent, tag, progress); - ICVSRemoteResource remote = null; - if (remoteParent != null) { - try { - remote = (ICVSRemoteResource)remoteParent.getChild(resource.getName()); - } catch (CVSException e) { - remote = null; - } - // The types need to match or we're in trouble - if (remote != null && !(remote.isContainer() == managed.isFolder())) - throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTeamProvider.typesDiffer", resource.getFullPath().toString()), null)); //$NON-NLS-1$ - } - return remote; - } - - public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException { - return getRemoteTree(resource, tag, false /* cache file contents hint */, progress); - } - - /** - * Return the remote tree that corresponds to the given local resource. Return - * null if the remote tree doesn't exist remotely or if the local - * resource is not mapped to a remote (i.e. is not managed by CVS). - * - * @param resource the local resource - * @param tag the tag to be queried remotely - * @param cacheFileContentsHint hint which indicates whether file contents will be required - * @param progress - * @return the remote tree or null - * @throws TeamException - */ - public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, boolean cacheFileContentsHint, IProgressMonitor progress) throws TeamException { - ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource); - ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource); - if (remote == null) { - progress.beginTask(null, 100); - remote = getRemoteTreeFromParent(resource, managed, tag, Policy.subMonitorFor(progress, 50)); - if (cacheFileContentsHint && remote != null && remote instanceof RemoteFile) { - RemoteFile file = (RemoteFile)remote; - // get the storage for the file to ensure that the contents are cached - file.getStorage(Policy.subMonitorFor(progress, 50)); - } - progress.done(); - } else if(resource.getType() == IResource.FILE) { - ICVSRepositoryLocation location = remote.getRepository(); - if (cacheFileContentsHint) { - remote = FileContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress); - } else { - remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress); - } - } else { - ICVSRepositoryLocation location = remote.getRepository(); - if (cacheFileContentsHint) { - remote = FileContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); - } else { - remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); - } - } - return remote; - } - - public static boolean hasRemote(IResource resource) { - try { - ICVSResource cvsResource = getCVSResourceFor(resource); - int type = resource.getType(); - if(type!=IResource.FILE) { - if(type==IResource.PROJECT) { - return ((ICVSFolder)cvsResource).isCVSFolder(); - } else { - return cvsResource.isManaged(); - } - } else { - byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes(); - if(syncBytes!=null) { - return !ResourceSyncInfo.isAddition(syncBytes); - } else { - return false; - } - } - } catch(CVSException e) { - return false; - } - } - - public ICVSRepositoryLocation getRemoteLocation() throws CVSException { - FolderSyncInfo info = localRoot.getFolderSyncInfo(); - if (info == null) { - throw new CVSException(Policy.bind("CVSWorkspaceRoot.notCVSFolder", localRoot.getName())); //$NON-NLS-1$ - } - return KnownRepositories.getInstance().getRepository(info.getRoot()); - } - - public ICVSFolder getLocalRoot() { - return localRoot; - } - - - /** - * Return true if the resource is part of a link (i.e. a linked resource or - * one of it's children. - * - * @param container - * @return boolean - */ - public static boolean isLinkedResource(IResource resource) { - // check the resource directly first - if (resource.isLinked()) return true; - // projects and root cannot be links - if (resource.getType() == IResource.PROJECT || resource.getType() == IResource.ROOT) { - return false; - } - // look one level under the project to see if the resource is part of a link - String linkedParentName = resource.getProjectRelativePath().segment(0); - IFolder linkedParent = resource.getProject().getFolder(linkedParentName); - return linkedParent.isLinked(); - } - - /** - * A resource is considered shared - * @param resource - * @return boolean - */ - public static boolean isSharedWithCVS(IResource resource) throws CVSException { - if (!resource.isAccessible()) return false; - if(isLinkedResource(resource)) return false; - - if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) { - return false; - } - - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (cvsResource.isManaged()) return true; - if (!cvsResource.exists()) return false; - if (cvsResource.isFolder() && ((ICVSFolder) cvsResource).isCVSFolder()) return true; - if (cvsResource.isIgnored()) return false; - return cvsResource.getParent().isCVSFolder(); - } - - /** - * Return whether the given container is an orphaned subtree. An orphaned subtree - * is folder (i.e. non-project) that is a CVS folder but is not managed and is not - * a linked resource. To know if the resource is a descendant of an orphaned subtree, - * the client must invoked this method for each ancestor of a resource. - * @param container the container being tested - * @return whether the container is an orphaned CVS folder - * @throws CVSException - */ - public static boolean isOrphanedSubtree(IContainer container) throws CVSException { - ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(container); - return (mFolder.isCVSFolder() - && ! mFolder.isManaged() - && mFolder.getIResource().getType() == IResource.FOLDER - && !isLinkedResource(container)); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java deleted file mode 100644 index 96ee1df9b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java +++ /dev/null @@ -1,613 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.io.File; -import java.io.InputStream; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Represents handles to CVS resource on the local file system. Synchronization - * information is taken from the CVS subdirectories. - */ -public class EclipseFile extends EclipseResource implements ICVSFile { - - private static final String TEMP_FILE_EXTENSION = ".tmp";//$NON-NLS-1$ - private static final IPath PROJECT_META_DATA_PATH = new Path(".project");//$NON-NLS-1$ - - /** - * Create a handle based on the given local resource. - */ - protected EclipseFile(IFile file) { - super(file); - } - - /* - * @see ICVSResource#delete() - */ - public void delete() throws CVSException { - try { - ((IFile)resource).delete(false /*force*/, true /*keepHistory*/, null); - } catch(CoreException e) { - throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_deleting_resource", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - public long getSize() { - return getIOFile().length(); - } - - public InputStream getContents() throws CVSException { - try { - return getIFile().getContents(); - } catch (CoreException e) { - throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_accessing_resource", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /* - * @see ICVSFile#getTimeStamp() - */ - public Date getTimeStamp() { - long timestamp = getIFile().getLocalTimeStamp(); - if( timestamp == IResource.NULL_STAMP) { - // If there is no file, return the same timestamp as ioFile.lastModified() would - return new Date(0L); - } - return new Date((timestamp/1000)*1000); - } - - /* - * @see ICVSFile#setTimeStamp(Date) - */ - public void setTimeStamp(Date date) throws CVSException { - long time; - if (date == null) { - time = System.currentTimeMillis(); - } else { - time = date.getTime(); - } - EclipseSynchronizer.getInstance().setTimeStamp(this, time); - } - - /* - * @see ICVSResource#isFolder() - */ - public boolean isFolder() { - return false; - } - - /* - * @see ICVSFile#isModified() - */ - public boolean isModified(IProgressMonitor monitor) throws CVSException { - - // ignore the monitor, there is no valuable progress to be shown when - // calculating the dirty state for files. It is relatively fast. - - if (!exists()) { - return getSyncBytes() != null; - } - int state = EclipseSynchronizer.getInstance().getModificationState(getIFile()); - - if (state != UNKNOWN) { - boolean dirty = state != CLEAN; - // Check to make sure that cached state is the real state. - // They can be different if deltas happen in the wrong order. - if (dirty == isDirty()) { - return dirty; - } - } - - // nothing cached, need to manually check (and record) - byte[] syncBytes = getSyncBytes(); - if (syncBytes == null && isIgnored()) return false; - // unmanaged files are reported as modified - return EclipseSynchronizer.getInstance().setModified(this, UNKNOWN); - } - - /* - * @see ICVSResource#accept(ICVSResourceVisitor) - */ - public void accept(ICVSResourceVisitor visitor) throws CVSException { - visitor.visitFile(this); - } - - /* - * @see ICVSResource#accept(ICVSResourceVisitor, boolean) - */ - public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException { - visitor.visitFile(this); - } - - /* - * This is to be used by the Copy handler. The filename of the form .#filename - */ - public void copyTo(String filename) throws CVSException { - try { - IPath targetPath = new Path(null, filename); - IFile targetFile = getIFile().getParent().getFile(targetPath); - if (targetFile.exists()) { - // There is a file in the target location. - // Delete it and keep the history just in case - targetFile.delete(false /* force */, true /* keep history */, null); - } - getIFile().copy(targetPath, true /*force*/, null); - } catch(CoreException e) { - throw new CVSException(e.getStatus()); - } - } - - /* - * @see ICVSResource#getRemoteLocation() - */ - public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException { - return getParent().getRemoteLocation(stopSearching) + SEPARATOR + getName(); - } - - /* - * @see ICVSFile#setReadOnly() - */ - public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException { - try { - IFile file = getIFile(); - if (PROJECT_META_DATA_PATH.equals(file.getFullPath().removeFirstSegments(1))) { - responseType = UPDATED; - } - switch (responseType) { - case UPDATED: - if (resource.exists()) { - file.setContents(stream, false /*force*/, true /*keep history*/, monitor); - break; - } - case CREATED: // creating a new file so it should not exist locally - file.create(stream, false /*force*/, monitor); - break; - case MERGED: // merging contents into a file that exists locally - // Ensure we don't leave the file in a partially written state - IFile tempFile = file.getParent().getFile(new Path(null, file.getName() + TEMP_FILE_EXTENSION)); - monitor.beginTask(null, 100); - if (tempFile.exists()) - tempFile.delete(true /* force */, Policy.subMonitorFor(monitor, 25)); - tempFile.create(stream, true /*force*/, Policy.subMonitorFor(monitor, 25)); - file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 25)); - tempFile.move(new Path(null, file.getName()), false /*force*/, true /*history*/, Policy.subMonitorFor(monitor, 25)); - monitor.done(); - break; - case UPDATE_EXISTING: // creating a new file so it should exist locally - file.setContents(stream, false /*force*/, true /*keep history*/, monitor); - break; - } - } catch(CoreException e) { - String message = null; - if (e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) { - // This error indicates that Core couldn't read from the server stream - // The real reason will be in the message of the wrapped exception - Throwable t = e.getStatus().getException(); - if (t != null) message = t.getMessage(); - } - if (message == null) message = e.getMessage(); - throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_writing_resource", resource.getFullPath().toString(), message), e); //$NON-NLS-1$ - } - } - - /* - * @see ICVSFile#setReadOnly() - */ - public void setReadOnly(boolean readOnly) throws CVSException { - ResourceAttributes attributes = resource.getResourceAttributes(); - if (attributes != null) { - attributes.setReadOnly(readOnly); - try { - resource.setResourceAttributes(attributes); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - } - - /* - * @see ICVSFile#isReadOnly() - */ - public boolean isReadOnly() throws CVSException { - return getIFile().isReadOnly(); - } - - /* - * @see ICVSFile#setExecutable() - */ - public void setExecutable(boolean executable) throws CVSException { - ResourceAttributes attributes = resource.getResourceAttributes(); - if (attributes != null) { - attributes.setExecutable(executable); - try { - resource.setResourceAttributes(attributes); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - } - - /* - * @see ICVSFile#isExectuable() - */ - public boolean isExecutable() throws CVSException { - ResourceAttributes attributes = resource.getResourceAttributes(); - if (attributes != null) { - return attributes.isExecutable(); - } else { - return false; - } - } - - /* - * Typecasting helper - */ - public IFile getIFile() { - return (IFile)resource; - } - - /* - * To allow accessing size and timestamp for the underlying java.io.File - */ - private File getIOFile() { - IPath location = resource.getLocation(); - if(location!=null) { - return location.toFile(); - } - return null; - } - /** - * @see ICVSFile#getLogEntries(IProgressMonitor) - */ - public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException { - byte[] syncBytes = getSyncBytes(); - if(syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) { - ICVSRemoteResource remoteFile = CVSWorkspaceRoot.getRemoteResourceFor(resource); - return ((ICVSRemoteFile)remoteFile).getLogEntries(monitor); - } - return new ILogEntry[0]; - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setNotifyInfo(NotifyInfo) - */ - public void setNotifyInfo(NotifyInfo info) throws CVSException { - if (isManaged()) { - EclipseSynchronizer.getInstance().setNotifyInfo(resource, info); - // On an edit, the base should be cached - // On an unedit, the base should be restored (and cleared?) - // On a commit, the base should be cleared - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getNotifyInfo() - */ - public NotifyInfo getNotifyInfo() throws CVSException { - if (isManaged()) { - return EclipseSynchronizer.getInstance().getNotifyInfo(resource); - } - return null; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setNotifyInfo(NotifyInfo) - */ - public void setBaserevInfo(BaserevInfo info) throws CVSException { - if (isManaged()) { - if (info == null) { - EclipseSynchronizer.getInstance().deleteBaserevInfo(resource); - EclipseSynchronizer.getInstance().deleteFileFromBaseDirectory(getIFile(), null); - } else - EclipseSynchronizer.getInstance().setBaserevInfo(resource, info); - } - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getNotifyInfo() - */ - public BaserevInfo getBaserevInfo() throws CVSException { - if (isManaged()) { - return EclipseSynchronizer.getInstance().getBaserevInfo(resource); - } - return null; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkout(int) - */ - public void edit(final int notifications, IProgressMonitor monitor) throws CVSException { - if (!isReadOnly()) return; - run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - byte[] syncBytes = getSyncBytes(); - if (syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)) return; - - // convert the notifications to internal form - char[] internalFormat; - if (notifications == NO_NOTIFICATION) { - internalFormat = null; - } else if (notifications == NOTIFY_ON_ALL) { - internalFormat = NotifyInfo.ALL; - } else { - List notificationCharacters = new ArrayList(); - if ((notifications & NOTIFY_ON_EDIT) >0) - notificationCharacters.add(new Character(NotifyInfo.EDIT)); - if ((notifications & NOTIFY_ON_UNEDIT) >0) - notificationCharacters.add(new Character(NotifyInfo.UNEDIT)); - if ((notifications & NOTIFY_ON_COMMIT) >0) - notificationCharacters.add(new Character(NotifyInfo.COMMIT)); - internalFormat = new char[notificationCharacters.size()]; - for (int i = 0; i < internalFormat.length; i++) { - internalFormat[i] = ((Character)notificationCharacters.get(i)).charValue(); - } - } - - // record the notification - NotifyInfo notifyInfo = new NotifyInfo(getName(), NotifyInfo.EDIT, new Date(), internalFormat); - setNotifyInfo(notifyInfo); - - // Only record the base if the file is not modified - if (!isModified(null)) { - EclipseSynchronizer.getInstance().copyFileToBaseDirectory(getIFile(), monitor); - setBaserevInfo(new BaserevInfo(getName(), ResourceSyncInfo.getRevision(syncBytes))); - } - - try { - // allow editing - setReadOnly(false); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } - } - }, monitor); - - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#uncheckout() - */ - public void unedit(IProgressMonitor monitor) throws CVSException { - if (isReadOnly()) return; - run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - // record the notification - NotifyInfo info = getNotifyInfo(); - if (info != null && info.getNotificationType() == NotifyInfo.EDIT) { - info = null; - } else { - info = new NotifyInfo(getName(), NotifyInfo.UNEDIT, new Date(), null); - } - setNotifyInfo(info); - - if (isModified(null)) { - ResourceSyncInfo syncInfo = getSyncInfo(); - BaserevInfo baserevInfo = getBaserevInfo(); - EclipseSynchronizer.getInstance().restoreFileFromBaseDirectory(getIFile(), monitor); - // reset any changes that may have been merged from the server - if (!syncInfo.getRevision().equals(baserevInfo.getRevision())) { - MutableResourceSyncInfo newInfo = syncInfo.cloneMutable(); - newInfo.setRevision(baserevInfo.getRevision()); - newInfo.setTimeStamp(getTimeStamp()); - newInfo.setDeleted(false); - setSyncInfo(newInfo, ICVSFile.CLEAN); - } else { - // an unedited file is no longer modified - EclipseSynchronizer.getInstance().setModified(EclipseFile.this, CLEAN); - } - } else { - // We still need to report a state change - setSyncBytes(getSyncBytes(), ICVSFile.CLEAN); - } - setBaserevInfo(null); - - try { - // prevent editing - setReadOnly(true); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } - } - }, monitor); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#notificationCompleted() - */ - public void notificationCompleted() throws CVSException { - EclipseSynchronizer.getInstance().deleteNotifyInfo(resource); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getPendingNotification() - */ - public NotifyInfo getPendingNotification() throws CVSException { - return getNotifyInfo(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkedIn(java.lang.String) - */ - public void checkedIn(String entryLine, boolean commit) throws CVSException { - ResourceSyncInfo oldInfo = getSyncInfo(); - ResourceSyncInfo newInfo = null; - int modificationState = ICVSFile.CLEAN; - if (entryLine == null) { - // cvs commit: the file contents matched the server contents so no entry line was sent - if (oldInfo == null) return; - Date timeStamp = oldInfo.getTimeStamp(); - if (timeStamp == null || oldInfo.isMergedWithConflicts()) { - // If the entry line has no timestamp, put the file timestamp in the entry line - if(! oldInfo.isAdded()) { - MutableResourceSyncInfo mutable = oldInfo.cloneMutable(); - mutable.setTimeStamp(getTimeStamp(), true /* clear merged */); - newInfo = mutable; - } - } else { - // reset the file timestamp to the one from the entry line - boolean reset = false; - if (isReadOnly()) { - // We can only set the timestamp if the file is not read-only. - // We will get a situation like this if the timestamp changes due to a time change (e.g. daylight savings) - setReadOnly(false); - reset = true; - } - setTimeStamp(timeStamp); - if (reset) { - // Make sure we set the file back to read-only - setReadOnly(true); - } - // (newInfo = null) No need to set the newInfo as there is no sync info change - } - // (modified = false) the file will be no longer modified - } else if (oldInfo == null) { - // cvs add: addition of a file - newInfo = new ResourceSyncInfo(entryLine, null, null); - // an added file should show up as modified - modificationState = ICVSFile.DIRTY; - } else { - // cvs commit: commit of a changed file - // cvs update: update of a file whose contents match the server contents - Date timeStamp; - if (commit) { - // This is a commit. Put the file timestamp in the entry - timeStamp = getTimeStamp(); - } else { - // This is an update. Reset the file timestamp to match the entry - timeStamp = oldInfo.getTimeStamp(); - if (timeStamp == null) { - timeStamp = getTimeStamp(); - } else { - setTimeStamp(timeStamp); - } - } - newInfo = new ResourceSyncInfo(entryLine, oldInfo.getPermissions(), timeStamp); - - } - if (newInfo != null) setSyncInfo(newInfo, modificationState); - clearCachedBase(); - } - - private void clearCachedBase() throws CVSException { - BaserevInfo base = getBaserevInfo(); - if (base != null) { - setBaserevInfo(null); - try { - setReadOnly(true); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSResource#unmanage(org.eclipse.core.runtime.IProgressMonitor) - */ - public void unmanage(IProgressMonitor monitor) throws CVSException { - run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - EclipseFile.super.unmanage(monitor); - clearCachedBase(); - } - }, monitor); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isEdited() - */ - public boolean isEdited() throws CVSException { - return EclipseSynchronizer.getInstance().isEdited(getIFile()); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSResource#setSyncInfo(org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo) - */ - public void setSyncInfo(ResourceSyncInfo info, int modificationState) throws CVSException { - setSyncBytes(info.getBytes(), info, modificationState); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.EclipseResource#setSyncBytes(byte[], int) - */ - public void setSyncBytes(byte[] syncBytes, int modificationState) throws CVSException { - setSyncBytes(syncBytes, null, modificationState); - } - - /* - * @see org.eclipse.team.internal.ccvs.core.resources.EclipseResource#setSyncBytes(byte[], int) - */ - private void setSyncBytes(byte[] syncBytes, ResourceSyncInfo info, int modificationState) throws CVSException { - Assert.isNotNull(syncBytes); - setSyncBytes(syncBytes); - EclipseSynchronizer.getInstance().setModified(this, modificationState); - } - - public void handleModification(boolean forAddition) throws CVSException { - if (isIgnored()) { - // Special case handling for when a resource passes from the un-managed state - // to the ignored state (e.g. ignoring the ignore file). Parent dirty state must be - // recalculated but since the resource's end state is ignored there is a lot of code - // in the plugin that simply disregards the change to the resource. - // There may be a better was of handling resources that transition from un-managed to - // ignored but for now this seems like the safest change. - if(! resource.isDerived()) { - EclipseSynchronizer.getInstance().setModified(this, CLEAN); - } - return; - } - // set the modification state to what it really is and return true if the modification state changed - EclipseSynchronizer.getInstance().setModified(this, UNKNOWN); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getRepositoryRelativePath() - */ - public String getRepositoryRelativePath() throws CVSException { - if (!isManaged()) return null; - String parentPath = getParent().getRepositoryRelativePath(); - if (parentPath == null) return null; - return parentPath + Session.SERVER_SEPARATOR + getName(); - } - - protected boolean isDirty() throws CVSException { - boolean dirty; - byte[] syncBytes = getSyncBytes(); - if (syncBytes == null) { - dirty = exists(); - } else { - // isMerged() must be called because when a file is updated and merged by the cvs server the timestamps - // are equal. Merged files should however be reported as dirty because the user should take action and commit - // or review the merged contents. - if(ResourceSyncInfo.isAddition(syncBytes) || ResourceSyncInfo.isMerge(syncBytes) || !exists()) { - dirty = true; - } else { - // TODO: non-optimal as ResourceSyncInfo is created each time - ResourceSyncInfo info = new ResourceSyncInfo(syncBytes); - dirty = !getTimeStamp().equals(info.getTimeStamp()); - } - } - return dirty; - } - -} - - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java deleted file mode 100644 index c4c7431e0..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java +++ /dev/null @@ -1,380 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Implements the ICVSFolder interface on top of an - * instance of the ICVSFolder interface - * - * @see ICVSFolder - */ -class EclipseFolder extends EclipseResource implements ICVSFolder { - - protected EclipseFolder(IContainer container) { - super(container); - } - - /** - * @see ICVSFolder#members(int) - */ - public ICVSResource[] members(int flags) throws CVSException { - final List result = new ArrayList(); - IResource[] resources = EclipseSynchronizer.getInstance().members((IContainer)resource); - boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0)); - boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0)); - boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0)); - boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0)); - boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0); - boolean includeExisting = (((flags & EXISTING_MEMBERS) != 0) || ((flags & (EXISTING_MEMBERS | PHANTOM_MEMBERS)) == 0)); - boolean includePhantoms = (((flags & PHANTOM_MEMBERS) != 0) || ((flags & (EXISTING_MEMBERS | PHANTOM_MEMBERS)) == 0)); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if ((includeFiles && (resource.getType()==IResource.FILE)) - || (includeFolders && (resource.getType()==IResource.FOLDER))) { - boolean isManaged = cvsResource.isManaged(); - boolean isIgnored = cvsResource.isIgnored(); - if ((isManaged && includeManaged)|| (isIgnored && includeIgnored) - || ( ! isManaged && ! isIgnored && includeUnmanaged)) { - boolean exists = cvsResource.exists(); - if ((includeExisting && exists) || (includePhantoms && !exists && isManaged)) { - result.add(cvsResource); - } - } - - } - } - return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]); - } - - /** - * @see ICVSFolder#createFolder(String) - */ - public ICVSFolder getFolder(String name) throws CVSException { - if ((CURRENT_LOCAL_FOLDER.equals(name)) || ((CURRENT_LOCAL_FOLDER + SEPARATOR).equals(name))) - return this; - IPath path = new Path(null, name); - if(resource.getType()==IResource.ROOT && path.segmentCount()==1) { - return new EclipseFolder(((IWorkspaceRoot)resource).getProject(name)); - } else { - return new EclipseFolder(((IContainer)resource).getFolder(path)); - } - } - - /** - * @see ICVSFolder#createFile(String) - */ - public ICVSFile getFile(String name) throws CVSException { - return new EclipseFile(((IContainer)resource).getFile(new Path(null, name))); - } - - /** - * @see ICVSFolder#mkdir() - */ - public void mkdir() throws CVSException { - try { - if(resource.getType()==IResource.PROJECT) { - IProject project = (IProject)resource; - project.create(null); - project.open(null); - } else { - ((IFolder)resource).create(false /*don't force*/, true /*make local*/, null); - // We need to signal the creation to the synchronizer immediately because - // we may do additional CVS operations on the folder before the next delta - // occurs. - EclipseSynchronizer.getInstance().created(getIResource());; - } - } catch (CoreException e) { - throw CVSException.wrapException(resource, Policy.bind("EclipseFolder_problem_creating", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$ - } - } - - /** - * @see ICVSResource#isFolder() - */ - public boolean isFolder() { - return true; - } - - /** - * @see ICVSFolder#acceptChildren(ICVSResourceVisitor) - */ - public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException { - - // Visit files and then folders - ICVSResource[] subFiles = members(FILE_MEMBERS); - for (int i=0; inull
              if resource - * the resource. - * - * @see ICVSResource#getParent() - */ - public ICVSFolder getParent() { - IContainer parent = resource.getParent(); - if (parent==null) { - return null; - } - return new EclipseFolder(parent); - } - - /* - * @see ICVSResource#getName() - */ - public String getName() { - return resource.getName(); - } - - /* - * @see ICVSResource#isIgnored() - */ - public boolean isIgnored() throws CVSException { - // a managed resource is never ignored - if(isManaged() || resource.getType()==IResource.ROOT || resource.getType()==IResource.PROJECT) { - return false; - } - - // If the resource is a derived or linked resource, it is ignored - if (resource.isDerived() || resource.isLinked()) { - return true; - } - - // always ignore CVS - String name = getName(); - if (name.equals("CVS")) return true; //$NON-NLS-1$ - - // check the global ignores from Team - if (Team.isIgnoredHint(resource)) return true; - - // check ignore patterns from the .cvsignore file. - if(EclipseSynchronizer.getInstance().isIgnored(resource)) { - return true; - } - - // check the parent, if the parent is ignored or mapped to CVSROOT/Emptydir - // then this resource is ignored also - ICVSFolder parent = getParent(); - if(parent==null) return false; - if (parent.isIgnored()) return true; - FolderSyncInfo info = parent.getFolderSyncInfo(); - if (info == null) return false; - return info.isVirtualDirectory(); - } - - /* - * @see ICVSResource#setIgnoredAs(String) - */ - public void setIgnoredAs(final String pattern) throws CVSException { - run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - EclipseSynchronizer.getInstance().addIgnored(resource.getParent(), pattern); - } - }, null); - } - - /* - * @see ICVSResource#isManaged() - */ - public boolean isManaged() throws CVSException { - return isManaged(getSyncBytes()); - } - - /* - * Helper method that captures the sematics of isManaged given a ResourceSyncInfo - */ - public boolean isManaged(byte[] syncBytes) { - return syncBytes != null; - } - - /** - * Two ManagedResources are equal, if there cvsResources are - * equal (and that is, if the point to the same file) - */ - public boolean equals(Object obj) { - - if (!(obj instanceof EclipseResource)) { - return false; - } else { - return getPath().equals(((EclipseResource) obj).getPath()); - } - } - - /* - * @see ICVSResource#getPath() - */ - public String getPath() { - return resource.getFullPath().toString(); - } - - /* - * @see ICVSResource#isFolder() - */ - public boolean isFolder() { - return false; - } - - /* - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes() - */ - public byte[] getSyncBytes() throws CVSException { - return EclipseSynchronizer.getInstance().getSyncBytes(getIResource()); - } - - /* - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setSyncBytes(byte[]) - */ - public void setSyncBytes(byte[] syncBytes) throws CVSException { - if (getParent().isCVSFolder()) { - EclipseSynchronizer.getInstance().setSyncBytes(getIResource(), syncBytes); - } - } - - /* - * @see ICVSResource#getSyncInfo() - */ - public ResourceSyncInfo getSyncInfo() throws CVSException { - return EclipseSynchronizer.getInstance().getResourceSync(resource); - } - - /* - * Implement the hashcode on the underlying strings, like it is done in the equals. - */ - public int hashCode() { - return getPath().hashCode(); - } - - /* - * Give the pathname back - */ - public String toString() { - return getPath(); - } - - /* - * @see ICVSResource#unmanage() - */ - public void unmanage(IProgressMonitor monitor) throws CVSException { - EclipseSynchronizer.getInstance().deleteResourceSync(resource); - } - - /* - * @see Comparable#compareTo(Object) - */ - public int compareTo(Object arg0) { - EclipseResource other = (EclipseResource)arg0; - return resource.getFullPath().toString().compareTo(other.resource.getFullPath().toString()); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getIResource() - */ - public IResource getIResource() { - return resource; - } - - /** - * Called by a resource change listener when a resource is changed or added. This allows - * CVS resources to adjust any internal state based on the change. - * - * @param forAddition modification is an addition - * @throws CVSException - */ - public abstract void handleModification(boolean forAddition) throws CVSException; - - public void run(final ICVSRunnable job, IProgressMonitor monitor) throws CVSException { - final CVSException[] error = new CVSException[1]; - try { - // Do not use a scheduling rule in the workspace run since one - // will be obtained by the EclipseSynchronizer - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - EclipseSynchronizer.getInstance().run(getIResource(), job, monitor); - } catch(CVSException e) { - error[0] = e; - } - } - }, null /* no rule */, 0, monitor); - } catch(CoreException e) { - throw CVSException.wrapException(e); - } - if(error[0]!=null) { - throw error[0]; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java deleted file mode 100644 index e572e42d5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java +++ /dev/null @@ -1,1888 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.CVSThreadInfo; -import org.eclipse.team.internal.ccvs.core.util.*; -import org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation; -import org.eclipse.team.internal.core.subscribers.BatchingLock.ThreadInfo; -import org.osgi.framework.Bundle; - -/** - * A synchronizer is responsible for managing synchronization information for local - * CVS resources. - * - * This class is thread safe but only allows one thread to modify the cache at a time. It - * doesn't support fine grain locking on a resource basis. Lock ordering between the workspace - * lock and the synchronizer lock is guaranteed to be deterministic. That is, the workspace - * lock is *always* acquired before the synchronizer lock. This protects against possible - * deadlock cases where the synchronizer lock is acquired before a workspace lock. - * - * Special processing has been added for linked folders and their childen so - * that their CVS meta files are never read or written. - * - * IMPORTANT NOTICE: It is the reponsibility of the clients of EclipseSynchronizer - * to ensure that they have wrapped operations that may modify the workspace in - * an IWorkspaceRunnable. If this is not done, deltas may fore at inopertune times - * and corrupt the sync info. The wrapping could be done within the synchronizer - * itself but would require the creation of an inner class for each case that requires - * it. - * - * @see ResourceSyncInfo - * @see FolderSyncInfo - */ -public class EclipseSynchronizer implements IFlushOperation { - private static final String IS_DIRTY_INDICATOR = SyncInfoCache.IS_DIRTY_INDICATOR; - private static final String NOT_DIRTY_INDICATOR = SyncInfoCache.NOT_DIRTY_INDICATOR; - private static final String RECOMPUTE_INDICATOR = SyncInfoCache.RECOMPUTE_INDICATOR; - - // the cvs eclipse synchronizer is a singleton - private static EclipseSynchronizer instance; - - // track resources that have changed in a given operation - private ILock lock = Platform.getJobManager().newLock(); - private ReentrantLock resourceLock = new ReentrantLock(); - - private SynchronizerSyncInfoCache synchronizerCache = new SynchronizerSyncInfoCache(); - private SessionPropertySyncInfoCache sessionPropertyCache = new SessionPropertySyncInfoCache(synchronizerCache); - - /* - * Package private contructor to allow specialized subclass for handling folder deletions - */ - EclipseSynchronizer() { - } - - /** - * Returns the singleton instance of the synchronizer. - */ - public static EclipseSynchronizer getInstance() { - if(instance==null) { - instance = new EclipseSynchronizer(); - } - return instance; - } - - public SyncInfoCache getSyncInfoCacheFor(IResource resource) { - if (resource.exists() && resource.isLocal(IResource.DEPTH_ZERO)) { - return sessionPropertyCache; - } else { - return synchronizerCache; - } - } - - private boolean isValid(IResource resource) { - return resource.exists() || synchronizerCache.isPhantom(resource); - } - - /** - * Sets the folder sync info for the specified folder. - * The folder must exist and must not be the workspace root. - * - * @param folder the folder - * @param info the folder sync info, must not be null - * @see #getFolderSync, #deleteFolderSync - */ - public void setFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException { - Assert.isNotNull(info); // enforce the use of deleteFolderSync - // ignore folder sync on the root (i.e. CVSROOT/config/TopLevelAdmin=yes but we just ignore it) - if (folder.getType() == IResource.ROOT) return; - if (!isValid(folder)) { - // This means that the folder doesn't exist and is not a phantom - // Allow the set if the parent is a CVS folder since - // this can occur when creating phatom folders - if (getFolderSync(folder.getParent()) == null) { - throw new CVSException(IStatus.ERROR, CVSException.UNABLE, - Policy.bind("EclipseSynchronizer.ErrorSettingFolderSync", folder.getFullPath().toString())); //$NON-NLS-1$ - } - } - ISchedulingRule rule = null; - try { - rule = beginBatching(folder, null); - try { - beginOperation(); - // get the old info - FolderSyncInfo oldInfo = getFolderSync(folder); - // set folder sync and notify - getSyncInfoCacheFor(folder).setCachedFolderSync(folder, info, true); - // if the sync info changed from null, we may need to adjust the ancestors - if (oldInfo == null) { - adjustDirtyStateRecursively(folder, RECOMPUTE_INDICATOR); - } - folderChanged(folder); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Gets the folder sync info for the specified folder. - * - * @param folder the folder - * @return the folder sync info associated with the folder, or null if none. - * @see #setFolderSync, #deleteFolderSync - */ - public FolderSyncInfo getFolderSync(IContainer folder) throws CVSException { - if (folder.getType() == IResource.ROOT || !isValid(folder)) return null; - try { - beginOperation(); - cacheFolderSync(folder); - return getSyncInfoCacheFor(folder).getCachedFolderSync(folder); - } finally { - endOperation(); - } - } - - /** - * Deletes the folder sync for the specified folder and the resource sync - * for all of its children. Does not recurse. - * - * @param folder the folder - * @see #getFolderSync, #setFolderSync - */ - public void deleteFolderSync(IContainer folder) throws CVSException { - if (folder.getType() == IResource.ROOT || !isValid(folder)) return; - ISchedulingRule rule = null; - try { - rule = beginBatching(folder, null); - try { - beginOperation(); - // iterate over all children with sync info and prepare notifications - // this is done first since deleting the folder sync may remove a phantom - cacheResourceSyncForChildren(folder, true /* can modify workspace */); - IResource[] children = folder.members(true); - for (int i = 0; i < children.length; i++) { - IResource resource = children[i]; - resourceChanged(resource); - // delete resource sync for all children - getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, null, true); - } - // delete folder sync - getSyncInfoCacheFor(folder).setCachedFolderSync(folder, null, true); - folderChanged(folder); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - private void folderChanged(IContainer folder) { - resourceLock.folderChanged(folder); - } - - private void resourceChanged(IResource resource) { - resourceLock.resourceChanged(resource); - } - - /** - * Sets the resource sync info for the specified resource. - * The parent folder must exist and must not be the workspace root. - * - * @param resource the resource - * @param info the resource sync info, must not be null - * @see #getResourceSync, #deleteResourceSync - */ - public void setResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException { - Assert.isNotNull(info); // enforce the use of deleteResourceSync - IContainer parent = resource.getParent(); - if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) { - throw new CVSException(IStatus.ERROR, CVSException.UNABLE, - Policy.bind("EclipseSynchronizer.ErrorSettingResourceSync", resource.getFullPath().toString())); //$NON-NLS-1$ - } - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - // cache resource sync for siblings, set for self, then notify - cacheResourceSyncForChildren(parent, true /* can modify workspace */); - setCachedResourceSync(resource, info); - resourceChanged(resource); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Gets the resource sync info for the specified folder. - * - * @param resource the resource - * @return the resource sync info associated with the resource, or null if none. - * @see #setResourceSync, #deleteResourceSync - */ - public ResourceSyncInfo getResourceSync(IResource resource) throws CVSException { - byte[] info = getSyncBytes(resource); - if (info == null) return null; - return new ResourceSyncInfo(info); - } - - /** - * Gets the resource sync info for the specified folder. - * - * @param resource the resource - * @return the resource sync info associated with the resource, or null if none. - * @see #setResourceSync, #deleteResourceSync - */ - public byte[] getSyncBytes(IResource resource) throws CVSException { - IContainer parent = resource.getParent(); - if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) return null; - try { - beginOperation(); - // cache resource sync for siblings, then return for self - try { - cacheResourceSyncForChildren(parent, false /* cannot modify workspace */); - } catch (CVSException e) { - if (isCannotModifySynchronizer(e) || isResourceNotFound(e)) { - // We will resort to loading the sync info for the requested resource from disk - byte[] bytes = getSyncBytesFromDisk(resource); - if (!resource.exists() && bytes != null && !ResourceSyncInfo.isDeletion(bytes)) { - bytes = ResourceSyncInfo.convertToDeletion(bytes); - } - return bytes; - } else { - throw e; - } - } - return getCachedSyncBytes(resource); - } finally { - endOperation(); - } - } - - /** - * Sets the resource sync info for the specified resource. - * The parent folder must exist and must not be the workspace root. - * - * @param resource the resource - * @param info the resource sync info, must not be null - * @see #getResourceSync, #deleteResourceSync - */ - public void setSyncBytes(IResource resource, byte[] syncBytes) throws CVSException { - Assert.isNotNull(syncBytes); // enforce the use of deleteResourceSync - IContainer parent = resource.getParent(); - if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) { - throw new CVSException(IStatus.ERROR, CVSException.UNABLE, - Policy.bind("EclipseSynchronizer.ErrorSettingResourceSync", resource.getFullPath().toString())); //$NON-NLS-1$ - } - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - // cache resource sync for siblings, set for self, then notify - cacheResourceSyncForChildren(parent, true /* can modify workspace */); - setCachedSyncBytes(resource, syncBytes); - resourceChanged(resource); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Deletes the resource sync info for the specified resource, if it exists. - * - * @param resource the resource - * @see #getResourceSync, #setResourceSync - */ - public void deleteResourceSync(IResource resource) throws CVSException { - IContainer parent = resource.getParent(); - if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) return; - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - // cache resource sync for siblings, delete for self, then notify - cacheResourceSyncForChildren(parent, true /* can modify workspace */); - if (getCachedSyncBytes(resource) != null) { // avoid redundant notifications - setCachedSyncBytes(resource, null); - clearDirtyIndicator(resource); - resourceChanged(resource); - } - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * @param resource - */ - private void clearDirtyIndicator(IResource resource) throws CVSException { - getSyncInfoCacheFor(resource).flushDirtyCache(resource); - adjustDirtyStateRecursively(resource.getParent(), RECOMPUTE_INDICATOR); - } - - /** - * Gets the array of ignore patterns for the specified folder. - * - * @param folder the folder - * @return the patterns, or an empty array if none - * @see #addIgnored - */ - public boolean isIgnored(IResource resource) throws CVSException { - if (resource.getType() == IResource.ROOT || - resource.getType() == IResource.PROJECT || - ! resource.exists()) { - return false; - } - try { - beginOperation(); - FileNameMatcher matcher = cacheFolderIgnores(resource.getParent()); - return matcher.match(resource.getName()); - } finally { - endOperation(); - } - } - - /** - * Adds a pattern to the set of ignores for the specified folder. - * - * @param folder the folder - * @param pattern the pattern - */ - public void addIgnored(IContainer folder, String pattern) throws CVSException { - if (folder.getType() == IResource.ROOT || ! folder.exists()) { - throw new CVSException(IStatus.ERROR, CVSException.UNABLE, - Policy.bind("EclipseSynchronizer.ErrorSettingIgnorePattern", folder.getFullPath().toString())); //$NON-NLS-1$ - } - ISchedulingRule rule = null; - try { - rule = beginBatching(folder.getFile(new Path(SyncFileWriter.IGNORE_FILE)), null); - try { - beginOperation(); - String[] ignores = SyncFileWriter.readCVSIgnoreEntries(folder); - if (ignores != null) { - // verify that the pattern has not already been added - for (int i = 0; i < ignores.length; i++) { - if (ignores[i].equals(pattern)) return; - } - // add the pattern - String[] oldIgnores = ignores; - ignores = new String[oldIgnores.length + 1]; - System.arraycopy(oldIgnores, 0, ignores, 0, oldIgnores.length); - ignores[oldIgnores.length] = pattern; - } else { - ignores = new String[] { pattern }; - } - setCachedFolderIgnores(folder, ignores); - SyncFileWriter.writeCVSIgnoreEntries(folder, ignores); - // broadcast changes to unmanaged children - they are the only candidates for being ignored - List possibleIgnores = new ArrayList(); - accumulateNonManagedChildren(folder, possibleIgnores); - ResourceStateChangeListeners.getListener().resourceSyncInfoChanged((IResource[])possibleIgnores.toArray(new IResource[possibleIgnores.size()])); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * Returns the members of this folder including deleted resources with sync info, - * but excluding special resources such as CVS subdirectories. - * - * @param folder the container to list - * @return the array of members - */ - public IResource[] members(IContainer folder) throws CVSException { - if (! isValid(folder)) return new IResource[0]; - try { - beginOperation(); - if (folder.getType() != IResource.ROOT) { - // ensure that the sync info is cached so any required phantoms are created - cacheResourceSyncForChildren(folder, false); - } - } catch (CVSException e) { - if (!isCannotModifySynchronizer(e) && !isResourceNotFound(e)) { - throw e; - } - } finally { - endOperation(); - } - try { - return folder.members(true); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - private boolean isCannotModifySynchronizer(CVSException e) { - // IResourceStatus.WORKSPACE_LOCKED can occur if the resource sync is loaded - // during the POST_CHANGE delta phase. - // CVSStatus.FAILED_TO_CACHE_SYNC_INFO can occur if the resource sync is loaded - // when no scheduling rule is held. - return (e.getStatus().getCode() == IResourceStatus.WORKSPACE_LOCKED - || e.getStatus().getCode() == CVSStatus.FAILED_TO_CACHE_SYNC_INFO); - } - - private boolean isResourceNotFound(CVSException e) { - return e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND; - } - - /** - * Begins a batch of operations in order to optimize sync file writing. - * The provided scheduling rule indicates the resources - * that the resources affected by the operation while the returned scheduling rule - * is the rule obtained by the lock. It may differ from the provided rule as it must - * encompass any sync files that may change as a result of the operation. - */ - public ISchedulingRule beginBatching(ISchedulingRule resourceRule, IProgressMonitor monitor) { - return resourceLock.acquire(resourceRule, this /* IFlushOperation */, monitor); - } - - /** - * Ends a batch of operations. The provided rule must be the one that was returned - * by the corresponding call to beginBatching. - *

              - * Progress cancellation is ignored while writting the cache to disk. This - * is to ensure cache to disk consistency. - *

              - * - * @param monitor the progress monitor, may be null - * @exception CVSException with a status with code COMMITTING_SYNC_INFO_FAILED - * if all the CVS sync information could not be written to disk. - */ - public void endBatching(ISchedulingRule rule, IProgressMonitor monitor) throws CVSException { - try { - resourceLock.release(rule, monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - - /* (non-Javadoc) - * - * Callback which is invoked when the batching resource lock is released - * or when a flush is requested (see beginBatching(IResource)). - * - * @see org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.IRunnableOnExit#run(org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.ThreadInfo, org.eclipse.core.runtime.IProgressMonitor) - */ - public void flush(final ThreadInfo info, IProgressMonitor monitor) throws CVSException { - if (info != null && !info.isEmpty()) { - try { - beginOperation(); - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor pm) throws CoreException { - IStatus status = commitCache(info, pm); - if (!status.isOK()) { - throw new CVSException(status); - } - } - }, null, 0 /* no flags */, monitor); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - endOperation(); - } - } - } - - /* - * Begin an access to the internal data structures of the synchronizer - */ - private void beginOperation() { - try { - // Do not try to acquire the lock if the resources tree is locked - // The reason for this is that during the resource delta phase (i.e. when the tree is locked) - // the workspace lock is held. If we obtain our lock, there is - // a chance of dealock. It is OK if we don't as we are still protected - // by scheduling rules and the workspace lock. - if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; - } catch (RuntimeException e) { - // If we are not active, throw a cancel. Otherwise, propogate it. - // (see bug 78303) - if (Platform.getBundle(CVSProviderPlugin.ID).getState() == Bundle.ACTIVE) { - throw e; - } else { - throw new OperationCanceledException(); - } - } - lock.acquire(); - } - - /* - * End an access to the internal data structures of the synchronizer - */ - private void endOperation() { - try { - // See beginOperation() for a description of why the lock is not obtained when the tree is locked - if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; - } catch (RuntimeException e) { - // If we are not active, throw a cancel. Otherwise, propogate it. - // (see bug 78303) - if (Platform.getBundle(CVSProviderPlugin.ID).getState() == Bundle.ACTIVE) { - throw e; - } else { - throw new OperationCanceledException(); - } - } - lock.release(); - } - - /** - * Flush the sync information from the in-memory cache to disk and purge - * the entries from the cache. - *

              - * Recursively flushes the sync information for all resources - * below the root to disk and purges the entries from memory - * so that the next time it is accessed it will be retrieved from disk. - * May flush more sync information than strictly needed, but never less. - *

              - * - * @param root the root of the subtree to purge - * @param deep purge sync from child folders - * @param monitor the progress monitor, may be null - */ - public void flush(IContainer root, boolean deep, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 10); - ISchedulingRule rule = null; - try { - rule = beginBatching(root, Policy.subMonitorFor(monitor, 1)); - try { - beginOperation(); - try { - // Flush changes to disk - resourceLock.flush(Policy.subMonitorFor(monitor, 8)); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } finally { - // Purge the in-memory cache - sessionPropertyCache.purgeCache(root, deep); - } - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 1)); - monitor.done(); - } - } - - public void deconfigure(final IProject project, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ISchedulingRule rule = null; - try { - rule = beginBatching(project, Policy.subMonitorFor(monitor, 10)); - // Flush the sync info - flush(project, true /* deep */, Policy.subMonitorFor(monitor, 80)); - - purgeDirtyCache(project, Policy.subMonitorFor(monitor, 5)); - - // forget about pruned folders however the top level pruned folder will have resource sync (e.g. - // a line in the Entry file). As a result the folder is managed but is not a CVS folder. - synchronizerCache.purgeCache(project, true); - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5)); - monitor.done(); - } - } - - /** - * Called to notify the synchronizer that meta files have changed on disk, outside - * of the workbench. The cache will be flushed for this folder and it's immediate - * children and appropriate state change events are broadcasts to state change - * listeners. - */ - public void ignoreFilesChanged(IContainer[] roots) throws CVSException { - for (int i = 0; i < roots.length; i++) { - IContainer container = roots[i]; - ISchedulingRule rule = null; - try { - Set changed = new HashSet(); - rule = beginBatching(container, null); - try { - beginOperation(); - changed.addAll(Arrays.asList( - sessionPropertyCache.purgeCache(container, false /*don't flush children*/))); - } finally { - endOperation(); - } - if (!changed.isEmpty()) { - ResourceStateChangeListeners.getListener().resourceSyncInfoChanged( - (IResource[]) changed.toArray(new IResource[changed.size()])); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - } - - public void syncFilesChangedExternally(IContainer[] changedMetaFiles, IFile[] externalDeletions) throws CVSException { - List changed = new ArrayList(); - for (int i = 0; i < changedMetaFiles.length; i++) { - IContainer container = changedMetaFiles[i]; - if (!isWithinActiveOperationScope(container)) { - changed.addAll(Arrays.asList( - sessionPropertyCache.purgeCache(container, false /*don't flush children*/))); - } - } - for (int i = 0; i < externalDeletions.length; i++) { - IFile file = externalDeletions[i]; - if (!isWithinActiveOperationScope(file)) { - sessionPropertyCache.purgeCache(file.getParent(), false /*don't flush children*/); - changed.add(file); - } - } - if (!changed.isEmpty()) { - ResourceStateChangeListeners.getListener().externalSyncInfoChange( - (IResource[]) changed.toArray(new IResource[changed.size()])); - } - } - - /* - * The resource is about to be deleted by the move delete hook. - * In all cases (except when the resource doesn't exist), this method - * will indicate that the dirty state of the parent needs to be recomputed. - * For managed resources, it will move the cached sync info from the session - * property cache into the sycnrhonizer cache, purging the session cache. - * @param resource the resource about to be deleted. - *

              - * Note taht this method is not recursive. Hence, for managed resources - * - * @returns whether children need to be prepared - * @throws CVSException - */ - /* private */ boolean prepareForDeletion(IResource resource) throws CVSException { - if (!resource.exists()) return false; - ISchedulingRule rule = null; - try { - rule = beginBatching(resource, null); - try { - beginOperation(); - // Flush the dirty info for the resource and it's ancestors. - // Although we could be smarter, we need to do this because the - // deletion may fail. - adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR); - if (resource.getType() == IResource.FILE) { - byte[] syncBytes = getSyncBytes(resource); - if (syncBytes != null) { - if (ResourceSyncInfo.isAddition(syncBytes)) { - deleteResourceSync(resource); - } else { - syncBytes = convertToDeletion(syncBytes); - synchronizerCache.setCachedSyncBytes(resource, syncBytes, true); - } - sessionPropertyCache.purgeResourceSyncCache(resource); - resourceChanged(resource); - } - return false; - } else { - IContainer container = (IContainer)resource; - if (container.getType() == IResource.PROJECT) { - synchronizerCache.flush((IProject)container); - return false; - } else { - // Move the folder sync info into phantom space - FolderSyncInfo info = getFolderSync(container); - if (info == null) return false; - synchronizerCache.setCachedFolderSync(container, info, true); - folderChanged(container); - // move the resource sync as well - byte[] syncBytes = getSyncBytes(resource); - synchronizerCache.setCachedSyncBytes(resource, syncBytes, true); - sessionPropertyCache.purgeResourceSyncCache(container); - sessionPropertyCache.purgeCache(container, false); - return true; - } - } - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * The resource has been deleted. Make sure any cached state is cleared. - * This is needed because the move/delete hook is not invoked in all situations - * (e.g. external deletion). - * - * @param resource - * @throws CVSException - */ - protected void handleDeleted(IResource resource) throws CVSException { - if (resource.exists()) return; - try { - beginOperation(); - adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR); - } finally { - endOperation(); - } - } - - /** - * Prepare for the deletion of the target resource from within - * the move/delete hook. The method is invoked by both the - * deleteFile/Folder methods and for the source resource - * of moveFile/Folder. This method will move the cached sync info - * into the phantom (ISynchronizer) cache so that outgoing deletions - * and known remote folders are preserved. - * - * @param resource - * @param monitor - * @throws CVSException - */ - public void prepareForDeletion(IResource resource, IProgressMonitor monitor) throws CVSException { - // Move sync info to phantom space for the resource and all it's children - monitor = Policy.monitorFor(monitor); - try { - beginOperation(); - monitor.beginTask(null, 100); - try { - resource.accept(new IResourceVisitor() { - public boolean visit(IResource innerResource) throws CoreException { - try { - return prepareForDeletion(innerResource); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - throw new CoreException(e.getStatus()); - } - } - }); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } finally { - endOperation(); - monitor.done(); - } - } - - /** - * If not already cached, loads and caches the resource sync for the children of the container. - * Folder must exist and must not be the workspace root. - * - * @param container the container - */ - private void cacheResourceSyncForChildren(IContainer container, boolean canModifyWorkspace) throws CVSException { - // don't try to load if the information is already cached - if (! getSyncInfoCacheFor(container).isResourceSyncInfoCached(container)) { - // load the sync info from disk - byte[][] infos; - // do not load the sync info for resources that are linked - if (isLinkedResource(container)) { - infos = null; - } else { - infos = SyncFileWriter.readAllResourceSync(container); - } - try { - if (infos != null) { - for (int i = 0; i < infos.length; i++) { - byte[] syncBytes = infos[i]; - IPath name = new Path(null, getName(syncBytes)); - IResource resource; - if (isFolder(syncBytes)) { - resource = container.getFolder(name); - } else { - resource = container.getFile(name); - } - getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, canModifyWorkspace); - } - } - getSyncInfoCacheFor(container).setResourceSyncInfoCached(container); - } catch (CVSException e) { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.err.println("Failed to cache Entries for folder " + container.getFullPath()); //$NON-NLS-1$ - } - throw e; - } - } - } - - /** - * If not already cached, loads and caches the folder sync for the - * container. Folder must exist and must not be the workspace root. - * - * @param container the container - */ - private void cacheFolderSync(IContainer container) throws CVSException { - // don't try to load if the information is already cached - if (! getSyncInfoCacheFor(container).isFolderSyncInfoCached(container)) { - // load the sync info from disk - FolderSyncInfo info; - // do not load the sync info for resources that are linked - if (isLinkedResource(container)) { - info = null; - } else { - info = SyncFileWriter.readFolderSync(container); - } - getSyncInfoCacheFor(container).setCachedFolderSync(container, info, false); - } - } - - private boolean isLinkedResource(IResource resource) { - return CVSWorkspaceRoot.isLinkedResource(resource); - } - - /** - * Load the sync info for the given resource from disk - * @param resource - * @return byte[] - */ - private byte[] getSyncBytesFromDisk(IResource resource) throws CVSException { - byte[][] infos = SyncFileWriter.readAllResourceSync(resource.getParent()); - if (infos == null) return null; - for (int i = 0; i < infos.length; i++) { - byte[] syncBytes = infos[i]; - if (resource.getName().equals(getName(syncBytes))) { - return syncBytes; - } - } - return null; - } - - /** - * Commits the cache after a series of operations. - * - * Will return STATUS_OK unless there were problems writting sync - * information to disk. If an error occurs a multistatus is returned - * with the list of reasons for the failures. Failures are recovered, - * and all changed resources are given a chance to be written to disk. - * - * @param monitor the progress monitor, may be null - */ - /* internal use only */ IStatus commitCache(ThreadInfo threadInfo, IProgressMonitor monitor) { - if (threadInfo.isEmpty()) { - return SyncInfoCache.STATUS_OK; - } - List errors = new ArrayList(); - try { - /*** prepare operation ***/ - // find parents of changed resources - IResource[] changedResources = threadInfo.getChangedResources(); - IContainer[] changedFolders; - if (threadInfo instanceof CVSThreadInfo) { - changedFolders = ((CVSThreadInfo)threadInfo).getChangedFolders(); - } else { - changedFolders = new IContainer[0]; - } - Set dirtyParents = new HashSet(); - for (int i = 0; i < changedResources.length; i++) { - IResource resource = changedResources[i]; - IContainer folder = resource.getParent(); - dirtyParents.add(folder); - } - - monitor = Policy.monitorFor(monitor); - int numDirty = dirtyParents.size(); - int numResources = changedFolders.length + numDirty; - monitor.beginTask(null, numResources); - if(monitor.isCanceled()) { - monitor.subTask(Policy.bind("EclipseSynchronizer.UpdatingSyncEndOperationCancelled")); //$NON-NLS-1$ - } else { - monitor.subTask(Policy.bind("EclipseSynchronizer.UpdatingSyncEndOperation")); //$NON-NLS-1$ - } - - /*** write sync info to disk ***/ - // folder sync info changes - for (int i = 0; i < changedFolders.length; i++) { - IContainer folder = changedFolders[i]; - if (folder.exists() && folder.getType() != IResource.ROOT) { - try { - FolderSyncInfo info = sessionPropertyCache.getCachedFolderSync(folder); - // Do not write the folder sync for linked resources - if (info == null) { - // deleted folder sync info since we loaded it - // (but don't overwrite the sync info for linked folders - if (!isLinkedResource(folder)) - SyncFileWriter.deleteFolderSync(folder); - dirtyParents.remove(folder); - } else { - // modified or created new folder sync info since we loaded it - SyncFileWriter.writeFolderSync(folder, info); - } - } catch(CVSException e) { - try { - sessionPropertyCache.purgeCache(folder, true /* deep */); - } catch(CVSException pe) { - errors.add(pe.getStatus()); - } - errors.add(e.getStatus()); - } - } - monitor.worked(1); - } - - // update progress for parents we will skip because they were deleted - monitor.worked(numDirty - dirtyParents.size()); - - // resource sync info changes - for (Iterator it = dirtyParents.iterator(); it.hasNext();) { - IContainer folder = (IContainer) it.next(); - if (folder.exists() && folder.getType() != IResource.ROOT) { - // write sync info for all children in one go - try { - List infos = new ArrayList(); - IResource[] children = folder.members(true); - for (int i = 0; i < children.length; i++) { - IResource resource = children[i]; - byte[] syncBytes = getSyncBytes(resource); - if (syncBytes != null) { - infos.add(syncBytes); - } - } - // do not overwrite the sync info for linked resources - if (infos.size() > 0 || !isLinkedResource(folder)) - SyncFileWriter.writeAllResourceSync(folder, - (byte[][]) infos.toArray(new byte[infos.size()][])); - } catch(CVSException e) { - try { - sessionPropertyCache.purgeCache(folder, false /* depth 1 */); - } catch(CVSException pe) { - errors.add(pe.getStatus()); - } - errors.add(e.getStatus()); - } catch (CoreException e) { - try { - sessionPropertyCache.purgeCache(folder, false /* depth 1 */); - } catch(CVSException pe) { - errors.add(pe.getStatus()); - } - errors.add(e.getStatus()); - } - } - monitor.worked(1); - } - - /*** broadcast events ***/ - monitor.subTask(Policy.bind("EclipseSynchronizer.NotifyingListeners")); //$NON-NLS-1$ - Set allChanges = new HashSet(); - allChanges.addAll(Arrays.asList(changedResources)); - allChanges.addAll(Arrays.asList(changedFolders)); - allChanges.addAll(dirtyParents); - IResource[] resources = (IResource[]) allChanges.toArray( - new IResource[allChanges.size()]); - broadcastResourceStateChanges(resources); - if ( ! errors.isEmpty()) { - MultiStatus status = new MultiStatus(CVSProviderPlugin.ID, - CVSStatus.COMMITTING_SYNC_INFO_FAILED, - Policy.bind("EclipseSynchronizer.ErrorCommitting"), //$NON-NLS-1$ - null); - for (int i = 0; i < errors.size(); i++) { - status.merge((IStatus)errors.get(i)); - } - return status; - } - return SyncInfoCache.STATUS_OK; - } finally { - monitor.done(); - } - } - - /** - * Broadcasts the resource state changes for the given resources to CVS Provider Plugin - */ - void broadcastResourceStateChanges(IResource[] resources) { - if (resources.length > 0) { - ResourceStateChangeListeners.getListener().resourceSyncInfoChanged(resources); - } - } - - /** - * Returns the resource sync info for the resource; null if none. - * Parent must exist and must not be the workspace root. - * The resource sync info for the children of the parent container MUST ALREADY BE CACHED. - * - * @param resource the resource - * @return the resource sync info for the resource, or null - * @see #cacheResourceSyncForChildren - */ - private byte[] getCachedSyncBytes(IResource resource) throws CVSException { - return getSyncInfoCacheFor(resource).getCachedSyncBytes(resource); - } - - /** - * Returns the resource sync info for the resource; null if none. - * Parent must exist and must not be the workspace root. - * The resource sync info for the children of the parent container MUST ALREADY BE CACHED. - * - * @param resource the resource - * @return the resource sync info for the resource, or null - * @see #cacheResourceSyncForChildren - */ - private void setCachedSyncBytes(IResource resource, byte[] syncBytes) throws CVSException { - getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, true); - resourceChanged(resource); - } - - /** - * Sets the resource sync info for the resource; if null, deletes it. Parent - * must exist and must not be the workspace root. The resource sync info for - * the children of the parent container MUST ALREADY BE CACHED. - * - * @param resource the resource - * @param info the new resource sync info - * @see #cacheResourceSyncForChildren - */ - private void setCachedResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException { - //todo - byte[] syncBytes = null; - if (info != null) syncBytes = info.getBytes(); - getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, true); - } - - /** - * If not already cached, loads and caches the folder ignores sync for the container. - * Folder must exist and must not be the workspace root. - * - * @param container the container - * @return the folder ignore patterns, or an empty array if none - */ - private FileNameMatcher cacheFolderIgnores(IContainer container) throws CVSException { - return sessionPropertyCache.cacheFolderIgnores(container); - } - - /** - * Sets the array of folder ignore patterns for the container, must not be null. - * Folder must exist and must not be the workspace root. - * - * @param container the container - * @param ignores the array of ignore patterns - */ - private void setCachedFolderIgnores(IContainer container, String[] ignores) throws CVSException { - sessionPropertyCache.setCachedFolderIgnores(container, ignores); - } - - /* - * Recursively adds to the possibleIgnores list all children of the given - * folder that can be ignored. This method may only be invoked when a - * schedling rule for the given foldr is held and when the CVs sync lock is - * held. - * - * @param folder the folder to be searched - * @param possibleIgnores the list of IResources that can be ignored - */ - private void accumulateNonManagedChildren(IContainer folder, List possibleIgnores) throws CVSException { - try { - cacheResourceSyncForChildren(folder, true /* can modify workspace */); - IResource[] children = folder.members(); - List folders = new ArrayList(); - // deal with all files first and then folders to be otimized for caching scheme - for (int i = 0; i < children.length; i++) { - IResource child = children[i]; - if(getCachedSyncBytes(child)==null) { - possibleIgnores.add(child); - } - if(child.getType()!=IResource.FILE) { - folders.add(child); - } - } - for (Iterator iter = folders.iterator(); iter.hasNext();) { - IContainer child = (IContainer) iter.next(); - accumulateNonManagedChildren(child, possibleIgnores); - } - } catch(CoreException e) { - throw CVSException.wrapException(e); - } - } - - /** - * Add the entry to the CVS/Notify file. We are not initially concerned with efficiency - * since edit/unedit are typically issued on a small set of files. - * - * XXX If there was a previous notify entry for the resource, it is replaced. This is - * probably not the proper behavior (see EclipseFile). - * - * A value of null for info indicates that any entry for the given - * resource is to be removed from the Notify file. - * - * @param resource - * @param info - */ - public void setNotifyInfo(IResource resource, NotifyInfo info) throws CVSException { - NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent()); - if (infos == null) { - // if the file is empty and we are removing an entry, just return; - if (info == null) return; - infos = new NotifyInfo[] { info }; - } else { - Map infoMap = new HashMap(); - for (int i = 0; i < infos.length; i++) { - NotifyInfo notifyInfo = infos[i]; - infoMap.put(notifyInfo.getName(), notifyInfo); - } - if (info == null) { - // if the info is null, remove the entry - infoMap.remove(resource.getName()); - } else { - // add the new entry to the list - infoMap.put(info.getName(), info); - } - - NotifyInfo[] newInfos = new NotifyInfo[infoMap.size()]; - int i = 0; - for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) { - newInfos[i++] = (NotifyInfo) iter.next(); - } - infos = newInfos; - } - SyncFileWriter.writeAllNotifyInfo(resource.getParent(), infos); - } - - /** - * Method getNotifyInfo. - * @param resource - * @return NotifyInfo - */ - public NotifyInfo getNotifyInfo(IResource resource) throws CVSException { - NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent()); - if (infos == null) return null; - for (int i = 0; i < infos.length; i++) { - NotifyInfo notifyInfo = infos[i]; - if (notifyInfo.getName().equals(resource.getName())) { - return notifyInfo; - } - } - return null; - } - - /** - * Method deleteNotifyInfo. - * @param resource - */ - public void deleteNotifyInfo(IResource resource) throws CVSException { - NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent()); - if (infos == null) return; - Map infoMap = new HashMap(); - for (int i = 0; i < infos.length; i++) { - NotifyInfo notifyInfo = infos[i]; - infoMap.put(notifyInfo.getName(), notifyInfo); - } - infoMap.remove(resource.getName()); - NotifyInfo[] newInfos = new NotifyInfo[infoMap.size()]; - int i = 0; - for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) { - newInfos[i++] = (NotifyInfo) iter.next(); - } - SyncFileWriter.writeAllNotifyInfo(resource.getParent(), newInfos); - } - - /** - * Add the entry to the CVS/Baserev file. We are not initially concerned - * with efficiency since edit/unedit are typically issued on a small set of - * files. - * - * XXX If there was a previous notify entry for the resource, it is replaced. This is - * probably not the proper behavior (see EclipseFile). - * - * @param resource - * @param info - */ - public void setBaserevInfo(IResource resource, BaserevInfo info) throws CVSException { - BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent()); - if (infos == null) { - infos = new BaserevInfo[] { info }; - } else { - Map infoMap = new HashMap(); - for (int i = 0; i < infos.length; i++) { - infoMap.put(infos[i].getName(), infos[i]); - } - infoMap.put(info.getName(), info); - BaserevInfo[] newInfos = new BaserevInfo[infoMap.size()]; - int i = 0; - for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) { - newInfos[i++] = (BaserevInfo) iter.next(); - } - infos = newInfos; - } - SyncFileWriter.writeAllBaserevInfo(resource.getParent(), infos); - } - - /** - * Method getBaserevInfo. - * @param resource - * @return BaserevInfo - */ - public BaserevInfo getBaserevInfo(IResource resource) throws CVSException { - BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent()); - if (infos == null) return null; - for (int i = 0; i < infos.length; i++) { - BaserevInfo info = infos[i]; - if (info.getName().equals(resource.getName())) { - return info; - } - } - return null; - } - - /** - * Method deleteNotifyInfo. - * @param resource - */ - public void deleteBaserevInfo(IResource resource) throws CVSException { - BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent()); - if (infos == null) return; - Map infoMap = new HashMap(); - for (int i = 0; i < infos.length; i++) { - infoMap.put(infos[i].getName(), infos[i]); - } - infoMap.remove(resource.getName()); - BaserevInfo[] newInfos = new BaserevInfo[infoMap.size()]; - int i = 0; - for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) { - newInfos[i++] = (BaserevInfo) iter.next(); - } - SyncFileWriter.writeAllBaserevInfo(resource.getParent(), newInfos); - } - - public void copyFileToBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ISchedulingRule rule = null; - try { - rule = beginBatching(file, Policy.subMonitorFor(monitor, 10)); - ResourceSyncInfo info = getResourceSync(file); - // The file must exist remotely and locally - if (info == null || info.isAdded() || info.isDeleted()) - return; - SyncFileWriter.writeFileToBaseDirectory(file, Policy.subMonitorFor(monitor, 80)); - resourceChanged(file); - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - } - - public void restoreFileFromBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ISchedulingRule rule = null; - try { - rule = beginBatching(file, Policy.subMonitorFor(monitor, 10)); - ResourceSyncInfo info = getResourceSync(file); - // The file must exist remotely - if (info == null || info.isAdded()) - return; - SyncFileWriter.restoreFileFromBaseDirectory(file, Policy.subMonitorFor(monitor, 80)); - resourceChanged(file); - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - } - - public void deleteFileFromBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException { - ResourceSyncInfo info = getResourceSync(file); - // The file must exist remotely - if (info == null || info.isAdded()) - return; - SyncFileWriter.deleteFileFromBaseDirectory(file, monitor); - } - - /** - * Method isSyncInfoLoaded returns true if all the sync info for the - * provided resources is loaded into the internal cache. - * - * @param resources - * @param i - * @return boolean - */ - public boolean isSyncInfoLoaded(IResource[] resources, int depth) throws CVSException { - // get the folders involved - IContainer[] folders = getParentFolders(resources, depth); - // for all folders that have a CVS folder, ensure the sync info is cached - for (int i = 0; i < folders.length; i++) { - IContainer parent = folders[i]; - if (!getSyncInfoCacheFor(parent).isSyncInfoLoaded(parent)) { - return false; - } - } - return true; - } - - /** - * Method ensureSyncInfoLoaded loads all the relevent sync info into the cache. - * This method can only be invoked when the workspace is open for modification. - * in other words it cannot be invoked from inside a POST_CHANGE delta listener. - * @param resources - * @param i - * @return Object - */ - public void ensureSyncInfoLoaded(IResource[] resources, int depth) throws CVSException { - // get the folders involved - IContainer[] folders = getParentFolders(resources, depth); - // Cache the sync info for all the folders - for (int i = 0; i < folders.length; i++) { - IContainer parent = folders[i]; - ISchedulingRule rule = null; - try { - rule = beginBatching(parent, null); - try { - beginOperation(); - cacheResourceSyncForChildren(parent, true /* can modify workspace */); - cacheFolderSync(parent); - cacheFolderIgnores(parent); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - } - - /* - * Collect the projects and parent folders of the resources since - * thats were the sync info is kept. - */ - private IContainer[] getParentFolders(IResource[] resources, int depth) throws CVSException { - final Set folders = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - folders.add(resource.getProject()); - if (resource.getType() != IResource.PROJECT) { - folders.add(resource.getParent()); - } - // use the depth to gather child folders when appropriate - if (depth != IResource.DEPTH_ZERO) { - try { - resource.accept(new IResourceVisitor() { - public boolean visit(IResource innerResource) throws CoreException { - if (innerResource.getType() == IResource.FOLDER) - folders.add(innerResource); - // let the depth determine who we visit - return true; - } - }, depth, false); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - } - return (IContainer[]) folders.toArray(new IContainer[folders.size()]); - } - - /** - * Perform sync info batching within the context of the given resource - * scheduling rule while running the given ICVSRunnable. - * @param runnable - * @param monitor - * @throws CVSException - */ - public void run(ISchedulingRule resourceRule, ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - ISchedulingRule rule = beginBatching(resourceRule, Policy.subMonitorFor(monitor, 10)); - try { - runnable.run(Policy.subMonitorFor(monitor, 80)); - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - } - - /** - * This method is invoked from the IMoveDeleteHook to batch the resulting sync file - * changes. - */ - public void run(ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException { - // Use the root resource as the rule. - // Note: This will not lock the workspace due to behavior in ReentrantLock - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - run(root, runnable, monitor); - } - - /** - * Method isEdited returns true if a "cvs edit" was performed on the given - * file and no commit or unedit has yet been performed. - * @param iResource - * @return boolean - */ - public boolean isEdited(IFile resource) { - return SyncFileWriter.isEdited(resource); - } - - /* package */ void adjustDirtyStateRecursively(IResource resource, String indicator) throws CVSException { - if (resource.getType() == IResource.ROOT) return; - try { - beginOperation(); - - if (getSyncInfoCacheFor(resource).cachesDirtyState()) { - if (indicator == getDirtyIndicator(resource)) { - return; - } - getSyncInfoCacheFor(resource).setDirtyIndicator(resource, indicator); - } - - if (Policy.DEBUG_DIRTY_CACHING) { - debug(resource, indicator, "adjusting dirty state"); //$NON-NLS-1$ - } - - IContainer parent = resource.getParent(); - if(indicator == NOT_DIRTY_INDICATOR) { - adjustDirtyStateRecursively(parent, RECOMPUTE_INDICATOR); - } - - if(indicator == RECOMPUTE_INDICATOR) { - adjustDirtyStateRecursively(parent, RECOMPUTE_INDICATOR); - } - - if(indicator == IS_DIRTY_INDICATOR) { - adjustDirtyStateRecursively(parent, indicator); - } - } finally { - endOperation(); - } - } - - protected String getDirtyIndicator(IResource resource) throws CVSException { - try { - beginOperation(); - return getSyncInfoCacheFor(resource).getDirtyIndicator(resource); - } finally { - endOperation(); - } - } - - /* - * Mark the given resource as either modified or clean using a persistant - * property. Do nothing if the modified state is already what we want. - * Return true if the modification state was changed. - */ - protected void setDirtyIndicator(IResource resource, boolean modified) throws CVSException { - String indicator = modified ? IS_DIRTY_INDICATOR : NOT_DIRTY_INDICATOR; - // set the dirty indicator and adjust the parent accordingly - adjustDirtyStateRecursively(resource, indicator); - } - - /** - * Method getName. - * @param syncBytes - */ - private String getName(byte[] syncBytes) throws CVSException { - return ResourceSyncInfo.getName(syncBytes); - } - - /** - * Method isFolder. - * @param syncBytes - * @return boolean - */ - private boolean isFolder(byte[] syncBytes) { - return ResourceSyncInfo.isFolder(syncBytes); - } - - /** - * Method convertToDeletion. - * @param syncBytes - * @return byte[] - */ - private byte[] convertToDeletion(byte[] syncBytes) throws CVSException { - return ResourceSyncInfo.convertToDeletion(syncBytes); - } - - /** - * Method createdByMove clears any session properties on the file so it - * appears as an ADDED file. - * - * @param destination - */ - public void createdByMove(IFile file) throws CVSException { - deleteResourceSync(file); - } - - static public void debug(IResource resource, String indicator, String string) { - String di = EclipseSynchronizer.IS_DIRTY_INDICATOR; - if(indicator == EclipseSynchronizer.IS_DIRTY_INDICATOR) { - di = "dirty"; //$NON-NLS-1$ - } else if(indicator == EclipseSynchronizer.NOT_DIRTY_INDICATOR) { - di = "clean"; //$NON-NLS-1$ - } else { - di = "needs recomputing"; //$NON-NLS-1$ - } - System.out.println("["+string + ":" + di + "] " + resource.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - static public void debug(IResource resource, boolean modified, String string) { - debug(resource, modified ? IS_DIRTY_INDICATOR : NOT_DIRTY_INDICATOR, string); - } - - /** - * @param file - * @return int - */ - public int getModificationState(IResource resource) throws CVSException { - String indicator = getDirtyIndicator(resource); - if (Policy.DEBUG_DIRTY_CACHING) { - debug(resource, indicator, "getModificationState"); //$NON-NLS-1$ - } - if (indicator == null || indicator == RECOMPUTE_INDICATOR) { - return ICVSFile.UNKNOWN; - } else if (indicator == IS_DIRTY_INDICATOR) { - return ICVSFile.DIRTY; - } else if (indicator == NOT_DIRTY_INDICATOR) { - return ICVSFile.CLEAN; - } else { - return ICVSFile.UNKNOWN; - } - } - - /** - * Return whether the resource is within the scope of a currently active - * CVS operation. - * @param resource - * @return - */ - public boolean isWithinActiveOperationScope(IResource resource) { - return resourceLock.isWithinActiveOperationScope(resource); - } - - /** - * Set the timestamp of the given file and set it to be CLEAN. It is - * assumed that this method is only invoked to reset the file timestamp - * to the timestamp that is in the CVS/Entries file. - * @param file - * @param time - * @throws CVSException - */ - public void setTimeStamp(EclipseFile cvsFile, long time) throws CVSException { - ISchedulingRule rule = null; - IFile file = (IFile)cvsFile.getIResource(); - try { - rule = beginBatching(file, null); - try { - beginOperation(); - try { - file.setLocalTimeStamp(time); - setModified(cvsFile, ICVSFile.CLEAN); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - resourceChanged(file); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, null); - } - } - - /** - * React to a resource that was just moved by the move/delete hook. - * @param resource the resource that was moved (at its new location) - */ - public void postMove(IResource resource) throws CVSException { - try { - beginOperation(); - if (resource.getType() == IResource.FILE) { - // Purge any copied sync info so true sync info will - // be obtained from the synchronizer cache - sessionPropertyCache.purgeResourceSyncCache(resource); - } else { - IContainer container = (IContainer)resource; - // Purge any copied sync info - sessionPropertyCache.purgeCache(container, true /* deep */); - // Dirty all resources so old sync info will be rewritten to disk - try { - container.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if (getSyncBytes(resource) != null) { - resourceChanged(resource); - } - if (resource.getType() != IResource.FILE) { - if (getFolderSync((IContainer)resource) != null) { - folderChanged((IContainer)resource); - return true; - } - } - return false; - } - }); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - // Flush the sync info to disk - flush(container, true /* deep */, null); - } - } finally { - endOperation(); - } - } - - /** - * This method is to be invoked only from the move/delete hook. It's purpose - * is to obtain the sync look in order to prevent other threads from accessing - * sync info while the move/delete is taking place. - * @param runnable - * @param monitor - * @throws CVSException - */ - public void performMoveDelete(ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException { - ISchedulingRule rule = null; - try { - monitor.beginTask(null, 100); - rule = beginBatching(null, null); - try { - beginOperation(); - runnable.run(Policy.subMonitorFor(monitor, 95)); - } finally { - endOperation(); - } - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5)); - monitor.done(); - } - } - - /** - * Compute the modification state for the given file. If the modificationState is - * ICVSFile.UNKNOWN, it is computed. However, if it is CLEAN or DIRTY, - * it is set accordingly. CLEAN or DIRTY can only be used if the caller is protected - * from resource modifications (either by a scheduling rule or inside a delta handler). - * @param file - * @param modificationState - * @return true if the file is dirty - */ - public boolean setModified(EclipseFile cvsFile, int modificationState) throws CVSException { - try { - beginOperation(); - boolean dirty; - if (modificationState == ICVSFile.UNKNOWN) { - dirty = cvsFile.isDirty(); - } else { - dirty = modificationState == ICVSFile.DIRTY; - } - setDirtyIndicator(cvsFile.getIResource(), dirty); - return dirty; - } finally { - endOperation(); - } - - } - - /** - * Set the modified state of the folder. This method can be called when no resource locks are - * held. It will check the cached modification state of all the folder's children before setting. - * If the states of the children do not match, the state for the folder is not cached. - * @param folder - * @param modified - */ - public void setModified(ICVSFolder cvsFolder, boolean modified) throws CVSException { - try { - beginOperation(); - IContainer folder = (IContainer)cvsFolder.getIResource(); - // The drop out condition for clean or dirty are the opposite. - // (i.e. if modified and a dirty is found we can set the indicator - // and if not modified and a dirty or unknown is found we cannot set the indicator) - boolean okToSet = !modified; - // Obtain the children while we're locked to ensure some were not added or changed - ICVSResource[] children = cvsFolder.members(ICVSFolder.ALL_UNIGNORED_MEMBERS); - for (int i = 0; i < children.length; i++) { - IResource resource = children[i].getIResource(); - if (modified) { - if (getDirtyIndicator(resource) == IS_DIRTY_INDICATOR) { - okToSet = true; - break; - } - } else { - if (getDirtyIndicator(resource) != NOT_DIRTY_INDICATOR) { - okToSet = false; - break; - } - } - } - if (okToSet) { - setDirtyIndicator(folder, modified); - } - } finally { - endOperation(); - } - } - - public boolean wasPhantom(IResource resource) { - if (resource.exists()) { - try { - return (synchronizerCache.getCachedSyncBytes(resource) != null - || (resource.getType() == IResource.FOLDER - && synchronizerCache.hasCachedFolderSync((IContainer)resource))); - } catch (CVSException e) { - // Log and assume resource is not a phantom - CVSProviderPlugin.log(e); - } - } - return false; - } - - /** - * Method called from background handler when resources that are mapped to CVS are recreated - * @param resources - * @param monitor - * @throws CVSException - */ - public void resourcesRecreated(IResource[] resources, IProgressMonitor monitor) throws CVSException { - if (resources.length == 0) return; - ISchedulingRule rule = null; - ISchedulingRule projectsRule = getProjectRule(resources); - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - rule = beginBatching(projectsRule, monitor); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - try { - created(resource); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - } - } finally { - if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5)); - monitor.done(); - } - } - - private ISchedulingRule getProjectRule(IResource[] resources) { - HashSet set = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - set.add(resource.getProject()); - } - IProject[] projects = (IProject[]) set.toArray(new IProject[set.size()]); - if (projects.length == 1) { - return projects[0]; - } - return new MultiRule(projects); - } - - protected void created(IResource resource) throws CVSException { - try { - beginOperation(); - if (resource.exists()) { - restoreResourceSync(resource); - if (resource.getType() == IResource.FOLDER) { - restoreFolderSync((IFolder)resource); - } - } - } finally { - endOperation(); - } - } - - /* - * Restore the folder sync info for the given folder - */ - private void restoreFolderSync(IFolder folder) throws CVSException { - try { - // set the dirty count using what was cached in the phantom it - beginOperation(); - FolderSyncInfo folderInfo = synchronizerCache.getCachedFolderSync(folder); - if (folderInfo != null) { - // There is folder sync info to restore - if (folder.getFolder(SyncFileWriter.CVS_DIRNAME).exists()) { - // There is already a CVS subdirectory which indicates that - // either the folder was recreated by an external tool or that - // a folder with CVS information was copied from another location. - // To know the difference, we need to compare the folder sync info. - // If they are mapped to the same root and repository then just - // purge the phantom info. Otherwise, keep the original sync info. - - // Get the new folder sync info - FolderSyncInfo newFolderInfo = getFolderSync(folder); - if (newFolderInfo.getRoot().equals(folderInfo.getRoot()) - && newFolderInfo.getRepository().equals(folderInfo.getRepository())) { - // The folder is the same so use what is on disk. - // Fall through to ensure that the Root and Repository files exist - } else { - // The folder is mapped to a different location. - // Purge new resource sync before restoring from phantom - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); - ICVSResource[] children = cvsFolder.members(ICVSFolder.MANAGED_MEMBERS); - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - deleteResourceSync(resource.getIResource()); - } - } - } - - // set the sync info using what was cached in the phantom - setFolderSync(folder, folderInfo); - // purge the dirty cache so any old persisted dirty state is purged - sessionPropertyCache.purgeDirtyCache(folder); - // if there are managed members, indicate that 1 is changed so the Entries file is written - IResource[] members = members(folder); - for (int i = 0; i < members.length; i++) { - IResource resource = members[i]; - if (getSyncBytes(resource) != null) { - resourceChanged(resource); - break; - } - } - } - } finally { - try { - endOperation(); - } finally { - synchronizerCache.flush(folder); - } - } - } - - /* - * Restore the resource sync info for the given resource. - */ - private void restoreResourceSync(IResource resource) throws CVSException { - try { - beginOperation(); - byte[] syncBytes = synchronizerCache.getCachedSyncBytes(resource); - if (syncBytes != null) { - if (!ResourceSyncInfo.isFolder(syncBytes)) { - syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes); - } - byte[] newBytes = getSyncBytes(resource); - if (newBytes != null && !ResourceSyncInfo.isFolder(newBytes)) { - newBytes = ResourceSyncInfo.convertFromDeletion(newBytes); - } - if (newBytes == null || Util.equals(syncBytes, newBytes)) { - // only move the sync info if there is no new sync info - setSyncBytes(resource, syncBytes); - } - } - } finally { - try { - endOperation(); - } finally { - synchronizerCache.setCachedSyncBytes(resource, null, true); - } - } - } - - private void purgeDirtyCache(IProject project, IProgressMonitor monitor) throws CVSException { - sessionPropertyCache.purgeDirtyCache(project); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java deleted file mode 100644 index 5d8310ec0..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; - -/** - * This class can be used to fetch and cache file contents for remote files. - */ -public class FileContentCachingService { - - String[] fileDiffs; - private CVSRepositoryLocation repository; - private ICVSFolder remoteRoot; - - public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); - try { - RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag); - RemoteFolderTree tree = builder.buildTree(new ICVSResource[] { root }, Policy.subMonitorFor(monitor, 50)); - FileContentCachingService service = new FileContentCachingService(repository, tree, builder.getFileDiffs()); - service.cacheFileContents(Policy.subMonitorFor(monitor, 50)); - return tree; - } finally { - monitor.done(); - } - } - - /** - * Fetch and cache the file contents for the specified files. - * @param root the root folder for the files being fetched - * @param filePaths the root relative file paths - * @param monitor - * @throws CVSException - */ - public static void fetchFileContents(RemoteFolderTree root, String[] filePaths, IProgressMonitor monitor) throws CVSException { - FileContentCachingService service = new FileContentCachingService((CVSRepositoryLocation)root.getRepository(), root, filePaths); - service.cacheFileContents(monitor); - } - - public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); - try { - RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag); - RemoteFile remote = builder.buildTree(file, monitor); - if (builder.getFileDiffs().length > 0) { - // Getting the storage of the file will cache the contents - remote.getStorage(Policy.subMonitorFor(monitor, 50)); - } - return remote; - } catch (TeamException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - public FileContentCachingService(CVSRepositoryLocation repository, RemoteFolderTree tree, String[] fileDiffs) { - this.repository = repository; - this.remoteRoot = tree; - this.fileDiffs = fileDiffs; - } - - private void cacheFileContents(IProgressMonitor monitor) throws CVSException { - String[] files = getUncachedFiles(); - if (files.length == 0) return; - // Fetch the file contents for all out-of-sync files by running an update - // on the remote tree passing the known changed files as arguments - monitor.beginTask(null, 10 + files.length * 100); - Policy.checkCanceled(monitor); - Session session = new Session(repository, remoteRoot, false); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - Policy.checkCanceled(monitor); - IStatus status = Command.UPDATE.execute(session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, - files, - null, - Policy.subMonitorFor(monitor, files.length * 100)); - if (!status.isOK()) { - // No big deal but log the problem anyway - CVSProviderPlugin.log (new CVSException(status)); - } - } finally { - session.close(); - monitor.done(); - } - } - - /* - * Only return those file in the diff list that exist remotely and whose contents are not already cached - */ - private String[] getUncachedFiles() { - if (fileDiffs.length == 0) return fileDiffs; - List existing = new ArrayList(); - for (int i = 0; i < fileDiffs.length; i++) { - String filePath = fileDiffs[i]; - try { - ICVSFile file = remoteRoot.getFile(filePath); - if (file instanceof RemoteFile) { - if (!((RemoteFile)file).isContentsCached()) { - existing.add(filePath); - } - } - } catch (CVSException e) { - // The child does not exists so exclude it - } - } - return (String[]) existing.toArray(new String[existing.size()]); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java deleted file mode 100644 index a490b889d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ISaveContext; -import org.eclipse.core.resources.ISaveParticipant; -import org.eclipse.core.resources.ISavedState; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners; - -/** - * This class performs several functions related to determining the modified - * status of files under CVS control. First, it listens for change delta's for - * files and brodcasts them to all listeners. It also registers as a save - * participant so that deltas generated before the plugin are loaded are not - * missed. Secondly, it listens for CVS resource state change events and uses - * these to properly mark files and folders as modified. - */ -public class FileModificationManager implements IResourceChangeListener, ISaveParticipant { - - private static final QualifiedName UPDATE_TIMESTAMP = new QualifiedName(CVSProviderPlugin.ID, "update-timestamp"); //$NON-NLS-1$ - - /* private */Set modifiedResources = new HashSet(); - - // consider the following changes types and ignore the others (e.g. marker and description changes are ignored) - protected int INTERESTING_CHANGES = IResourceDelta.CONTENT | - IResourceDelta.MOVED_FROM | - IResourceDelta.MOVED_TO | - IResourceDelta.OPEN | - IResourceDelta.REPLACED | - IResourceDelta.TYPE; - - /** - * Listen for file modifications and fire modification state changes - * - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - event.getDelta().accept(new IResourceDeltaVisitor() { - public boolean visit(IResourceDelta delta) { - IResource resource = delta.getResource(); - - if (resource.getType()==IResource.PROJECT) { - IProject project = (IProject)resource; - if (!project.isAccessible()) { - return false; - } - if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { - return false; - } - if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) { - return false; - } - } - - if (resource.getType()==IResource.FILE && delta.getKind() == IResourceDelta.CHANGED && resource.exists()) { - int flags = delta.getFlags(); - if((flags & INTERESTING_CHANGES) != 0) { - resourceChanged(resource, false); - } - } else if (delta.getKind() == IResourceDelta.ADDED) { - resourceChanged(resource, true); - } else if (delta.getKind() == IResourceDelta.REMOVED) { - try { - EclipseSynchronizer.getInstance().handleDeleted(resource); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - modifiedResources.add(resource); - } - - return true; - } - }); - if (!modifiedResources.isEmpty()) { - ResourceStateChangeListeners.getListener().resourceModified( - (IResource[])modifiedResources.toArray(new IResource[modifiedResources.size()])); - modifiedResources.clear(); - } - } catch (CoreException e) { - CVSProviderPlugin.log(e); - } - - } - - /** - * We register a save participant so we can get the delta from workbench - * startup to plugin startup. - * @throws CoreException - */ - public void registerSaveParticipant() throws CoreException { - IWorkspace ws = ResourcesPlugin.getWorkspace(); - ISavedState ss = ws.addSaveParticipant(CVSProviderPlugin.getPlugin(), this); - if (ss != null) { - ss.processResourceChangeEvents(this); - } - ws.removeSaveParticipant(CVSProviderPlugin.getPlugin()); - } - - /** - * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext) - */ - public void doneSaving(ISaveContext context) { - // Do nothing - } - /** - * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext) - */ - public void prepareToSave(ISaveContext context) { - // Do nothing - } - /** - * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext) - */ - public void rollback(ISaveContext context) { - // Do nothing - } - /** - * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext) - */ - public void saving(ISaveContext context) { - // Do nothing - } - - - /** - * Method updated flags the objetc as having been modfied by the updated - * handler. This flag is read during the resource delta to determine whether - * the modification made the file dirty or not. - * - * @param mFile - */ - public void updated(ICVSFile mFile) { - try { - if (mFile instanceof EclipseFile) { - IFile file = (IFile)mFile.getIResource(); - file.setSessionProperty(UPDATE_TIMESTAMP, new Long(file.getModificationStamp())); - } - } catch (CoreException e) { - CVSProviderPlugin.log(e); - } - } - - /* - * Handle added and changed resources by signaling the change to the corresponding - * CVS resource and recording the change for broadcast to interested listeners. - */ - /* private */void resourceChanged(IResource resource, boolean addition) { - if (isCleanUpdate(resource)) return; - try { - EclipseResource cvsResource = (EclipseResource)CVSWorkspaceRoot.getCVSResourceFor(resource); - if (!cvsResource.isIgnored()) { - cvsResource.handleModification(addition); - modifiedResources.add(resource); - } - } catch (CVSException e) { - // Log the exception and continue - CVSProviderPlugin.log(e); - } - } - - /** - * If the file was the result of a clean update, the cached timestamp will - * be removed. - * - * @param resource - * @return boolean - */ - private boolean isCleanUpdate(IResource resource) { - if(resource.getType() != IResource.FILE) return false; - long modStamp = resource.getModificationStamp(); - Long whenWeWrote; - try { - whenWeWrote = (Long)resource.getSessionProperty(UPDATE_TIMESTAMP); - resource.setSessionProperty(UPDATE_TIMESTAMP, null); - } catch(CoreException e) { - CVSProviderPlugin.log(e); - whenWeWrote = null; - } - return (whenWeWrote!=null && whenWeWrote.longValue() == modStamp); - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java deleted file mode 100644 index e685233a5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java +++ /dev/null @@ -1,657 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.ILogEntryListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * This class provides the implementation of ICVSRemoteFile and IManagedFile for - * use by the repository and sync view. - */ -public class RemoteFile extends RemoteResource implements ICVSRemoteFile { - - /* - * Listener for accumulating the entries fetched using the "cvs log" command - */ - private final class LogEntryListener implements ILogEntryListener { - private final List entries = new ArrayList(); - public void handleLogEntryReceived(ILogEntry entry) { - if (entry.getRemoteFile().getRepositoryRelativePath().equals(getRepositoryRelativePath())) { - entries.add(entry); - } - } - public ILogEntry[] getEntries() { - return (ILogEntry[])entries.toArray(new ILogEntry[entries.size()]); - } - } - - // sync info in byte form - private byte[] syncBytes; - // cache the log entry for the remote file - private ILogEntry entry; - // state that indicates that the handle is actively fetching content - private boolean fetching = false; - - /** - * Static method which creates a file as a single child of its parent. - * This should only be used when one is only interested in the file alone. - * - * The returned RemoteFile represents the base of the local resource. - * If the local resource does not have a base, then null is returned - * even if the resource does exists remotely (e.g. created by another party). - */ - public static RemoteFile getBase(RemoteFolder parent, ICVSFile managed) throws CVSException { - Assert.isNotNull(parent, "A parent folder must be provided for file " + managed.getName()); //$NON-NLS-1$ - byte[] syncBytes = managed.getSyncBytes(); - if ((syncBytes == null) || ResourceSyncInfo.isAddition(syncBytes)) { - // Either the file is unmanaged or has just been added (i.e. doesn't necessarily have a remote) - return null; - } - if (ResourceSyncInfo.isDeletion(syncBytes)) { - syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes); - } - RemoteFile file = new RemoteFile(parent, syncBytes); - parent.setChildren(new ICVSRemoteResource[] {file}); - return file; - } - - /** - * This method is used by the CVS subscribers to create file handles. - */ - public static RemoteFile fromBytes(IResource local, byte[] bytes, byte[] parentBytes) throws CVSException { - Assert.isNotNull(bytes); - Assert.isTrue(local.getType() == IResource.FILE); - RemoteFolder parent = RemoteFolder.fromBytes(local.getParent(), parentBytes); - RemoteFile file = new RemoteFile(parent, bytes); - parent.setChildren(new ICVSRemoteResource[] {file}); - return file; - } - - /** - * Create a remote file handle for the given file path that is relative to the - * given location. - */ - public static RemoteFile create(String filePath, ICVSRepositoryLocation location) { - Assert.isNotNull(filePath); - Assert.isNotNull(location); - IPath path = new Path(null, filePath); - RemoteFolder parent = new RemoteFolder(null /* parent */, location, path.removeLastSegments(1).toString(), null /* tag */); - RemoteFile file = new RemoteFile(parent, Update.STATE_NONE, path.lastSegment(), null /* revision */, null /* keyword mode */, null /* tag */); - parent.setChildren(new ICVSRemoteResource[] {file}); - return file; - } - - /** - * Constructor for RemoteFile that should be used when nothing is know about the - * file ahead of time. - * @param parent the folder that is the parent of the file - * @param workspaceSyncState the workspace state (use Update.STATE_NONE if unknown) - * @param name the name of the file - * @param revision revision of the file or null if the revision is not known - * @param keywordMode keyword mode of the file or null if the mode is not known - * @param tag tag for the file - */ - public RemoteFile(RemoteFolder parent, int workspaceSyncState, String name, String revision, KSubstOption keywordMode, CVSTag tag) { - this(parent, name, workspaceSyncState, getSyncBytes(name, revision, keywordMode, tag)); - } - - private static byte[] getSyncBytes(String name, String revision, KSubstOption keywordMode, CVSTag tag) { - if (revision == null) { - revision = ResourceSyncInfo.ADDED_REVISION; - } - if (keywordMode == null) { - keywordMode = KSubstOption.getDefaultTextMode(); - } - MutableResourceSyncInfo newInfo = new MutableResourceSyncInfo(name, revision); - newInfo.setKeywordMode(keywordMode); - newInfo.setTag(tag); - return newInfo.getBytes(); - } - - /* package */ RemoteFile(RemoteFolder parent, byte[] syncBytes) throws CVSException { - this(parent, Update.STATE_NONE, syncBytes); - } - - /* package */ RemoteFile(RemoteFolder parent, int workspaceSyncState, byte[] syncBytes) throws CVSException { - this(parent, ResourceSyncInfo.getName(syncBytes), workspaceSyncState, syncBytes); - } - - private RemoteFile(RemoteFolder parent, String name, int workspaceSyncState, byte[] syncBytes) { - super(parent, name); - this.syncBytes = syncBytes; - setWorkspaceSyncState(workspaceSyncState); - } - - /** - * @see ICVSResource#accept(ICVSResourceVisitor) - */ - public void accept(ICVSResourceVisitor visitor) throws CVSException { - visitor.visitFile(this); - } - - /** - * @see ICVSResource#accept(ICVSResourceVisitor, boolean) - */ - public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException { - visitor.visitFile(this); - } - - /** - * @see ICVSRemoteFile#getContents() - */ - public InputStream getContents(IProgressMonitor monitor) throws CVSException { - try { - return getStorage(monitor).getContents(); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - protected void fetchContents(IProgressMonitor monitor) throws TeamException { - try { - aboutToReceiveContents(getSyncBytes()); - internalFetchContents(monitor); - // If the fetch succeeded but no contents were cached from the server - // than we can assume that the remote file has no contents. - if (!isContentsCached()) { - setContents(new ByteArrayInputStream(new byte[0]), monitor); - } - } finally { - doneReceivingContents(); - } - } - - private void internalFetchContents(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$ - if (getRevision().equals(ResourceSyncInfo.ADDED_REVISION)) { - // The revision of the remote file is not known so we need to use the tag to get the status of the file - CVSTag tag = getSyncInfo().getTag(); - if (tag == null) tag = CVSTag.DEFAULT; - RemoteFolderMemberFetcher fetcher = new RemoteFolderMemberFetcher((RemoteFolder)getParent(), tag); - fetcher.updateFileRevisions(new ICVSFile[] { this }, Policy.subMonitorFor(monitor, 10)); - } - Session session = new Session(getRepository(), parent, false /* create backups */); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - IStatus status = Command.UPDATE.execute( - session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { - Update.makeTagOption(new CVSTag(getRevision(), CVSTag.VERSION)), - Update.IGNORE_LOCAL_CHANGES }, - new ICVSResource[] { this }, - null, - Policy.subMonitorFor(monitor, 80)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - } finally { - session.close(); - monitor.done(); - } - } - - /* - * @see ICVSRemoteFile#getLogEntry(IProgressMonitor) - */ - public ILogEntry getLogEntry(IProgressMonitor monitor) throws CVSException { - if (entry == null) { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$ - Session session = new Session(getRepository(), parent, false /* output to console */); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - try { - LogEntryListener listener = new LogEntryListener(); - IStatus status = Command.LOG.execute( - session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { - Log.makeRevisionOption(getRevision())}, - new ICVSResource[] { RemoteFile.this }, - new LogListener(RemoteFile.this, listener), - Policy.subMonitorFor(monitor, 90)); - ILogEntry[] entries = listener.getEntries(); - if (entries.length == 1) { - entry = entries[0]; - } - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - } finally { - monitor.done(); - } - } finally { - session.close(); - } - } - return entry; - } - - /** - * @see ICVSRemoteFile#getLogEntries() - */ - public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$ - Session session = new Session(getRepository(), parent, false /* output to console */); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); - try { - CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); - LogEntryListener listener = new LogEntryListener(); - IStatus status = Command.LOG.execute( - session, - Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS, - new ICVSResource[] { RemoteFile.this }, new LogListener(RemoteFile.this, listener), - Policy.subMonitorFor(monitor, 90)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - return listener.getEntries(); - } finally { - CVSProviderPlugin.getPlugin().setQuietness(quietness); - monitor.done(); - } - } finally { - session.close(); - } - } - - /** - * @see ICVSRemoteFile#getRevision() - */ - public String getRevision() { - try { - return ResourceSyncInfo.getRevision(syncBytes); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return ResourceSyncInfo.ADDED_REVISION; - } - } - - private KSubstOption getKeywordMode() { - try { - return ResourceSyncInfo.getKeywordMode(syncBytes); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return KSubstOption.getDefaultTextMode(); - } - } - - /* - * Get a different revision of the remote file. - * - * We must also create a new parent since the child is accessed through the parent from within CVS commands. - * Therefore, we need a new parent so that we can fecth the contents of the remote file revision - */ - public RemoteFile toRevision(String revision) { - RemoteFolder newParent = new RemoteFolder(null, parent.getRepository(), parent.getRepositoryRelativePath(), parent.getTag()); - RemoteFile file = new RemoteFile(newParent, getWorkspaceSyncState(), getName(), revision, getKeywordMode(), CVSTag.DEFAULT); - newParent.setChildren(new ICVSRemoteResource[] {file}); - return file; - } - - /** - * @see ICVSFile#getSyncInfo() - */ - public ResourceSyncInfo getSyncInfo() { - try { - return new ResourceSyncInfo(syncBytes); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return null; - } - } - - /** - * @see ICVSResource#getRemoteLocation(ICVSFolder) - */ - public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException { - return parent.getRemoteLocation(stopSearching) + Session.SERVER_SEPARATOR + getName(); - } - - /** - * Get the remote path for the receiver relative to the repository location path - */ - public String getRepositoryRelativePath() { - String parentPath = parent.getRepositoryRelativePath(); - return parentPath + Session.SERVER_SEPARATOR + getName(); - } - - /** - * Return the server root directory for the repository - */ - public ICVSRepositoryLocation getRepository() { - return parent.getRepository(); - } - - /** - * @see IManagedFile#setFileInfo(FileProperties) - */ - public void setSyncInfo(ResourceSyncInfo fileInfo, int modificationState) { - setSyncBytes(fileInfo.getBytes(),modificationState); - } - - /** - * Set the revision for this remote file. - * - * @param revision to associated with this remote file - */ - public void setRevision(String revision) throws CVSException { - syncBytes = ResourceSyncInfo.setRevision(syncBytes, revision); - } - - public InputStream getContents() throws CVSException { - if (!fetching) { - // Return the cached contents - if (isContentsCached()) { - try { - InputStream cached = getCachedContents(); - if (cached != null) { - return cached; - } - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - } - // There was nothing cached so return an empty stream. - // This is done to allow the contents to be fetched - // (i.e. update sends empty contents and real contents are sent back) - return new ByteArrayInputStream(new byte[0]); - } - - protected InputStream getCachedContents() throws TeamException { - if (isHandleCached()) { - RemoteFile file = (RemoteFile)getCachedHandle(); - if (file != null) { - byte[] newSyncBytes = file.getSyncBytes(); - if (newSyncBytes != null) { - // Make sure the sync bytes match the content that is being accessed - syncBytes = newSyncBytes; - } - } - } - return super.getCachedContents(); - } - - public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException { - try { - setContents(stream, monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - - /* - * @see ICVSFile#setReadOnly(boolean) - */ - public void setReadOnly(boolean readOnly) { - // RemoteFiles are always read only - } - - /* - * @see ICVSFile#isReadOnly() - */ - public boolean isReadOnly() { - return true; - } - - /* - * @see ICVSFile#getTimeStamp() - */ - public Date getTimeStamp() { - return getSyncInfo().getTimeStamp(); - } - - /* - * @see ICVSFile#setTimeStamp(Date) - */ - public void setTimeStamp(Date date) { - // RemoteFiles are not muttable so do not support timestamp changes - } - - /** - * @see ICVSFile#moveTo(String) - */ - public void copyTo(String mFile) { - // Do nothing - } - - /* - * @see IRemoteResource#members(IProgressMonitor) - */ - public ICVSRemoteResource[] members(IProgressMonitor progress) { - return new ICVSRemoteResource[0]; - } - - /* - * @see IRemoteResource#isContainer() - */ - public boolean isContainer() { - return false; - } - - /* - * @see ICVSResource#isFolder() - */ - public boolean isFolder() { - return false; - } - - /* - * @see ICVSResource#tag(CVSTag, LocalOption[], IProgressMonitor) - * - * The revision of the remote file is used as the base for the tagging operation - */ - public IStatus tag(final CVSTag tag, final LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - Session session = new Session(getRepository(), getParent(), true /* output to console */); - session.open(Policy.subMonitorFor(monitor, 10), true /* open for modification */); - try { - return Command.RTAG.execute( - session, - Command.NO_GLOBAL_OPTIONS, - localOptions, - new CVSTag(getRevision(), CVSTag.VERSION), - tag, - new ICVSRemoteResource[] { RemoteFile.this }, - Policy.subMonitorFor(monitor, 90)); - } finally { - session.close(); - } - } - - public boolean equals(Object target) { - if (this == target) - return true; - if (!(target instanceof RemoteFile)) - return false; - RemoteFile remote = (RemoteFile) target; - return super.equals(target) && remote.getRevision().equals(getRevision()); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkout(int) - */ - public void edit(int notifications, IProgressMonitor monitor) { - // do nothing - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#uncheckout() - */ - public void unedit(IProgressMonitor monitor) { - // do nothing - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#notificationCompleted() - */ - public void notificationCompleted() { - // do nothing - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getPendingNotification() - */ - public NotifyInfo getPendingNotification() { - return null; - } - - /** - * @see RemoteResource#forTag(ICVSRemoteFolder, CVSTag) - */ - public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tag) { - return new RemoteFile((RemoteFolder)parent, getWorkspaceSyncState(), getName(), getRevision(), getKeywordMode(), tag); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSRemoteResource#forTag(org.eclipse.team.internal.ccvs.core.CVSTag) - */ - public ICVSRemoteResource forTag(CVSTag tag) { - RemoteFolderTree remoteFolder = new RemoteFolderTree(null, getRepository(), - ((ICVSRemoteFolder)getParent()).getRepositoryRelativePath(), - tag); - RemoteFile remoteFile = (RemoteFile)forTag(remoteFolder, tag); - remoteFolder.setChildren(new ICVSRemoteResource[] { remoteFile }); - return remoteFile; - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#committed(org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo) - */ - public void checkedIn(String info, boolean commit) { - // do nothing - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isEdited() - */ - public boolean isEdited() { - return false; - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes() - */ - public byte[] getSyncBytes() { - return syncBytes; - } - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setSyncBytes(byte[]) - */ - public void setSyncBytes(byte[] syncBytes, int modificationState) { - if (fetching) { - RemoteFile file = (RemoteFile)getCachedHandle(); - if (file == null) { - cacheHandle(); - } else if (file != this) { - file.setSyncBytes(syncBytes, modificationState); - } - } - this.syncBytes = syncBytes; - } - - public String toString() { - return super.toString() + " " + getRevision(); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.IRemoteResource#getComment() - */ - public String getComment() throws CVSException { - ILogEntry entry = getLogEntry(new NullProgressMonitor()); - return entry.getComment(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.IRemoteResource#getContentIdentifier() - */ - public String getContentIdentifier() { - return getRevision(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.sync.IRemoteResource#getCreatorDisplayName() - */ - public String getCreatorDisplayName() throws CVSException { - ILogEntry entry = getLogEntry(new NullProgressMonitor()); - return entry.getAuthor(); - } - - /** - * Callback which indicates that the remote file is about to receive contents that should be cached - * @param entryLine - */ - public void aboutToReceiveContents(byte[] entryLine) { - setSyncBytes(entryLine, ICVSFile.CLEAN); - fetching = true; - } - - /** - * The contents for the file have already been provided. - */ - public void doneReceivingContents() { - fetching = false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ResourceVariant#isContentsCached() - */ - public boolean isContentsCached() { - // Made public for use by FileContentCachingService - return super.isContentsCached(); - } - - /** - * Cache the contents of the given IFile as the contents for this remote file handle. - * The caller must ensure that the local file is mapped to the same revision and is - * not modified since it was loaded from CVS. - * @param file - * @throws CoreException - * @throws TeamException - */ - public void setContents(IFile file, IProgressMonitor monitor) throws TeamException, CoreException { - setContents(file.getContents(), monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setExecutable(boolean) - */ - public void setExecutable(boolean executable) throws CVSException { - // remote files are never executable - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isExecutable() - */ - public boolean isExecutable() throws CVSException { - // remote files are always not executable - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java deleted file mode 100644 index 9c314ade3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java +++ /dev/null @@ -1,615 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener; -import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.*; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class provides the implementation of ICVSRemoteFolder - * - * The parent of the RemoteFolder represents the folders parent in a local configuration. - * For instance, the parent may correspond to the remote parent or may be a folder in the - * same repository that has no physical relationship to the RemoteFolder (resulting from the use - * of a module definition, for instance). A RemoteFolder may not have a parent, indicating that it is - * the root of the local configuration it represents. - * - * A RemoteFolder has the following: - * A name in the folder's local configuration - * - */ -public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, ICVSFolder { - - protected static final int CHILD_DOES_NOT_EXIST = 1000; - - protected FolderSyncInfo folderInfo; - private ICVSRemoteResource[] children; - private ICVSRepositoryLocation repository; - - public static RemoteFolder fromBytes(IResource local, byte[] bytes) throws CVSException { - Assert.isNotNull(bytes); - Assert.isTrue(local.getType() != IResource.FILE); - FolderSyncInfo syncInfo = FolderSyncInfo.getFolderSyncInfo(bytes); - return new RemoteFolder(null, local.getName(), KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag(), syncInfo.getIsStatic()); - } - - /** - * Constructor for RemoteFolder. - */ - public RemoteFolder(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) { - this(parent, - repositoryRelativePath == null ? "" : Util.getLastSegment(repositoryRelativePath), //$NON-NLS-1$ - repository, - repositoryRelativePath, - tag, - false); - } - - public RemoteFolder(RemoteFolder parent, String name, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag, boolean isStatic) { - super(parent, name); - if (repository != null) { - this.folderInfo = new FolderSyncInfo(repositoryRelativePath.toString(), repository.getLocation(), tag, isStatic); - } - this.repository = repository; - } - - /** - * @see ICVSResource#accept(ICVSResourceVisitor) - */ - public void accept(ICVSResourceVisitor visitor) throws CVSException { - visitor.visitFolder(this); - } - - /** - * @see ICVSResource#accept(ICVSResourceVisitor, boolean) - */ - public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException { - visitor.visitFolder(this); - ICVSResource[] resources; - if (recurse) { - resources = members(ICVSFolder.ALL_MEMBERS); - } else { - resources = members(ICVSFolder.FILE_MEMBERS); - } - for (int i = 0; i < resources.length; i++) { - resources[i].accept(visitor, recurse); - } - } - - /* - * @see ICVSRemoteResource#exists(IProgressMonitor) - */ - public boolean exists(IProgressMonitor monitor) throws TeamException { - try { - members(monitor); - return true; - } catch (CVSException e) { - if (e.getStatus().getCode() == CVSStatus.DOES_NOT_EXIST) { - return false; - } else { - throw e; - } - } - } - - /* - * Check whether the given resource is a child of the receiver remotely - */ - protected boolean exists(ICVSRemoteResource child, IProgressMonitor monitor) throws CVSException { - return exists(child, getTag(), monitor); - } - - /* - * Check whether the child exists for the given tag. This additional method is required because - * CVS will signal an error if a folder only contains subfolders when a tag is used. If we get this - * error and we're looking for a folder, we need to reissue the command without a tag. - */ - protected boolean exists(final ICVSRemoteResource child, CVSTag tag, IProgressMonitor monitor) throws CVSException { - final IProgressMonitor progress = Policy.monitorFor(monitor); - progress.beginTask(Policy.bind("RemoteFolder.exists"), 100); //$NON-NLS-1$ - try { - // Create the listener for remote files and folders - final boolean[] exists = new boolean[] {true}; - final IUpdateMessageListener listener = new IUpdateMessageListener() { - public void directoryInformation(ICVSFolder parent, String path, boolean newDirectory) { - exists[0] = true; - } - public void directoryDoesNotExist(ICVSFolder parent, String path) { - exists[0] = false; - } - public void fileInformation(int type, ICVSFolder parent, String filename) { - // We can't set exists true here as we may get a conflict on a deleted file. - // i.e. remote files are always communicated to the server as modified. - } - public void fileDoesNotExist(ICVSFolder parent, String filename) { - exists[0] = false; - } - }; - - // Build the local options - final List localOptions = new ArrayList(); - localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES); - if (tag != null && tag.getType() != CVSTag.HEAD) - localOptions.add(Update.makeTagOption(tag)); - - // Retrieve the children and any file revision numbers in a single connection - // Perform a "cvs -n update -d -r tagName folderName" with custom message and error handlers - boolean retry = false; - Session session = new Session(getRepository(), this, false /* output to console */); - session.open(Policy.subMonitorFor(progress, 10), false /* read-only */); - try { - IStatus status = Command.UPDATE.execute( - session, - new GlobalOption[] { Command.DO_NOT_CHANGE }, - (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]), - new ICVSResource[] { child }, new UpdateListener(listener), - Policy.subMonitorFor(progress, 70)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - CVSServerException e = new CVSServerException(status); - if (e.isNoTagException() && child.isContainer()) { - retry = true; - } else { - if (e.containsErrors()) { - throw e; - } - } - } - } finally { - session.close(); - } - - // We now know that this is an exception caused by a cvs bug. - // If the folder has no files in it (just subfolders) CVS does not respond with the subfolders... - // Workaround: Retry the request with no tag to get the directory names (if any) - if (retry) { - Policy.checkCanceled(progress); - return exists(child, null, Policy.subMonitorFor(progress, 20)); - } - return exists[0]; - } finally { - progress.done(); - } - } - - /** - * @see ICVSRemoteFolder#getMembers() - */ - public ICVSRemoteResource[] getMembers(IProgressMonitor monitor) throws TeamException { - return getMembers(getTag(), monitor); - } - - /** - * This method gets the members for a given tag and returns them. - * During the execution of this method, the instance variable children - * will be used to contain the children. However, the variable is reset - * and the result returned. Thus, instances of RemoteFolder do not - * persist the children. Subclasses (namely RemoteFolderTree) may - * persist the children. - */ - protected ICVSRemoteResource[] getMembers(CVSTag tag, IProgressMonitor monitor) throws CVSException { - // Fetch the children - RemoteFolderMemberFetcher fetcher = new RemoteFolderMemberFetcher(this, tag); - fetcher.fetchMembers(Policy.monitorFor(monitor)); - // children is assigned in the InternalRemoteFolderMembersFetcher - return children; - } - - /** - * @see ICVSFolder#members(int) - */ - public ICVSResource[] members(int flags) throws CVSException { - final List result = new ArrayList(); - ICVSRemoteResource[] resources = getChildren(); - if (children == null) { - return new ICVSResource[0]; - } - // RemoteFolders never have phantom members - if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == 1) { - return new ICVSResource[0]; - } - boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0)); - boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0)); - boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0)); - boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0)); - boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0); - for (int i = 0; i < resources.length; i++) { - ICVSResource cvsResource = resources[i]; - if ((includeFiles && ( ! cvsResource.isFolder())) - || (includeFolders && (cvsResource.isFolder()))) { - boolean isManaged = cvsResource.isManaged(); - boolean isIgnored = cvsResource.isIgnored(); - if ((isManaged && includeManaged)|| (isIgnored && includeIgnored) - || ( ! isManaged && ! isIgnored && includeUnmanaged)) { - result.add(cvsResource); - } - - } - } - return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]); - } - - /** - * @see ICVSFolder#getFolder(String) - */ - public ICVSFolder getFolder(String name) throws CVSException { - if (name.equals(Session.CURRENT_LOCAL_FOLDER) || name.equals(Session.CURRENT_LOCAL_FOLDER + Session.SERVER_SEPARATOR)) - return this; - ICVSResource child = getChild(name); - if (child.isFolder()) - return (ICVSFolder)child; - throw new CVSException(IStatus.ERROR, CHILD_DOES_NOT_EXIST, Policy.bind("RemoteFolder.invalidChild", name, getName())); //$NON-NLS-1$ - } - - /** - * @see ICVSFolder#getFile(String) - */ - public ICVSFile getFile(String name) throws CVSException { - ICVSResource child = getChild(name); - if (!child.isFolder()) - return (ICVSFile)child; - throw new CVSException(IStatus.ERROR, CHILD_DOES_NOT_EXIST, Policy.bind("RemoteFolder.invalidChild", name, getName())); //$NON-NLS-1$ - } - - public LocalOption[] getLocalOptions() { - return Command.NO_LOCAL_OPTIONS; - } - - public String getRepositoryRelativePath() { - // The REPOSITORY property of the folder info is the repository relative path - return getFolderSyncInfo().getRepository(); - } - - /** - * @see ICVSResource#getRelativePath(ICVSFolder) - */ - public String getRelativePath(ICVSFolder ancestor) throws CVSException { - // Check to see if the receiver is the ancestor - if (ancestor == this) return Session.CURRENT_LOCAL_FOLDER; - // Otherwise, we need a parent to continue - if (parent == null) { - throw new CVSException(Policy.bind("RemoteFolder.invalidChild", getName(), ancestor.getName())); //$NON-NLS-1$ - } - return super.getRelativePath(ancestor); - } - - public ICVSRepositoryLocation getRepository() { - return repository; - } - - /** - * @see ICVSRemoteFolder#isExpandable() - */ - public boolean isExpandable() { - return true; - } - - /** - * @see ICVSResource#isFolder() - */ - public boolean isFolder() { - return true; - } - - /** - * @see ICVSFolder#childExists(String) - */ - public boolean childExists(String path) { - try { - return getChild(path) != null; - } catch (CVSException e) { - return false; - } - } - - /** - * @see ICVSFolder#getChild(String) - * - * This getChild is geared to work with the Command hierarchy. Therefore it only returns - * children that were previously fetched by a call to getMembers(). If the request child - * does not exist, an exception is thrown. - */ - public ICVSResource getChild(String path) throws CVSException { - if (path.equals(Session.CURRENT_LOCAL_FOLDER) || path.length() == 0) - return this; - if (path.indexOf(Session.SERVER_SEPARATOR) != -1) { - IPath p = new Path(null, path); - try { - return ((RemoteFolder)getChild(p.segment(0))).getChild(p.removeFirstSegments(1).toString()); - } catch (CVSException e) { - // regenerate the exception to give as much info as possible - throw new CVSException(IStatus.ERROR, CHILD_DOES_NOT_EXIST, Policy.bind("RemoteFolder.invalidChild", path, getName()));//$NON-NLS-1$ - } - } else { - ICVSRemoteResource[] children = getChildren(); - if (children == null) - throw new CVSException(IStatus.ERROR, CHILD_DOES_NOT_EXIST, Policy.bind("RemoteFolder.invalidChild", path, getName()));//$NON-NLS-1$ - for (int i=0;i 0) { - updateFileRevisions(remoteFiles, Policy.subMonitorFor(progress, 50)); - } else { - progress.worked(50); - } - } catch (CVSServerException e) { - if ( ! e.isNoTagException() && e.containsErrors()) - throw e; - if (tag == null) - throw e; - // we now know that this is an exception caused by a cvs bug. - // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders... - // workaround: retry the request with no tag to get the directory names (if any) - Policy.checkCanceled(progress); - fetchMembers(Policy.subMonitorFor(progress, 50), null); - } finally { - progress.done(); - } - } - - protected IStatus performUpdate(IProgressMonitor progress, CVSTag tag) throws CVSException { - progress.beginTask(null, 100); - Session session = new Session(parentFolder.getRepository(), parentFolder, false /* output to console */); - session.open(Policy.subMonitorFor(progress, 10), false /* read-only */); - try { - // Build the local options - final List localOptions = new ArrayList(); - localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES); - if (tag != null) localOptions.add(Update.makeTagOption(tag)); - - return Command.UPDATE.execute( - session, - new GlobalOption[] { Command.DO_NOT_CHANGE }, - (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]), - new ICVSResource[] { parentFolder }, - new UpdateListener(this), - Policy.subMonitorFor(progress, 90)); - } finally { - session.close(); - } - } - - protected void updateFileRevisions(final ICVSFile[] files, IProgressMonitor monitor) throws CVSException { - - // Perform a "cvs status..." with a listener - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); - try { - CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); - Session session = new Session(parentFolder.getRepository(), parentFolder, false /* output to console */); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - IStatus status = Command.STATUS.execute( - session, - Command.NO_GLOBAL_OPTIONS, - Command.NO_LOCAL_OPTIONS, - files, - new StatusListener(this), - Policy.subMonitorFor(monitor, 90)); - performErrorCheck(status, Policy.bind("RemoteFolder.errorFetchingRevisions")); //$NON-NLS-1$ - // TODO: Ensure all files have a revision? - } finally { - session.close(); - } - } finally { - CVSProviderPlugin.getPlugin().setQuietness(quietness); - } - } - - private void performErrorCheck(IStatus status, String errorTitle) throws CVSException { - if (status.getCode() == CVSStatus.SERVER_ERROR) { - // Only throw the exception if no files or folders were found - if (folders.size() + files.size() == 0) { - throw new CVSServerException(status); - } else { - CVSProviderPlugin.log(new CVSServerException(status)); - } - } - if (!exists) { - throw new CVSException(new CVSStatus(CVSStatus.ERROR, CVSStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", this.parentFolder.getRepositoryRelativePath()))); //$NON-NLS-1$ - } - - // Report any internal exceptions that occured fetching the members - if ( ! exceptions.isEmpty()) { - if (exceptions.size() == 1) { - throw (CVSException)exceptions.get(0); - } else { - MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, errorTitle, null); - for (int i = 0; i < exceptions.size(); i++) { - multi.merge(((CVSException)exceptions.get(i)).getStatus()); - } - throw new CVSException(multi); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#directoryInformation(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, boolean) - */ - public void directoryInformation(ICVSFolder commandRoot, String stringPath, boolean newDirectory) { - try { - IPath path = this.parentFolder.getRelativePathFromRootRelativePath(commandRoot, new Path(null, stringPath)); - if (path.segmentCount() == 1) { - String pathName = path.lastSegment(); - if (!pathName.equals(".")) { //$NON-NLS-1$ - recordFolder(path.lastSegment()); - } - } - } catch (CVSException e) { - exceptions.add(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#directoryDoesNotExist(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String) - */ - public void directoryDoesNotExist(ICVSFolder parent, String stringPath) { - try { - IPath path = this.parentFolder.getRelativePathFromRootRelativePath(parent, new Path(null, stringPath)); - if (path.isEmpty()) { - parentDoesNotExist(); - } - } catch (CVSException e) { - exceptions.add(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#fileInformation(int, org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String) - */ - public void fileInformation(int type, ICVSFolder parent, String filename) { - try { - IPath filePath = new Path(null, filename); - filePath = this.parentFolder.getRelativePathFromRootRelativePath(parent, filePath); - if( filePath.segmentCount() == 1 ) { - String properFilename = filePath.lastSegment(); - recordFile(properFilename); - } - } catch (CVSException e) { - exceptions.add(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#fileDoesNotExist(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String) - */ - public void fileDoesNotExist(ICVSFolder parent, String filename) { - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IStatusListener#fileStatus(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, java.lang.String) - */ - public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision) { - if (remoteRevision == IStatusListener.FOLDER_REVISION) - // Ignore any folders - return; - try { - ((RemoteFile)parentFolder.getChild(Util.getLastSegment(path))).setRevision(remoteRevision); - } catch (CVSException e) { - exceptions.add(e); - } - } - - /** - * This method is invoked for each child folder as the reponses are being recieved from - * the server. Default behavior is to record the folder for later retrieval using getChilren(). - * Subclasses may override but should invoke the inherited method to ensure the folder gets recorded. - * @param name the name of the child folder - */ - protected RemoteFolder recordFolder(String name) { - RemoteFolder folder = new RemoteFolder( - parentFolder, - parentFolder.getRepository(), - Util.appendPath(parentFolder.getRepositoryRelativePath(), name), - tag); - folders.add(folder); - return folder; - } - - /** - * This method is invoked for each child file as the reponses are being recieved from - * the server. Default behavior is to record the file for later retrieval using getChildren(). - * Subclasses may override but should invoke the inherited method to ensure the file gets recorded. - * This is important because the file revisions for any files are fetched subsequent to the fecthing - * of the children. - * @param name the name of the child folder - */ - protected RemoteFile recordFile(String name) { - RemoteFile file = new RemoteFile( - parentFolder, - Update.STATE_NONE, - name, - null, /* revision unknown */ - null, /* keyword mode unknown */ - tag); - files.add(file); - return file; - } - - /** - * This method is invoked to indicate that the parent beig queried for children - * does not exist. Subclasses may override to get early notification of this but - * should still invoke the inherited method. - */ - protected void parentDoesNotExist() { - exists = false; - } - - /** - * Update the parent folder such that it's children are the - * children that have been fecthed by the reciever. - */ - protected void updateParentFolderChildren() { - parentFolder.setChildren(getFetchedChildren()); - } - - /** - * Return the child files fetched from the server. - * @return - */ - protected ICVSFile[] getFiles() { - return (ICVSFile[]) files.toArray(new ICVSFile[files.size()]); - } - - /** - * Return an array of all fecthed children. - * @return - */ - public ICVSRemoteResource[] getFetchedChildren() { - ICVSRemoteResource[] resources = new ICVSRemoteResource[folders.size() + files.size()]; - int count = 0; - for (Iterator iter = folders.iterator(); iter.hasNext();) { - ICVSRemoteResource resource = (ICVSRemoteResource) iter.next(); - resources[count++] = resource; - } - for (Iterator iter = files.iterator(); iter.hasNext();) { - ICVSRemoteResource resource = (ICVSRemoteResource) iter.next(); - resources[count++] = resource; - } - return resources; - } - -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java deleted file mode 100644 index ec103d092..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.client.Update; - -/** - * This specialized remote folder supports the creation of a cached sandbox. - */ -public class RemoteFolderSandbox extends RemoteFolder { - - public RemoteFolderSandbox(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) { - super(parent, repository, repositoryRelativePath, tag); - setChildren(new ICVSRemoteResource[0]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getFile(java.lang.String) - */ - public ICVSFile getFile(String name) throws CVSException { - try { - return super.getFile(name); - } catch (CVSException e) { - if (e.getStatus().getCode() == CHILD_DOES_NOT_EXIST) { - IPath path = new Path(null, name); - String fileName = path.lastSegment(); - RemoteFolderSandbox parent = getFolder(path); - RemoteFile file = new RemoteFile(parent, Update.STATE_NONE, fileName, null, null, getTag()); - parent.addChild(file); - return file; - } - throw e; - } - } - - private void addChild(RemoteResource resource) { - ICVSRemoteResource[] children = getChildren(); - ICVSRemoteResource[] newChildren = new ICVSRemoteResource[children.length + 1]; - System.arraycopy(children, 0, newChildren, 0, children.length); - newChildren[children.length] = resource; - setChildren(newChildren); - } - - private RemoteFolderSandbox getFolder(IPath path) throws CVSException { - IPath parentPath = path.removeLastSegments(1); - String parentString; - if (parentPath.isEmpty()) { - parentString = Session.CURRENT_LOCAL_FOLDER; - } else { - parentString = path.removeLastSegments(1).toString(); - } - RemoteFolderSandbox parent = (RemoteFolderSandbox)getFolder(parentString); - return parent; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getFolder(java.lang.String) - */ - public ICVSFolder getFolder(String name) throws CVSException { - try { - return super.getFolder(name); - } catch (CVSException e) { - if (e.getStatus().getCode() == CHILD_DOES_NOT_EXIST) { - IPath path = new Path(null, name); - RemoteFolderSandbox parent = getFolder(path); - String repoPath = new Path(null, getRepositoryRelativePath()).append(name).removeTrailingSeparator().toString(); - RemoteFolderSandbox folder = new RemoteFolderSandbox(parent, getRepository(), repoPath, getTag()); - parent.addChild(folder); - return folder; - } - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.RemoteFolder#getMembers(org.eclipse.core.runtime.IProgressMonitor) - */ - public ICVSRemoteResource[] getMembers(IProgressMonitor monitor) throws TeamException { - return getChildren(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java deleted file mode 100644 index e98a48f8d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; - -/** - * Whereas the RemoteFolder class provides access to a remote hierarchy using - * lazy retrieval via getMembers(), the RemoteFolderTree will force - * a recursive retrieval of the remote hierarchy in one round trip. - */ -public class RemoteFolderTree extends RemoteFolder { - - public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) { - super(parent, repository, repositoryRelativePath, tag); - } - - public RemoteFolderTree(RemoteFolder parent, String name, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) { - super(parent, name, repository, repositoryRelativePath, tag, false); - } - - /* - * Override of inherited method which persists the children - */ - public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException { - if (getChildren() == null) - setChildren(super.getMembers(tagName, monitor)); - return getChildren(); - } - - /* - * This method is public to allow access by the RemoteFolderTreeBuilder utility class. - * No other external classes should use this method. - */ - public void setChildren(ICVSRemoteResource[] children) { - super.setChildren(children); - } - - /* - * @see ICVSFolder#acceptChildren(ICVSResourceVisitor) - */ - public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException { - ICVSRemoteResource[] children = getChildren(); - if (children == null) return; - for (int i=0; i 1) { - // XXX This is an error condition that needs to be reported - } - - // An alias expands to one or more modules or paths - List expansions = new ArrayList(10); - expansions.add(next); - while (tokenizer.hasMoreTokens()) - expansions.add(tokenizer.nextToken()); - - moduleAliases.put(moduleName, expansions.toArray(new String[expansions.size()])); - modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true)); - - } else { - - // The module definition may have a leading directory which can be followed by some files - if (!(next.charAt(0) == '&')) { - String directory = next; - List files = new ArrayList(); - while (tokenizer.hasMoreTokens() && (next.charAt(0) != '&')) { - next = tokenizer.nextToken() ; - if ((next.charAt(0) != '&')) - files.add(next); - } - RemoteModule remoteModule = new RemoteModule(moduleName, null, repository, directory, localOptions, tag, ! files.isEmpty()); - modules.put(moduleName, remoteModule); - if ( ! files.isEmpty()) { - ICVSRemoteResource[] children = new ICVSRemoteResource[files.size()]; - for (int j = 0; j < children.length; j++) { - children[j] = new RemoteFile(remoteModule, Update.STATE_NONE, (String)files.get(j), null, null, tag); - remoteModule.setChildren(children); - } - } - } else { - modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true)); - } - - // Record any referenced modules so that can be cross-referenced below - if (next.charAt(0) == '&') { - List children = new ArrayList(10); - children.add(next); - while (tokenizer.hasMoreTokens()) - children.add(tokenizer.nextToken()); - referencedModulesTable.put(moduleName, children.toArray(new String[children.size()])); - } - } - } - - // Second pass: Cross reference aliases to modules - // XXX Aliases can reference other aliases which confuses the expansion! - Iterator iter = moduleAliases.keySet().iterator(); - while (iter.hasNext()) { - String moduleName = (String)iter.next(); - RemoteModule module = (RemoteModule)modules.get(moduleName); - String[] expansion = (String[])moduleAliases.get(moduleName); - List referencedFolders = new ArrayList(); - boolean expandable = true; - for (int i = 0; i < expansion.length; i++) { - if (expansion[i].charAt(0) == '!') { - // XXX Unsupported for now - expandable = false; - } else { - IPath path = new Path(null, expansion[i]); - if (path.segmentCount() > 1) { - // XXX Unsupported for now - expandable = false; - } else { - RemoteModule child = (RemoteModule)modules.get(expansion[i]); - if (child == null) { - referencedFolders.add(new RemoteFolder(null, repository, path.toString(), tag)); - } else { - // Need to check if the child is a module alias - if (child.isAlias()) { - // XXX Unsupported for now - expandable = false; - } else { - referencedFolders.add(child); - } - } - } - } - } - if (expandable) { - //TODO: Make module static?? - module.setChildren((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()])); - } else { - module.setExpandable(false); - } - } - - // Third pass: Cross reference remote modules where necessary - iter = modules.keySet().iterator(); - while (iter.hasNext()) { - String moduleName = (String)iter.next(); - String[] children = (String[])referencedModulesTable.get(moduleName); - if (children != null) { - RemoteModule module = (RemoteModule)modules.get(moduleName); - List referencedFolders = new ArrayList(); - boolean expandable = true; - for (int i = 0; i < children.length; i++) { - RemoteModule child = (RemoteModule)modules.get(children[i].substring(1)); - if (child == null) { - // invalid module definition - expandable = false; - } else if (child.isAlias()) { - // Include alias children in-line - expandable = false; -// referencedFolders.addAll(Arrays.asList(child.getChildren())); - } else { - // XXX not expandable if child has local directory option (-d) - if (Command.findOption(child.getLocalOptions(), "-d") != null) { //$NON-NLS-1$ - expandable = false; - } else { - referencedFolders.add(child); - } - } - } - if (expandable) { - module.setReferencedModules((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()])); - } else { - module.setExpandable(false); - } - } - } - - return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]); - } - - public RemoteModule(String label, RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, LocalOption[] localOptions, CVSTag tag, boolean isStatic) { - super(parent, - label, - repository, - repositoryRelativePath == null ? FolderSyncInfo.VIRTUAL_DIRECTORY : repositoryRelativePath, - tag, - isStatic); - this.localOptions = localOptions; - this.label = label; - this.expandable = true; - } - - public LocalOption[] getLocalOptions() { - return localOptions; - } - /* - * Override of inherited getMembers in order to combine the physical members with any referenced modules - */ - public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException { - - if ( ! expandable) return new ICVSRemoteResource[0]; - - ICVSRemoteResource[] physicalChildren; - if ( folderInfo.getIsStatic()) { - physicalChildren = getChildren(); - } else { - physicalChildren = super.getMembers(tagName, monitor); - } - ICVSRemoteResource[] allChildren; - if (referencedModules != null && referencedModules.length > 0) { - if (physicalChildren == null) { - allChildren = referencedModules; - } else { - // Combine two sets of children - allChildren = new ICVSRemoteResource[physicalChildren.length + referencedModules.length]; - for (int i = 0; i < physicalChildren.length; i++) { - allChildren[i] = physicalChildren[i]; - } - for (int i = 0; i < referencedModules.length; i++) { - allChildren[i + physicalChildren.length] = referencedModules[i]; - } - } - } else if (physicalChildren != null) { - allChildren = physicalChildren; - } else { - allChildren = new ICVSRemoteResource[0]; - } - return allChildren; - } - - private void setReferencedModules(ICVSRemoteResource[] referencedModules) { - this.referencedModules = referencedModules; - } - - public boolean isAlias() { - return Checkout.ALIAS.isElementOf(localOptions); - } - - /** - * @see ICVSRemoteFolder#isExpandable() - */ - public boolean isExpandable() { - return expandable; - } - - private void setExpandable(boolean expandable) { - this.expandable = expandable; - } - - /** - * @see ICVSRemoteFolder#forTag(CVSTag) - */ - public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName) { - RemoteModule r = new RemoteModule(label, (RemoteFolder)parent, getRepository(), folderInfo.getRepository(), localOptions, tagName, folderInfo.getIsStatic()); - r.setExpandable(expandable); - if (folderInfo.getIsStatic()) { - ICVSRemoteResource[] children = getChildren(); - if (children != null) { - List taggedChildren = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - ICVSRemoteResource resource = children[i]; - taggedChildren.add(((RemoteResource)resource).forTag(r, tagName)); - } - r.setChildren((ICVSRemoteResource[]) taggedChildren.toArray(new ICVSRemoteResource[taggedChildren.size()])); - } - } - if (referencedModules != null) { - List taggedModules = new ArrayList(referencedModules.length); - for (int i = 0; i < referencedModules.length; i++) { - RemoteModule module = (RemoteModule)referencedModules[i]; - taggedModules.add(module.forTag(r, tagName)); - } - r.setReferencedModules((ICVSRemoteResource[]) taggedModules.toArray(new ICVSRemoteResource[taggedModules.size()])); - } - return r; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder#isDefinedModule() - */ - public boolean isDefinedModule() { - return true; - } - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object arg0) { - if (arg0 instanceof RemoteModule) { - RemoteModule module = (RemoteModule) arg0; - return (getName().equals(module.getName()) && super.equals(module)); - } - return false; - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return super.hashCode() | getName().hashCode(); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getChild(java.lang.String) - */ - public ICVSResource getChild(String path) throws CVSException { - if (path.equals(Session.CURRENT_LOCAL_FOLDER) || path.length() == 0) - return this; - // If the path is one segment and it's a referenced module, return the module - // Note: the overriden method will extract the first segment from a multi segment - // path and re-invoke this method so we only need to check for one segment here - // and use the inherited method in the other cases - if (referencedModules != null) { - if (path.indexOf(Session.SERVER_SEPARATOR) == -1) { - for (int i=0;ifromBytes method on either - * RemoteFolder or RemoteFile. - * - * TODO: It would be nice to have a method on RmeoteResource to recreate the handles - * but the file requires the bytes for the parent folder since this folder may not - * exist locally. - * - * @return - */ - abstract public byte[] getSyncBytes(); - - public String toString() { - return "Remote " + (isContainer() ? "Folder: " : "File: ") + getName(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ResourceVariant#getUniquePath() - */ - public String getCachePath() { - ICVSRepositoryLocation location = getRepository(); - IPath path = new Path(null, location.getHost()); - path = path.append(location.getRootDirectory()); - path = path.append(parent.getRepositoryRelativePath()); - path = path.append(getName() + ' ' + getContentIdentifier()); - return path.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ResourceVariant#getCacheId() - */ - protected String getCacheId() { - return CVSProviderPlugin.ID; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#asBytes() - */ - public byte[] asBytes() { - return getSyncBytes(); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java deleted file mode 100644 index bd2b8f7db..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java +++ /dev/null @@ -1,490 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher; -import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter; - -/** - * This cache uses session properties to hold the bytes representing the sync - * info. In addition when the workbench closes or a project is closed, the dirty - * state for all cvs managed folders are persisted using the resource's plugin - * synchronizer. - */ -/*package*/ class SessionPropertySyncInfoCache extends SyncInfoCache implements ISaveParticipant { - - // key used on a folder to indicate that the resource sync has been cahced for it's children - private static final QualifiedName RESOURCE_SYNC_CACHED_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync-cached"); //$NON-NLS-1$ - private static final Object RESOURCE_SYNC_CACHED = new Object(); - - /*package*/ static final FileNameMatcher NULL_IGNORES = new FileNameMatcher(); - private static final FolderSyncInfo NULL_FOLDER_SYNC_INFO = new FolderSyncInfo("dummy-repo", "dummy-root", null, false); //$NON-NLS-1$ //$NON-NLS-2$ - - private QualifiedName FOLDER_DIRTY_STATE_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-dirty-state-cached"); //$NON-NLS-1$ - - // defer to the sychronizer if there is no sync info - // (i.e. for those cases where a deleted resource is recreated) - private SynchronizerSyncInfoCache synchronizerCache; - - /*package*/ SessionPropertySyncInfoCache(SynchronizerSyncInfoCache synchronizerCache) { - this.synchronizerCache = synchronizerCache; - try { - // this save participant is removed when the plugin is shutdown. - ResourcesPlugin.getWorkspace().addSaveParticipant(CVSProviderPlugin.getPlugin(), this); - ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer(); - synchronizer.add(FOLDER_DIRTY_STATE_KEY); - } catch (CoreException e) { - CVSProviderPlugin.log(e); - } - } - - /** - * If not already cached, loads and caches the folder ignores sync for the container. - * Folder must exist and must not be the workspace root. - * - * @param container the container - * @return the folder ignore patterns, or an empty array if none - */ - /*package*/ FileNameMatcher cacheFolderIgnores(IContainer container) throws CVSException { - // don't try to load if the information is already cached - FileNameMatcher matcher = (FileNameMatcher)safeGetSessionProperty(container, IGNORE_SYNC_KEY); - if (matcher == null) { - // read folder ignores and remember it - String[] ignores = SyncFileWriter.readCVSIgnoreEntries(container); - if (ignores == null) { - matcher = NULL_IGNORES; - } else { - matcher = new FileNameMatcher(ignores); - } - safeSetSessionProperty(container, IGNORE_SYNC_KEY, matcher); - } - return matcher; - } - - /*package*/ boolean isFolderSyncInfoCached(IContainer container) throws CVSException { - Object info = safeGetSessionProperty(container, FOLDER_SYNC_KEY); - if (info == null){ - // Defer to the synchronizer in case the folder was recreated - info = synchronizerCache.getCachedFolderSync(container); - } - return info != null; - } - - /*package*/ boolean isResourceSyncInfoCached(IContainer container) throws CVSException { - return safeGetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY) != null; - } - - /*package*/ void setResourceSyncInfoCached(IContainer container) throws CVSException { - safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, RESOURCE_SYNC_CACHED); - } - - /** - * Returns the folder sync info for the container; null if none. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container MUST ALREADY BE CACHED. - * - * @param container the container - * @return the folder sync info for the folder, or null if none. - * @see #cacheFolderSync - */ - FolderSyncInfo getCachedFolderSync(IContainer container) throws CVSException { - FolderSyncInfo info = (FolderSyncInfo)safeGetSessionProperty(container, FOLDER_SYNC_KEY); - if (info == null) { - // Defer to the synchronizer in case the folder was recreated - info = synchronizerCache.getCachedFolderSync(container); - if (info != null) { - safeSetSessionProperty(container, FOLDER_SYNC_KEY, info); - } - } - if (info == null) { - // There should be sync info but it was missing. Report the error - throw new CVSException(Policy.bind("EclipseSynchronizer.folderSyncInfoMissing", container.getFullPath().toString())); //$NON-NLS-1$ - } - if (info == NULL_FOLDER_SYNC_INFO) return null; - return info; - } - - /** - * Purges the cache recursively for all resources beneath the container. - * There must not be any pending uncommitted changes. - * @return the resources whose sync info was flushed - */ - /*package*/ IResource[] purgeCache(IContainer container, boolean deep) throws CVSException { - if (! container.exists()) return new IResource[0]; - try { - Set flushed = new HashSet(); - if (container.getType() != IResource.ROOT) { - safeSetSessionProperty(container, IGNORE_SYNC_KEY, null); - safeSetSessionProperty(container, FOLDER_SYNC_KEY, null); - safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, null); - flushed.add(container); - EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(container, RECOMPUTE_INDICATOR); - } - IResource[] members = container.members(); - for (int i = 0; i < members.length; i++) { - IResource resource = members[i]; - purgeResourceSyncCache(resource); - flushed.add(resource); - if (deep && resource.getType() != IResource.FILE) { - IResource[] flushedChildren = purgeCache((IContainer) resource, deep); - flushed.addAll(Arrays.asList(flushedChildren)); - } - } - return (IResource[]) flushed.toArray(new IResource[flushed.size()]); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /* package*/ void purgeResourceSyncCache(IResource resource) throws CVSException { - safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, null); - EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR); - } - - /** - * Sets the array of folder ignore patterns for the container, must not be null. - * Folder must exist and must not be the workspace root. - * - * @param container the container - * @param ignores the array of ignore patterns - */ - /*package*/ void setCachedFolderIgnores(IContainer container, String[] ignores) throws CVSException { - safeSetSessionProperty(container, IGNORE_SYNC_KEY, new FileNameMatcher(ignores)); - } - - - /** - * Sets the folder sync info for the container; if null, deletes it. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container need not have previously been cached. - * - * @param container the container - * @param info the new folder sync info - */ - void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException { - if (!container.exists()) return; - if (info == null) { - info = NULL_FOLDER_SYNC_INFO; - } - safeSetSessionProperty(container, FOLDER_SYNC_KEY, info); - // Ensure the synchronizer is clear for exiting resources - if (canModifyWorkspace && synchronizerCache.getCachedFolderSync(container) != null) { - synchronizerCache.setCachedFolderSync(container, null, true); - } - } - - /*package*/ void setDirtyIndicator(IResource resource, String indicator) throws CVSException { - if (resource.getType() == IResource.FILE) { - internalSetDirtyIndicator((IFile)resource, indicator); - } else { - internalSetDirtyIndicator((IContainer)resource, indicator); - } - } - /*package*/ String getDirtyIndicator(IResource resource) throws CVSException { - if (resource.getType() == IResource.FILE) { - return internalGetDirtyIndicator((IFile)resource); - } else { - return internalGetDirtyIndicator((IContainer)resource); - } - } - - private void internalSetDirtyIndicator(IFile file, String indicator) throws CVSException { - safeSetSessionProperty(file, IS_DIRTY, indicator); - } - - private String internalGetDirtyIndicator(IFile file) throws CVSException { - String di = (String)safeGetSessionProperty(file, IS_DIRTY); - if(di == null) { - di = RECOMPUTE_INDICATOR; - } - return di; - } - - private void internalSetDirtyIndicator(IContainer container, String indicator) throws CVSException { - safeSetSessionProperty(container, IS_DIRTY, indicator); - } - - private String internalGetDirtyIndicator(IContainer container) throws CVSException { - try { - String di = (String)safeGetSessionProperty(container, IS_DIRTY); - - // if the session property is not available then restore from persisted sync info. At this - // time the sync info is not flushed because we don't want the workspace to generate - // a delta. - if(di == null) { - byte [] diBytes = ResourcesPlugin.getWorkspace().getSynchronizer().getSyncInfo(FOLDER_DIRTY_STATE_KEY, container); - if(diBytes != null && !CVSProviderPlugin.getPlugin().crashOnLastRun()) { - di = new String(diBytes); - if(di.equals(NOT_DIRTY_INDICATOR)) { - di = NOT_DIRTY_INDICATOR; - } else if(di.equals(IS_DIRTY_INDICATOR)) { - di = IS_DIRTY_INDICATOR; - } else { - di = RECOMPUTE_INDICATOR; - } - } else { - di = RECOMPUTE_INDICATOR; - } - setDirtyIndicator(container, di); - } - return di; - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Flush dirty cache for the resource - */ - /*package*/ void flushDirtyCache(IResource resource) throws CVSException { - if (resource.exists()) { - if (resource.getType() == IResource.FILE) { - safeSetSessionProperty(resource, IS_DIRTY, null); - } else { - safeSetSessionProperty(resource, IS_DIRTY, null); - flushDirtyStateFromDisk((IContainer)resource); - } - } - } - - /** - * Method isSyncInfoLoaded returns true if all the sync info for the - * provided resources is loaded into the internal cache. - * - * @param resources - * @param i - * @return boolean - */ - /*package*/ boolean isSyncInfoLoaded(IContainer parent) throws CVSException { - if (parent.getFolder(new Path(SyncFileWriter.CVS_DIRNAME)).exists()) { - if (safeGetSessionProperty(parent, RESOURCE_SYNC_CACHED_KEY) == null) - return false; - if (safeGetSessionProperty(parent, FOLDER_SYNC_KEY) == null) - return false; -// if (parent.getSessionProperty(IGNORE_SYNC_KEY) == null) -// return false; - } - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getCachedSyncBytes(org.eclipse.core.resources.IResource) - */ - byte[] getCachedSyncBytes(IResource resource) throws CVSException { - byte[] bytes = (byte[])safeGetSessionProperty(resource, RESOURCE_SYNC_KEY); - if (bytes == null) { - // Defer to the synchronizer in case the file was recreated - bytes = synchronizerCache.getCachedSyncBytes(resource); - if (bytes != null) { - boolean genderChange = false; - if (resource.getType() == IResource.FILE) { - if (ResourceSyncInfo.isFolder(bytes)) { - genderChange = true; - } - } else if (!ResourceSyncInfo.isFolder(bytes)) { - genderChange = true; - } - if (genderChange) { - // Return null if it is a gender change - bytes = null; - } else { - safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, ResourceSyncInfo.convertFromDeletion(bytes)); - } - } - } - return bytes; - } - - Object safeGetSessionProperty(IResource resource, QualifiedName key) throws CVSException { - try { - return resource.getSessionProperty(key); - } catch (CoreException e) { - IStatus status = e.getStatus(); - if(status != null) { - int code = e.getStatus().getCode(); - if(code != IResourceStatus.RESOURCE_NOT_LOCAL || - code != IResourceStatus.RESOURCE_NOT_FOUND) { - // ignore error since a phantom would of been created - // and we can safely ignore these cases - return null; - } - } - // some other error we did not expect - throw CVSException.wrapException(e); - } - } - - void safeSetSessionProperty(IResource resource, QualifiedName key, Object value) throws CVSException { - try { - resource.setSessionProperty(key, value); - } catch (CoreException e) { - IStatus status = e.getStatus(); - if(status != null) { - int code = e.getStatus().getCode(); - if(code == IResourceStatus.RESOURCE_NOT_LOCAL || - code == IResourceStatus.RESOURCE_NOT_FOUND || - code == IResourceStatus.PROJECT_NOT_OPEN) { - // ignore error since a phantom would of been created - // and we can safely ignore these cases - } - // some other error we did not expect - throw CVSException.wrapException(e); - } - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setCachedSyncBytes(org.eclipse.core.resources.IResource, byte[]) - */ - void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException { - // Ensure that the sync bytes do not indicate a deletion - if (syncBytes != null && ResourceSyncInfo.isDeletion(syncBytes)) { - syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes); - } - // Put the sync bytes into the cache - safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, syncBytes); - // Ensure the synchronizer is clear - if (canModifyWorkspace && synchronizerCache.getCachedSyncBytes(resource) != null) { - synchronizerCache.setCachedSyncBytes(resource, null, canModifyWorkspace); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isDirtyCacheFlushed(org.eclipse.core.resources.IContainer) - */ - boolean isDirtyCacheFlushed(IContainer resource) throws CVSException { - if (resource.exists()) { - return getDirtyIndicator(resource) == RECOMPUTE_INDICATOR; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext) - */ - public void doneSaving(ISaveContext context) { - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext) - */ - public void prepareToSave(ISaveContext context) throws CoreException { - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext) - */ - public void rollback(ISaveContext context) { - } - - /* Called when the workbench is shutdown or projects are closed. The dirty state - * of folders is persisted, using sync info, so that at startup or project open - * the folder state can be quickly calculated. This is mainly for improving decorator - * performance. - * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext) - */ - public void saving(ISaveContext context) throws CoreException { - boolean fullSave = (context.getKind() == ISaveContext.FULL_SAVE); - boolean projectSave = (context.getKind() == ISaveContext.PROJECT_SAVE); - - if((projectSave || fullSave)) { - // persist all session properties for folders into sync info. - final ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer(); - - // traverse the workspace looking for CVS managed projects or just the - // specific projects being closed - IProject[] projects; - if(projectSave) { - projects = new IProject[1]; - projects[0] = context.getProject(); - } else { - projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - } - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - RepositoryProvider provider = RepositoryProvider.getProvider( - project, - CVSProviderPlugin.getTypeId()); - - // found a project managed by CVS, convert each session property on a - // folder to a sync object. - if (provider != null) { - project.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if(resource.getType() != IResource.FILE) { - String di = null; - try { - di = getDirtyIndicator(resource); - } catch (CVSException e) { - // continue traversal - CVSProviderPlugin.log(e); - } - if(di != null) { - synchronizer.setSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, di.getBytes()); - } - } - return true; - } - }); - } - } - } - } - - /* - * Called to clear the folder dirty state from the resource sync tree and stop persisting - * these values to disk. - */ - private void flushDirtyStateFromDisk(IContainer container) { - final ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer(); - try { - synchronizer.flushSyncInfo(FOLDER_DIRTY_STATE_KEY, container, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - CVSProviderPlugin.log(e); - } - } - - /* - * Flush all the cahced dirty state for the resource and its members. - */ - /* package*/ void purgeDirtyCache(IResource resource) throws CVSException { - if (! resource.exists()) return; - try { - if (resource.getType() != IResource.ROOT) { - safeSetSessionProperty(resource, IS_DIRTY, null); - } - if (resource.getType() != IResource.FILE) { - ResourcesPlugin.getWorkspace().getSynchronizer().flushSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, IResource.DEPTH_INFINITE); - IResource[] members = ((IContainer)resource).members(); - for (int i = 0; i < members.length; i++) { - purgeDirtyCache(members[i]); - } - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#cachesDirtyState() - */ - public boolean cachesDirtyState() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java deleted file mode 100644 index bdda48ce2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.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.team.internal.ccvs.core.resources; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; - -/** - * The low level cache provides the sync info as bytes - */ -/*package*/ abstract class SyncInfoCache { - - // the resources plugin synchronizer is used to cache and possibly persist. These - // are keys for storing the sync info. - /*package*/ static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$ - /*package*/ static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$ - /*package*/ static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore"); //$NON-NLS-1$ - - /*package*/ static final byte[][] EMPTY_RESOURCE_SYNC_INFOS = new byte[0][0]; - - /*package*/ static final QualifiedName IS_DIRTY = new QualifiedName(CVSProviderPlugin.ID, "is-dirty"); //$NON-NLS-1$ - /*package*/ static final String IS_DIRTY_INDICATOR = "d"; //$NON-NLS-1$ - /*package*/ static final String NOT_DIRTY_INDICATOR = "c"; //$NON-NLS-1$ - /*package*/ static final String RECOMPUTE_INDICATOR = "r"; //$NON-NLS-1$ - - /*package*/ static final IStatus STATUS_OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, Policy.bind("ok"), null); //$NON-NLS-1$ - - /** - * Returns the folder sync info for the container; null if none. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container MUST ALREADY BE CACHED. - *

              - * The canModifyWorkspace - * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for - * the given resource. A value of true indicates that the client - * holds a scheduling rule that encompasses the resource and the workspace is - * open for modification. - * - * @param container the container - * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer - * @return the folder sync info for the folder, or null if none. - * @see #cacheFolderSync - */ - /*package*/ abstract FolderSyncInfo getCachedFolderSync(IContainer container) throws CVSException; - - /** - * Sets the folder sync info for the container; if null, deletes it. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container need not have previously been - * cached. The canModifyWorkspace - * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for - * the given resource. A value of true indicates that the client - * holds a scheduling rule that encompasses the resource and the workspace is - * open for modification. - * - * @param container the container - * @param info the new folder sync info - * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer - */ - /*package*/ abstract void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException; - - /** - * Returns the resource sync info for the given resource. The resource sync - * info for the resource MUST ALREADY BE CACHED. - * - * @param resource the resource - * @return the bytes containing the resource's sync info - * @see #cacheResourceSyncForChildren - */ - /*package*/ abstract byte[] getCachedSyncBytes(IResource resource) throws CVSException; - - /** - * Sets the resource sync info for the resource; if null, deletes it. Parent - * must exist and must not be the workspace root. The resource sync info for - * the resource MUST ALREADY BE CACHED. The canModifyWorkspace - * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for - * the given resource. A value of true indicates that the client - * holds a scheduling rule that encompasses the resource and the workspace is - * open for modification. - * - * @param resource the resource - * @param syncBytes the bytes containing the new resource sync info - * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer - * @see #cacheResourceSyncForChildren - */ - /*package*/ abstract void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException; - - /*package*/ abstract String getDirtyIndicator(IResource resource) throws CVSException; - - /*package*/ abstract void setDirtyIndicator(IResource resource, String indicator) throws CVSException; - - /*package*/ abstract void flushDirtyCache(IResource resource) throws CVSException; - - /*package*/ abstract boolean isSyncInfoLoaded(IContainer parent) throws CVSException; - - /** - * Query the low level cache to see if the sync info for the provided - * container is loaded. - * - * @param container - * @return boolean - * @throws CVSException - */ - /*package*/ abstract boolean isFolderSyncInfoCached(IContainer container) throws CVSException; - - /** - * Query the low level cache to see if the sync info for the direct children - * of the provided container is loaded. - * - * @param container - * @return boolean - */ - /*package*/ abstract boolean isResourceSyncInfoCached(IContainer container) throws CVSException; - - /** - * Indicate to the low level cache that the sync info for all it's direct - * children have been set so they match what is on disk. - * - * @param container - */ - /*package*/ abstract void setResourceSyncInfoCached(IContainer container) throws CVSException; - - /** - * @param resource - * @return boolean - */ - /*package*/ abstract boolean isDirtyCacheFlushed(IContainer resource) throws CVSException; - - /** - * Return whether the cache also caches dirty state or recomputes it - * each time it is requested. - */ - public abstract boolean cachesDirtyState(); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java deleted file mode 100644 index c96c060ed..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java +++ /dev/null @@ -1,337 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.resources; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.ISynchronizer; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This cache uses session properties to hold the bytes representing the sync - * info - */ -/*package*/ class SynchronizerSyncInfoCache extends SyncInfoCache { - - // ap of sync bytes that were set without a scheduling rule - Map pendingCacheWrites = new HashMap(); - private static final Object BYTES_REMOVED = new byte[0]; - - public SynchronizerSyncInfoCache() { - getWorkspaceSynchronizer().add(FOLDER_SYNC_KEY); - getWorkspaceSynchronizer().add(RESOURCE_SYNC_KEY); - } - /** - * Return the Eclipse Workspace Synchronizer (from org.eclipse.core.resources) - */ - private ISynchronizer getWorkspaceSynchronizer() { - return ResourcesPlugin.getWorkspace().getSynchronizer(); - } - - /*package*/ void flush(IProject project) throws CVSException { - purgeCache(project, true); - } - - /** - * Method flush. - * @param folder - */ - /*package*/ void flush(IFolder folder) throws CVSException { - purgeCache(folder, false); - } - - /** - * Returns the folder sync info for the container; null if none. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container MUST ALREADY BE CACHED. - * - * @param container the container - * @return the folder sync info for the folder, or null if none. - * @see #cacheFolderSync - */ - FolderSyncInfo getCachedFolderSync(IContainer container) throws CVSException { - byte[] bytes = internalGetCachedSyncBytes(container); - if (bytes == null) return null; - return FolderSyncInfo.getFolderSyncInfo(bytes); - } - - boolean hasCachedFolderSync(IContainer container) throws CVSException { - return internalGetCachedSyncBytes(container) != null; - }; - - /* - * Retieve the cached sync bytes from the synchronizer. A null - * is returned if there are no cached sync bytes. - */ - private byte[] internalGetCachedSyncBytes(IContainer container) throws CVSException { - try { - return getWorkspaceSynchronizer().getSyncInfo(FOLDER_SYNC_KEY, container); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - /** - * Sets the folder sync info for the container; if null, deletes it. - * Folder must exist and must not be the workspace root. - * The folder sync info for the container need not have previously been - * cached. - * - * @param container the container - * @param info the new folder sync info - */ - void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException { - try { - if (info == null) { - if (container.exists() || container.isPhantom()) { - getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, container, IResource.DEPTH_ZERO); - } - } else { - getWorkspaceSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, container, info.getBytes()); - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getCachedSyncBytes(org.eclipse.core.resources.IResource) - */ - byte[] getCachedSyncBytes(IResource resource) throws CVSException { - try { - byte[] bytes; - if (pendingCacheWrites.containsKey(resource)) { - bytes = (byte[])pendingCacheWrites.get(resource); - if (bytes == BYTES_REMOVED) { - bytes = null; - } - } else { - bytes = getWorkspaceSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, resource); - } - if (bytes != null && resource.getType() == IResource.FILE) { - if (ResourceSyncInfo.isAddition(bytes)) { - // The local file has been deleted but was an addition - // Therefore, ignoe the sync bytes - bytes = null; - } else if (!ResourceSyncInfo.isDeletion(bytes)) { - // Ensure the bytes indicate an outgoing deletion - bytes = ResourceSyncInfo.convertToDeletion(bytes); - } - } - return bytes; - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setCachedSyncBytes(org.eclipse.core.resources.IResource, byte[]) - */ - void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException { - byte[] oldBytes = getCachedSyncBytes(resource); - try { - if (syncBytes == null) { - if (oldBytes != null) { - if (canModifyWorkspace) { - if (resource.exists() || resource.isPhantom()) { - getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, resource, IResource.DEPTH_ZERO); - } - pendingCacheWrites.remove(resource); - } else { - if (resource.exists() || resource.isPhantom()) { - pendingCacheWrites.put(resource, BYTES_REMOVED); - } - } - } - } else { - // ensure that the sync info is not already set to the same thing. - // We do this to avoid causing a resource delta when the sync info is - // initially loaded (i.e. the synchronizer has it and so does the Entries file - // Ignore the - if (oldBytes == null || !equals(syncBytes, oldBytes)) { - if (canModifyWorkspace) { - getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, syncBytes); - pendingCacheWrites.remove(resource); - } else { - pendingCacheWrites.put(resource, syncBytes); - } - } - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Convert file sync bytes to deletions to ensure proper comparison - */ - private boolean equals(byte[] syncBytes, byte[] oldBytes) throws CVSException { - if (!ResourceSyncInfo.isFolder(syncBytes)) { - syncBytes = ResourceSyncInfo.convertToDeletion(syncBytes); - } - if (!ResourceSyncInfo.isFolder(oldBytes)) { - try { - oldBytes = ResourceSyncInfo.convertToDeletion(oldBytes); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return false; - } - } - return Util.equals(syncBytes, oldBytes); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getDirtyIndicator(org.eclipse.core.resources.IResource) - */ - String getDirtyIndicator(IResource resource) throws CVSException { - if (resource.getType() == IResource.FILE) { - // a phantom file is dirty if it was managed before it was deleted - return getCachedSyncBytes(resource) != null ? - IS_DIRTY_INDICATOR : - NOT_DIRTY_INDICATOR; - } else { - return calculateDirtyCountForPhantomFolder((IContainer)resource); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setDirtyIndicator(org.eclipse.core.resources.IResource, java.lang.String) - */ - void setDirtyIndicator(IResource resource, String indicator) throws CVSException { - // We don't cache the dirty count for folders because it would cause - // resource delta's in the decorator thread and possible deadlock. - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#cachesDirtyState() - */ - public boolean cachesDirtyState() { - // We don't cache the dirty count for folders because it would cause - // resource delta's in the decorator thread and possible deadlock. - return false; - } - - /*package*/ void flushDirtyCache(IResource container) throws CVSException { - // Dirty state is not cached - } - - /*package*/ boolean isSyncInfoLoaded(IContainer parent) throws CVSException { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isResourceSyncInfoCached(org.eclipse.core.resources.IContainer) - */ - boolean isResourceSyncInfoCached(IContainer container) throws CVSException { - // the sync info is always cahced when using the synchronizer - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setResourceSyncInfoCached(org.eclipse.core.resources.IContainer) - */ - void setResourceSyncInfoCached(IContainer container) throws CVSException { - // do nothing - } - /** - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isFolderSyncInfoCached(org.eclipse.core.resources.IContainer) - */ - boolean isFolderSyncInfoCached(IContainer container) throws CVSException { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isDirtyCacheFlushed(org.eclipse.core.resources.IContainer) - */ - boolean isDirtyCacheFlushed(IContainer resource) throws CVSException { - return false; - } - - /* - * Calculate the dirty count for the given phantom folder, performing any - * necessary calculations on the childen as well - */ - private String calculateDirtyCountForPhantomFolder(IContainer parent) throws CVSException { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(parent); - if(getCachedFolderSync(parent) == null) { - return NOT_DIRTY_INDICATOR; - } - - String indicator = NOT_DIRTY_INDICATOR; - ICVSResource[] children = cvsFolder.members(ICVSFolder.MANAGED_MEMBERS | ICVSFolder.PHANTOM_MEMBERS); - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - // keep looking into phantom folders until a managed phantom file - // is found. - if (resource.isFolder()) { - indicator = calculateDirtyCountForPhantomFolder((IContainer)resource.getIResource()); - } else { - // Any non-existant managed files are dirty (outgoing deletion) - indicator = IS_DIRTY_INDICATOR; - break; - } - } - return indicator; - } - - /** - * @param root - * @param deep - */ - public void purgeCache(IContainer root, boolean deep) throws CVSException { - int depth = deep ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO; - try { - if (root.exists() || root.isPhantom()) { - getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, root, depth); - } - if (root.exists() || root.isPhantom()) { - getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, root, depth); - } - if (deep) { - IPath fullPath = root.getFullPath(); - for (Iterator iter = pendingCacheWrites.keySet().iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (fullPath.isPrefixOf(resource.getFullPath())) { - iter.remove(); - } - } - } else { - pendingCacheWrites.remove(root); - } - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - // Must have been deleted since we checked - return; - } - throw CVSException.wrapException(e); - } - - } - - public boolean isPhantom(IResource resource) { - return resource.isPhantom() || pendingCacheWrites.containsKey(resource); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java deleted file mode 100644 index 41ebfb14a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class represents the information in the CVS/Baserev file - */ -public class BaserevInfo { - private static final String BASEREV_PREFIX = "B"; //$NON-NLS-1$ - - private String name; - private String revision; - - public BaserevInfo(String entryLine) throws CVSException { - setEntryLine(entryLine); - } - - public BaserevInfo(String name, String revision) { - this.name = name; - this.revision = revision; - } - /** - * Return the entry line as it appears in the CVS/Baserev file - * @return String - */ - public String getEntryLine() { - StringBuffer result = new StringBuffer(); - result.append(BASEREV_PREFIX); - result.append(name); - result.append(ResourceSyncInfo.SEPARATOR); - result.append(revision); - result.append(ResourceSyncInfo.SEPARATOR); - return result.toString(); - } - private void setEntryLine(String entryLine) throws CVSException { - if(entryLine.startsWith(BASEREV_PREFIX)) { - entryLine = entryLine.substring(1); - } - String[] strings = Util.parseIntoSubstrings(entryLine, ResourceSyncInfo.SEPARATOR); - // Accept either a length of 2 or 3. If the length is 3, we ignore the last - // string as per the CVS spec. - if(strings.length != 2 && strings.length != 3) { - throw new CVSException(Policy.bind("BaseRevInfo.malformedEntryLine", entryLine)); //$NON-NLS-1$ - } - - name = strings[0]; - - if(name.length()==0) { - throw new CVSException(Policy.bind("BaseRevInfo.malformedEntryLine", entryLine)); //$NON-NLS-1$ - } - - revision = strings[1]; - - if(revision.length()==0) { - throw new CVSException(Policy.bind("BaseRevInfo.malformedEntryLine", entryLine)); //$NON-NLS-1$ - } - } - /** - * Returns the name. - * @return String - */ - public String getName() { - return name; - } - - /** - * Returns the revision. - * @return String - */ - public String getRevision() { - return revision; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java deleted file mode 100644 index b8fd7edd2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.ResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; - - -public class CVSBaseResourceVariantTree extends ResourceVariantByteStore { - public void dispose() { - // Do nothing - } - public byte[] getBytes(IResource resource) throws TeamException { - if (resource.getType() == IResource.FILE) { - // For a file, return the entry line - byte[] bytes = EclipseSynchronizer.getInstance().getSyncBytes(resource); - if (bytes != null) { - // Use the base sync info (i.e. no deletion or addition) - if (ResourceSyncInfo.isDeletion(bytes)) { - bytes = ResourceSyncInfo.convertFromDeletion(bytes); - } else if (ResourceSyncInfo.isAddition(bytes)) { - bytes = null; - } - } - return bytes; - } else { - // For a folder, return the folder sync info bytes - FolderSyncInfo info = EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource); - if (info == null) return null; - return info.getBytes(); - } - } - public boolean isVariantKnown(IResource resource) throws TeamException { - return getBytes(resource) != null; - } - public boolean flushBytes(IResource resource, int depth) throws TeamException { - throw new UnsupportedOperationException(); - } - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - throw new UnsupportedOperationException(); - } - public boolean deleteBytes(IResource resource) throws TeamException { - throw new UnsupportedOperationException(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.utils.SynchronizationCache#members(org.eclipse.core.resources.IResource) - */ - public IResource[] members(IResource resource) throws TeamException { - if(resource.getType() == IResource.FILE) { - return new IResource[0]; - } - return EclipseSynchronizer.getInstance().members((IContainer)resource); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java deleted file mode 100644 index 7bed719a1..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.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.team.internal.ccvs.core.syncinfo; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.PersistantResourceVariantByteStore; -import org.eclipse.team.core.variants.ResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.core.subscribers.DescendantResourceVariantByteStore; - -/** - * CVS sycnrhonization cache that ignores stale remote bytes - */ -public class CVSDescendantResourceVariantByteStore extends DescendantResourceVariantByteStore { - - public CVSDescendantResourceVariantByteStore(ResourceVariantByteStore baseCache, PersistantResourceVariantByteStore remoteCache) { - super(baseCache, remoteCache); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.DescendantSynchronizationCache#isDescendant(org.eclipse.core.resources.IResource, byte[], byte[]) - */ - protected boolean isDescendant(IResource resource, byte[] baseBytes, byte[] remoteBytes) throws TeamException { - if (resource.getType() != IResource.FILE) return true; - try { - return ResourceSyncInfo.isLaterRevisionOnSameBranch(remoteBytes, baseBytes); - } catch (CVSException e) { - throw TeamException.asTeamException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.helpers.SynchronizationCache#setSyncBytes(org.eclipse.core.resources.IResource, byte[]) - */ - public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { - boolean changed = super.setBytes(resource, bytes); - if (resource.getType() == IResource.FILE && getBytes(resource) != null && !parentHasSyncBytes(resource)) { - // Log a warning if there is no sync bytes available for the resource's - // parent but there is valid sync bytes for the child - CVSProviderPlugin.log(new TeamException(Policy.bind("ResourceSynchronizer.missingParentBytesOnSet", ((PersistantResourceVariantByteStore)getRemoteStore()).getSyncName().toString(), resource.getFullPath().toString()))); //$NON-NLS-1$ - } - return changed; - } - - /** - * Indicates whether the parent of the given local resource has sync bytes for its - * corresponding remote resource. The parent bytes of a remote resource are required - * (by CVS) to create a handle to the remote resource. - */ - protected boolean parentHasSyncBytes(IResource resource) throws TeamException { - if (resource.getType() == IResource.PROJECT) return true; - return (getBytes(resource.getParent()) != null); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#isVariantKnown(org.eclipse.core.resources.IResource) - */ - public boolean isVariantKnown(IResource resource) throws TeamException { - return ((PersistantResourceVariantByteStore)getRemoteStore()).isVariantKnown(resource); - } - - /* - * TODO: Could possibly be generalized and moved up - */ - public IStatus handleResourceChanges(IResource[] changedResources, boolean canModifyWorkspace) { - // IMPORTANT NOTE: This will throw exceptions if performed during the POST_CHANGE delta phase!!! - List errors = new ArrayList(); - for (int i = 0; i < changedResources.length; i++) { - IResource resource = changedResources[i]; - try { - if (!isInCVSProject(resource)) continue; - if (resource.getType() == IResource.FILE - && (resource.exists() || resource.isPhantom())) { - byte[] remoteBytes = getBytes(resource); - if (remoteBytes == null) { - if (isVariantKnown(resource)) { - // The remote is known not to exist. If the local resource is - // managed then this information is stale - if (getBaseStore().getBytes(resource) != null) { - if (canModifyWorkspace) { - flushBytes(resource, IResource.DEPTH_ZERO); - } else { - // The revision comparison will handle the stale sync bytes - // TODO: Unless the remote is known not to exist (see bug 52936) - } - } - } - } else { - byte[] localBytes = getBaseStore().getBytes(resource); - if (localBytes == null || !isDescendant(resource, localBytes, remoteBytes)) { - if (canModifyWorkspace) { - flushBytes(resource, IResource.DEPTH_ZERO); - } else { - // The remote byte store handles the stale sync bytes - } - } - } - } else if (resource.getType() == IResource.FOLDER) { - // If the base has sync info for the folder, purge the remote bytes - if (getBaseStore().getBytes(resource) != null && canModifyWorkspace) { - flushBytes(resource, IResource.DEPTH_ZERO); - } - } - } catch (TeamException e) { - errors.add(e); - } - } - for (Iterator iter = errors.iterator(); iter.hasNext();) { - TeamException e = (TeamException) iter.next(); - CVSProviderPlugin.log(e); - } - return Status.OK_STATUS; // TODO - } - - private boolean isInCVSProject(IResource resource) { - return RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) != null; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java deleted file mode 100644 index 394d0f21c..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.*; - -/** - * CVS Specific refresh operation - */ -public class CVSResourceVariantTree extends ResourceVariantTree { - - private CVSTag tag; - private boolean cacheFileContentsHint; - private CVSSyncTreeSubscriber subscriber; - - public CVSResourceVariantTree(ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint) { - super(cache); - this.tag = tag; - this.cacheFileContentsHint = cacheFileContentsHint; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.RefreshOperation#getSynchronizationCache() - */ - public ResourceVariantByteStore getByteStore() { - return super.getByteStore(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.RefreshOperation#getRemoteSyncBytes(org.eclipse.core.resources.IResource, org.eclipse.team.core.subscribers.ISubscriberResource) - */ - protected byte[] getBytes(IResource local, IResourceVariant remote) throws TeamException { - if (remote != null) { - return super.getBytes(local, remote); - } else { - if (local.getType() == IResource.FOLDER) { - // If there is no remote, use the local sync for the folder - return getBaseBytes((IContainer)local, getTag(local)); - } - return null; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.RefreshOperation#getRemoteChildren(org.eclipse.team.core.subscribers.ISubscriberResource, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResourceVariant[] fetchMembers(IResourceVariant remote, IProgressMonitor progress) throws TeamException { - ICVSRemoteResource[] children = remote != null ? (ICVSRemoteResource[])((RemoteResource)remote).members(progress) : new ICVSRemoteResource[0]; - IResourceVariant[] result = new IResourceVariant[children.length]; - for (int i = 0; i < children.length; i++) { - result[i] = (IResourceVariant)children[i]; - } - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.RefreshOperation#buildRemoteTree(org.eclipse.core.resources.IResource, int, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - // TODO: we are currently ignoring the depth parameter because the build remote tree is - // by default deep! - return (IResourceVariant)CVSWorkspaceRoot.getRemoteTree(resource, getTag(resource), cacheFileContentsHint, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTreeRefreshOperation#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IResource[] collectChanges(IResource local, - IResourceVariant remote, int depth, IProgressMonitor monitor) - throws TeamException { - return super.collectChanges(local, remote, depth, monitor); - } - - public IResource[] members(IResource resource) throws TeamException { - if (resource.getType() == IResource.FILE) { - return new IResource[0]; - } - // Must ensure that any shared folders are included - Set members = new HashSet(); - members.addAll(Arrays.asList(super.members(resource))); - try { - IResource[] localMembers = ((IContainer)resource).members(true); - for (int i = 0; i < localMembers.length; i++) { - IResource local = localMembers[i]; - if (local.getType() != IResource.FILE) { - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local); - if (folder.isCVSFolder()) { - members.add(local); - } - } - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - return (IResource[]) members.toArray(new IResource[members.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#roots() - */ - public IResource[] roots() { - return subscriber.roots(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#getResourceVariant(org.eclipse.core.resources.IResource) - */ - public IResourceVariant getResourceVariant(IResource resource) throws TeamException { - byte[] remoteBytes = getByteStore().getBytes(resource); - if (remoteBytes == null) { - // There is no remote handle for this resource - return null; - } else { - if (resource.getType() == IResource.FILE) { - byte[] parentBytes = getParentBytes(resource); - if (parentBytes == null) { - IProject project = resource.getProject(); - if (project.exists() && RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) { - CVSProviderPlugin.log(new CVSException( - Policy.bind("ResourceSynchronizer.missingParentBytesOnGet", getSyncName(getByteStore()).toString(), resource.getFullPath().toString()))); //$NON-NLS-1$ - // Assume there is no remote and the problem is a programming error - } - return null; - } - return RemoteFile.fromBytes(resource, remoteBytes, parentBytes); - } else { - return RemoteFolder.fromBytes(resource, remoteBytes); - } - } - } - - private String getSyncName(ResourceVariantByteStore cache) { - if (cache instanceof PersistantResourceVariantByteStore) { - return ((PersistantResourceVariantByteStore)cache).getSyncName().toString(); - } - return cache.getClass().getName(); - } - - - private byte[] getParentBytes(IResource resource) throws TeamException { - IContainer parent = resource.getParent(); - byte[] bytes = getByteStore().getBytes(parent); - if (bytes == null ) { - bytes = getBaseBytes(parent, getTag(resource)); - } - return bytes; - } - - private byte[] getBaseBytes(IContainer parent, CVSTag tag) throws CVSException { - byte[] bytes; - // Look locally for the folder bytes - ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor(parent); - FolderSyncInfo info = local.getFolderSyncInfo(); - if (info == null) { - bytes = null; - } else { - // Use the folder sync from the workspace and the tag from the store - FolderSyncInfo newInfo = new FolderSyncInfo(info.getRepository(), info.getRoot(), tag, false); - bytes = newInfo.getBytes(); - } - return bytes; - } - - private boolean hasLocalSyncInfo(IContainer folder) { - ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor(folder); - try { - return local.getFolderSyncInfo() != null; - } catch (CVSException e) { - // Say that there is sync info and let the failure occur elsewhere - return true; - } - } - - public CVSTag getTag(IResource resource) { - return tag; - } - - /** - * Dispose of the underlying byte store - */ - public void dispose() { - getByteStore().dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTree#setVariant(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant) - */ - protected boolean setVariant(IResource local, IResourceVariant remote) throws TeamException { - if (local.getType() == IResource.FOLDER && remote != null - && !hasLocalSyncInfo((IFolder)local) - && hasLocalSyncInfo(local.getParent())) { - // Manage the folder locally since folders exist in all versions, etc - // Use the info from the remote except get the tag from the locla parent - CVSTag tag = CVSWorkspaceRoot.getCVSFolderFor(local.getParent()).getFolderSyncInfo().getTag(); - FolderSyncInfo info = FolderSyncInfo.getFolderSyncInfo(remote.asBytes()); - FolderSyncInfo newInfo = new FolderSyncInfo(info.getRepository(), info.getRoot(), tag, info.getIsStatic()); - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IFolder)local); - cvsFolder.setFolderSyncInfo(newInfo); - } - boolean changed = super.setVariant(local, remote); - if (local.getType() == IResource.FILE && getByteStore().getBytes(local) != null && !parentHasSyncBytes(local)) { - // Log a warning if there is no sync bytes available for the resource's - // parent but there is valid sync bytes for the child - CVSProviderPlugin.log(new TeamException(Policy.bind("ResourceSynchronizer.missingParentBytesOnSet", getSyncName(getByteStore()), local.getFullPath().toString()))); //$NON-NLS-1$ - } - return changed; - } - - private boolean parentHasSyncBytes(IResource resource) throws TeamException { - if (resource.getType() == IResource.PROJECT) return true; - return getParentBytes(resource) != null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.caches.AbstractResourceVariantTree#collectedMembers(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IResource[]) - */ - protected IResource[] collectedMembers(IResource local, IResource[] members) throws TeamException { - // Look for resources that have sync bytes but are not in the resources we care about - IResource[] resources = getStoredMembers(local); - List children = new ArrayList(); - List changedResources = new ArrayList(); - children.addAll(Arrays.asList(members)); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (!children.contains(resource)) { - // These sync bytes are stale. Purge them - flushVariants(resource, IResource.DEPTH_INFINITE); - changedResources.add(resource); - } - } - return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]); - } - - /** - * Return all the members of that have resource variant information associated with them, - * such as members that are explicitly flagged as not having a resource variant. This list - * is used by the collection algorithm to flush variants for which there is no local and - * no remote. - * @param local the locla resource - * @return the local children that have resource variant information cached - * @throws TeamException - */ - private IResource[] getStoredMembers(IResource local) throws TeamException { - try { - if (local.getType() != IResource.FILE && (local.exists() || local.isPhantom())) { - IResource[] allChildren = ((IContainer)local).members(true /* include phantoms */); - List childrenWithSyncBytes = new ArrayList(); - for (int i = 0; i < allChildren.length; i++) { - IResource resource = allChildren[i]; - if (getByteStore().getBytes(resource) != null) { - childrenWithSyncBytes.add(resource); - } - } - return (IResource[]) childrenWithSyncBytes.toArray( - new IResource[childrenWithSyncBytes.size()]); - } - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } - return new IResource[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#refresh(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - IResource[] changedResources = null; - monitor.beginTask(null, 100); - // Wait while a build is running - // Initially wait for a short time and then increase the wait - // if the build is still running - int count = 0; - int waitTime = 10; - while (count < 15 - && (isJobInFamilyRunning(ResourcesPlugin.FAMILY_AUTO_BUILD) - || isJobInFamilyRunning(ResourcesPlugin.FAMILY_MANUAL_BUILD))) { - try { - Thread.sleep(waitTime); - } catch (InterruptedException e) { - // Conitinue - } - count++; - if (count >= 10) { - waitTime = 1000; - } else if (count >= 5) { - waitTime = 100; - } - Policy.checkCanceled(monitor); - } - try { - changedResources = super.refresh(resource, depth, Policy.subMonitorFor(monitor, 99)); - } catch (TeamException e) { - // Try to properly handle exceptions that are due to project modifications - // performed while the refresh was happening - if (!resource.getProject().isAccessible()) { - // The project is closed so silently skip it - return new IResource[0]; - } - throw e; - } finally { - monitor.done(); - } - if (changedResources == null) return new IResource[0]; - return changedResources; - } - - private boolean isJobInFamilyRunning(Object family) { - Job[] jobs = Platform.getJobManager().find(family); - if (jobs != null && jobs.length > 0) { - for (int i = 0; i < jobs.length; i++) { - Job job = jobs[i]; - if (job.getState() != Job.NONE) { - return true; - } - } - } - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java deleted file mode 100644 index 3eaf2718a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.core.BackgroundEventHandler; - -/** - * This class handles resources changes that are reported in deltas - * in a deferred manner (i.e. in a background job) - */ -public class DeferredResourceChangeHandler extends BackgroundEventHandler { - - public DeferredResourceChangeHandler() { - super(Policy.bind("DeferredResourceChangeHandler.0"), Policy.bind("DeferredResourceChangeHandler.1")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - private static final int IGNORE_FILE_CHANGED = 1; - private static final int RECREATED_CVS_RESOURCE = 2; - - private Set changedIgnoreFiles = new HashSet(); - private Set recreatedResources = new HashSet(); - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#processEvent(org.eclipse.team.core.subscribers.BackgroundEventHandler.Event, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void processEvent(Event event, IProgressMonitor monitor) throws TeamException { - int type = event.getType(); - switch (type) { - case IGNORE_FILE_CHANGED : - changedIgnoreFiles.add(event.getResource()); - case RECREATED_CVS_RESOURCE : - recreatedResources.add(event.getResource()); - } - } - - private IContainer[] getParents(Set files) { - Set parents = new HashSet(); - for (Iterator iter = files.iterator(); iter.hasNext();) { - IFile file = (IFile) iter.next(); - parents.add(file.getParent()); - } - return (IContainer[]) parents.toArray(new IContainer[parents.size()]); - } - - public void ignoreFileChanged(IFile file) { - queueEvent(new ResourceEvent(file, IGNORE_FILE_CHANGED, IResource.DEPTH_ZERO), false); - } - - /** - * The resource has been added and has sync info that has not been written to disk. - * Queue an event to ensure that the CVS directory files - * are written to disk. - * @param resource the recently add resource - */ - public void recreated(IResource resource) { - queueEvent(new ResourceEvent(resource, RECREATED_CVS_RESOURCE, IResource.DEPTH_ZERO), false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#dispatchEvents() - */ - protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { - // Handle ignore file changes - boolean workDone = !changedIgnoreFiles.isEmpty() || !recreatedResources.isEmpty(); - EclipseSynchronizer.getInstance().ignoreFilesChanged(getParents(changedIgnoreFiles)); - changedIgnoreFiles.clear(); - // Handle recreations by project to reduce locking granularity - Map recreations = getResourcesByProject((IResource[]) recreatedResources.toArray(new IResource[recreatedResources.size()])); - recreatedResources.clear(); - for (Iterator iter = recreations.values().iterator(); iter.hasNext();) { - List resources = (List) iter.next(); - try { - EclipseSynchronizer.getInstance().resourcesRecreated((IResource[]) resources.toArray(new IResource[resources.size()]), monitor); - } catch (CVSException e) { - // Log and continue - CVSProviderPlugin.log(e); - } - } - return workDone; - } - - private Map getResourcesByProject(IResource[] resources) { - Map result = new HashMap(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IProject project = resource.getProject(); - List projectResources = (List)result.get(project); - if (projectResources == null) { - projectResources = new ArrayList(); - result.put(project, projectResources); - } - projectResources.add(resource); - } - return result; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java deleted file mode 100644 index 13b5e41c7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java +++ /dev/null @@ -1,324 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Value (immutable) object that represents workspace state information about the contents of a - * folder that was retreived from a CVS repository. It is a specialized representation of the files from - * the CVS sub-directory that contain folder specific connection information (e.g. Root, Repository, Tag). - * - * @see ICVSFolder#getFolderSyncInfo() - */ -public class FolderSyncInfo { - - // The Repository value for virtual directories (i.e. local with no corresponding remote) - public static final String VIRTUAL_DIRECTORY = "CVSROOT/Emptydir"; //$NON-NLS-1$ - - // relative path of this folder in the repository, project1/folder1/folder2 - protected String repository; - - // :pserver:user@host:/home/user/repo - private String root; - - // sticky tag (e.g. version, date, or branch tag applied to folder) - private CVSEntryLineTag tag; - - // if true then it means only part of the folder was fetched from the repository, and CVS will not create - // additional files in that folder. - private boolean isStatic; - - /** - * Construct a folder sync object. - * - * @param repo the relative path of this folder in the repository, cannot be null. - * @param root the location of the repository, cannot be null. - * @param tag the tag set for the folder or null if there is no tag applied. - * @param isStatic to indicate is only part of the folder was fetched from the server. - */ - public FolderSyncInfo(String repo, String root, CVSTag tag, boolean isStatic) { - Assert.isNotNull(repo); - Assert.isNotNull(root); - this.repository = repo; - // intern the root so that caching of FolderSyncInfos for folders will use less space - this.root = root.intern(); - ensureRepositoryRelativeToRoot(); - this.isStatic = isStatic; - setTag(tag); - } - - /** - * Method ensureRepositoryRelativeToRoot. - */ - private void ensureRepositoryRelativeToRoot() { - String rootDir; - try { - rootDir = getRootDirectory(); - } catch (CVSException e) { - // Ignore the for now. Using the root will show the error to the user. - return; - } - if (repository.startsWith(rootDir)) { - repository = repository.substring(rootDir.length()); - } - if (repository.startsWith(ResourceSyncInfo.SEPARATOR)) { - repository = repository.substring(ResourceSyncInfo.SEPARATOR.length()); - } - } - - public boolean equals(Object other) { - if(other == this) return true; - if (!(other instanceof FolderSyncInfo)) return false; - - FolderSyncInfo syncInfo = ((FolderSyncInfo)other); - if (!getRoot().equals(syncInfo.getRoot())) return false; - if (!getRepository().equals(syncInfo.getRepository())) return false; - if (getIsStatic() != syncInfo.getIsStatic()) return false; - if ((getTag() == null) || (syncInfo.getTag() == null)) { - if ((getTag() == null) && (syncInfo.getTag() != null) && (syncInfo.getTag().getType() != CVSTag.HEAD)) { - return false; - } else if ((syncInfo.getTag() == null) && (getTag() != null) && (getTag().getType() != CVSTag.HEAD)) { - return false; - } - } else if (!getTag().equals(syncInfo.getTag())) { - return false; - } - return true; - } - /** - * Gets the root, cannot be null. - * - * @return Returns a String - */ - public String getRoot() { - return root; - } - - /** - * Answer the directory portion of the root. For example, if - * root = :pserver:user@host:/home/user/repo - * then /home/user/repo is return. - *

              - * The root does not neccesarily contain a user name, in which cas the format is - * :pserver:host:/home/user/repo. - * - * - * @return String - */ - private String getRootDirectory() throws CVSException { - try { - String root = getRoot(); - int index = root.indexOf(CVSRepositoryLocation.HOST_SEPARATOR); - if (index == -1) { - // If the username is missing, we have to find the third ':'. - index = root.indexOf(CVSRepositoryLocation.COLON); - if (index == 0) { - // This indicates that the conection method is present. - // It is surrounded by two colons so skip them. - index = root.indexOf(CVSRepositoryLocation.COLON, index + 1); - index = root.indexOf(CVSRepositoryLocation.COLON, index + 1); - } - if (index == -1) { - // The host colon is missing. - // Look for a slash to find the path - index = root.indexOf(ResourceSyncInfo.SEPARATOR); - // Decrement the index since the slash is part of the path - if (index != -1) index--; - } - } else { - // If the username was there, we find the first ':' past the '@' - index = root.indexOf(CVSRepositoryLocation.COLON, index + 1); - } - index++; - // strip off a leading port if there is one - char c = root.charAt(index); - while (Character.isDigit(c)) { - c = root.charAt(++index); - } - return root.substring(index); - } catch (IndexOutOfBoundsException e) { - throw new CVSException(Policy.bind("FolderSyncInfo_Maleformed_root_4")); //$NON-NLS-1$ - } - } - - /** - * Gets the tag, may be null. - * - * @return Returns a String - */ - public CVSEntryLineTag getTag() { - return tag; - } - - /** - * Gets the repository, may be null. - * - * @return Returns a String - */ - public String getRepository() { - return repository; - } - - /** - * Gets the isStatic. - * - * @return Returns a boolean - */ - public boolean getIsStatic() { - return isStatic; - } - - /** - * Answers a full path to the folder on the remote server. This by appending the repository to the - * repository location speficied in the root. - * - * Example: - * root = :pserver:user@host:/home/user/repo - * repository = folder1/folder2 - * - * Returns: - * /home/users/repo/folder1/folder2 - * - * Note: CVS supports repository root directories that end in a slash (/). - * For these directories, the remote location must contain two slashes (//) - * between the root directory and the rest of the path. For example: - * root = :pserver:user@host:/home/user/repo/ - * repository = folder1/folder2 - * must return: - * /home/users/repo//folder1/folder2 - * - * @return the full path of this folder on the server. - * @throws a CVSException if the root or repository is malformed. - */ - public String getRemoteLocation() throws CVSException { - return getRootDirectory() + ResourceSyncInfo.SEPARATOR + getRepository(); //$NON-NLS-1$ - } - - /* - * Provide a hashCode() method that gaurentees that equal object will have the - * same hashCode - */ - public int hashCode() { - return getRoot().hashCode() | getRepository().hashCode(); - } - - /** - * Sets the tag for the folder. - * - * @param tag The tag to set - */ - protected void setTag(CVSTag tag) { - if (tag == null || tag.equals(CVSTag.DEFAULT)) { - this.tag = null; - } else { - this.tag = new CVSEntryLineTag(tag); - } - } - /* - * @see Object#toString() - */ - public String toString() { - return getRoot() + "/" + getRepository() + "/" + getTag(); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public MutableFolderSyncInfo cloneMutable() { - MutableFolderSyncInfo newSync = new MutableFolderSyncInfo(this); - return newSync; - } - - /** - * Return true if this FolderSyncInfo is mapped to the same remote directory - * as the other FolderSyncInfo passed as a parameter. - * - * @param remoteInfo - * @return - */ - public boolean isSameMapping(FolderSyncInfo other) { - if (other == null) return false; - return (this.getRoot().equals(other.getRoot()) - && this.getRepository().equals(other.getRepository())) ; - } - -/** - * Convert a FolderSyncInfo into a byte array that can be stored - * in the workspace synchronizer - */ - public byte[] getBytes() throws CVSException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(out); - try { - dos.writeUTF(getRoot()); - dos.writeUTF(getRepository()); - CVSEntryLineTag t = getTag(); - if (t == null) { - dos.writeUTF(""); //$NON-NLS-1$ - } else { - dos.writeUTF(t.toString()); - } - dos.writeBoolean(getIsStatic()); - dos.close(); - } catch (IOException e) { - throw CVSException.wrapException(e); - } - return out.toByteArray(); - } - - /** - * Convert a byte array that was created using getBytes(FolderSyncInfo) - * into a FolderSyncInfo - */ - public static FolderSyncInfo getFolderSyncInfo(byte[] bytes) throws CVSException { - ByteArrayInputStream in = new ByteArrayInputStream(bytes); - DataInputStream dis = new DataInputStream(in); - String root; - String repository; - CVSEntryLineTag tag; - boolean isStatic; - try { - root = dis.readUTF(); - repository = dis.readUTF(); - String tagName = dis.readUTF(); - if (tagName.length() == 0) { - tag = null; - } else { - tag = new CVSEntryLineTag(tagName); - } - isStatic = dis.readBoolean(); - } catch (IOException e) { - throw CVSException.wrapException(e); - } - return new FolderSyncInfo(repository, root, tag, isStatic); - } - - /** - * Return whether the local directory is mapped to an existing remote - * directory or is just a local placeholder for child folders. a return type - * of true indicates that the local folder is not mapped to a - * remote folder. - * @return whether the directory is a local placeholder - */ - public boolean isVirtualDirectory() { - return getRepository().equals(VIRTUAL_DIRECTORY); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java deleted file mode 100644 index b8deab4b2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.variants.ResourceVariantByteStore; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * A CVS resource variant tree that associates a different tag with each root project. - */ -public class MultiTagResourceVariantTree extends CVSResourceVariantTree { - - Map resources = new HashMap(); - - public MultiTagResourceVariantTree(ResourceVariantByteStore cache, boolean cacheFileContentsHint) { - super(cache, null, cacheFileContentsHint); - } - - public void addResource(IResource resource, CVSTag tag) { - Assert.isNotNull(resource); - Assert.isNotNull(tag); - resources.put(resource, tag); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree#getTag(org.eclipse.core.resources.IResource) - */ - public CVSTag getTag(IResource resource) { - return (CVSTag)resources.get(resource); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java deleted file mode 100644 index 9eadb57b7..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import org.eclipse.team.internal.ccvs.core.CVSTag; - -/** - * Mutable version of FolderSyncInfo. Can be used when either creating a - * folder sync object from scratch or when modifying an existing - * FolderSyncInfo instance. Example usage: - *

              - * FolderSyncInfo info = folder.getFolderSyncInfo(); 
              - * if(info!=null) {
              - *    MutableFolderSyncInfo newInfo = info.cloneMutable(); 
              - *    newInfo.setTag(CVSTag.DEFAULT);
              - *    folder.setFolderSyncInfo(newInfo);
              - * }
              - * 
              - * @see FolderSyncInfo - */ -public class MutableFolderSyncInfo extends FolderSyncInfo { - - /** - * Constructor MutableFolderSyncInfo. - * @param folderSyncInfo - */ - public MutableFolderSyncInfo(FolderSyncInfo info) { - this(info.getRepository(), info.getRoot(), info.getTag(), info.getIsStatic()); - } - - /** - * Constructor for MutableFolderSyncInfo. - * @param repo - * @param root - * @param tag - * @param isStatic - */ - public MutableFolderSyncInfo(String repo, String root, CVSTag tag, boolean isStatic) { - super(repo, root, tag, isStatic); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo#setTag(org.eclipse.team.internal.ccvs.core.CVSTag) - */ - public void setTag(CVSTag tag) { - super.setTag(tag); - } - /** - * Method setRepository. - * @param string - */ - public void setRepository(String repository) { - this.repository = repository; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java deleted file mode 100644 index caf694892..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.util.Date; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.util.Assert; - -/** - * Mutable version of ResourceSyncInfo. Can be used when either creating a resource sync - * object from scratch (e.g. without an entry line) or want to modify an existing - * ResourceSyncInfo instance. Example usage: - *
              - * ResourceSyncInfo info = resource.getSyncInfo();
              - * if(info!=null) {
              - *   MutableResourceSyncInfo newInfo = info.cloneMutable();
              - *   newInfo.setRevision("1.22");
              - *   resource.setSyncInfo(newInfo);
              - * }
              - * 
              - * @see ResourceSyncInfo - */ -public class MutableResourceSyncInfo extends ResourceSyncInfo { - - boolean reported; - boolean changed; - - protected MutableResourceSyncInfo(ResourceSyncInfo info) { - this.name = info.getName(); - setRevision(info.getRevision()); - setTag(info.getTag()); - this.permissions = info.getPermissions(); - this.timeStamp = info.getTimeStamp(); - this.isDirectory = info.isDirectory(); - this.keywordMode = info.getKeywordMode(); - this.isDeleted = info.isDeleted(); - if(info.isMergedWithConflicts()) { - setSyncType(TYPE_MERGED_WITH_CONFLICTS); - } else if(info.isMerged()) { - setSyncType(TYPE_MERGED); - } else { - setSyncType(TYPE_REGULAR); - } - } - - /** - * Creates a default sync info, if revision is null then - * the sync info will be considered in the newly added state. - */ - public MutableResourceSyncInfo(String name, String revision) { - Assert.isNotNull(name); - this.name = name; - setRevision(revision); - this.reported = false; - this.changed = false; - } - - void setResourceInfoType(int type) { - this.syncType = type; - } - - /** - * Sets the revision. - * @param revision The revision to set - */ - public void setRevision(String revision) { - super.setRevision(revision); - } - - /** - * Sets the timeStamp. - * @param timeStamp The timeStamp to set - */ - public void setTimeStamp(Date timeStamp) { - this.timeStamp = timeStamp; - this.changed = true; - } - - /** - * Sets the timeStamp. - * @param timeStamp The timeStamp to set - */ - public void setTimeStamp(Date timeStamp, boolean clearMerged) { - setTimeStamp(timeStamp); - if (clearMerged) setSyncType(TYPE_REGULAR); - } - - /** - * Sets the keywordMode. - * @param keywordMode The keywordMode to set - */ - public void setKeywordMode(KSubstOption keywordMode) { - this.keywordMode = keywordMode; - this.changed = true; - } - - /** - * Sets the tag. - * @param tag The tag to set - */ - public void setTag(CVSTag tag) { - super.setTag(tag); - } - - /** - * Sets the permissions. - * @param permissions The permissions to set - */ - public void setPermissions(String permissions) { - this.permissions = permissions; - } - - /** - * Sets the deleted state. - * @param isDeleted The deleted state of this resource sync - */ - public void setDeleted(boolean isDeleted) { - this.isDeleted = isDeleted; - this.changed = true; - } - - /** - * Sets to the added state. The timestamp and other are cleared. - */ - public void setAdded() { - setRevision(ADDED_REVISION); - this.changed = true; - } - - /** - * Sets that this resource sync is a result of a non-conflicting merge - */ - public void setMerged() { - // if already merged state then ignore - if(syncType==TYPE_REGULAR) { - this.syncType = TYPE_MERGED; - this.changed = true; - } - } - - public boolean needsReporting() { - return changed && !reported; - } - - public void reported() { - this.reported = true; - } - /** - * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo#setEntryLine(java.lang.String) - */ - public void setEntryLine(String entryLine) throws CVSException { - super.setEntryLine(entryLine); - this.changed = true; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java deleted file mode 100644 index bee8ae3ac..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.text.ParseException; -import java.util.Date; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class contains the information required by the server for edit/unedit. - */ -public class NotifyInfo { - - // constants for the notifiation type and watches - public static final char EDIT = 'E'; - public static final char UNEDIT = 'U'; - public static final char COMMIT = 'C'; - public static final char[] ALL = new char[] {EDIT, UNEDIT, COMMIT}; - - protected static final String TAB_SEPARATOR = "\t"; //$NON-NLS-1$ - - private String filename; - private char notificationType; - private Date timeStamp; - private char[] watches; - - /** - * Constructor for setting all variables - */ - public NotifyInfo(String filename, char notificationType, Date timeStamp, char[] watches) { - - this.filename = filename; - this.notificationType = notificationType; - this.timeStamp = timeStamp; - this.watches = watches; - } - - /** - * Constructor for a line from the CVS/Notify file - * @param line - */ - public NotifyInfo(IContainer parent, String line) throws CVSException { - String[] strings = Util.parseIntoSubstrings(line, ResourceSyncInfo.SEPARATOR); - if(strings.length != 4) { - throw new CVSException(Policy.bind("NotifyInfo.MalformedLine", line)); //$NON-NLS-1$ - } - this.filename = strings[0]; - - String type = strings[1]; - if (type.length() != 1) { - throw new CVSException(Policy.bind("NotifyInfo.MalformedNotificationType", line)); //$NON-NLS-1$ - } - this.notificationType = type.charAt(0); - - String date = strings[2]; - try { - this.timeStamp = CVSDateFormatter.entryLineToDate(date); - } catch(ParseException e) { - throw new CVSException(Policy.bind("NotifyInfo.MalformedNotifyDate", line)); //$NON-NLS-1$ - } - - String watchesString = strings[3]; - if (watchesString.length() > 0) { - this.watches = new char[watchesString.length()]; - for (int i = 0; i < watchesString.length(); i++) { - watches[i] = watchesString.charAt(i); - } - } else { - this.watches = null; - } - } - - /** - * Answer a Sting formatted to be written to the CVS/Notify file. - * - * XXX NOTE: This is a guess at the local format. Need to obtain proper format - * - * @return String - */ - public String getNotifyLine() { - StringBuffer buffer = new StringBuffer(); - buffer.append(getName()); - buffer.append(ResourceSyncInfo.SEPARATOR); - buffer.append(notificationType); - buffer.append(ResourceSyncInfo.SEPARATOR); - buffer.append(CVSDateFormatter.dateToEntryLine(timeStamp)); - buffer.append(ResourceSyncInfo.SEPARATOR); - if (watches != null) { - for (int i = 0; i < watches.length; i++) { - char c = watches[i]; - buffer.append(c); - } - } - return buffer.toString(); - } - - /** - * Answer a Sting formatted to be sent to the server. - * - * @return String - */ - public String getServerLine(ICVSFolder parent) throws CVSException { - StringBuffer buffer = new StringBuffer(); - buffer.append(notificationType); - buffer.append(TAB_SEPARATOR); - buffer.append(getServerTimestamp()); - buffer.append(TAB_SEPARATOR); - buffer.append(getHost()); - buffer.append(TAB_SEPARATOR); - buffer.append(getWorkingDirectory(parent)); - buffer.append(TAB_SEPARATOR); - if (watches != null) { - for (int i = 0; i < watches.length; i++) { - char c = watches[i]; - buffer.append(c); - } - } - return buffer.toString(); - } - - /** - * Answer the timestamp in GMT format. - * @return String - */ - private String getServerTimestamp() { - return CVSDateFormatter.dateToNotifyServer(timeStamp); - } - - /** - * Answer the working directory for the receiver's file. The format - * is NOT device dependant (i.e. /'s are used as the path separator). - * - * @return String - */ - private String getWorkingDirectory(ICVSFolder parent) throws CVSException { - return parent.getIResource().getLocation().toString(); - } - - /** - * Answer the host name of the client machine. - * @return String - */ - private String getHost() throws CVSException { - try { - return InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - throw CVSException.wrapException(e); - } - } - - /** - * Answer the name of the file associated with the notification - * @return String - */ - public String getName() { - return filename; - } - - /** - * Answer the notification type associated with the notification - * @return char - */ - public char getNotificationType() { - return notificationType; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java deleted file mode 100644 index 06f35c9bd..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.core.subscribers.BatchingLock; - -/** - * Provides a per-thread nested locking mechanism. A thread can acquire a - * lock on a specific resource by calling acquire(). Subsequently, acquire() can be called - * multiple times on the resource or any of its children from within the same thread - * without blocking. Other threads that try - * and acquire the lock on those same resources will be blocked until the first - * thread releases all it's nested locks. - *

              - * The locking is managed by the platform via scheduling rules. This class simply - * provides the nesting mechnism in order to allow the client to determine when - * the lock for the thread has been released. Therefore, this lock will block if - * another thread already locks the same resource.

              - */ -public class ReentrantLock extends BatchingLock { - - public class CVSThreadInfo extends ThreadInfo{ - private Set changedFolders = new HashSet(); - public CVSThreadInfo(IFlushOperation operation) { - super(operation); - } - public void addChangedFolder(IContainer container) { - changedFolders.add(container); - } - public boolean isEmpty() { - return changedFolders.isEmpty() && super.isEmpty(); - } - public IContainer[] getChangedFolders() { - return (IContainer[]) changedFolders.toArray(new IContainer[changedFolders.size()]); - } - public void flush(IProgressMonitor monitor) throws TeamException { - try { - super.flush(monitor); - } finally { - // We have to clear the resources no matter what since the next attempt - // to flush may not have an appropriate scheduling rule - changedFolders.clear(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.BatchingLock#createThreadInfo(org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation) - */ - protected ThreadInfo createThreadInfo(IFlushOperation operation) { - return new CVSThreadInfo(operation); - } - - public void folderChanged(IContainer folder) { - CVSThreadInfo info = (CVSThreadInfo)getThreadInfo(); - Assert.isNotNull(info, "Folder changed outside of resource lock"); //$NON-NLS-1$ - info.addChangedFolder(folder); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java deleted file mode 100644 index eefb5912a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java +++ /dev/null @@ -1,962 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Incorporated - is/setExecutable() code - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.syncinfo; - - -import java.text.ParseException; -import java.util.Date; - -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Value (immutable) object that represents workspace state information about a resource contained in - * a CVS repository. It is a specialized representation of a line in the CVS/Entry file with the addition of - * file permissions. - *

              - * ResourceSyncInfo instances are created from entry lines from the CVS server and from the CVS/Entries - * file. Although both entry lines have slightly different formats (e.g. timestamps) they can safely be passed - * to the constructor.

              - *

              - * A class named MutableResourceSyncInfo can be used to modify an existing resource - * sync or create sync info without an entry line.

              - * - * Example entry line from the CVS/Entry file: - * - * /new.java/1.2/Fri Dec 7 00:17:52 2001/-kb/ - * D/src//// - * - * @see MutableResourceSyncInfo - * @see ICVSResource#getSyncInfos() - */ -public class ResourceSyncInfo { - - // [Note: permissions aren't honoured in this current implementation] - // safe default permissions. Permissions are saved separately so that the correct permissions - // can be sent back to the server on systems that don't save execute bits (e.g. windows). - private static final String DEFAULT_PERMISSIONS = "u=rw,g=rw,o=r"; //$NON-NLS-1$ - private static final String DEFAULT_EXECUTABLE_PERMISSIONS = "u=rwx,g=rwx,o=rx"; //$NON-NLS-1$ - - // file sync information can be associated with a local resource that has been deleted. This is - // noted by prefixing the revision with this character. - private static final String DELETED_PREFIX = "-"; //$NON-NLS-1$ - private static final byte DELETED_PREFIX_BYTE = '-'; - - // a sync element with a revision of '0' is considered a new file that has - // not been comitted to the repo. Is visible so that clients can create sync infos - // for new files. - public static final String ADDED_REVISION = "0"; //$NON-NLS-1$ - - // Timestamp constants used to identify special cases - protected static final int TYPE_REGULAR = 1; - protected static final int TYPE_MERGED = 2; - protected static final int TYPE_MERGED_WITH_CONFLICTS = 3; - - protected static final String TIMESTAMP_DUMMY = "dummy timestamp"; //$NON-NLS-1$ - protected static final String TIMESTAMP_MERGED = "Result of merge"; //$NON-NLS-1$ - protected static final String TIMESTAMP_MERGED_WITH_CONFLICT = TIMESTAMP_MERGED + "+"; //$NON-NLS-1$ - - protected static final String TIMESTAMP_SERVER_MERGED = "+modified"; //$NON-NLS-1$ - protected static final String TIMESTAMP_SERVER_MERGED_WITH_CONFLICT = "+="; //$NON-NLS-1$ - - // a directory sync info will have nothing more than a name - protected boolean isDirectory = false; - protected boolean isDeleted = false; - - // utility constants - protected static final String DIRECTORY_PREFIX = "D"; //$NON-NLS-1$ - protected static final String SEPARATOR = "/"; //$NON-NLS-1$ - protected static final byte SEPARATOR_BYTE = (byte)'/'; - - // fields describing the synchronization of a resource in CVS parlance - protected String name; - protected String revision; - protected Date timeStamp; - protected KSubstOption keywordMode; - protected CVSEntryLineTag tag; - protected String permissions; - - // type of sync - protected int syncType = TYPE_REGULAR; - protected ResourceSyncInfo() { - // Added for use by subclasses - } - - public ResourceSyncInfo(byte[] entryLine) throws CVSException { - this(new String(entryLine), null, null); - } - - /** - * Constructor to create a sync object from entry line formats. The entry lines are parsed by this class. - * The constructor can handle parsing entry lines from the server or from an entry file. - * - * @param entryLine the entry line (e.g. /new.java/1.2/Fri Dec 07 00:17:52 2001/-kb/) - * @param permissions the file permission (e.g. u=rw,g=rw,o=r). May be null. - * @param timestamp if not included in the entry line. May be null. - * - * @exception CVSException is thrown if the entry cannot be parsed. - */ - public ResourceSyncInfo(String entryLine, String permissions, Date timestamp) throws CVSException { - Assert.isNotNull(entryLine); - setEntryLine(entryLine); - - if (permissions != null) { - this.permissions = permissions; - } - // override the timestamp that may of been in entryLine. In some cases the timestamp is not in the - // entry line (e.g. receiving entry lines from the server versus reading them from the Entry file). - if(timestamp!=null) { - this.timeStamp = timestamp; - } - } - - /** - * Constructor to create a resource sync object for a folder. - * - * @param name of the resource for which this sync state is associatied, cannot be null. - */ - public ResourceSyncInfo(String name) { - Assert.isNotNull(name); - this.name = name; - this.isDirectory = true; - } - /** - * Answers if this sync information is for a folder in which case only a name is - * available. - * - * @return true if the sync information is for a folder and false - * if it is for a file. - */ - public boolean isDirectory() { - return isDirectory; - } - - /** - * Answers if this sync information is for a resource that has been merged by the cvs server with - * conflicts and has not been modified yet relative to the given timestamp. - * - * @param otherTimestamp is the timestamp of the file associated with this resource sync - * @return true if the sync information is for a file that has been merged and - * false for folders and for files that have not been merged. - */ - public boolean isNeedsMerge(Date otherTimestamp) { - return syncType == TYPE_MERGED_WITH_CONFLICTS && timeStamp.equals(otherTimestamp); - } - - /** - * Answers if this sync information is for a resource that has been merged with conflicts by the - * cvs server. - * - * @return true if the sync information is for a file that has been merged and - * false for folders and for files that have not been merged. - */ - public boolean isMergedWithConflicts() { - return syncType == TYPE_MERGED_WITH_CONFLICTS; - } - - /** - * Answers if this sync information is for a resource that has been merged by the cvs server. - * - * @return true if the sync information is for a file that has been merged and - * false for folders and for files that have not been merged. - */ - public boolean isMerged() { - return syncType == TYPE_MERGED || isMergedWithConflicts(); - } - - /** - * Answers if this sync information is for a file that has been added but not comitted - * to the CVS repository yet. - * - * @return true if the sync information is new or false if - * the sync is for an file that exists remotely. For folder sync info this returns - * false. - */ - public boolean isAdded() { - if(!isDirectory) { - return getRevision().equals(ADDED_REVISION); - } else { - return false; - } - } - - /** - * Answers if this sync information is for a file that is scheduled to be deleted - * from the repository but the deletion has not yet been comitted. - * - * @return true if the sync information is deleted or false if - * the sync is for an file that exists remotely. - */ - public boolean isDeleted() { - return isDeleted; - } - - /** - * Returns an entry line that can be saved in the CVS/Entries file. For sending entry lines to the - * server use getServerEntryLine. - * - * @return a file or folder entry line reflecting the state of this sync object. - */ - public String getEntryLine() { - return getEntryLine(true /*include timestamps*/, null /*no timestamp override*/); - } - - /** - * Same as getEntryLine except it considers merged files in entry line timestamp format. - * This is only valid for sending the file to the server. - * - * @param fileTimestamp is timestamp of the resource associated with this sync info. - * @return a file or folder entry line reflecting the state of this sync object. - */ - public String getServerEntryLine(Date fileTimestamp) { - String serverTimestamp; - if(fileTimestamp != null && (isMerged() || isMergedWithConflicts())) { - if(isNeedsMerge(fileTimestamp)) { - serverTimestamp = TIMESTAMP_SERVER_MERGED_WITH_CONFLICT; - } else { - serverTimestamp = TIMESTAMP_SERVER_MERGED; - } - return getEntryLine(true, serverTimestamp); - } else { - return getEntryLine(false, null); - } - } - - /** - * Anwsers a compatible permissions line for files. - * - * @return a permission line for files and null if this sync object is - * a directory. - */ - public String getPermissionLine() { - if(isDirectory) { - return null; - } else { - String permissions = this.permissions; - if (permissions == null) - permissions = DEFAULT_PERMISSIONS; - return SEPARATOR + name + SEPARATOR + permissions; - } - } - - /** - * Gets the permissions. Returns null for directories and - * a non-null permission for files. - * - * @return a string of the format "u=rw,g=rw,o=r" - */ - public String getPermissions() { - if(isDirectory) { - return null; - } else { - if(permissions==null) { - return DEFAULT_PERMISSIONS; - } else { - return permissions; - } - } - } - /** - * Gets the tag or null if a tag is not available. - * - * @return Returns a String - */ - public CVSTag getTag() { - return tag; - } - /** - * Gets the timeStamp or null if a timestamp is not available. - * - * @return a date instance representing the timestamp - */ - public Date getTimeStamp() { - return timeStamp; - } - /** - * Gets the version or null if this is a folder sync info. The returned - * revision will never include the DELETED_PREFIX. To found out if this sync info is - * for a deleted resource call isDeleted(). - * - * @return Returns a String - */ - public String getRevision() { - return revision; - } - - /** - * Gets the name. - * - * @return Returns a String - */ - public String getName() { - return name; - } - /** - * Gets the keyword mode. - * @return the keyword substitution option - */ - public KSubstOption getKeywordMode() { - return keywordMode; - } - - /** - * Answers the default permissions string. - */ - public static String getDefaultPermissions() { - return DEFAULT_PERMISSIONS; - } - - /** - * Answers the default permissions string that is executable. - */ - public static String getDefaultExecutablePermissions() { - return DEFAULT_EXECUTABLE_PERMISSIONS; - } - - /** - * Name equality between resource sync info objects. - */ - public boolean equals(Object other) { - if(other instanceof ResourceSyncInfo) { - ResourceSyncInfo syncInfo = ((ResourceSyncInfo)other); - if(other == this) return true; - if(getName() == syncInfo.getName()) return true; - return getName().equals(syncInfo.getName()); - } else { - return false; - } - } - - public int hashCode() { - return getName().hashCode(); - } - - /* - * @see Object#toString() - */ - public String toString() { - return getEntryLine(true, null /*no timestamp override*/); - } - public MutableResourceSyncInfo cloneMutable() { - MutableResourceSyncInfo newSync = new MutableResourceSyncInfo(this); - return newSync; - } - /** - * Sets the tag for the resource. - */ - protected void setTag(CVSTag tag) { - if(tag!=null) { - this.tag = new CVSEntryLineTag(tag); - } else { - this.tag = null; - } - } - - - /* - * Sets the sync type - */ - protected void setSyncType(int syncType) { - this.syncType = syncType; - } - /** - * Sets the version and decides if the revision is for a deleted resource the revision field - * will not include the deleted prefix '-'. - * - * @param version the version to set - */ - protected void setRevision(String revision) { - if(revision==null || revision.equals(ADDED_REVISION)) { - this.revision = ADDED_REVISION; - timeStamp = null; - syncType = TYPE_REGULAR; - isDeleted = false; - } else if(revision.startsWith(DELETED_PREFIX)) { - this.revision = revision.substring(DELETED_PREFIX.length()); - isDeleted = true; - } else { - this.revision = revision; - isDeleted = false; - } - } - - /** - * Set the entry line - * - * @throws CVSException if the entryLine is malformed - */ - protected void setEntryLine(String entryLine) throws CVSException { - - String[] strings = Util.parseIntoSubstrings(entryLine, SEPARATOR); - if(strings.length < 6) { - throw new CVSException(Policy.bind("Malformed_entry_line___11") + entryLine); //$NON-NLS-1$ - } - - isDirectory = (strings[0].equals(DIRECTORY_PREFIX)); - - name = strings[1]; - - if(name.length()==0) { - throw new CVSException(Policy.bind("Malformed_entry_line,_missing_name___12") + entryLine); //$NON-NLS-1$ - } - - String rev = strings[2]; - - if(rev.length()==0 && !isDirectory()) { - throw new CVSException(Policy.bind("Malformed_entry_line,_missing_revision___13") + entryLine); //$NON-NLS-1$ - } else { - setRevision(rev); - } - - String date = strings[3]; - - // possible timestamps are: - // from server: "+=" and "+modified" - // from entry line: "Result of Merge+Thu May 25 12:33:33 2002" - // "Result of Merge" - // "Thu May 25 12:33:33 2002" - // - // The server will send a timestamp of "+=" if - // the file was merged with conflicts. The '+' indicates that there are conflicts and the - // '=' indicate that the timestamp for the file should be used. If the merge does not - // have conflicts, simply add a text only timestamp and the file will be regarded as - // having outgoing changes. - // The purpose for having the two different timestamp options for merges is to - // dissallow commit of files that have conflicts until they have been manually edited. - if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) { - syncType = TYPE_MERGED; - date = null; - } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) { - syncType = TYPE_MERGED_WITH_CONFLICTS; - date = null; - } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) { - date = date.substring(date.indexOf("+") + 1); //$NON-NLS-1$ - syncType = TYPE_MERGED_WITH_CONFLICTS; - } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) { - syncType = TYPE_MERGED; - date = null; - } - - if(date==null || "".equals(date)) { //$NON-NLS-1$ - timeStamp = null; - } else { - try { - timeStamp = CVSDateFormatter.entryLineToDate(date); - } catch(ParseException e) { - // something we don't understand, just make this sync have no timestamp and - // never be in sync with the server. - timeStamp = null; - } - } - keywordMode = KSubstOption.fromMode(strings[4]); - String tagEntry; - if (strings.length == 6) { - tagEntry = strings[5]; - } else { - // It turns out that CVS supports slashes (/) in the tag even though this breaks the spec - // See http://dev.eclipse.org/bugs/show_bug.cgi?id=26717 - StringBuffer buffer = new StringBuffer(); - for (int i = 5; i < strings.length; i++) { - buffer.append(strings[i]); - if (i < strings.length - 1) { - buffer.append(SEPARATOR); - } - } - tagEntry = buffer.toString(); - } - - if(tagEntry.length()>0) { - tag = new CVSEntryLineTag(tagEntry); - } else { - tag = null; - } - } - - private String getEntryLine(boolean includeTimeStamp, String timestampOverride) { - StringBuffer result = new StringBuffer(); - - if(isDirectory) { - result.append(DIRECTORY_PREFIX); - result.append(SEPARATOR); - result.append(name); - for (int i = 0; i < 4; i++) { - result.append(SEPARATOR); - } - } else { - result.append(SEPARATOR); - result.append(name); - result.append(SEPARATOR); - - if(isDeleted){ - result.append(DELETED_PREFIX); - } - result.append(revision); - result.append(SEPARATOR); - if(includeTimeStamp) { - String entryLineTimestamp = ""; //$NON-NLS-1$ - if(timestampOverride!=null) { - entryLineTimestamp = timestampOverride; - } else { - switch(syncType) { - case TYPE_REGULAR: - if(timeStamp==null) { - entryLineTimestamp = TIMESTAMP_DUMMY; - } else { - entryLineTimestamp = CVSDateFormatter.dateToEntryLine(timeStamp); - } break; - case TYPE_MERGED: - entryLineTimestamp = TIMESTAMP_MERGED; break; - case TYPE_MERGED_WITH_CONFLICTS: - entryLineTimestamp = TIMESTAMP_MERGED_WITH_CONFLICT + CVSDateFormatter.dateToEntryLine(timeStamp); break; - } - } - result.append(entryLineTimestamp); - } - result.append(SEPARATOR); - if (keywordMode != null) result.append(keywordMode.toMode()); - result.append(SEPARATOR); - if (tag != null) { - result.append(tag.toEntryLineFormat(true)); - } - } - return result.toString(); - } - - public boolean needsReporting() { - return false; - } - - public void reported() { - // do nothing - } - - /** - * Method getBytes. - * @return byte[] - */ - public byte[] getBytes() { - return getEntryLine().getBytes(); - } - - /** - * Method getName. - * @param syncBytes - * @return String - */ - public static String getName(byte[] syncBytes) throws CVSException { - String name = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 1, false); - if (name == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - return name; - } - - /** - * Method getKeywordMode. - * @param syncBytes - * @return String - */ - public static KSubstOption getKeywordMode(byte[] syncBytes) throws CVSException { - String mode = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 4, false); - if (mode == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - return KSubstOption.fromMode(mode); - } - - /** - * Method getKeywordMode. - * @param syncBytes - * @return String - */ - public static byte[] setKeywordMode(byte[] syncBytes, KSubstOption mode) throws CVSException { - return setKeywordMode(syncBytes, mode.toMode().getBytes()); - } - - /** - * Method getKeywordMode. - * @param syncBytes - * @return String - */ - public static byte[] setKeywordMode(byte[] syncBytes, byte[] modeBytes) throws CVSException { - return setSlot(syncBytes, 4, modeBytes); - } - - /** - * Return whether the provided syncBytes represent a binary file. - * @param syncBytes - * @return boolean - * @throws CVSException - */ - public static boolean isBinary(byte[] syncBytes) throws CVSException { - if (syncBytes == null) return false; - String mode = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 4, false); - if (mode == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - return "-kb".equals(mode); //$NON-NLS-1$ - } - - /** - * Method isFolder. - * @param syncBytes - * @return boolean - */ - public static boolean isFolder(byte[] syncBytes) { - return syncBytes.length > 0 && syncBytes[0] == 'D'; - } - - /** - * Method isAddition. - * @param syncBytes - * @return boolean - */ - public static boolean isAddition(byte[] syncBytes) throws CVSException { - int start = startOfSlot(syncBytes, 2); - // There must be a slot and, in the very least, there must be two characters after the slot - if (start == -1 || start > syncBytes.length - 3) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - // If the zero is followed by a dot, then it is a valid revision and not an addition - return syncBytes[start + 1] == '0' && syncBytes[start + 2] != '.'; - } - - /** - * Method isDeleted. - * @param syncBytes - * @return boolean - */ - public static boolean isDeletion(byte[] syncBytes) throws CVSException { - int start = startOfSlot(syncBytes, 2); - if (start == -1 || start >= syncBytes.length) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - return syncBytes[start + 1] == DELETED_PREFIX_BYTE; - } - - /** - * Method convertToDeletion. - * @param syncBytes - * @return byte[] - */ - public static byte[] convertToDeletion(byte[] syncBytes) throws CVSException { - int index = startOfSlot(syncBytes, 2); - if (index == -1) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - if (syncBytes.length > index && syncBytes[index+1] != DELETED_PREFIX_BYTE) { - byte[] newSyncBytes = new byte[syncBytes.length + 1]; - System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1); - newSyncBytes[index + 1] = DELETED_PREFIX_BYTE; - System.arraycopy(syncBytes, index + 1, newSyncBytes, index + 2, syncBytes.length - index - 1); - return newSyncBytes; - } - return syncBytes; - } - - /** - * Method convertFromDeletion. - * @param syncBytes - * @return byte[] - */ - public static byte[] convertFromDeletion(byte[] syncBytes) throws CVSException { - int index = startOfSlot(syncBytes, 2); - if (index == -1) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - if (syncBytes.length > index && syncBytes[index+1] == DELETED_PREFIX_BYTE) { - byte[] newSyncBytes = new byte[syncBytes.length - 1]; - System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1); - System.arraycopy(syncBytes, index + 2, newSyncBytes, index + 1, newSyncBytes.length - index - 1); - return newSyncBytes; - } - return syncBytes; - } - /** - * Method startOfSlot returns the index of the slash that occurs before the - * given slot index. The provided index should be >= 1 which assumes that - * slot zero occurs before the first slash. - * - * @param syncBytes - * @param i - * @return int - */ - private static int startOfSlot(byte[] syncBytes, int slot) { - int count = 0; - for (int j = 0; j < syncBytes.length; j++) { - if (syncBytes[j] == SEPARATOR_BYTE) { - count++; - if (count == slot) return j; - } - } - return -1; - } - - /** - * Method setSlot. - * @param syncBytes - * @param i - * @param b - * @return byte[] - */ - private static byte[] setSlot(byte[] syncBytes, int slot, byte[] newBytes) throws CVSException { - int start = startOfSlot(syncBytes, slot); - if (start == -1) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - int end = startOfSlot(syncBytes, slot + 1); - int totalLength = start + 1 + newBytes.length; - if (end != -1) { - totalLength += syncBytes.length - end; - } - byte[] result = new byte[totalLength]; - System.arraycopy(syncBytes, 0, result, 0, start + 1); - System.arraycopy(newBytes, 0, result, start + 1, newBytes.length); - if (end != -1) { - System.arraycopy(syncBytes, end, result, start + 1 + newBytes.length, syncBytes.length - end); - } - return result; - } - - /** - * Return the timestamp portion of the sync info that is to be sent to the - * server. - * - * @param syncBytes - * @param fileTimestamp - * @return String - */ - public static String getTimestampToServer(byte[] syncBytes, Date fileTimestamp) throws CVSException { - if(fileTimestamp != null) { - String syncTimestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false); - if (syncTimestamp == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - int syncType = getSyncType(syncTimestamp); - if (syncType != TYPE_REGULAR) { - if (syncType == TYPE_MERGED_WITH_CONFLICTS && fileTimestamp.equals(getTimestamp(syncTimestamp))) { - return TIMESTAMP_SERVER_MERGED_WITH_CONFLICT; - } else { - return TIMESTAMP_SERVER_MERGED; - } - } - } - return null; - } - /** - * Method getTimestamp. - * @param syncTimestamp - * @return Object - */ - private static Date getTimestamp(String syncTimestamp) { - String dateString= syncTimestamp; - if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) { - dateString = null; - } else if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) { - dateString = null; - } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) { - dateString = syncTimestamp.substring(syncTimestamp.indexOf("+") + 1); //$NON-NLS-1$ - } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED)!=-1) { - dateString = null; - } - - if(dateString==null || "".equals(dateString)) { //$NON-NLS-1$ - return null; - } else { - try { - return CVSDateFormatter.entryLineToDate(dateString); - } catch(ParseException e) { - // something we don't understand, just make this sync have no timestamp and - // never be in sync with the server. - return null; - } - } - } - - /** - * Method getSyncType. - * @param syncTimestamp - * @return int - */ - private static int getSyncType(String date) { - if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) { - return TYPE_MERGED; - } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) { - return TYPE_MERGED_WITH_CONFLICTS; - } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) { - return TYPE_MERGED_WITH_CONFLICTS; - } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) { - return TYPE_MERGED; - } - return TYPE_REGULAR; - } - - /** - * Method getTag. - * @param syncBytes - * @return String - */ - public static byte[] getTagBytes(byte[] syncBytes) throws CVSException { - byte[] tag = Util.getBytesForSlot(syncBytes, SEPARATOR_BYTE, 5, true); - if (tag == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - return tag; - } - - /** - * Method setTag. - * @param syncBytes - * @param tagString - * @return byte[] - */ - public static byte[] setTag(byte[] syncBytes, byte[] tagBytes) throws CVSException { - return setSlot(syncBytes, 5, tagBytes); - } - - /** - * Method setTag. - * @param syncBytes - * @param tag - * @return ResourceSyncInfo - */ - public static byte[] setTag(byte[] syncBytes, CVSTag tag) throws CVSException { - CVSEntryLineTag entryTag; - if (tag instanceof CVSEntryLineTag) { - entryTag = (CVSEntryLineTag)tag; - } else { - entryTag = new CVSEntryLineTag(tag); - } - return setTag(syncBytes, entryTag.toEntryLineFormat(true).getBytes()); - } - - /** - * Method getRevision. - * @param syncBytes - */ - public static String getRevision(byte[] syncBytes) throws CVSException { - String revision = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 2, false); - if (revision == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - if(revision.startsWith(DELETED_PREFIX)) { - revision = revision.substring(DELETED_PREFIX.length()); - } - return revision; - } - - /** - * Method setRevision. - * @param syncBytes - * @param revision - * @return byte[] - */ - public static byte[] setRevision(byte[] syncBytes, String revision) throws CVSException { - return setSlot(syncBytes, 2, revision.getBytes()); - } - - /** - * Method isMerge. - * @param syncBytes1 - * @return boolean - */ - public static boolean isMerge(byte[] syncBytes) throws CVSException { - String timestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false); - if (timestamp == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - int syncType = getSyncType(timestamp); - return syncType == TYPE_MERGED || syncType == TYPE_MERGED_WITH_CONFLICTS; - } - - /** - * Method isMerge. - * @param syncBytes1 - * @return boolean - */ - public static boolean isMergedWithConflicts(byte[] syncBytes) throws CVSException { - String timestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false); - if (timestamp == null) { - throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes))); //$NON-NLS-1$ - } - int syncType = getSyncType(timestamp); - return syncType == TYPE_MERGED_WITH_CONFLICTS; - } - - - /** - * Return true if the remoteBytes represents a later revision on the same - * branch as localBytes. Return false if remoteBytes is the same or an earlier - * revision or if the bytes are on a separate branch (or tag) - * @param remoteBytes - * @param localBytes - * @return - */ - public static boolean isLaterRevisionOnSameBranch(byte[] remoteBytes, byte[] localBytes) throws CVSException { - // If the two byte arrays are the same, then the remote isn't a later revision - if (remoteBytes == localBytes) return false; - // If the tags differ, then the remote isn't a later revision - byte[] remoteTag = ResourceSyncInfo.getTagBytes(remoteBytes); - byte[] localTag = ResourceSyncInfo.getTagBytes(localBytes); - if (!Util.equals(remoteTag, localTag)) return false; - // If the revisions are the same, the remote isn't later - String remoteRevision = ResourceSyncInfo.getRevision(remoteBytes); - String localRevision = ResourceSyncInfo.getRevision(localBytes); - if (remoteRevision.equals(localRevision)) return false; - return isLaterRevision(remoteRevision, localRevision); - } - - /** - * Return true if the remoteRevision represents a later revision than the local revision - * on the same branch. - * @param remoteRevision - * @param localRevision - * @return - */ - public static boolean isLaterRevision(String remoteRevision, String localRevision) { - int localDigits[] = Util.convertToDigits(localRevision); - if (localDigits.length == 0) return false; - int remoteDigits[] = Util.convertToDigits(remoteRevision); - if (remoteDigits.length == 0) return false; - - if (localRevision.equals(ADDED_REVISION)) { - return (remoteDigits.length >= 2); - } - if (localDigits.length < remoteDigits.length) { - // If there are more digits in the remote revision then all - // the leading digits must match - for (int i = 0; i < localDigits.length; i++) { - int localDigit = localDigits[i]; - int remoteDigit = remoteDigits[i]; - if (remoteDigit != localDigit) return false; - } - return true; - } - // They are the same length or the local is longer. - // The last digit must differ and all others must be the same. - // If the local is longer, ignore the addition numbers - // (this can occur as the result on an import) - for (int i = 0; i < remoteDigits.length - 1; i++) { - int localDigit = localDigits[i]; - int remoteDigit = remoteDigits[i]; - if (remoteDigit != localDigit) return false; - } - // All the leading digits are equals so the remote is later if the last digit is greater - return localDigits[remoteDigits.length - 1] < remoteDigits[remoteDigits.length - 1] ; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java deleted file mode 100644 index f24cb6720..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -/** - * Assert is useful for for embedding runtime sanity checks - * in code. - * The predicate methods all test a condition and throw some - * type of unchecked exception if the condition does not hold. - *

              - * Assertion failure exceptions, like most runtime exceptions, are - * thrown when something is misbehaving. Assertion failures are invariably - * unspecified behavior; consequently, clients should never rely on - * these being thrown (and certainly should not being catching them - * specifically). - *

              - */ -public final class Assert { - /* This class is not intended to be instantiated. */ - private Assert() { - } - /** Asserts that an argument is legal. If the given boolean is - * not true, an IllegalArgumentException - * is thrown. - * - * @param expression the outcode of the check - * @return true if the check passes (does not return - * if the check fails) - * @exception IllegalArgumentException if the legality test failed - */ - public static boolean isLegal(boolean expression) { - return isLegal(expression, ""); //$NON-NLS-1$ - } - /** Asserts that an argument is legal. If the given boolean is - * not true, an IllegalArgumentException - * is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param expression the outcode of the check - * @param message the message to include in the exception - * @return true if the check passes (does not return - * if the check fails) - * @exception IllegalArgumentException if the legality test failed - */ - public static boolean isLegal(boolean expression, String message) { - if (!expression) - throw new IllegalArgumentException(message); - return expression; - } - /** Asserts that the given object is not null. If this - * is not the case, some kind of unchecked exception is thrown. - * - * @param object the value to test - * @exception IllegalArgumentException if the object is null - */ - public static void isNotNull(Object object) { - isNotNull(object, ""); //$NON-NLS-1$ - } - /** Asserts that the given object is not null. If this - * is not the case, some kind of unchecked exception is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param object the value to test - * @param message the message to include in the exception - * @exception IllegalArgumentException if the object is null - */ - public static void isNotNull(Object object, String message) { - if (object == null) - throw new AssertionFailedException("null argument:" + message); //$NON-NLS-1$ - } - /** Asserts that the given boolean is true. If this - * is not the case, some kind of unchecked exception is thrown. - * - * @param expression the outcode of the check - * @return true if the check passes (does not return - * if the check fails) - */ - public static boolean isTrue(boolean expression) { - return isTrue(expression, ""); //$NON-NLS-1$ - } - /** Asserts that the given boolean is true. If this - * is not the case, some kind of unchecked exception is thrown. - * The given message is included in that exception, to aid debugging. - * - * @param expression the outcode of the check - * @param message the message to include in the exception - * @return true if the check passes (does not return - * if the check fails) - */ - public static boolean isTrue(boolean expression, String message) { - if (!expression) - throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$ - return expression; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java deleted file mode 100644 index 1b4dd6b47..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -/** - * AssertionFailedException is a runtime exception thrown - * by some of the methods in Assert. - *

              - * This class is not declared public to prevent some misuses; programs that catch - * or otherwise depend on assertion failures are susceptible to unexpected - * breakage when assertions in the code are added or removed. - *

              - */ -/* package */ -class AssertionFailedException extends RuntimeException { -private static final long serialVersionUID = 1L; -/** Constructs a new exception. - */ -public AssertionFailedException() { -} -/** Constructs a new exception with the given message. - */ -public AssertionFailedException(String detail) { - super(detail); -} -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java deleted file mode 100644 index 580ed29b9..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; - -/** - * Cleanup any CVS folders that were copied by a builder. This will also clean up - * CVS folders that were copied by the user since the last auto-build. - */ -public class BuildCleanupListener implements IResourceDeltaVisitor, IResourceChangeListener { - - public static IResource getResourceFor(IProject container, IResource destination, IPath originating) { - switch(destination.getType()) { - case IResource.FILE : return container.getFile(originating); - case IResource.FOLDER: return container.getFolder(originating); - case IResource.PROJECT: return ResourcesPlugin.getWorkspace().getRoot().getProject(originating.toString()); - } - return destination; - } - - /** - * @see IResourceDeltaVisitor#visit(IResourceDelta) - */ - public boolean visit(IResourceDelta delta) throws CoreException { - IResource resource = delta.getResource(); - boolean movedFrom = (delta.getFlags() & IResourceDelta.MOVED_FROM) > 0; - switch (delta.getKind()) { - case IResourceDelta.ADDED : - // make sure the added resource isn't a phantom - if (resource.exists()) { - if (EclipseSynchronizer.getInstance().wasPhantom(resource)) { - EclipseSynchronizer.getInstance().resourcesRecreated(new IResource[] { resource }, null); - } - if (resource.getType() == IResource.FOLDER) { - handleOrphanedSubtree((IContainer)resource); - } - } - break; - case IResourceDelta.CHANGED : - // This state means there is a resource before and after but changes were made by deleting and moving. - // For files, we shouldn'd do anything. - // For folders, we should purge the CVS info - if (movedFrom && resource.getType() == IResource.FOLDER && resource.exists()) { - // When folders are moved, purge the CVS folders - return ! handleOrphanedSubtree((IContainer)resource); - } - break; - } - return true; - } - - /* - * Determine if the container is an orphaned subtree. - * If it is, handle it and return true. - * Otherwise, return false - */ - private boolean handleOrphanedSubtree(IContainer container) { - try { - if (CVSWorkspaceRoot.isOrphanedSubtree(container)) { - ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(container); - mFolder.unmanage(null); - return true; - } - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - return false; - } - - public void resourceChanged(IResourceChangeEvent event) { - try { - IResourceDelta root = event.getDelta(); - IResourceDelta[] projectDeltas = root.getAffectedChildren(); - for (int i = 0; i < projectDeltas.length; i++) { - final IResourceDelta delta = projectDeltas[i]; - IResource resource = delta.getResource(); - - if (resource.getType() == IResource.PROJECT) { - // If the project is not accessible, don't process it - if (!resource.isAccessible()) continue; - if ((delta.getFlags() & IResourceDelta.OPEN) != 0) continue; - } - - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()); - - // Make sure that the project is a CVS folder. - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource.getProject()); - if (provider != null) { - try { - if (! folder.isCVSFolder()) { - RepositoryProvider.unmap(resource.getProject()); - provider = null; - } - } catch (TeamException e) { - CVSProviderPlugin.log(e); - } - } - - // if a project is moved the originating project will not be associated with the CVS provider - // however listeners will probably still be interested in the move delta. - if ((delta.getFlags() & IResourceDelta.MOVED_TO) > 0) { - IResource destination = getResourceFor(resource.getProject(), resource, delta.getMovedToPath()); - provider = RepositoryProvider.getProvider(destination.getProject()); - } - - if(provider!=null) { - // Traverse the delta is a runnable so that files are only written at the end - folder.run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - try { - delta.accept(BuildCleanupListener.this); - } catch (CoreException e) { - Util.logError(Policy.bind("ResourceDeltaVisitor.visitError"), e);//$NON-NLS-1$ - } - } - }, Policy.monitorFor(null)); - } - } - } catch (CVSException e) { - Util.logError(Policy.bind("ResourceDeltaVisitor.visitError"), e);//$NON-NLS-1$ - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java deleted file mode 100644 index c75025842..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; - -/** - * Utility class for converting timestamps used in Entry file lines. The format - * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996). - *

              - * To be compatible with asctime(), the day field in the entryline format is - * padded with a space and not a zero. Most other CVS clients use string comparison - * for timestamps based on the result of the C function asctime(). - *

              - */ -public class CVSDateFormatter { - - private static final String ENTRYLINE_FORMAT = "E MMM dd HH:mm:ss yyyy"; //$NON-NLS-1$ - private static final String SERVER_FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$ - private static final int ENTRYLINE_TENS_DAY_OFFSET = 8; - - private static final SimpleDateFormat serverFormat = new SimpleDateFormat(SERVER_FORMAT, Locale.US); - private static SimpleDateFormat entryLineFormat = new SimpleDateFormat(ENTRYLINE_FORMAT, Locale.US); - - static { - entryLineFormat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ - } - static synchronized public Date serverStampToDate(String text) throws ParseException { - serverFormat.setTimeZone(getTimeZone(text)); - Date date = serverFormat.parse(text); - return date; - } - - static synchronized public String dateToServerStamp(Date date) { - serverFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$ - return serverFormat.format(date) + " -0000"; //$NON-NLS-1$ - } - - static synchronized public Date entryLineToDate(String text) throws ParseException { - try { - if (text.charAt(ENTRYLINE_TENS_DAY_OFFSET) == ' ') { - StringBuffer buf = new StringBuffer(text); - buf.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, '0'); - text = buf.toString(); - } - } catch (StringIndexOutOfBoundsException e) { - throw new ParseException(e.getMessage(), ENTRYLINE_TENS_DAY_OFFSET); - } - return entryLineFormat.parse(text); - } - - static synchronized public String dateToEntryLine(Date date) { - if (date == null) return ""; //$NON-NLS-1$ - String passOne = entryLineFormat.format(date); - if (passOne.charAt(ENTRYLINE_TENS_DAY_OFFSET) != '0') return passOne; - StringBuffer passTwo = new StringBuffer(passOne); - passTwo.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, ' '); - return passTwo.toString(); - } - - static synchronized public String dateToNotifyServer(Date date) { - serverFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$ - return serverFormat.format(date) + " GMT"; //$NON-NLS-1$ - } - - /* - * Converts timezone text from date string from CVS server and - * returns a timezone representing the received timezone. - * Timezone string is of the following format: [-|+]MMSS - */ - static private TimeZone getTimeZone(String dateFromServer) { - if (dateFromServer.lastIndexOf("0000") != -1) //$NON-NLS-1$ - return TimeZone.getTimeZone("GMT");//$NON-NLS-1$ - String tz = null; - StringBuffer resultTz = new StringBuffer("GMT");//$NON-NLS-1$ - if (dateFromServer.indexOf("-") != -1) {//$NON-NLS-1$ - resultTz.append("-");//$NON-NLS-1$ - tz = dateFromServer.substring(dateFromServer.indexOf("-"));//$NON-NLS-1$ - } else if (dateFromServer.indexOf("+") != -1) {//$NON-NLS-1$ - resultTz.append('+'); - tz = dateFromServer.substring(dateFromServer.indexOf("+"));//$NON-NLS-1$ - } - try { - if(tz!=null) { - resultTz.append(tz.substring(1, 3) /*hours*/ + ":" + tz.substring(3, 5) /*minutes*/);//$NON-NLS-1$ - return TimeZone.getTimeZone(resultTz.toString()); - } - } catch(IndexOutOfBoundsException e) { - return TimeZone.getTimeZone("GMT");//$NON-NLS-1$ - } - return TimeZone.getTimeZone("GMT");//$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java deleted file mode 100644 index 2447dacf1..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import java.util.ArrayList; -import java.util.List; - -/** - * A FileNameMatcher associates a String with a String pattern. - */ -public class FileNameMatcher { - - private List matchers = new ArrayList(); - private List results = new ArrayList(); - private static final String TRUE = "true"; //$NON-NLS-1$ - - public FileNameMatcher() { - } - - public FileNameMatcher(String[] patterns) { - register(patterns); - } - - void register(String[] patterns) { - for (int i = 0; i < patterns.length; i++) { - register(patterns[i],TRUE); - } - } - - public void register(String pattern, String result) { - - Assert.isTrue(matchers.size() == results.size()); - - pattern = pattern.trim(); - - // The empty pattern matches everything, but we want to match - // nothing with it, so we just do not register anything - if (pattern.length() == 0) { - return; - } - - matchers.add(new StringMatcher(pattern,false,false)); - results.add(result); - - } - - public String getMatch(String name) { - StringMatcher stringMatcher; - - for (int i = 0; i < matchers.size(); i++) { - stringMatcher = (StringMatcher) matchers.get(i); - if (stringMatcher.match(name)) { - return (String)results.get(i); - } - } - - return null; - } - - public boolean match(String name) { - return getMatch(name) != null; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java deleted file mode 100644 index 741a89ed6..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - -import java.util.*; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * This class keeps track of the CVS repository locations that are known to - * the CVS plugin. - */ -public class KnownRepositories { - - private List repositoryListeners = new ArrayList(); - private Map repositories; - - private static KnownRepositories instance; - - public static synchronized KnownRepositories getInstance() { - if (instance == null) { - instance = new KnownRepositories(); - } - return instance; - } - - /* - * Private class used to safely notify listeners of resouce sync info changes. - * Subclass override the notify(IResourceStateChangeListener) method to - * fire specific events inside an ISafeRunnable. - */ - private abstract class Notification implements ISafeRunnable { - private ICVSListener listener; - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in Platform#run - } - public void run(ICVSListener listener) { - this.listener = listener; - Platform.run(this); - } - public void run() throws Exception { - notify(listener); - } - /** - * Subsclasses overide this method to send an event safely to a lsistener - * @param listener - */ - protected abstract void notify(ICVSListener listener); - } - - /** - * Register to receive notification of repository creation and disposal - */ - public void addRepositoryListener(ICVSListener listener) { - synchronized(repositoryListeners) { - repositoryListeners.add(listener); - } - } - - /** - * De-register a listener - */ - public void removeRepositoryListener(ICVSListener listener) { - synchronized(repositoryListeners) { - repositoryListeners.remove(listener); - } - } - - /** - * Add the repository to the receiver's list of known repositories. Doing this will enable - * password caching accross platform invokations. - */ - public ICVSRepositoryLocation addRepository(final ICVSRepositoryLocation repository, boolean broadcast) { - // Check the cache for an equivalent instance and if there is one, just update the cache - CVSRepositoryLocation existingLocation = internalGetRepository(repository.getLocation()); - if (existingLocation == null) { - // Store the location - store((CVSRepositoryLocation)repository); - existingLocation = (CVSRepositoryLocation)repository; - } - // Notify no matter what since it may not have been broadcast before - if (broadcast) { - ((CVSRepositoryLocation)repository).updateCache(); - fireNotification(new Notification() { - public void notify(ICVSListener listener) { - listener.repositoryAdded(repository); - } - }); - } - return existingLocation; - } - - /** - * Dispose of the repository location - * - * Removes any cached information about the repository such as a remembered password. - */ - public void disposeRepository(final ICVSRepositoryLocation repository) { - ((CVSRepositoryLocation)repository).dispose(); - if (getRepositoriesMap().remove(repository.getLocation()) != null) { - fireNotification(new Notification() { - public void notify(ICVSListener listener) { - listener.repositoryRemoved(repository); - } - }); - } - } - - /** - * Answer whether the provided repository location is known by the provider or not. - * The location string corresponds to the Strin returned by ICVSRepositoryLocation#getLocation() - */ - public boolean isKnownRepository(String location) { - return internalGetRepository(location) != null; - } - - /** - * Return a list of the know repository locations - */ - public ICVSRepositoryLocation[] getRepositories() { - return (ICVSRepositoryLocation[])getRepositoriesMap().values().toArray(new ICVSRepositoryLocation[getRepositoriesMap().size()]); - } - - /** - * Get the repository instance which matches the given String. The format of the String is - * the same as that returned by ICVSRepositoryLocation#getLocation(). - * The format is: - * - * connection:user[:password]@host[#port]:root - * - * where [] indicates optional and the identier meanings are: - * - * connection The connection method to be used - * user The username for the connection - * password The password used for the connection (optional) - * host The host where the repository resides - * port The port to connect to (optional) - * root The server directory where the repository is located - * - * If the repository is already registered, the cahced instance is returned. - * Otherwise, a new uncached instance is returned. - * - * WARNING: Providing the password as part of the String will result in the password being part - * of the location permanently. This means that it cannot be modified by the authenticator. - */ - public ICVSRepositoryLocation getRepository(String location) throws CVSException { - ICVSRepositoryLocation repository = internalGetRepository(location); - if (repository == null) { - repository = CVSRepositoryLocation.fromString(location); - } - return repository; - } - - private CVSRepositoryLocation internalGetRepository(String location) { - return (CVSRepositoryLocation)getRepositoriesMap().get(location); - } - - /* - * Cache the location and store it in the preferences for persistance - */ - private void store(CVSRepositoryLocation location) { - // Cache the location instance for later retrieval - getRepositoriesMap().put(location.getLocation(), location); - location.storePreferences(); - } - - private Map getRepositoriesMap() { - if (repositories == null) { - // Load the repositories from the preferences - repositories = new HashMap(); - Preferences prefs = CVSRepositoryLocation.getParentPreferences(); - try { - String[] keys = prefs.childrenNames(); - for (int i = 0; i < keys.length; i++) { - String key = keys[i]; - try { - Preferences node = prefs.node(key); - String location = node.get(CVSRepositoryLocation.PREF_LOCATION, null); - if (location != null) { - repositories.put(location, CVSRepositoryLocation.fromString(location)); - } else { - node.removeNode(); - prefs.flush(); - } - } catch (CVSException e) { - // Log and continue - CVSProviderPlugin.log(e); - } - } - if (repositories.isEmpty()) { - getRepositoriesFromProjects(); - } - } catch (BackingStoreException e) { - // Log and continue (although all repos will be missing) - CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("KnownRepositories.0"), e); //$NON-NLS-1$ - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - } - return repositories; - } - - private void getRepositoriesFromProjects() throws CVSException { - // If the file did not exist, then prime the list of repositories with - // the providers with which the projects in the workspace are shared. - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - RepositoryProvider provider = RepositoryProvider.getProvider(projects[i], CVSProviderPlugin.getTypeId()); - if (provider!=null) { - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(projects[i]); - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info != null) { - addRepository(getRepository(info.getRoot()), false); - } - } - } - } - - private ICVSListener[] getListeners() { - synchronized(repositoryListeners) { - return (ICVSListener[]) repositoryListeners.toArray(new ICVSListener[repositoryListeners.size()]); - } - } - - private void fireNotification(Notification notification) { - // Get a snapshot of the listeners so the list doesn't change while we're firing - ICVSListener[] listeners = getListeners(); - // Notify each listener in a safe manner (i.e. so their exceptions don't kill us) - for (int i = 0; i < listeners.length; i++) { - ICVSListener listener = listeners[i]; - notification.run(listener); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java deleted file mode 100644 index 8dad4e254..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileModificationValidator; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.resources.team.IResourceTree; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; - -/** - * This hook exists to ensure that folders deletions will be recorded so that outgoing file - * deletions can be properly communicated to the server. - */ -public class MoveDeleteHook implements IMoveDeleteHook { - - /** - * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor) - */ - public boolean deleteFile( - final IResourceTree tree, - final IFile file, - final int updateFlags, - IProgressMonitor monitor) { - - try { - monitor.beginTask(null, 100); - - // No special handling required for team-private members - if (file.isTeamPrivateMember()) return false; - - // If the file is ignored by CVS then we can just delete it. - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - if (cvsFile.isIgnored()) return false; - - // If we can't check out the files, return. - if (!checkOutFiles(tree, new IFile[] {file}, Policy.subMonitorFor(monitor, 30))) { - // Return that the delete was handled because the checkout - // will have reported the error to the IResourceTree - return true; - } - - // Otherwise, we need to prepare properly for the delete - EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 100); - EclipseSynchronizer.getInstance().prepareForDeletion(file, Policy.subMonitorFor(monitor, 40)); - tree.standardDeleteFile(file, updateFlags, Policy.subMonitorFor(monitor, 60)); - } finally { - monitor.done(); - } - } - }, Policy.subMonitorFor(monitor, 70)); - } catch (CVSException e) { - tree.failed(e.getStatus()); - } finally { - monitor.done(); - } - return true; - } - - /** - * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor) - */ - public boolean deleteFolder( - final IResourceTree tree, - final IFolder folder, - final int updateFlags, - IProgressMonitor monitor) { - - // No special handling required for team-private members - if (folder.isTeamPrivateMember()) return false; - monitor.beginTask(null, 100); - try { - final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); - if (cvsFolder.isCVSFolder() && ensureCheckedOut(new IFolder[] {folder}, tree, Policy.subMonitorFor(monitor, 30))) { - EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 100); - EclipseSynchronizer.getInstance().prepareForDeletion(folder, Policy.subMonitorFor(monitor, 20)); - tree.standardDeleteFolder(folder, updateFlags, Policy.subMonitorFor(monitor, 50)); - } finally { - monitor.done(); - } - } - }, Policy.subMonitorFor(monitor, 70)); - return true; - } else if (!cvsFolder.isIgnored()) { - EclipseSynchronizer.getInstance().prepareForDeletion(cvsFolder.getIResource(), Policy.subMonitorFor(monitor, 70)); - } - } catch (CVSException e) { - tree.failed(e.getStatus()); - } finally { - monitor.done(); - } - return false; - } - - /** - * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor) - */ - public boolean deleteProject( - IResourceTree tree, - IProject project, - int updateFlags, - IProgressMonitor monitor) { - - // We need to flush any remembered folder deletions for the deleted project. - // All other sync info is stored in session and persistant properties, which - // are deleted when the associated resources are deleted - try { - EclipseSynchronizer.getInstance().prepareForDeletion(project, monitor); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - // todo: Perform a "cvs release" if there are any edits on the project - return false; - } - - /** - * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor) - */ - public boolean moveFile( - final IResourceTree tree, - final IFile source, - final IFile destination, - final int updateFlags, - IProgressMonitor monitor) { - - try { - monitor.beginTask(null, 100); - - // ensure we can write to both the source and the destination - IFile[] filesToCheckOut; - if (destination.exists()) { - filesToCheckOut = new IFile[] {source, destination}; - } else { - filesToCheckOut = new IFile[] {source}; - } - if (!checkOutFiles(tree, filesToCheckOut, Policy.subMonitorFor(monitor, 30))) { - // Return that the move was handled because the checkout - // will have reported the error to the IResourceTree - return true; - } - - // Perform the move - EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 100); - EclipseSynchronizer.getInstance().prepareForDeletion(source, Policy.subMonitorFor(monitor, 40)); - if (destination.exists()) { - EclipseSynchronizer.getInstance().prepareForDeletion(destination, Policy.subMonitorFor(monitor, 20)); - } - tree.standardMoveFile(source, destination, updateFlags, Policy.subMonitorFor(monitor, 40)); - EclipseSynchronizer.getInstance().postMove(destination); - } finally { - monitor.done(); - } - } - }, Policy.subMonitorFor(monitor, 70)); - } catch (CVSException e) { - tree.failed(e.getStatus()); - } finally { - monitor.done(); - } - return true; - } - - /** - * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor) - */ - public boolean moveFolder( - final IResourceTree tree, - final IFolder source, - final IFolder destination, - final int updateFlags, - IProgressMonitor monitor) { - - monitor.beginTask(null, 100); - try { - final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(source); - if (cvsFolder.isManaged()) { - if (!ensureCheckedOut(new IFolder[] {source, destination}, tree, Policy.subMonitorFor(monitor, 20))) return true; - EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - EclipseSynchronizer.getInstance().prepareForDeletion(source, Policy.subMonitorFor(monitor, 20)); - if (destination.exists()) { - EclipseSynchronizer.getInstance().prepareForDeletion(destination, Policy.subMonitorFor(monitor, 20)); - } - tree.standardMoveFolder(source, destination, updateFlags, Policy.subMonitorFor(monitor, 30)); - purgeCVSFolders(destination, Policy.subMonitorFor(monitor, 20)); - EclipseSynchronizer.getInstance().postMove(destination); - } - private void purgeCVSFolders(IFolder destination, final IProgressMonitor monitor) throws CVSException { - // Delete any CVS folders - try { - destination.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if (resource.getType() == IResource.FOLDER && resource.getName().equals(SyncFileWriter.CVS_DIRNAME)) { - tree.standardDeleteFolder((IFolder)resource, updateFlags, monitor); - return false; - } - return true; - } - }, IResource.DEPTH_INFINITE, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - }, Policy.subMonitorFor(monitor, 60)); - return true; - } else if (!cvsFolder.isIgnored()) { - EclipseSynchronizer.getInstance().prepareForDeletion(cvsFolder.getIResource(), Policy.subMonitorFor(monitor, 60)); - } - } catch (CVSException e) { - tree.failed(e.getStatus()); - return true; - } finally { - monitor.done(); - } - - return false; - } - - /** - * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor) - */ - public boolean moveProject( - IResourceTree tree, - IProject source, - IProjectDescription description, - int updateFlags, - IProgressMonitor monitor) { - - // We need to move (or flush) any remembered folder deletions for the deleted project - // XXX We flush for now. This means that deleting a managed folder and then moving the - // project will mean that the file deletions will be lost. It also means that phantom - // folders are lost. - try { - EclipseSynchronizer.getInstance().prepareForDeletion(source, monitor); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - return false; - } - - /** - * Ensure that the given file is checked out (i.e. not read only). Return - * true if it is OK to procede and false otherwise. - * - * @param tree - * @param file - * @return boolean - */ - /* private */ boolean checkOutFiles(IResourceTree tree, IFile[] files, IProgressMonitor monitor) { - // Ensure that the file is "checked out" (i.e. not read-only - IFileModificationValidator validator = getFileModificationValidator(files); - if (validator instanceof ICVSFileModificationValidator) { - IStatus status = ((ICVSFileModificationValidator)validator).validateMoveDelete(files, monitor); - if (status.isOK()) { - return true; - } else { - tree.failed(status); - return false; - } - } - return true; - } - - private boolean ensureCheckedOut(IFolder[] folders, IResourceTree tree, IProgressMonitor monitor) { - final List readOnlyFiles = new ArrayList(); - try { - // Find any read-only files - for (int i = 0; i < folders.length; i++) { - IFolder folder = folders[i]; - if (folder.exists()) { - folder.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if (resource.getType() == IResource.FILE) { - IFile file = (IFile) resource; - if (file.isReadOnly()) { - readOnlyFiles.add(file); - } - } - return true; - } - }); - } - } - if (readOnlyFiles.isEmpty()) return true; - // Ensure read-only files are checked out - return checkOutFiles(tree, (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), monitor); - } catch (CoreException e) { - tree.failed(e.getStatus()); - return false; - } - } - - private IFileModificationValidator getFileModificationValidator(IFile[] files) { - return getProvider(files).getFileModificationValidator(); - } - - private CVSTeamProvider getProvider(IFile[] files) { - CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(files[0].getProject(), CVSProviderPlugin.getTypeId()); - return provider; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java deleted file mode 100644 index 1f602b780..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * This class is used to prepare a local CVS workspace for replacement by - * the corresponding remote resources. More specifically, this class will - * unmanage added and deleted resources so that, after the operation, the - * resources in the local workspace will either correspond to the remote - * counterparts or be unmanaged. - */ -public class PrepareForReplaceVisitor implements ICVSResourceVisitor { - - private IProgressMonitor monitor; - private int depth; - - /** - * @see ICVSResourceVisitor#visitFile(ICVSFile) - */ - public void visitFile(ICVSFile file) throws CVSException { - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes == null) { - // Delete unmanaged files if the user wants them deleted - if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) { - file.delete(); - } - } else if (ResourceSyncInfo.isAddition(syncBytes)) { - file.delete(); - file.unmanage(null); - } else if (ResourceSyncInfo.isDeletion(syncBytes)) { - // If deleted, null the sync info so the file will be refetched - file.unmanage(null); - } else if (file.isModified(null)) { - // If the file is modified, delete and unmanage it and allow the - // replace operaton to fetch it again. This is required because "update -C" - // will fail for locally modified resources that have been deleted remotely. - file.delete(); - // Only unmanage if the delete was succesful (bug 76029) - file.unmanage(null); - } - monitor.worked(1); - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder folder) throws CVSException { - // Delete unmanaged folders if the user wants them deleted - if (!folder.isCVSFolder() && CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) { - folder.delete(); - } else { - // Visit the children of the folder as appropriate - if (depth == IResource.DEPTH_INFINITE) { - folder.acceptChildren(this); - } else if (depth == IResource.DEPTH_ONE) { - ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS); - for (int i = 0; i < files.length; i++) { - files[i].accept(this); - } - } - // Also delete ignored child files that start with .# - ICVSResource[] ignoredFiles = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.IGNORED_MEMBERS); - for (int i = 0; i < ignoredFiles.length; i++) { - ICVSResource cvsResource = ignoredFiles[i]; - if (cvsResource.getName().startsWith(".#")) { //$NON-NLS-1$ - cvsResource.delete(); - } - } - } - monitor.worked(1); - } - - public void visitResources(IProject project, final ICVSResource[] resources, final String key, int depth, IProgressMonitor pm) throws CVSException { - this.depth = depth; - CVSWorkspaceRoot.getCVSFolderFor(project).run(new ICVSRunnable() { - public void run(IProgressMonitor pm) throws CVSException { - monitor = Policy.infiniteSubMonitorFor(pm, 100); - monitor.beginTask(null, 512); - for (int i = 0; i < resources.length; i++) { - if (key != null) { - monitor.subTask(Policy.bind(key, resources[i].getIResource().getFullPath().toString())); //$NON-NLS-1$ - } - resources[i].accept(PrepareForReplaceVisitor.this); - } - monitor.done(); - } - }, pm); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java deleted file mode 100644 index e4f36e23b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.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.team.internal.ccvs.core.util; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -public class ReplaceWithBaseVisitor implements ICVSResourceVisitor { - - private IProgressMonitor monitor; - private int depth; - private Session session; - - /** - * @see ICVSResourceVisitor#visitFile(ICVSFile) - */ - public void visitFile(final ICVSFile file) throws CVSException { - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes == null) { - // Delete unmanaged files if the user wants them deleted - if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) { - file.delete(); - } - } else if (ResourceSyncInfo.isAddition(syncBytes)) { - file.delete(); - file.unmanage(null); - } else { - byte[] tagBytes = ResourceSyncInfo.getTagBytes(syncBytes); - boolean isModified = file.isModified(null); - if (ResourceSyncInfo.isDeletion(syncBytes)) { - // If deleted, null the sync info so the file will be refetched - syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes); - file.setSyncBytes(syncBytes, ICVSFile.UNKNOWN); - isModified = true; - } - // Fetch the file from the server - if (isModified) { - // Use the session opened in tghe replaceWithBase method to make the connection. - Command.UPDATE.execute(this.session, Command.NO_GLOBAL_OPTIONS, - new LocalOption[] {Update.makeTagOption(CVSTag.BASE), Update.IGNORE_LOCAL_CHANGES}, - new ICVSResource[] { file }, null, Policy.subMonitorFor(monitor, 1)); - - // Set the tag to be the original tag - syncBytes = file.getSyncBytes(); - syncBytes = ResourceSyncInfo.setTag(syncBytes, tagBytes); - file.setSyncBytes(syncBytes, ICVSFile.UNKNOWN); - } - } - monitor.worked(1); - } - - /** - * @see ICVSResourceVisitor#visitFolder(ICVSFolder) - */ - public void visitFolder(ICVSFolder folder) throws CVSException { - // Visit the children of the folder as appropriate - if (depth == IResource.DEPTH_INFINITE) { - folder.acceptChildren(this); - } else if (depth == IResource.DEPTH_ONE) { - ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS); - for (int i = 0; i < files.length; i++) { - files[i].accept(this); - } - } - // Also delete ignored child files that start with .# - ICVSResource[] ignoredFiles = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.IGNORED_MEMBERS); - for (int i = 0; i < ignoredFiles.length; i++) { - ICVSResource cvsResource = ignoredFiles[i]; - if (cvsResource.getName().startsWith(".#")) { //$NON-NLS-1$ - cvsResource.delete(); - } - } - monitor.worked(1); - } - - /* - * This method will replace any changed resources in the local workspace with the - * base resource. Although CVS allows this operation using "cvs update -r BASE" the - * results in the workspace are "sticky". This operation does not leave the local workspace "sticky". - * - * NOTE: This operation issues multiple commands over a single connection. It may fail - * with some servers that are configured to run scripts during an update (see bug 40145). - */ - public void replaceWithBase(IProject project, final IResource[] resources, int depth, IProgressMonitor pm) throws CVSException { - this.depth = depth; - final ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project); - FolderSyncInfo folderInfo = root.getFolderSyncInfo(); - IProgressMonitor monitor = Policy.monitorFor(pm); - monitor.beginTask(null, 100); - this.session = new Session(KnownRepositories.getInstance().getRepository(folderInfo.getRoot()), root, true /* creat e backups */); - this.session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - this.monitor = Policy.infiniteSubMonitorFor(monitor, 90); - this.monitor.beginTask(null, 512); - for (int i = 0; i < resources.length; i++) { - this.monitor.subTask(Policy.bind("ReplaceWithBaseVisitor.replacing", resources[i].getFullPath().toString())); //$NON-NLS-1$ - CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(this); - } - } finally { - this.session.close(); - monitor.done(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java deleted file mode 100644 index dec26d8f8..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener; -import org.eclipse.team.internal.ccvs.core.Policy; - -/** - * Class that manages the listeners of CVS sync change notification - */ -public class ResourceStateChangeListeners { - - private static List listeners = new ArrayList(); - - private static ResourceStateChangeListeners instance; - - public static synchronized ResourceStateChangeListeners getListener() { - if (instance == null) { - instance = new ResourceStateChangeListeners(); - } - return instance; - } - - /* - * Private class used to safely notify listeners of resouce sync info changes. - * Subclass override the notify(IResourceStateChangeListener) method to - * fire specific events inside an ISafeRunnable. - */ - private abstract class Notification implements ISafeRunnable { - private IResourceStateChangeListener listener; - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in Platform#run - } - public void run(IResourceStateChangeListener listener) { - this.listener = listener; - Platform.run(this); - } - public void run() throws Exception { - notify(listener); - } - /** - * Subsclasses overide this method to send an event safely to a lsistener - * @param listener - */ - protected abstract void notify(IResourceStateChangeListener listener); - } - - private IResourceStateChangeListener[] getListeners() { - synchronized(listeners) { - return (IResourceStateChangeListener[]) listeners.toArray(new IResourceStateChangeListener[listeners.size()]); - } - } - - private void fireNotification(Notification notification) { - // Get a snapshot of the listeners so the list doesn't change while we're firing - IResourceStateChangeListener[] listeners = getListeners(); - // Notify each listener in a safe manner (i.e. so their exceptions don't kill us) - for (int i = 0; i < listeners.length; i++) { - IResourceStateChangeListener listener = listeners[i]; - notification.run(listener); - } - } - - public void addResourceStateChangeListener(IResourceStateChangeListener listener) { - synchronized(listeners) { - listeners.add(listener); - } - } - - public void removeResourceStateChangeListener(IResourceStateChangeListener listener) { - synchronized(listeners) { - listeners.remove(listener); - } - } - - public void resourceSyncInfoChanged(final IResource[] resources) { - if (Policy.DEBUG_SYNC_CHANGE_EVENTS) { - printDebugInfo("Sync info change event ", resources); //$NON-NLS-1$ - } - fireNotification(new Notification() { - public void notify(IResourceStateChangeListener listener) { - listener.resourceSyncInfoChanged(resources); - } - }); - } - - public void externalSyncInfoChange(final IResource[] resources) { - if (Policy.DEBUG_SYNC_CHANGE_EVENTS) { - printDebugInfo("External sync info change event ", resources); //$NON-NLS-1$ - } - fireNotification(new Notification() { - public void notify(IResourceStateChangeListener listener) { - listener.externalSyncInfoChange(resources); - } - }); - } - - public void resourceModified(final IResource[] resources) { - if (Policy.DEBUG_SYNC_CHANGE_EVENTS) { - printDebugInfo("Resource modified change event ", resources); //$NON-NLS-1$ - } - fireNotification(new Notification() { - public void notify(IResourceStateChangeListener listener) { - listener.resourceModified(resources); - } - }); - } - public void projectConfigured(final IProject project) { - if (Policy.DEBUG_SYNC_CHANGE_EVENTS) { - printDebugInfo("Project configured change event ", new IResource[] { project }); //$NON-NLS-1$ - } - fireNotification(new Notification() { - public void notify(IResourceStateChangeListener listener) { - listener.projectConfigured(project); - } - }); - } - public void projectDeconfigured(final IProject project) { - if (Policy.DEBUG_SYNC_CHANGE_EVENTS) { - printDebugInfo("Project deconfigured change event ", new IResource[] { project }); //$NON-NLS-1$ - } - fireNotification(new Notification() { - public void notify(IResourceStateChangeListener listener) { - listener.projectDeconfigured(project); - } - }); - } - - private void printDebugInfo(String prefix, IResource[] resources) { - System.out.print(prefix); - System.out.print(" from thread " + Thread.currentThread().getName()); //$NON-NLS-1$ - System.out.print(" for the following " + resources.length + " resources"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(":"); //$NON-NLS-1$ - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - System.out.println(resource.getFullPath().toString()); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java deleted file mode 100644 index e9e151d36..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import java.util.*; - -/** - * A string pattern matcher, suppporting * and ? wildcards. - * Note: code copied from org.eclipse.jdt.internal.core.util.StringMatcher on April 3, 2001 - * (version 0.1 - 010901H18 [rename jbl]). - */ -public class StringMatcher { - protected String fPattern; - protected int fLength; // pattern length - protected boolean fIgnoreWildCards; - protected boolean fIgnoreCase; - protected boolean fHasLeadingStar; - protected boolean fHasTrailingStar; - protected String fSegments[]; //the given pattern is split into * separated segments - - /* boundary value beyond which we don't need to search in the text */ - protected int fBound = 0; - - - protected static final char fSingleWildCard = '\u0000'; - - public static class Position { - int start; //inclusive - int end; //exclusive - public Position(int start, int end) { - this.start = start; - this.end = end; - } - public int getStart() { - return start; - } - public int getEnd() { - return end; - } - } - /** - * Find the first occurrence of the pattern between startend(exclusive). - * @param text, the String object to search in - * @param start, the starting index of the search range, inclusive - * @param end, the ending index of the search range, exclusive - * @return an StringMatcher.Position object that keeps the starting - * (inclusive) and ending positions (exclusive) of the first occurrence of the - * pattern in the specified range of the text; return null if not found or subtext - * is empty (start==end). A pair of zeros is returned if pattern is empty string - * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc" - * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned - */ - - public StringMatcher.Position find(String text, int start, int end) { - if (fPattern == null|| text == null) - throw new IllegalArgumentException(); - - int tlen = text.length(); - if (start < 0) - start = 0; - if (end > tlen) - end = tlen; - if (end < 0 ||start >= end ) - return null; - if (fLength == 0) - return new Position(start, start); - if (fIgnoreWildCards) { - int x = posIn(text, start, end); - if (x < 0) - return null; - return new Position(x, x+fLength); - } - - int segCount = fSegments.length; - if (segCount == 0)//pattern contains only '*'(s) - return new Position (start, end); - - int curPos = start; - int matchStart = -1; - int i; - for (i = 0; i < segCount && curPos < end; ++i) { - String current = fSegments[i]; - int nextMatch = regExpPosIn(text, curPos, end, current); - if (nextMatch < 0 ) - return null; - if(i == 0) - matchStart = nextMatch; - curPos = nextMatch + current.length(); - } - if (i < segCount) - return null; - return new Position(matchStart, curPos); - } - /** - * StringMatcher constructor takes in a String object that is a simple - * pattern which may contain *  for 0 and many characters and - * ?  for exactly one character. - * - * Literal '*' and '?' characters must be escaped in the pattern - * e.g., "\*" means literal "*", etc. - * - * Escaping any other character (including the escape character itself), - * just results in that character in the pattern. - * e.g., "\a" means "a" and "\\" means "\" - * - * If invoking the StringMatcher with string literals in Java, don't forget - * escape characters are represented by "\\". - * - * @param aPattern the pattern to match text with - * @param ignoreCase if true, case is ignored - * @param ignoreWildCards if true, wild cards and their escape sequences are ignored - * (everything is taken literally). - */ - public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) { - fIgnoreCase = ignoreCase; - fIgnoreWildCards = ignoreWildCards; - fLength = aPattern.length(); - - /* convert case */ - if (fIgnoreCase) { - fPattern = aPattern.toUpperCase(); - } else { - fPattern = aPattern; - } - - if (fIgnoreWildCards) { - parseNoWildCards(); - } else { - parseWildCards(); - } - } - /** - * Given the starting (inclusive) and the ending (exclusive) poisitions in the - * text, determine if the given substring matches with aPattern - * @return true if the specified portion of the text matches the pattern - * @param String text, a String object that contains the substring to match - * @param int start marks the starting position (inclusive) of the substring - * @param int end marks the ending index (exclusive) of the substring - */ - public boolean match(String text, int start, int end) { - if (null == text) - throw new IllegalArgumentException(); - - if (start > end) - return false; - - if (fIgnoreWildCards) - return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); - int segCount= fSegments.length; - if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s) - return true; - if (start == end) - return fLength == 0; - if (fLength == 0) - return start == end; - - int tlen= text.length(); - if (start < 0) - start= 0; - if (end > tlen) - end= tlen; - - int tCurPos= start; - int bound= end - fBound; - if ( bound < 0) - return false; - int i=0; - String current= fSegments[i]; - int segLength= current.length(); - - /* process first segment */ - if (!fHasLeadingStar){ - if(!regExpRegionMatches(text, start, current, 0, segLength)) { - return false; - } else { - ++i; - tCurPos= tCurPos + segLength; - } - } - if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) { - // only one segment to match, no wildcards specified - return tCurPos == end; - } - /* process middle segments */ - while (i < segCount) { - current= fSegments[i]; - int currentMatch; - int k= current.indexOf(fSingleWildCard); - if (k < 0) { - currentMatch= textPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } else { - currentMatch= regExpPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } - tCurPos= currentMatch + current.length(); - i++; - } - - /* process final segment */ - if (!fHasTrailingStar && tCurPos != end) { - int clen= current.length(); - return regExpRegionMatches(text, end - clen, current, 0, clen); - } - return i == segCount ; - } - /** - * match the given text with the pattern - * @return true if matched eitherwise false - * @param text, a String object - */ - public boolean match(String text) { - return match(text, 0, text.length()); - } - /** - * This method parses the given pattern into segments separated by wildcard '*' characters. - * Since wildcards are not being used in this case, the pattern consists of a single segment. - */ - private void parseNoWildCards() { - fSegments = new String[1]; - fSegments[0] = fPattern; - fBound = fLength; - } - /** - * This method parses the given pattern into segments separated by wildcard '*' characters. - * @param p, a String object that is a simple regular expression with *  and/or ?  - */ - private void parseWildCards() { - if(fPattern.startsWith("*"))//$NON-NLS-1$ - fHasLeadingStar = true; - if(fPattern.endsWith("*")) {//$NON-NLS-1$ - /* make sure it's not an escaped wildcard */ - if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') { - fHasTrailingStar = true; - } - } - - Vector temp = new Vector(); - - int pos = 0; - StringBuffer buf = new StringBuffer(); - while (pos < fLength) { - char c = fPattern.charAt(pos++); - switch (c) { - case '\\': - if (pos >= fLength) { - buf.append(c); - } else { - char next = fPattern.charAt(pos++); - /* if it's an escape sequence */ - if (next == '*' || next == '?' || next == '\\') { - buf.append(next); - } else { - /* not an escape sequence, just insert literally */ - buf.append(c); - buf.append(next); - } - } - break; - case '*': - if (buf.length() > 0) { - /* new segment */ - temp.addElement(buf.toString()); - fBound += buf.length(); - buf.setLength(0); - } - break; - case '?': - /* append special character representing single match wildcard */ - buf.append(fSingleWildCard); - break; - default: - buf.append(c); - } - } - - /* add last buffer to segment list */ - if (buf.length() > 0) { - temp.addElement(buf.toString()); - fBound += buf.length(); - } - - fSegments = new String[temp.size()]; - temp.copyInto(fSegments); - } - /** - * @param text, a string which contains no wildcard - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int posIn(String text, int start, int end) {//no wild card in pattern - int max = end - fLength; - - if (!fIgnoreCase) { - int i = text.indexOf(fPattern, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i = start; i <= max; ++i) { - if (text.regionMatches(true, i, fPattern, 0, fLength)) - return i; - } - - return -1; - } - /** - * @param text, a simple regular expression that may only contain '?'(s) - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param p, a simple regular expression that may contains '?' - * @param caseIgnored, wether the pattern is not casesensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int regExpPosIn(String text, int start, int end, String p) { - int plen = p.length(); - - int max = end - plen; - for (int i = start; i <= max; ++i) { - if (regExpRegionMatches(text, i, p, 0, plen)) - return i; - } - return -1; - } - /** - * - * @return boolean - * @param text, a String to match - * @param start, int that indicates the starting index of match, inclusive - * @param end int that indicates the ending index of match, exclusive - * @param p, String, String, a simple regular expression that may contain '?' - * @param ignoreCase, boolean indicating wether code>p is case sensitive - */ - protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { - while (plen-- > 0) { - char tchar = text.charAt(tStart++); - char pchar = p.charAt(pStart++); - - /* process wild cards */ - if (!fIgnoreWildCards) { - /* skip single wild cards */ - if (pchar == fSingleWildCard) { - continue; - } - } - if (pchar == tchar) - continue; - if (fIgnoreCase) { - char tc = Character.toUpperCase(tchar); - if (tc == pchar) - continue; - } - return false; - } - return true; - } - /** - * @param text, the string to match - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param code>p, a string that has no wildcard - * @param ignoreCase, boolean indicating wether code>p is case sensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int textPosIn(String text, int start, int end, String p) { - - int plen = p.length(); - int max = end - plen; - - if (!fIgnoreCase) { - int i = text.indexOf(p, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i = start; i <= max; ++i) { - if (text.regionMatches(true, i, p, 0, plen)) - return i; - } - - return -1; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java deleted file mode 100644 index 2caffd3e2..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.syncinfo.DeferredResourceChangeHandler; - -/* - * Listens to CVS meta-file changes and notifies the EclipseSynchronizer of changes made to sync files - * by 3rd parties. - * - * If CVS meta-directories are created outside of the CVS plugin their team-private state will be set - * by this listener however this change won't be known to other plugins because it does not generate - * a delta. As a result views, such as the navigator, may show CVS team-private directories. There - * are some common scenarios where a user may (depending on the order of delta traversal) see - * this behavior: - * - * 1. A user has an existing CVS project outside of Eclipse. By creating the project in Eclipse to point - * to the existing location the project's contents will be brought into Eclipse and the CVS folders - * will be marlked as team-private but other delta listeners that have handled the event already won't receive - * notification that the resource is now team-private. As a result, the user may have to close views or - * restart the workbench to have the CVS folders filtered. - * - * 2. A user performs CVS command line operations outside of Eclipse that result in new CVS folders. - * From Eclipse the refresh local will bring in the new folders and they will be marked as team-private. - * But as in 1, they may not appear in the UI. - * - * See: http://dev.eclipse.org/bugs/show_bug.cgi?id=12386 - */ -public class SyncFileChangeListener implements IResourceChangeListener { - - // consider the following changes types and ignore the others (e.g. marker and description changes are ignored) - protected int INTERESTING_CHANGES = IResourceDelta.CONTENT | - IResourceDelta.MOVED_FROM | - IResourceDelta.MOVED_TO | - IResourceDelta.OPEN | - IResourceDelta.REPLACED | - IResourceDelta.TYPE; - - protected boolean isProjectOpening = false; - - protected static DeferredResourceChangeHandler deferredHandler = new DeferredResourceChangeHandler(); - - /** - * This accessor is for use by test cases only. - * - * @return Returns the deferredHandler. - */ - public static DeferredResourceChangeHandler getDeferredHandler() { - return deferredHandler; - } - - /* - * When a resource changes this method will detect if the changed resources is a meta file that has changed - * by a 3rd party. For example, if the command line tool was run and then the user refreshed from local. To - * distinguish changes made by this class and thoses made by others a modification stamp is persisted with each - * metafile. - * - * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - final Set changedContainers = new HashSet(); - final Set externalDeletions = new HashSet(); - - setProjectOpening(false); - - event.getDelta().accept(new IResourceDeltaVisitor() { - - public boolean visit(IResourceDelta delta) { - IResource resource = delta.getResource(); - - if(resource.getType()==IResource.ROOT) { - // continue with the delta - return true; - } - - if (resource.getType() == IResource.PROJECT) { - // If the project is not accessible, don't process it - if (!resource.isAccessible()) return false; - setProjectOpening((delta.getFlags() & IResourceDelta.OPEN) != 0); - } - - String name = resource.getName(); - int kind = delta.getKind(); - - // if the file has changed but not in a way that we care - // then ignore the change (e.g. marker changes to files). - if(kind == IResourceDelta.CHANGED && - (delta.getFlags() & INTERESTING_CHANGES) == 0) { - return true; - } - - if(name.equals(SyncFileWriter.CVS_DIRNAME)) { - handleCVSDir((IContainer)resource, kind); - // if the project is opening there is no need to notify about chagned CVs/ meta files - // they will all be read from disk. - if(isProjectOpening()) return false; - } else { - // Inform the synchronizer about folder creations - if(isProjectOpening()) return true; - } - - if(isMetaFile(resource)) { - IResource[] toBeNotified = handleChangedMetaFile(resource); - if(toBeNotified.length>0 && isModifiedBy3rdParty(resource)) { - for (int i = 0; i < toBeNotified.length; i++) { - changedContainers.add(toBeNotified[i]); - } - if(Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath()); //$NON-NLS-1$ - } - return false; /*don't visit any children we have all the information we need*/ - } - } else if(isIgnoreFile(resource) && isModifiedBy3rdParty(resource)) { - deferredHandler.ignoreFileChanged((IFile)resource); - } else if (isExternalDeletion(resource, kind)) { - externalDeletions.add(resource); - } else if (kind == IResourceDelta.ADDED && isRecreation(resource)) { - deferredHandler.recreated(resource); - } - return true; - } - }, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS); - - if(!changedContainers.isEmpty() || !externalDeletions.isEmpty()) { - EclipseSynchronizer.getInstance().syncFilesChangedExternally( - (IContainer[])changedContainers.toArray(new IContainer[changedContainers.size()]), - (IFile[]) externalDeletions.toArray(new IFile[externalDeletions.size()])); - } - } catch(CoreException e) { - CVSProviderPlugin.log(e); - } - } - - /** - * Treat a resource as an external deletion if - * - it is a file - * - the delta says the file was removed - * - the file is not managed but its parent is a CVS folder - * - * There will be some false positives but the reaction to this situation - * is to purge the cahced CVS meta-information so nothing bad will happen - * for the false positives. - * - * @param resource - * @param kind - * @return - */ - protected boolean isExternalDeletion(IResource resource, int kind) { - if (kind != IResourceDelta.REMOVED) return false; - if (resource.getType() != IResource.FILE) return false; - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - try { - return (!file.isManaged() && file.getParent().isCVSFolder() && file.getParent().exists()); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return false; - } - } - - /* - * Consider non-existing resources as being recently deleted and thus modified, and resources - * with modification stamps that differ from when the CVS plugin last modified the meta-file. - */ - protected boolean isModifiedBy3rdParty(IResource resource) { - if(!resource.exists()) return true; - long modStamp = resource.getModificationStamp(); - Long whenWeWrote; - try { - whenWeWrote = (Long)resource.getSessionProperty(SyncFileWriter.MODSTAMP_KEY); - } catch(CoreException e) { - CVSProviderPlugin.log(e); - whenWeWrote = null; - } - return (whenWeWrote==null || whenWeWrote.longValue() != modStamp); - } - - /* - * If it's a new CVS directory with the canonical child metafiles then mark it as team-private. Otherwise - * if changed or deleted - */ - protected void handleCVSDir(IContainer cvsDir, int kind) { - if((kind & IResourceDelta.ALL_WITH_PHANTOMS)!=0) { - if(kind==IResourceDelta.ADDED) { - // should this dir be made team-private? If it contains CVS/Root and CVS/Repository then yes! - IFile rootFile = cvsDir.getFile(new Path(SyncFileWriter.ROOT)); - IFile repositoryFile = cvsDir.getFile(new Path(SyncFileWriter.REPOSITORY)); - if(rootFile.exists() && repositoryFile.exists() && !cvsDir.isTeamPrivateMember()) { - try { - // TODO: Is this considered a tree modification? - cvsDir.setTeamPrivateMember(true); - if(Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("[cvs] found a new CVS meta folder, marking as team-private: " + cvsDir.getFullPath()); //$NON-NLS-1$ - } - } catch(CoreException e) { - CVSProviderPlugin.log(CVSException.wrapException(cvsDir, Policy.bind("SyncFileChangeListener.errorSettingTeamPrivateFlag"), e)); //$NON-NLS-1$ - } - } - } - } - } - - protected boolean isIgnoreFile(IResource resource) { - return resource.getType() == IResource.FILE && - resource.getName().equals(SyncFileWriter.IGNORE_FILE); - } - - private boolean isRecreation(IResource resource) { - return EclipseSynchronizer.getInstance().wasPhantom(resource); - } - - /* - * It's a meta file if it's parent is a team-private CVS folder. - */ - protected boolean isMetaFile(IResource resource) { - IContainer parent = resource.getParent(); - return resource.getType() == IResource.FILE && - parent!=null && - parent.getName().equals(SyncFileWriter.CVS_DIRNAME) && - (parent.isTeamPrivateMember() || !parent.exists()); - } - - /* - * This is a meta file (e.g. folder/CVS/Entries), notify that 'folder' and it's immediate children - * may have their CVS sync state changed. If the 'folder' is deleted than no notification is - * required. - */ - protected IContainer[] handleChangedMetaFile(IResource resource) { - IContainer changedContainer = resource.getParent().getParent(); - if(changedContainer.exists()) { - return new IContainer[] {changedContainer}; - } else { - return new IContainer[0]; - } - } - - /** - * @return boolean - */ - public boolean isProjectOpening() { - return isProjectOpening; - } - - /** - * Sets the isProjectOpening. - * @param isProjectOpening The isProjectOpening to set - */ - public void setProjectOpening(boolean isProjectOpening) { - this.isProjectOpening = isProjectOpening; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java deleted file mode 100644 index b23fe4659..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java +++ /dev/null @@ -1,688 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag; -import org.eclipse.team.internal.ccvs.core.syncinfo.BaserevInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/* - * This is a helper class that knows the format of the CVS metafiles. It - * provides a bridge between the CVS metafile formats and location to the - * Eclipse CVS client ResourceSyncInfo and FolderSyncInfo types. - */ -public class SyncFileWriter { - - // the famous CVS meta directory name - public static final String CVS_DIRNAME = "CVS"; //$NON-NLS-1$ - - // CVS meta files located in the CVS subdirectory - public static final String REPOSITORY = "Repository"; //$NON-NLS-1$ - public static final String ROOT = "Root"; //$NON-NLS-1$ - public static final String STATIC = "Entries.Static"; //$NON-NLS-1$ - public static final String TAG = "Tag"; //$NON-NLS-1$ - public static final String ENTRIES = "Entries"; //$NON-NLS-1$ - //private static final String PERMISSIONS = "Permissions"; //$NON-NLS-1$ - public static final String ENTRIES_LOG="Entries.Log"; //$NON-NLS-1$ - public static final String NOTIFY = "Notify"; //$NON-NLS-1$ - public static final String BASE_DIRNAME = "Base"; //$NON-NLS-1$ - public static final String BASEREV = "Baserev"; //$NON-NLS-1$ - - // the local workspace file that contains pattern for ignored resources - public static final String IGNORE_FILE = ".cvsignore"; //$NON-NLS-1$ - - // Some older CVS clients may of added a line to the entries file consisting - // of only a 'D'. It is safe to ingnore these entries. - private static final String FOLDER_TAG="D"; //$NON-NLS-1$ - - // Command characters found in the Entries.log file - private static final String ADD_TAG="A "; //$NON-NLS-1$ - private static final String REMOVE_TAG="R "; //$NON-NLS-1$ - - // key for saving the mod stamp for each writen meta file - public static final QualifiedName MODSTAMP_KEY = new QualifiedName("org.eclipse.team.cvs.core", "meta-file-modtime"); //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Reads the CVS/Entries, CVS/Entries.log and CVS/Permissions files from the - * specified folder and returns ResourceSyncInfo instances for the data stored therein. - * If the folder does not have a CVS subdirectory then null is returned. - */ - public static byte[][] readAllResourceSync(IContainer parent) throws CVSException { - IFolder cvsSubDir = getCVSSubdirectory(parent); - if (! cvsSubDir.exists()) return null; - - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Reading Entries file for " + parent.getFullPath()); //$NON-NLS-1$ - } - - // process Entries file contents - String[] entries = readLines(cvsSubDir.getFile(ENTRIES)); - if (entries == null) return null; - Map infos = new TreeMap(); - for (int i = 0; i < entries.length; i++) { - String line = entries[i]; - if(!FOLDER_TAG.equals(line) && !"".equals(line)) { //$NON-NLS-1$ - try { - ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); - infos.put(info.getName(), info); - } catch (CVSException e) { - // There was a problem parsing the entry line. - // Log the problem and skip the entry - CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR, Policy.bind("SyncFileWriter.0", parent.getFullPath().toString()), e)); //$NON-NLS-1$ - } - } - } - - // process Entries.log file contents - String[] entriesLog = readLines(cvsSubDir.getFile(ENTRIES_LOG)); - if (entriesLog != null) { - for (int i = 0; i < entriesLog.length; i++) { - String line = entriesLog[i]; - if (line.startsWith(ADD_TAG)) { - line = line.substring(ADD_TAG.length()); - ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); - infos.put(info.getName(), info); - } else if (line.startsWith(REMOVE_TAG)) { - line = line.substring(REMOVE_TAG.length()); - ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); - infos.remove(info.getName()); - } - } - } - - //return (ResourceSyncInfo[])infos.values().toArray(new ResourceSyncInfo[infos.size()]); - byte[][] result = new byte[infos.size()][]; - int i = 0; - for (Iterator iter = infos.values().iterator(); iter.hasNext();) { - ResourceSyncInfo info = (ResourceSyncInfo) iter.next(); - result[i++] = info.getBytes(); - } - return result; - } - - public static void writeAllResourceSync(IContainer parent, byte[][] infos) throws CVSException { - try { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Writing Entries file for folder " + parent.getFullPath()); //$NON-NLS-1$ - } - IFolder cvsSubDir = createCVSSubdirectory(parent); - - // format file contents - String[] entries = new String[infos.length]; - for (int i = 0; i < infos.length; i++) { - byte[] info = infos[i]; - entries[i] = new String(info); - } - - // write Entries - writeLines(cvsSubDir.getFile(ENTRIES), entries); - - // delete Entries.log - cvsSubDir.getFile(ENTRIES_LOG).delete(IResource.NONE, null); - } catch(CoreException e) { - throw CVSException.wrapException(e); - } - } - /** - * Reads the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files from - * the specified folder and returns a FolderSyncInfo instance for the data stored therein. - * If the folder does not have a CVS subdirectory then null is returned. - */ - public static FolderSyncInfo readFolderSync(IContainer folder) throws CVSException { - IFolder cvsSubDir = getCVSSubdirectory(folder); - if (! cvsSubDir.exists()) return null; - - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Reading Root/Repository files for " + folder.getFullPath()); //$NON-NLS-1$ - } - - // check to make sure the the cvs folder is hidden - if (!cvsSubDir.isTeamPrivateMember()) { - try { - cvsSubDir.setTeamPrivateMember(true); - } catch (CoreException e) { - CVSProviderPlugin.log(e); - } - } - - // read CVS/Root - String root = readFirstLine(cvsSubDir.getFile(ROOT)); - if (root == null) return null; - - // read CVS/Repository - String repository = readFirstLine(cvsSubDir.getFile(REPOSITORY)); - if (repository == null) return null; - - // read CVS/Tag - String tag = readFirstLine(cvsSubDir.getFile(TAG)); - if (Policy.DEBUG_METAFILE_CHANGES && tag != null) { - System.out.println("Reading Tag file for " + folder.getFullPath()); //$NON-NLS-1$ - } - CVSTag cvsTag = (tag != null) ? new CVSEntryLineTag(tag) : null; - - // read Entries.Static - String staticDir = readFirstLine(cvsSubDir.getFile(STATIC)); - if (Policy.DEBUG_METAFILE_CHANGES && staticDir != null) { - System.out.println("Reading Static file for " + folder.getFullPath()); //$NON-NLS-1$ - } - boolean isStatic = (staticDir != null); - - // return folder sync - return new FolderSyncInfo(repository, root, cvsTag, isStatic); - } - - /** - * Writes the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files to the - * specified folder using the data contained in the specified FolderSyncInfo instance. - */ - public static void writeFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException { - try { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Writing Root/Respository files for " + folder.getFullPath()); //$NON-NLS-1$ - } - IFolder cvsSubDir = createCVSSubdirectory(folder); - - // write CVS/Root - writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()}); - - // write CVS/Repository - writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()}); - - // write CVS/Tag - IFile tagFile = cvsSubDir.getFile(TAG); - if (info.getTag() != null) { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Writing Tag file for " + folder.getFullPath()); //$NON-NLS-1$ - } - writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)}); - } else { - if(tagFile.exists()) { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Deleting Tag file for " + folder.getFullPath()); //$NON-NLS-1$ - } - tagFile.delete(IResource.NONE, null); - } - } - - // write CVS/Entries.Static - IFile staticFile = cvsSubDir.getFile(STATIC); - if(info.getIsStatic()) { - // the existance of the file is all that matters - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Writing Static file for " + folder.getFullPath()); //$NON-NLS-1$ - } - writeLines(staticFile, new String[] {""}); //$NON-NLS-1$ - } else { - if(staticFile.exists()) { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Deleting Static file for " + folder.getFullPath()); //$NON-NLS-1$ - } - staticFile.delete(IResource.NONE, null); - } - } - } catch(CoreException e) { - throw CVSException.wrapException(e); - } - } - - /** - * Returns all .cvsignore entries for the specified folder. - */ - public static String[] readCVSIgnoreEntries(IContainer folder) throws CVSException { - IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE)); - if (ignoreFile != null) { - return readLines(ignoreFile); - } - return null; - } - - /** - * Writes all entries to the specified folder's .cvsignore file, overwriting any - * previous edition of the file. - */ - public static void writeCVSIgnoreEntries(IContainer folder, String[] patterns) throws CVSException { - IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE)); - writeLines(ignoreFile, patterns); - } - - /** - * Delete folder sync is equilavent to removing the CVS subdir. - */ - public static void deleteFolderSync(IContainer folder) throws CVSException { - try { - if (Policy.DEBUG_METAFILE_CHANGES) { - System.out.println("Deleting CVS directory from " + folder.getFullPath()); //$NON-NLS-1$ - } - getCVSSubdirectory(folder).delete(IResource.NONE, null); - } catch(CoreException e) { - throw CVSException.wrapException(e); - } - } - - /** - * Reads the CVS/Notify file from the specified folder and returns NotifyInfo instances - * for the data stored therein. If the folder does not have a CVS subdirectory then null is returned. - */ - public static NotifyInfo[] readAllNotifyInfo(IContainer parent) throws CVSException { - IFolder cvsSubDir = getCVSSubdirectory(parent); - if (! cvsSubDir.exists()) return null; - - // process Notify file contents - String[] entries = readLines(cvsSubDir.getFile(NOTIFY)); - if (entries == null) return null; - Map infos = new TreeMap(); - for (int i = 0; i < entries.length; i++) { - String line = entries[i]; - if(!"".equals(line)) { //$NON-NLS-1$ - try { - NotifyInfo info = new NotifyInfo(parent, line); - infos.put(info.getName(), info); - } catch (CVSException e) { - // We couldn't parse the notify info - // Log it and ignore - CVSProviderPlugin.log(e); - } - } - } - - return (NotifyInfo[])infos.values().toArray(new NotifyInfo[infos.size()]); - } - - /** - * Writes the CVS/Notify file to the specified folder using the data contained in the - * specified NotifyInfo instances. A CVS subdirectory must already exist (an exception - * is thrown if it doesn't). - */ - public static void writeAllNotifyInfo(IContainer parent, NotifyInfo[] infos) throws CVSException { - // get the CVS directory - IFolder cvsSubDir = getCVSSubdirectory(parent); - // write lines will throw an exception if the CVS directoru does not exist - - if (infos.length == 0) { - // if there are no notify entries, delete the notify file - try { - IFile notifyFile = cvsSubDir.getFile(NOTIFY); - if(notifyFile.exists()) { - notifyFile.delete(IResource.NONE, null); - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } else { - // format file contents - String[] entries = new String[infos.length]; - for (int i = 0; i < infos.length; i++) { - NotifyInfo info = infos[i]; - entries[i] = info.getNotifyLine(); - } - - // write Notify entries - writeLines(cvsSubDir.getFile(NOTIFY), entries); - } - } - - /** - * Reads the CVS/Baserev file from the specified folder and returns - * BaserevInfo instances for the data stored therein. If the folder does not - * have a CVS subdirectory then null is returned. - */ - public static BaserevInfo[] readAllBaserevInfo(IContainer parent) throws CVSException { - IFolder cvsSubDir = getCVSSubdirectory(parent); - if (! cvsSubDir.exists()) return null; - - // process Notify file contents - String[] entries = readLines(cvsSubDir.getFile(BASEREV)); - if (entries == null) return null; - Map infos = new TreeMap(); - for (int i = 0; i < entries.length; i++) { - String line = entries[i]; - if(!"".equals(line)) { //$NON-NLS-1$ - BaserevInfo info = new BaserevInfo(line); - infos.put(info.getName(), info); - } - } - - return (BaserevInfo[])infos.values().toArray(new BaserevInfo[infos.size()]); - } - - /** - * Writes the CVS/Baserev file to the specified folder using the data - * contained in the specified BaserevInfo instances. A CVS subdirectory must - * already exist (an exception is thrown if it doesn't). - */ - public static void writeAllBaserevInfo(IContainer parent, BaserevInfo[] infos) throws CVSException { - // get the CVS directory - IFolder cvsSubDir = getCVSSubdirectory(parent); - // write lines will throw an exception if the CVS directory does not exist - - // format file contents - String[] entries = new String[infos.length]; - for (int i = 0; i < infos.length; i++) { - BaserevInfo info = infos[i]; - entries[i] = info.getEntryLine(); - } - - // write Notify entries - writeLines(cvsSubDir.getFile(BASEREV), entries); - } - - /** - * Returns the CVS subdirectory for this folder. - */ - private static IFolder getCVSSubdirectory(IContainer folder) { - return folder.getFolder(new Path(CVS_DIRNAME)); - } - - /** - * Creates and makes team-private and returns a CVS subdirectory in this folder. - */ - private static IFolder createCVSSubdirectory(IContainer folder) throws CVSException { - try { - final IFolder cvsSubDir = getCVSSubdirectory(folder); - if (! cvsSubDir.exists()) { - // important to have both the folder creation and setting of team-private in the - // same runnable so that the team-private flag is set before other delta listeners - // sees the CVS folder creation. - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // Recheck existance in case this method was called without a resource rule - if (! cvsSubDir.exists()) { - cvsSubDir.create(false /*don't force*/, true /*make local*/, null); - } - cvsSubDir.setTeamPrivateMember(true); - } - }, folder, 0, null); - } - return cvsSubDir; - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Reads the first line of the specified file. - * Returns null if the file does not exist, or the empty string if it is blank. - */ - private static String readFirstLine(IFile file) throws CVSException { - if (! file.exists()) return null; - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents(true)), 512); - try { - String line = reader.readLine(); - if (line == null) return ""; //$NON-NLS-1$ - return line; - } finally { - reader.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); - } catch (CoreException e) { - // If the IFile doesn't exist or the underlying File doesn't exist, - // just return null to indicate the absence of the file - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND - || e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) - return null; - throw CVSException.wrapException(e); - } - } - - /* - * Reads all lines of the specified file. - * Returns null if the file does not exist. - */ - private static String[] readLines(IFile file) throws CVSException { - try { - if(! file.exists()) return null; - // Peform a forced read (ignoring out-of-sync) - BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents(true))); - List fileContentStore = new ArrayList(); - try { - String line; - while ((line = reader.readLine()) != null) { - fileContentStore.add(line); - } - return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]); - } finally { - reader.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); - } catch (CoreException e) { - // If the IFile doesn't exist or the underlying File doesn't exist, - // just return null to indicate the absence of the file - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND - || e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) - return null; - throw CVSException.wrapException(e); - } - } - - /* - * Reads all lines of the specified file. - * Returns null if the file does not exist. - */ - public static byte[][] readLines(InputStream stream) throws CVSException { - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - List fileContentStore = new ArrayList(); - try { - String line; - while ((line = reader.readLine()) != null) { - fileContentStore.add(line.getBytes()); - } - return (byte[][]) fileContentStore.toArray(new byte[fileContentStore.size()][]); - } finally { - reader.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Writes all lines to the specified file, using linefeed terminators for - * compatibility with other CVS clients. - */ - private static void writeLines(final IFile file, final String[] contents) throws CVSException { - try { - // The creation of sync files has to be in a runnable in order for the resulting delta - // to include the MODSTAMP value. If not in a runnable then create/setContents - // will trigger a delta and the SyncFileWriter change listener won't know that the delta - // was a result of our own creation. - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - writeLinesToStreamAndClose(os, contents); - if(!file.exists()) { - file.create(new ByteArrayInputStream(os.toByteArray()), IResource.FORCE /*don't keep history but do force*/, null); - } else { - file.setContents(new ByteArrayInputStream(os.toByteArray()), IResource.FORCE /*don't keep history but do force*/, null); - } - file.setSessionProperty(MODSTAMP_KEY, new Long(file.getModificationStamp())); - } catch(CVSException e) { - throw new CoreException(e.getStatus()); - } - } - }, ResourcesPlugin.getWorkspace().getRuleFactory().createRule(file), 0, null); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - - private static void writeLinesToStreamAndClose(OutputStream os, String[] contents) throws CVSException { - byte[] lineEnd = getLineDelimiter(); - try { - try { - for (int i = 0; i < contents.length; i++) { - os.write(contents[i].getBytes()); - os.write(lineEnd); - } - } finally { - os.close(); - } - } catch (IOException e) { - throw CVSException.wrapException(e); - } - } - - /** - * Method writeFileToBaseDirectory. - * - * @param file - * @param info - */ - public static void writeFileToBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - try { - IFolder baseFolder = getBaseDirectory(file); - if (!baseFolder.exists()) { - baseFolder.create(false /* force */, true /* local */, Policy.subMonitorFor(monitor, 10)); - } - IFile target = baseFolder.getFile(new Path(null, file.getName())); - if (target.exists()) { - // XXX Should ensure that we haven't already copied it - // XXX write the revision to the CVS/Baserev file - if (target.isReadOnly()) { - target.setReadOnly(false); - } - target.delete(true, Policy.subMonitorFor(monitor, 10)); - } - // Copy the file so the timestamp is maintained - file.copy(target.getFullPath(), true /* force */, Policy.subMonitorFor(monitor, 80)); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - /** - * Method restoreFileFromBaseDirectory. - * @param file - * @param info - * @param monitor - */ - public static void restoreFileFromBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - try { - IFolder baseFolder = getBaseDirectory(file); - IFile source = baseFolder.getFile(new Path(null, file.getName())); - if (!source.exists()) { - throw new CVSException(Policy.bind("SyncFileWriter.baseNotAvailable", file.getFullPath().toString())); //$NON-NLS-1$ - } - if (file.exists()) { - file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 10)); - } - // Copy the file so the timestamp is maintained - source.move(file.getFullPath(), false /* force */, true /* keep history */,Policy.subMonitorFor(monitor, 100)); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - /** - * Method deleteFileFromBaseDirectory. - * @param file - * @param monitor - */ - public static void deleteFileFromBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - try { - IFolder baseFolder = getBaseDirectory(file); - IFile source = baseFolder.getFile(new Path(null, file.getName())); - if (source.exists()) { - if (source.isReadOnly()) { - source.setReadOnly(false); - } - source.delete(false, false, Policy.subMonitorFor(monitor, 100)); - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - private static IFolder getBaseDirectory(IFile file) { - IContainer cvsFolder = getCVSSubdirectory(file.getParent()); - IFolder baseFolder = cvsFolder.getFolder(new Path(BASE_DIRNAME)); - return baseFolder; - } - - /** - * Return a handle to the CVS/Template file for the given folder - * @param folder - * @return IFile - * @throws CVSException - */ - public static IFile getTemplateFile(IContainer folder) throws CVSException { - IFolder cvsFolder = createCVSSubdirectory(folder); - return cvsFolder.getFile("Template"); //$NON-NLS-1$ - } - - /** - * Method isEdited. - * @param resource - * @return boolean - */ - public static boolean isEdited(IFile file) { - IFolder baseFolder = getBaseDirectory(file); - IFile baseFile = baseFolder.getFile(file.getName()); - return baseFile.exists(); - } - - private static byte[] getLineDelimiter() { - if (CVSProviderPlugin.getPlugin().isUsePlatformLineend()) { - String property = System.getProperty("line.separator"); //$NON-NLS-1$ - if (property != null) return property.getBytes(); - } - return new byte[] { 0x0A }; //$NON-NLS-1$ - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java deleted file mode 100644 index 16e4ef8c0..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.util; - - -import java.io.IOException; -import java.io.InterruptedIOException; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.Policy; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * Unsorted static helper-methods - */ -public class Util { - - /** - * Return the last segment of the given path - * @param path - * @return String - */ - public static String getLastSegment(String path) { - int index = path.lastIndexOf(Session.SERVER_SEPARATOR); - if (index == -1) { - return path; - } - if (index == path.length() - 1) { - return getLastSegment(path.substring(0, index)); - } - return path.substring(index + 1); - - } - - /** - * Return the the given path with the last segment removed - * @param path - * @return String - */ - public static String removeLastSegment(String path) { - int index = path.lastIndexOf(Session.SERVER_SEPARATOR); - if (index == -1) - return ""; //$NON-NLS-1$ - else - return path.substring(0, index); - - } - /** - * Return the path without a trailing / - * @param path - * @return String - */ - public static String asPath(String path) { - if (path.endsWith(Session.SERVER_SEPARATOR)) { - return path.substring(0, path.length() - Session.SERVER_SEPARATOR.length()); - } - return path; - } - /* - * * - * Get the extention of the path of resource - * relative to the path of root - * - * @throws CVSException if root is not a root-folder of resource - */ - public static String getRelativePath(String rootName, String resourceName) - throws CVSException { - - if (!resourceName.startsWith(rootName) || rootName.length() > resourceName.length()) { - throw new CVSException(Policy.bind("Util.Internal_error,_resource_does_not_start_with_root_3")); //$NON-NLS-1$ - } - - // Otherwise we would get an ArrayOutOfBoundException - // in case of two equal Resources - if (rootName.length() == resourceName.length()) { - return ""; //$NON-NLS-1$ - } - - // Remove leading slash if there is one - String result = resourceName.substring(rootName.length()).replace('\\', '/'); - if (result.startsWith("/")) { //$NON-NLS-1$ - result = result.substring(1); - } - return result; - } - - /** - * Append the prefix and suffix to form a valid CVS path. - */ - public static String appendPath(String prefix, String suffix) { - if (prefix.length() == 0 || prefix.equals(Session.CURRENT_LOCAL_FOLDER)) { - return suffix; - } else if (prefix.endsWith(Session.SERVER_SEPARATOR)) { - if (suffix.startsWith(Session.SERVER_SEPARATOR)) - return prefix + suffix.substring(1); - else - return prefix + suffix; - } else if (suffix.startsWith(Session.SERVER_SEPARATOR)) - return prefix + suffix; - else - return prefix + Session.SERVER_SEPARATOR + suffix; - } - - public static void logError(String message, Throwable throwable) { - CVSProviderPlugin.log(IStatus.ERROR, message, throwable); - } - - /** - * If the number of segments in the relative path of resource to root is - * greater than split then the returned path is truncated to split number - * of segments and '...' is shown as the first segment of the path. - */ - public static String toTruncatedPath(ICVSResource resource, ICVSFolder root, int split) { - try { - String stringPath = resource.getRelativePath(root); - if (stringPath.equals(Session.CURRENT_LOCAL_FOLDER)) { - return resource.getName(); - } - String truncatedPath = toTruncatedPath(stringPath, split); - return truncatedPath; - } catch(CVSException e) { - return resource.getName(); - } - } - - public static String toTruncatedPath(String stringPath, int split) { - // Search backwards until split separators are found - int count = 0; - int index = stringPath.length(); - while (count++ < split && index != -1) { - index = stringPath.lastIndexOf(Session.SERVER_SEPARATOR, index - 1); - } - if (index == -1) { - return stringPath; - } else { - return Policy.bind("Util.truncatedPath", stringPath.substring(index)); //$NON-NLS-1$ - } - } - - /** - * Helper method that will time out when making a socket connection. - * This is required because there is no way to provide a timeout value - * when creating a socket and in some instances, they don't seem to - * timeout at all. - */ - public static Socket createSocket(final String host, final int port, IProgressMonitor monitor) throws UnknownHostException, IOException { - - // Start a thread to open a socket - final Socket[] socket = new Socket[] { null }; - final Exception[] exception = new Exception[] {null }; - final Thread thread = new Thread(new Runnable() { - public void run() { - try { - Socket newSocket = new Socket(host, port); - synchronized (socket) { - if (Thread.interrupted()) { - // we we're either cancelled or timed out so just close the socket - newSocket.close(); - } else { - socket[0] = newSocket; - } - } - } catch (UnknownHostException e) { - exception[0] = e; - } catch (IOException e) { - exception[0] = e; - } - } - }); - thread.start(); - - // Wait the appropriate number of seconds - int timeout = CVSProviderPlugin.getPlugin().getTimeout(); - if (timeout == 0) timeout = CVSProviderPlugin.DEFAULT_TIMEOUT; - for (int i = 0; i < timeout; i++) { - try { - // wait for the thread to complete or 1 second, which ever comes first - thread.join(1000); - } catch (InterruptedException e) { - // I think this means the thread was interupted but not necessarily timed out - // so we don't need to do anything - } - synchronized (socket) { - // if the user cancelled, clean up before preempting the operation - if (monitor.isCanceled()) { - if (thread.isAlive()) { - thread.interrupt(); - } - if (socket[0] != null) { - socket[0].close(); - } - // this method will throw the proper exception - Policy.checkCanceled(monitor); - } - } - } - // If the thread is still running (i.e. we timed out) signal that it is too late - synchronized (socket) { - if (thread.isAlive()) { - thread.interrupt(); - } - } - if (exception[0] != null) { - if (exception[0] instanceof UnknownHostException) - throw (UnknownHostException)exception[0]; - else - throw (IOException)exception[0]; - } - if (socket[0] == null) { - throw new InterruptedIOException(Policy.bind("Util.timeout", host)); //$NON-NLS-1$ - } - return socket[0]; - } - - /** - * Helper method that will time out when running an external command. - * This is required because there is no way to provide a timeout value - * when executing an external command and in some instances, they don't seem to - * timeout at all. - */ - public static Process createProcess(final String[] command, IProgressMonitor monitor) throws IOException { - - // Start a thread to execute the command and get a handle to the process - final Process[] process = new Process[] { null }; - final Exception[] exception = new Exception[] {null }; - final Thread thread = new Thread(new Runnable() { - public void run() { - try { - Process newProcess = Runtime.getRuntime().exec(command); - synchronized (process) { - if (Thread.interrupted()) { - // we we're either cancelled or timed out so just destroy the process - newProcess.destroy(); - } else { - process[0] = newProcess; - } - } - } catch (IOException e) { - exception[0] = e; - } - } - }); - thread.start(); - - // Wait the appropriate number of seconds - int timeout = CVSProviderPlugin.getPlugin().getTimeout(); - if (timeout == 0) timeout = CVSProviderPlugin.DEFAULT_TIMEOUT; - for (int i = 0; i < timeout; i++) { - try { - // wait for the thread to complete or 1 second, which ever comes first - thread.join(1000); - } catch (InterruptedException e) { - // I think this means the thread was interupted but not necessarily timed out - // so we don't need to do anything - } - synchronized (process) { - // if the user cancelled, clean up before preempting the operation - if (monitor.isCanceled()) { - if (thread.isAlive()) { - thread.interrupt(); - } - if (process[0] != null) { - process[0].destroy(); - } - // this method will throw the proper exception - Policy.checkCanceled(monitor); - } - } - } - // If the thread is still running (i.e. we timed out) signal that it is too late - synchronized (process) { - if (thread.isAlive()) { - thread.interrupt(); - } - } - if (exception[0] != null) { - throw (IOException)exception[0]; - } - if (process[0] == null) { - throw new InterruptedIOException(Policy.bind("Util.processTimeout", command[0])); //$NON-NLS-1$ - } - return process[0]; - } - - public static String[] parseIntoSubstrings(String string, String delimiter) { - List result = new ArrayList(); - int start = 0; - int index = string.indexOf(delimiter); - String next; - while (index != -1) { - next = string.substring(start, index); - result.add(next); - start = index + 1; - index = string.indexOf(delimiter, start); - } - if (start >= string.length()) { - next = "";//$NON-NLS-1$ - } else { - next = string.substring(start); - } - result.add(next); - return (String[]) result.toArray(new String[result.size()]); - } - - /** - * Return the substring at the given index (starting at 0) where each - * element is delimited by the provided delimiter. - * - * @param bytes - * @param delimiter - * @param index - * @param includeRest - * @return String - */ - public static String getSubstring(byte[] bytes, byte delimiter, int index, boolean includeRest) { - byte[] bytesForSlot = getBytesForSlot(bytes, delimiter, index, includeRest); - if (bytesForSlot == null) { - return null; - } - return new String(bytesForSlot); - } - - /** - * Return the offset the the Nth delimeter from the given start index. - * @param bytes - * @param delimiter - * @param start - * @param n - * @return int - */ - public static int getOffsetOfDelimeter(byte[] bytes, byte delimiter, int start, int n) { - int count = 0; - for (int i = start; i < bytes.length; i++) { - if (bytes[i] == delimiter) count++; - if (count == n) return i; - } - // the Nth delimeter was not found - return -1; - } - - /** - * Method getBytesForSlot. - * @param syncBytes - * @param SEPARATOR_BYTE - * @param i - * @param b - * @return byte[] - */ - public static byte[] getBytesForSlot(byte[] bytes, byte delimiter, int index, boolean includeRest) { - // Find the starting index - int start; - if (index == 0) { - // make start -1 so that end determination will start at offset 0. - start = -1; - } else { - start = getOffsetOfDelimeter(bytes, delimiter, 0, index); - if (start == -1) return null; - } - // Find the ending index - int end = getOffsetOfDelimeter(bytes, delimiter, start + 1, 1); - // Calculate the length - int length; - if (end == -1 || includeRest) { - length = bytes.length - start - 1; - } else { - length = end - start - 1; - } - byte[] result = new byte[length]; - System.arraycopy(bytes, start + 1, result, 0, length); - return result; - } - - /** - * Method equals. - * @param syncBytes - * @param oldBytes - * @return boolean - */ - public static boolean equals(byte[] syncBytes, byte[] oldBytes) { - if (syncBytes == null || oldBytes == null) return syncBytes == oldBytes; - if (syncBytes.length != oldBytes.length) return false; - for (int i = 0; i < oldBytes.length; i++) { - if (oldBytes[i] != syncBytes[i]) return false; - } - return true; - } - - /** - * Workaround a CVS bug where a CVS Folder with no immediately contained files has an incorrect - * Tag type stored in the TAG file. In this case, the tag type is always BRANCH (Tv1) - * - * The fix is for folders with no files, use the tag type for the containing project. Since projects almost - * always have files the TAG file is usually correct. - * - * For the case where the folder tag name does not match the project tag name we can not do much so we just - * return the folder tag which will currently always be a branch. - * - * @param resource The IResource being tested. Can not be null. - * @param tag The CVSTag as reported by CVS for the IResource. May be null. - * @return CVSTag The corrected tag for the resource. May be null. - */ - - public static CVSTag getAccurateFolderTag(IResource resource, CVSTag tag) { - - // Determine if the folder contains files as immediate children. - if (resource.getType() != IResource.FOLDER) { - return tag; - } - - IResource[] members = null; - try { - members = ((IFolder) resource).members(); - } catch (CoreException e1) { - return tag; - } - - for (int i = 0; i < members.length; i++) { - if (members[i].getType() == IResource.FILE) { - return tag; - } - } - - // Folder contains no files so this may not really be a branch. - // Make the type the same as the project tag type if both are the same tag name. - IProject project = resource.getProject(); - if (project == null) { - return tag; - } - - ICVSFolder projectFolder = CVSWorkspaceRoot.getCVSFolderFor(project); - FolderSyncInfo projectSyncInfo; - try { - projectSyncInfo = projectFolder.getFolderSyncInfo(); - } catch (CVSException e) { - return tag; - } - - if (projectSyncInfo == null) { - return tag; - } - - CVSTag projectTag = projectSyncInfo.getTag(); - - if (projectTag != null && projectTag.getName().equals(tag.getName())) { - return projectTag; - } else { - return tag; - } - } - - /** - * Workaround for CVS "bug" where CVS ENTRIES file does not contain correct - * Branch vs. Version info. Entries files always record a Tv1 so all entries would - * appear as branches. - * - * By comparing the revision number to the tag name - * you can determine if the tag is a branch or version. - * - * @param cvsResource the resource to test. Must nut be null. - * @return the correct cVSTag. May be null. - */ - - public static CVSTag getAccurateFileTag(ICVSResource cvsResource) throws CVSException { - - CVSTag tag = null; - ResourceSyncInfo info = cvsResource.getSyncInfo(); - if(info != null) { - tag = info.getTag(); - } - - FolderSyncInfo parentInfo = cvsResource.getParent().getFolderSyncInfo(); - CVSTag parentTag = null; - if(parentInfo != null) { - parentTag = parentInfo.getTag(); - } - - if(tag != null) { - if(tag.getName().equals(info.getRevision())) { - tag = new CVSTag(tag.getName(), CVSTag.VERSION); - } else if(parentTag != null){ - tag = new CVSTag(tag.getName(), parentTag.getType()); - } - } else { - // if a file doesn't have tag info, very possible for example - // when the file is in HEAD, use the parents. - tag = parentTag; - } - - return tag; - } - - /** - * Return the fullest path that we can obtain for the given resource - * @param resource - * @return - */ - public static String getFullestPath(ICVSResource resource) { - try { - IResource local = resource.getIResource(); - if (local != null) { - return local.getFullPath().toString(); - } - } catch (CVSException e) { - // Ignore and try the next method; - } - try { - String remotePath = resource.getRepositoryRelativePath(); - if (remotePath != null) { - return remotePath; - } - } catch (CVSException e) { - // Ignore and try the next method; - } - return resource.getName(); - } - - public static String getVariablePattern(String pattern, String variableName) { - return "(" + variableName + ":" + pattern + ":" + variableName + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - - /** - * @param localRevision - * @return - */ - public static int[] convertToDigits(String localRevision) { - try { - String digitStrings[] = localRevision.split("\\."); //$NON-NLS-1$ - int[] digits = new int[digitStrings.length]; - for (int i = 0; i < digitStrings.length; i++) { - String digitString = digitStrings[i]; - digits[i] = Integer.parseInt(digitString); - } - return digits; - } catch (NumberFormatException e) { - CVSProviderPlugin.log(CVSException.wrapException(e)); - return new int[0]; - } - } - - public static String toTruncatedPath(ICVSStorage file, ICVSFolder localRoot, int i) { - if (file instanceof ICVSResource) { - return toTruncatedPath((ICVSResource)file, localRoot, i); - } - return file.getName(); - } - - /** - * If the status/log returns that the file is in the Attic, then remove the - * Attic segment. This is because files added to a branch that are not in - * the main trunk (HEAD) are added to the Attic but cvs does magic on - * update to put them in the correct location. - * (e.g. /project/Attic/file.txt -> /project/file.txt) - */ - public static String removeAtticSegment(String path) { - int lastSeparator = path.lastIndexOf(Session.SERVER_SEPARATOR); - if (lastSeparator == -1) return path; - int secondLastSeparator = path.lastIndexOf(Session.SERVER_SEPARATOR, lastSeparator - 1); - if (secondLastSeparator == -1) return path; - String secondLastSegment = path.substring(secondLastSeparator + 1, lastSeparator); - if (secondLastSegment.equals("Attic")) { //$NON-NLS-1$ - return path.substring(0, secondLastSeparator) + path.substring(lastSeparator); - } - return path; - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh/.classpath b/bundles/org.eclipse.team.cvs.ssh/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ssh/.cvsignore b/bundles/org.eclipse.team.cvs.ssh/.cvsignore deleted file mode 100644 index c5e82d745..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh/.options b/bundles/org.eclipse.team.cvs.ssh/.options deleted file mode 100644 index 126e6d962..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/.options +++ /dev/null @@ -1,7 +0,0 @@ -# Debugging options for the org.eclipse.team.cvs.core plugin. - -# Turn on debugging for the plugin. -org.eclipse.team.cvs.ssh/debug=false - -# Shows ssh protocol messages -org.eclipse.team.cvs.ssh/ssh_protocol=false \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh/.project b/bundles/org.eclipse.team.cvs.ssh/.project deleted file mode 100644 index 04408daef..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.team.cvs.ssh - - - org.eclipse.core.boot - org.eclipse.core.resources - org.eclipse.core.runtime - org.eclipse.team.core - org.eclipse.team.cvs.core - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.team.cvs.ssh/about.html b/bundles/org.eclipse.team.cvs.ssh/about.html deleted file mode 100644 index 59a47b386..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/about.html +++ /dev/null @@ -1,92 +0,0 @@ - - - -About - - - -

              About This Content

              - -

              28th July, 2004

              -

              License

              -

              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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

              - -

              Third Party Content

              - -

              The Content includes items that have been sourced from third parties as follows:

              - -

              The Java (TM) Ssh Applet

              -

              The plug-in is based on software developed by Cedric Gourio. -If the source code is included, it is located in teamcvssshsrc.zip. The binary code is located in teamcvsssh.jar. The Java Ssh Applet includes the following copyright notice which -must be included in any redistribution:

              - -
              - Copyright (c) 1998 Cedric Gourio
              - (http://www.math.ucdavis.edu/~bill/java/ssh/)
              - (javassh@france-mail.com) - -

              This program is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE.
              - You can freely modify the code.

              - -

              You should however include this copyright notice in any redistribution
              - and please keep in touch with the author for any feedback.

              -
              - -

              The Blowfish Encryption Algorithm

              -

              The plug-in is based on an algorithm developed by Bruce Schneier. The algorithm was originally published in -a paper that is located at http://www.counterpane.com/bfsverlag.html. -Your use of the Blowfish Encryption Algorithm in both source and binary code form contained in the plug-in is not subject to any -additional terms and conditions. If the source code, Blowfish.java is included, it is located in teamcvssshsrc.zip. The binary code, Blowfish.class is located in -teamcvsssh.jar.

              - -

              Contributions

              - -

              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.

              - -

              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.

              - -

              Cryptography

              - -

              Export Control

              -

              The plug-in contains encryption software. The country in which you are currently may have restrictions on the import, possession, -and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's -laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this -is permitted.

              - -

              Encryption Items

              - -

              Details of the encryption software in this plug-in are provided to assist in obtaining relevant export control classification and approval. -Cryptography in this plug-in has been classified as Export Commodity Control Number (ECCN) 5D002.c.1 by the U.S. Government Department of Commerce, -Bureau of Export Administration and deemed eligible for export under License Exception Technology Software Unrestricted (TSU) for both object code -and source code.

              - -

              The plug-in contains an implementation of the Secure Shell (SSH) protocol that encrypts the network traffic (program code files -in file versioning systems) between a Concurrent Versions System (CVS) server and a CVS client. Data is encrypted using the Blowfish algorithm -which is a 64-bit symmetric cipher that uses a key varying in length from 32 bits to 448 bits. The RSA PKCS #1 v1.5 key exchange algorithm is -used to authenticate and exchange keys with a minimum modulus size of 96 bits and a maximum modulus size theoretically unlimited since the -implementation uses the java.math.BigInteger class which has a maximum positive integer range limited only by the available memory in the computer. -In practice, the key length is defined by the CVS server with which communication is initiated.

              - -

              The following Java classes contain encryption items (the plug-in may contain both binary and source code):

              - -
                -
              • org.eclipse.team.internal.ccvs.ssh.Blowfish
              • -
              • org.eclipse.team.internal.ccvs.ssh.Cipher
              • -
              • org.eclipse.team.internal.ccvs.ssh.Client
              • -
              • org.eclipse.team.internal.ccvs.ssh.ClientPacket
              • -
              • org.eclipse.team.internal.ccvs.ssh.Misc
              • -
              - -Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. - - - \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh/build.properties b/bundles/org.eclipse.team.cvs.ssh/build.properties deleted file mode 100644 index 487a6e818..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# Eclipse build contribution -source.teamcvsssh.jar=src/ -src.includes=about.html -bin.includes=about.html,plugin.xml,plugin.properties,*.jar,.options \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh/plugin.properties b/bundles/org.eclipse.team.cvs.ssh/plugin.properties deleted file mode 100644 index 357dec3bc..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/plugin.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -providerName=Eclipse.org -pluginName=CVS SSH Core \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh/plugin.xml b/bundles/org.eclipse.team.cvs.ssh/plugin.xml deleted file mode 100644 index 49db72b76..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/plugin.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Blowfish.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Blowfish.java deleted file mode 100644 index c72949045..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Blowfish.java +++ /dev/null @@ -1,1220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -public class Blowfish extends Cipher { - private int[] P = new int[18]; - private int[][] S = new int[4][256]; - - private int lastEncipherXL = 0; - private int lastEncipherXR = 0; - private int lastDecipherXL = 0; - private int lastDecipherXR = 0; - - private final static int[] INIT_DATA = - { - 0x243f6a88, - 0x85a308d3, - 0x13198a2e, - 0x03707344, - 0xa4093822, - 0x299f31d0, - 0x082efa98, - 0xec4e6c89, - 0x452821e6, - 0x38d01377, - 0xbe5466cf, - 0x34e90c6c, - 0xc0ac29b7, - 0xc97c50dd, - 0x3f84d5b5, - 0xb5470917, - 0x9216d5d9, - 0x8979fb1b, - 0xd1310ba6, - 0x98dfb5ac, - 0x2ffd72db, - 0xd01adfb7, - 0xb8e1afed, - 0x6a267e96, - 0xba7c9045, - 0xf12c7f99, - 0x24a19947, - 0xb3916cf7, - 0x0801f2e2, - 0x858efc16, - 0x636920d8, - 0x71574e69, - 0xa458fea3, - 0xf4933d7e, - 0x0d95748f, - 0x728eb658, - 0x718bcd58, - 0x82154aee, - 0x7b54a41d, - 0xc25a59b5, - 0x9c30d539, - 0x2af26013, - 0xc5d1b023, - 0x286085f0, - 0xca417918, - 0xb8db38ef, - 0x8e79dcb0, - 0x603a180e, - 0x6c9e0e8b, - 0xb01e8a3e, - 0xd71577c1, - 0xbd314b27, - 0x78af2fda, - 0x55605c60, - 0xe65525f3, - 0xaa55ab94, - 0x57489862, - 0x63e81440, - 0x55ca396a, - 0x2aab10b6, - 0xb4cc5c34, - 0x1141e8ce, - 0xa15486af, - 0x7c72e993, - 0xb3ee1411, - 0x636fbc2a, - 0x2ba9c55d, - 0x741831f6, - 0xce5c3e16, - 0x9b87931e, - 0xafd6ba33, - 0x6c24cf5c, - 0x7a325381, - 0x28958677, - 0x3b8f4898, - 0x6b4bb9af, - 0xc4bfe81b, - 0x66282193, - 0x61d809cc, - 0xfb21a991, - 0x487cac60, - 0x5dec8032, - 0xef845d5d, - 0xe98575b1, - 0xdc262302, - 0xeb651b88, - 0x23893e81, - 0xd396acc5, - 0x0f6d6ff3, - 0x83f44239, - 0x2e0b4482, - 0xa4842004, - 0x69c8f04a, - 0x9e1f9b5e, - 0x21c66842, - 0xf6e96c9a, - 0x670c9c61, - 0xabd388f0, - 0x6a51a0d2, - 0xd8542f68, - 0x960fa728, - 0xab5133a3, - 0x6eef0b6c, - 0x137a3be4, - 0xba3bf050, - 0x7efb2a98, - 0xa1f1651d, - 0x39af0176, - 0x66ca593e, - 0x82430e88, - 0x8cee8619, - 0x456f9fb4, - 0x7d84a5c3, - 0x3b8b5ebe, - 0xe06f75d8, - 0x85c12073, - 0x401a449f, - 0x56c16aa6, - 0x4ed3aa62, - 0x363f7706, - 0x1bfedf72, - 0x429b023d, - 0x37d0d724, - 0xd00a1248, - 0xdb0fead3, - 0x49f1c09b, - 0x075372c9, - 0x80991b7b, - 0x25d479d8, - 0xf6e8def7, - 0xe3fe501a, - 0xb6794c3b, - 0x976ce0bd, - 0x04c006ba, - 0xc1a94fb6, - 0x409f60c4, - 0x5e5c9ec2, - 0x196a2463, - 0x68fb6faf, - 0x3e6c53b5, - 0x1339b2eb, - 0x3b52ec6f, - 0x6dfc511f, - 0x9b30952c, - 0xcc814544, - 0xaf5ebd09, - 0xbee3d004, - 0xde334afd, - 0x660f2807, - 0x192e4bb3, - 0xc0cba857, - 0x45c8740f, - 0xd20b5f39, - 0xb9d3fbdb, - 0x5579c0bd, - 0x1a60320a, - 0xd6a100c6, - 0x402c7279, - 0x679f25fe, - 0xfb1fa3cc, - 0x8ea5e9f8, - 0xdb3222f8, - 0x3c7516df, - 0xfd616b15, - 0x2f501ec8, - 0xad0552ab, - 0x323db5fa, - 0xfd238760, - 0x53317b48, - 0x3e00df82, - 0x9e5c57bb, - 0xca6f8ca0, - 0x1a87562e, - 0xdf1769db, - 0xd542a8f6, - 0x287effc3, - 0xac6732c6, - 0x8c4f5573, - 0x695b27b0, - 0xbbca58c8, - 0xe1ffa35d, - 0xb8f011a0, - 0x10fa3d98, - 0xfd2183b8, - 0x4afcb56c, - 0x2dd1d35b, - 0x9a53e479, - 0xb6f84565, - 0xd28e49bc, - 0x4bfb9790, - 0xe1ddf2da, - 0xa4cb7e33, - 0x62fb1341, - 0xcee4c6e8, - 0xef20cada, - 0x36774c01, - 0xd07e9efe, - 0x2bf11fb4, - 0x95dbda4d, - 0xae909198, - 0xeaad8e71, - 0x6b93d5a0, - 0xd08ed1d0, - 0xafc725e0, - 0x8e3c5b2f, - 0x8e7594b7, - 0x8ff6e2fb, - 0xf2122b64, - 0x8888b812, - 0x900df01c, - 0x4fad5ea0, - 0x688fc31c, - 0xd1cff191, - 0xb3a8c1ad, - 0x2f2f2218, - 0xbe0e1777, - 0xea752dfe, - 0x8b021fa1, - 0xe5a0cc0f, - 0xb56f74e8, - 0x18acf3d6, - 0xce89e299, - 0xb4a84fe0, - 0xfd13e0b7, - 0x7cc43b81, - 0xd2ada8d9, - 0x165fa266, - 0x80957705, - 0x93cc7314, - 0x211a1477, - 0xe6ad2065, - 0x77b5fa86, - 0xc75442f5, - 0xfb9d35cf, - 0xebcdaf0c, - 0x7b3e89a0, - 0xd6411bd3, - 0xae1e7e49, - 0x00250e2d, - 0x2071b35e, - 0x226800bb, - 0x57b8e0af, - 0x2464369b, - 0xf009b91e, - 0x5563911d, - 0x59dfa6aa, - 0x78c14389, - 0xd95a537f, - 0x207d5ba2, - 0x02e5b9c5, - 0x83260376, - 0x6295cfa9, - 0x11c81968, - 0x4e734a41, - 0xb3472dca, - 0x7b14a94a, - 0x1b510052, - 0x9a532915, - 0xd60f573f, - 0xbc9bc6e4, - 0x2b60a476, - 0x81e67400, - 0x08ba6fb5, - 0x571be91f, - 0xf296ec6b, - 0x2a0dd915, - 0xb6636521, - 0xe7b9f9b6, - 0xff34052e, - 0xc5855664, - 0x53b02d5d, - 0xa99f8fa1, - 0x08ba4799, - 0x6e85076a, - 0x4b7a70e9, - 0xb5b32944, - 0xdb75092e, - 0xc4192623, - 0xad6ea6b0, - 0x49a7df7d, - 0x9cee60b8, - 0x8fedb266, - 0xecaa8c71, - 0x699a17ff, - 0x5664526c, - 0xc2b19ee1, - 0x193602a5, - 0x75094c29, - 0xa0591340, - 0xe4183a3e, - 0x3f54989a, - 0x5b429d65, - 0x6b8fe4d6, - 0x99f73fd6, - 0xa1d29c07, - 0xefe830f5, - 0x4d2d38e6, - 0xf0255dc1, - 0x4cdd2086, - 0x8470eb26, - 0x6382e9c6, - 0x021ecc5e, - 0x09686b3f, - 0x3ebaefc9, - 0x3c971814, - 0x6b6a70a1, - 0x687f3584, - 0x52a0e286, - 0xb79c5305, - 0xaa500737, - 0x3e07841c, - 0x7fdeae5c, - 0x8e7d44ec, - 0x5716f2b8, - 0xb03ada37, - 0xf0500c0d, - 0xf01c1f04, - 0x0200b3ff, - 0xae0cf51a, - 0x3cb574b2, - 0x25837a58, - 0xdc0921bd, - 0xd19113f9, - 0x7ca92ff6, - 0x94324773, - 0x22f54701, - 0x3ae5e581, - 0x37c2dadc, - 0xc8b57634, - 0x9af3dda7, - 0xa9446146, - 0x0fd0030e, - 0xecc8c73e, - 0xa4751e41, - 0xe238cd99, - 0x3bea0e2f, - 0x3280bba1, - 0x183eb331, - 0x4e548b38, - 0x4f6db908, - 0x6f420d03, - 0xf60a04bf, - 0x2cb81290, - 0x24977c79, - 0x5679b072, - 0xbcaf89af, - 0xde9a771f, - 0xd9930810, - 0xb38bae12, - 0xdccf3f2e, - 0x5512721f, - 0x2e6b7124, - 0x501adde6, - 0x9f84cd87, - 0x7a584718, - 0x7408da17, - 0xbc9f9abc, - 0xe94b7d8c, - 0xec7aec3a, - 0xdb851dfa, - 0x63094366, - 0xc464c3d2, - 0xef1c1847, - 0x3215d908, - 0xdd433b37, - 0x24c2ba16, - 0x12a14d43, - 0x2a65c451, - 0x50940002, - 0x133ae4dd, - 0x71dff89e, - 0x10314e55, - 0x81ac77d6, - 0x5f11199b, - 0x043556f1, - 0xd7a3c76b, - 0x3c11183b, - 0x5924a509, - 0xf28fe6ed, - 0x97f1fbfa, - 0x9ebabf2c, - 0x1e153c6e, - 0x86e34570, - 0xeae96fb1, - 0x860e5e0a, - 0x5a3e2ab3, - 0x771fe71c, - 0x4e3d06fa, - 0x2965dcb9, - 0x99e71d0f, - 0x803e89d6, - 0x5266c825, - 0x2e4cc978, - 0x9c10b36a, - 0xc6150eba, - 0x94e2ea78, - 0xa5fc3c53, - 0x1e0a2df4, - 0xf2f74ea7, - 0x361d2b3d, - 0x1939260f, - 0x19c27960, - 0x5223a708, - 0xf71312b6, - 0xebadfe6e, - 0xeac31f66, - 0xe3bc4595, - 0xa67bc883, - 0xb17f37d1, - 0x018cff28, - 0xc332ddef, - 0xbe6c5aa5, - 0x65582185, - 0x68ab9802, - 0xeecea50f, - 0xdb2f953b, - 0x2aef7dad, - 0x5b6e2f84, - 0x1521b628, - 0x29076170, - 0xecdd4775, - 0x619f1510, - 0x13cca830, - 0xeb61bd96, - 0x0334fe1e, - 0xaa0363cf, - 0xb5735c90, - 0x4c70a239, - 0xd59e9e0b, - 0xcbaade14, - 0xeecc86bc, - 0x60622ca7, - 0x9cab5cab, - 0xb2f3846e, - 0x648b1eaf, - 0x19bdf0ca, - 0xa02369b9, - 0x655abb50, - 0x40685a32, - 0x3c2ab4b3, - 0x319ee9d5, - 0xc021b8f7, - 0x9b540b19, - 0x875fa099, - 0x95f7997e, - 0x623d7da8, - 0xf837889a, - 0x97e32d77, - 0x11ed935f, - 0x16681281, - 0x0e358829, - 0xc7e61fd6, - 0x96dedfa1, - 0x7858ba99, - 0x57f584a5, - 0x1b227263, - 0x9b83c3ff, - 0x1ac24696, - 0xcdb30aeb, - 0x532e3054, - 0x8fd948e4, - 0x6dbc3128, - 0x58ebf2ef, - 0x34c6ffea, - 0xfe28ed61, - 0xee7c3c73, - 0x5d4a14d9, - 0xe864b7e3, - 0x42105d14, - 0x203e13e0, - 0x45eee2b6, - 0xa3aaabea, - 0xdb6c4f15, - 0xfacb4fd0, - 0xc742f442, - 0xef6abbb5, - 0x654f3b1d, - 0x41cd2105, - 0xd81e799e, - 0x86854dc7, - 0xe44b476a, - 0x3d816250, - 0xcf62a1f2, - 0x5b8d2646, - 0xfc8883a0, - 0xc1c7b6a3, - 0x7f1524c3, - 0x69cb7492, - 0x47848a0b, - 0x5692b285, - 0x095bbf00, - 0xad19489d, - 0x1462b174, - 0x23820e00, - 0x58428d2a, - 0x0c55f5ea, - 0x1dadf43e, - 0x233f7061, - 0x3372f092, - 0x8d937e41, - 0xd65fecf1, - 0x6c223bdb, - 0x7cde3759, - 0xcbee7460, - 0x4085f2a7, - 0xce77326e, - 0xa6078084, - 0x19f8509e, - 0xe8efd855, - 0x61d99735, - 0xa969a7aa, - 0xc50c06c2, - 0x5a04abfc, - 0x800bcadc, - 0x9e447a2e, - 0xc3453484, - 0xfdd56705, - 0x0e1e9ec9, - 0xdb73dbd3, - 0x105588cd, - 0x675fda79, - 0xe3674340, - 0xc5c43465, - 0x713e38d8, - 0x3d28f89e, - 0xf16dff20, - 0x153e21e7, - 0x8fb03d4a, - 0xe6e39f2b, - 0xdb83adf7, - 0xe93d5a68, - 0x948140f7, - 0xf64c261c, - 0x94692934, - 0x411520f7, - 0x7602d4f7, - 0xbcf46b2e, - 0xd4a20068, - 0xd4082471, - 0x3320f46a, - 0x43b7d4b7, - 0x500061af, - 0x1e39f62e, - 0x97244546, - 0x14214f74, - 0xbf8b8840, - 0x4d95fc1d, - 0x96b591af, - 0x70f4ddd3, - 0x66a02f45, - 0xbfbc09ec, - 0x03bd9785, - 0x7fac6dd0, - 0x31cb8504, - 0x96eb27b3, - 0x55fd3941, - 0xda2547e6, - 0xabca0a9a, - 0x28507825, - 0x530429f4, - 0x0a2c86da, - 0xe9b66dfb, - 0x68dc1462, - 0xd7486900, - 0x680ec0a4, - 0x27a18dee, - 0x4f3ffea2, - 0xe887ad8c, - 0xb58ce006, - 0x7af4d6b6, - 0xaace1e7c, - 0xd3375fec, - 0xce78a399, - 0x406b2a42, - 0x20fe9e35, - 0xd9f385b9, - 0xee39d7ab, - 0x3b124e8b, - 0x1dc9faf7, - 0x4b6d1856, - 0x26a36631, - 0xeae397b2, - 0x3a6efa74, - 0xdd5b4332, - 0x6841e7f7, - 0xca7820fb, - 0xfb0af54e, - 0xd8feb397, - 0x454056ac, - 0xba489527, - 0x55533a3a, - 0x20838d87, - 0xfe6ba9b7, - 0xd096954b, - 0x55a867bc, - 0xa1159a58, - 0xcca92963, - 0x99e1db33, - 0xa62a4a56, - 0x3f3125f9, - 0x5ef47e1c, - 0x9029317c, - 0xfdf8e802, - 0x04272f70, - 0x80bb155c, - 0x05282ce3, - 0x95c11548, - 0xe4c66d22, - 0x48c1133f, - 0xc70f86dc, - 0x07f9c9ee, - 0x41041f0f, - 0x404779a4, - 0x5d886e17, - 0x325f51eb, - 0xd59bc0d1, - 0xf2bcc18f, - 0x41113564, - 0x257b7834, - 0x602a9c60, - 0xdff8e8a3, - 0x1f636c1b, - 0x0e12b4c2, - 0x02e1329e, - 0xaf664fd1, - 0xcad18115, - 0x6b2395e0, - 0x333e92e1, - 0x3b240b62, - 0xeebeb922, - 0x85b2a20e, - 0xe6ba0d99, - 0xde720c8c, - 0x2da2f728, - 0xd0127845, - 0x95b794fd, - 0x647d0862, - 0xe7ccf5f0, - 0x5449a36f, - 0x877d48fa, - 0xc39dfd27, - 0xf33e8d1e, - 0x0a476341, - 0x992eff74, - 0x3a6f6eab, - 0xf4f8fd37, - 0xa812dc60, - 0xa1ebddf8, - 0x991be14c, - 0xdb6e6b0d, - 0xc67b5510, - 0x6d672c37, - 0x2765d43b, - 0xdcd0e804, - 0xf1290dc7, - 0xcc00ffa3, - 0xb5390f92, - 0x690fed0b, - 0x667b9ffb, - 0xcedb7d9c, - 0xa091cf0b, - 0xd9155ea3, - 0xbb132f88, - 0x515bad24, - 0x7b9479bf, - 0x763bd6eb, - 0x37392eb3, - 0xcc115979, - 0x8026e297, - 0xf42e312d, - 0x6842ada7, - 0xc66a2b3b, - 0x12754ccc, - 0x782ef11c, - 0x6a124237, - 0xb79251e7, - 0x06a1bbe6, - 0x4bfb6350, - 0x1a6b1018, - 0x11caedfa, - 0x3d25bdd8, - 0xe2e1c3c9, - 0x44421659, - 0x0a121386, - 0xd90cec6e, - 0xd5abea2a, - 0x64af674e, - 0xda86a85f, - 0xbebfe988, - 0x64e4c3fe, - 0x9dbc8057, - 0xf0f7c086, - 0x60787bf8, - 0x6003604d, - 0xd1fd8346, - 0xf6381fb0, - 0x7745ae04, - 0xd736fccc, - 0x83426b33, - 0xf01eab71, - 0xb0804187, - 0x3c005e5f, - 0x77a057be, - 0xbde8ae24, - 0x55464299, - 0xbf582e61, - 0x4e58f48f, - 0xf2ddfda2, - 0xf474ef38, - 0x8789bdc2, - 0x5366f9c3, - 0xc8b38e74, - 0xb475f255, - 0x46fcd9b9, - 0x7aeb2661, - 0x8b1ddf84, - 0x846a0e79, - 0x915f95e2, - 0x466e598e, - 0x20b45770, - 0x8cd55591, - 0xc902de4c, - 0xb90bace1, - 0xbb8205d0, - 0x11a86248, - 0x7574a99e, - 0xb77f19b6, - 0xe0a9dc09, - 0x662d09a1, - 0xc4324633, - 0xe85a1f02, - 0x09f0be8c, - 0x4a99a025, - 0x1d6efe10, - 0x1ab93d1d, - 0x0ba5a4df, - 0xa186f20f, - 0x2868f169, - 0xdcb7da83, - 0x573906fe, - 0xa1e2ce9b, - 0x4fcd7f52, - 0x50115e01, - 0xa70683fa, - 0xa002b5c4, - 0x0de6d027, - 0x9af88c27, - 0x773f8641, - 0xc3604c06, - 0x61a806b5, - 0xf0177a28, - 0xc0f586e0, - 0x006058aa, - 0x30dc7d62, - 0x11e69ed7, - 0x2338ea63, - 0x53c2dd94, - 0xc2c21634, - 0xbbcbee56, - 0x90bcb6de, - 0xebfc7da1, - 0xce591d76, - 0x6f05e409, - 0x4b7c0188, - 0x39720a3d, - 0x7c927c24, - 0x86e3725f, - 0x724d9db9, - 0x1ac15bb4, - 0xd39eb8fc, - 0xed545578, - 0x08fca5b5, - 0xd83d7cd3, - 0x4dad0fc4, - 0x1e50ef5e, - 0xb161e6f8, - 0xa28514d9, - 0x6c51133c, - 0x6fd5c7e7, - 0x56e14ec4, - 0x362abfce, - 0xddc6c837, - 0xd79a3234, - 0x92638212, - 0x670efa8e, - 0x406000e0, - 0x3a39ce37, - 0xd3faf5cf, - 0xabc27737, - 0x5ac52d1b, - 0x5cb0679e, - 0x4fa33742, - 0xd3822740, - 0x99bc9bbe, - 0xd5118e9d, - 0xbf0f7315, - 0xd62d1c7e, - 0xc700c47b, - 0xb78c1b6b, - 0x21a19045, - 0xb26eb1be, - 0x6a366eb4, - 0x5748ab2f, - 0xbc946e79, - 0xc6a376d2, - 0x6549c2c8, - 0x530ff8ee, - 0x468dde7d, - 0xd5730a1d, - 0x4cd04dc6, - 0x2939bbdb, - 0xa9ba4650, - 0xac9526e8, - 0xbe5ee304, - 0xa1fad5f0, - 0x6a2d519a, - 0x63ef8ce2, - 0x9a86ee22, - 0xc089c2b8, - 0x43242ef6, - 0xa51e03aa, - 0x9cf2d0a4, - 0x83c061ba, - 0x9be96a4d, - 0x8fe51550, - 0xba645bd6, - 0x2826a2f9, - 0xa73a3ae1, - 0x4ba99586, - 0xef5562e9, - 0xc72fefd3, - 0xf752f7da, - 0x3f046f69, - 0x77fa0a59, - 0x80e4a915, - 0x87b08601, - 0x9b09e6ad, - 0x3b3ee593, - 0xe990fd5a, - 0x9e34d797, - 0x2cf0b7d9, - 0x022b8b51, - 0x96d5ac3a, - 0x017da67d, - 0xd1cf3ed6, - 0x7c7d2d28, - 0x1f9f25cf, - 0xadf2b89b, - 0x5ad6b472, - 0x5a88f54c, - 0xe029ac71, - 0xe019a5e6, - 0x47b0acfd, - 0xed93fa9b, - 0xe8d3c48d, - 0x283b57cc, - 0xf8d56629, - 0x79132e28, - 0x785f0191, - 0xed756055, - 0xf7960e44, - 0xe3d35e8c, - 0x15056dd4, - 0x88f46dba, - 0x03a16125, - 0x0564f0bd, - 0xc3eb9e15, - 0x3c9057a2, - 0x97271aec, - 0xa93a072a, - 0x1b3f6d9b, - 0x1e6321f5, - 0xf59c66fb, - 0x26dcf319, - 0x7533d928, - 0xb155fdf5, - 0x03563482, - 0x8aba3cbb, - 0x28517711, - 0xc20ad9f8, - 0xabcc5167, - 0xccad925f, - 0x4de81751, - 0x3830dc8e, - 0x379d5862, - 0x9320f991, - 0xea7a90c2, - 0xfb3e7bce, - 0x5121ce64, - 0x774fbe32, - 0xa8b6e37e, - 0xc3293d46, - 0x48de5369, - 0x6413e680, - 0xa2ae0810, - 0xdd6db224, - 0x69852dfd, - 0x09072166, - 0xb39a460a, - 0x6445c0dd, - 0x586cdecf, - 0x1c20c8ae, - 0x5bbef7dd, - 0x1b588d40, - 0xccd2017f, - 0x6bb4e3bb, - 0xdda26a7e, - 0x3a59ff45, - 0x3e350a44, - 0xbcb4cdd5, - 0x72eacea8, - 0xfa6484bb, - 0x8d6612ae, - 0xbf3c6f47, - 0xd29be463, - 0x542f5d9e, - 0xaec2771b, - 0xf64e6370, - 0x740e0d8d, - 0xe75b1357, - 0xf8721671, - 0xaf537d5d, - 0x4040cb08, - 0x4eb4e2cc, - 0x34d2466a, - 0x0115af84, - 0xe1b00428, - 0x95983a1d, - 0x06b89fb4, - 0xce6ea048, - 0x6f3f3b82, - 0x3520ab82, - 0x011a1d4b, - 0x277227f8, - 0x611560b1, - 0xe7933fdc, - 0xbb3a792b, - 0x344525bd, - 0xa08839e1, - 0x51ce794b, - 0x2f32c9b7, - 0xa01fbac9, - 0xe01cc87e, - 0xbcc7d1f6, - 0xcf0111c3, - 0xa1e8aac7, - 0x1a908749, - 0xd44fbd9a, - 0xd0dadecb, - 0xd50ada38, - 0x0339c32a, - 0xc6913667, - 0x8df9317c, - 0xe0b12b4f, - 0xf79e59b7, - 0x43f5bb3a, - 0xf2d519ff, - 0x27d9459c, - 0xbf97222c, - 0x15e6fc2a, - 0x0f91fc71, - 0x9b941525, - 0xfae59361, - 0xceb69ceb, - 0xc2a86459, - 0x12baa8d1, - 0xb6c1075e, - 0xe3056a0c, - 0x10d25065, - 0xcb03a442, - 0xe0ec6e0e, - 0x1698db3b, - 0x4c98a0be, - 0x3278e964, - 0x9f1f9532, - 0xe0d392df, - 0xd3a0342b, - 0x8971f21e, - 0x1b0a7441, - 0x4ba3348c, - 0xc5be7120, - 0xc37632d8, - 0xdf359f8d, - 0x9b992f2e, - 0xe60b6f47, - 0x0fe3f11d, - 0xe54cda54, - 0x1edad891, - 0xce6279cf, - 0xcd3e7e6f, - 0x1618b166, - 0xfd2c1d05, - 0x848fd2c5, - 0xf6fb2299, - 0xf523f357, - 0xa6327623, - 0x93a83531, - 0x56cccd02, - 0xacf08162, - 0x5a75ebb5, - 0x6e163697, - 0x88d273cc, - 0xde966292, - 0x81b949d0, - 0x4c50901b, - 0x71c65614, - 0xe6c6c7bd, - 0x327a140a, - 0x45e1d006, - 0xc3f27b9a, - 0xc9aa53fd, - 0x62a80f00, - 0xbb25bfe2, - 0x35bdd2f6, - 0x71126905, - 0xb2040222, - 0xb6cbcf7c, - 0xcd769c2b, - 0x53113ec0, - 0x1640e3d3, - 0x38abbd60, - 0x2547adf0, - 0xba38209c, - 0xf746ce76, - 0x77afa1c5, - 0x20756060, - 0x85cbfe4e, - 0x8ae88dd8, - 0x7aaaf9b0, - 0x4cf9aa7e, - 0x1948c25c, - 0x02fb8a8c, - 0x01c36ae4, - 0xd6ebe1f9, - 0x90d4f869, - 0xa65cdea0, - 0x3f09252d, - 0xc208e69f, - 0xb74e6132, - 0xce77e25b, - 0x578fdfe3, - 0x3ac372e6 }; -public void decipher(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - int xL = lastDecipherXL; - int xR = lastDecipherXR; - - int dataXL; - int dataXR; - - int[] xLxR = new int[2]; - - for (int i = 0; i < len; i = i + 8) { - dataXL = (src[srcOff + i] & 0xff) | ((src[srcOff + i + 1] & 0xff) << 8) | ((src[srcOff + i + 2] & 0xff) << 16) | ((src[srcOff + i + 3] & 0xff) << 24); - dataXR = (src[srcOff + i + 4] & 0xff) | ((src[srcOff + i + 5] & 0xff) << 8) | ((src[srcOff + i + 6] & 0xff) << 16) | ((src[srcOff + i + 7] & 0xff) << 24); - - decipher(dataXL, dataXR, xLxR); - - xL ^= xLxR[0]; - xR ^= xLxR[1]; - - dst[dstOff + i] = (byte) (xL & 0xff); - dst[dstOff + i + 1] = (byte) ((xL >> 8) & 0xff); - dst[dstOff + i + 2] = (byte) ((xL >> 16) & 0xff); - dst[dstOff + i + 3] = (byte) ((xL >> 24) & 0xff); - dst[dstOff + i + 4] = (byte) (xR & 0xff); - dst[dstOff + i + 5] = (byte) ((xR >> 8) & 0xff); - dst[dstOff + i + 6] = (byte) ((xR >> 16) & 0xff); - dst[dstOff + i + 7] = (byte) ((xR >> 24) & 0xff); - - xL = dataXL; - xR = dataXR; - } - - lastDecipherXL = xL; - lastDecipherXR = xR; -} -private void decipher(int xL, int xR, int[] xLxR) { - xL ^= P[17]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[16]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[15]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[14]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[13]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[12]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[11]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[10]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[9]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[8]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[7]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[6]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[5]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[4]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[3]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[2]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[1]; - xR ^= P[0]; - - xLxR[0] = xR; - xLxR[1] = xL; -} -public void encipher(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - int xL = lastEncipherXL; - int xR = lastEncipherXR; - - int[] xLxR = new int[2]; - - for (int i = 0; i < len; i = i + 8) { - xL ^= (src[srcOff + i] & 0xff) | ((src[srcOff + i + 1] & 0xff) << 8) | ((src[srcOff + i + 2] & 0xff) << 16) | ((src[srcOff + i + 3] & 0xff) << 24); - xR ^= (src[srcOff + i + 4] & 0xff) | ((src[srcOff + i + 5] & 0xff) << 8) | ((src[srcOff + i + 6] & 0xff) << 16) | ((src[srcOff + i + 7] & 0xff) << 24); - - encipher(xL, xR, xLxR); - - xL = xLxR[0]; - xR = xLxR[1]; - - dst[dstOff + i] = (byte) (xL & 0xff); - dst[dstOff + i + 1] = (byte) ((xL >> 8) & 0xff); - dst[dstOff + i + 2] = (byte) ((xL >> 16) & 0xff); - dst[dstOff + i + 3] = (byte) ((xL >> 24) & 0xff); - dst[dstOff + i + 4] = (byte) (xR & 0xff); - dst[dstOff + i + 5] = (byte) ((xR >> 8) & 0xff); - dst[dstOff + i + 6] = (byte) ((xR >> 16) & 0xff); - dst[dstOff + i + 7] = (byte) ((xR >> 24) & 0xff); - } - - lastEncipherXL = xL; - lastEncipherXR = xR; -} -private void encipher(int xL, int xR, int[] xLxR) { - xL ^= P[0]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[1]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[2]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[3]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[4]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[5]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[6]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[7]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[8]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[9]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[10]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[11]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[12]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[13]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[14]; - xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[15]; - xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[16]; - xR ^= P[17]; - - xLxR[0] = xR; - xLxR[1] = xL; -} -public void setKey(byte key[]) { - int data = 0; - int offset = 0; - - for (int i = 0; i < P.length; ++i) { - P[i] = INIT_DATA[offset++]; - } - - for (int i = 0; i < S.length; ++i) { - for (int j = 0; j < S[i].length; ++j) { - S[i][j] = INIT_DATA[offset++]; - } - } - - offset = 0; - for (int i = 0; i < P.length; ++i) { - data = 0; - for (int k = 0; k < 4; ++k) { - data = (data << 8) | (key[offset++] & 0xff); - if (offset >= key.length) { - offset = 0; - } - } - P[i] = P[i] ^ data; - } - - int[] lr = new int[] { 0, 0 }; - for (int i = 0; i < P.length; i += 2) { - encipher(lr[0], lr[1], lr); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (int i = 0; i < S.length; ++i) { - for (int j = 0; j < S[i].length; j += 2) { - encipher(lr[0], lr[1], lr); - S[i][j] = lr[0]; - S[i][j + 1] = lr[1]; - } - } - - lastEncipherXL = 0; - lastEncipherXR = 0; - lastDecipherXL = 0; - lastDecipherXR = 0; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Cipher.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Cipher.java deleted file mode 100644 index 2e55a3ae6..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Cipher.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -public abstract class Cipher { -public abstract void decipher(byte[] src, int srcPos, byte[] dst, int dstPos, int len); -public abstract void encipher(byte[] src, int srcPos, byte[] dst, int dstPos, int len); -public static Cipher getInstance(String algorithm) { - try { - Class c = Class.forName("org.eclipse.team.internal.ccvs.ssh." + algorithm); //$NON-NLS-1$ - return (Cipher) c.newInstance(); - } catch (Exception e) { - return null; - } -} -public abstract void setKey(byte[] key); -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Client.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Client.java deleted file mode 100644 index 07ebaa3f1..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Client.java +++ /dev/null @@ -1,707 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -/** - * An SSH 1.5 client.. - */ - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; -import java.io.OutputStream; -import java.math.BigInteger; -import java.net.Socket; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.core.streams.PollingInputStream; -import org.eclipse.team.internal.core.streams.PollingOutputStream; -import org.eclipse.team.internal.core.streams.TimeoutOutputStream; - -public class Client { - // client identification string - private static final String clientId = "SSH-1.5-Java 1.2.2\n"; //$NON-NLS-1$ - - // server identification string - private static String serverId = null; - - // maximum outgoing packet size - private static final int MAX_CLIENT_PACKET_SIZE = 1024; - - // packet types - private static final int SSH_MSG_DISCONNECT = 1; - private static final int SSH_SMSG_PUBLIC_KEY = 2; - private static final int SSH_CMSG_SESSION_KEY = 3; - private static final int SSH_CMSG_USER = 4; - private static final int SSH_CMSG_AUTH_PASSWORD = 9; - private static final int SSH_CMSG_REQUEST_PTY = 10; - private static final int SSH_CMSG_EXEC_SHELL = 12; - private static final int SSH_CMSG_EXEC_CMD = 13; - private static final int SSH_SMSG_SUCCESS = 14; - private static final int SSH_SMSG_FAILURE = 15; - private static final int SSH_CMSG_STDIN_DATA = 16; - private static final int SSH_SMSG_STDOUT_DATA = 17; - private static final int SSH_SMSG_STDERR_DATA = 18; - private static final int SSH_SMSG_EXITSTATUS = 20; - private static final int SSH_CMSG_EXIT_CONFIRMATION = 33; - private static final int SSH_MSG_DEBUG = 36; - - // cipher names - private static String[] cipherNames = { "None", "IDEA", "DES", "3DES", "TSS", "RC4", "Blowfish" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ - - // cipher types - private static int SSH_CIPHER_BLOWFISH = 6; - - // preferred cipher types - private int[] preferredCipherTypes = { SSH_CIPHER_BLOWFISH }; - - private String host; - private int port; - private String username; - private String password; - private String command; - - private Socket socket; - private InputStream socketIn; - private PollingOutputStream socketOut; - private InputStream is; - private OutputStream os; - private boolean connected = false; - private int timeout = -1; - - private Cipher cipher = null; - - private class StandardInputStream extends InputStream { - private ServerPacket packet = null; - private InputStream buffer = null; - private boolean atEnd = false; - private boolean closed = false; - - public int available() throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed")); //$NON-NLS-1$ - } - - int available = buffer == null ? 0 : buffer.available(); - - if (available == 0 && socketIn.available() > 0) { - fill(); - if (atEnd) { - return 0; - } - available = buffer.available(); - } - - return available; - } - - public void close() throws IOException { - if (!closed) { - closed = true; - if (packet != null) { - packet.close(false); - buffer = null; - packet = null; - } - } - } - - public int read() throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - if (atEnd) { - return -1; - } - - if (buffer == null || buffer.available() == 0) { - fill(); - if (atEnd) { - return -1; - } - } - - return buffer.read(); - } - - public int read(byte b[], int off, int len) throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - if (atEnd) { - return -1; - } - - if (buffer == null || buffer.available() == 0) { - fill(); - if (atEnd) { - return -1; - } - } - - return buffer.read(b, off, len); - } - - private void fill() throws IOException { - if (buffer != null) { - buffer.close(); - } - - packet = skip_SSH_MSG_DEBUG(); - int packetType = packet.getType(); - - switch (packetType) { - case SSH_SMSG_STDOUT_DATA : - case SSH_SMSG_STDERR_DATA : - case SSH_MSG_DEBUG : - buffer = packet.getInputStream(); - Misc.readInt(buffer); - break; - case SSH_SMSG_EXITSTATUS : - buffer = null; - atEnd = true; - InputStream pis = packet.getInputStream(); - Misc.readInt(pis); - pis.close(); - send(SSH_CMSG_EXIT_CONFIRMATION, null); - break; - case SSH_MSG_DISCONNECT : - buffer = null; - atEnd = true; - handleDisconnect(packet.getInputStream()); - break; - default : - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - } - - private void handleDisconnect(InputStream in) throws IOException { - String description = null; - try { - description = Misc.readString(in); - } catch (IOException e) { - } finally { - in.close(); - } - - // Log the description provided by the server - if (description == null) { - description = Policy.bind("Client.noDisconnectDescription"); //$NON-NLS-1$ - } - - // Throw an IOException with the proper text - throw new IOException(Policy.bind("Client.disconnectDescription", new Object[] {description}));//$NON-NLS-1$ - } - } - - private class StandardOutputStream extends OutputStream { - private int MAX_BUFFER_SIZE = MAX_CLIENT_PACKET_SIZE; - private byte[] buffer = new byte[MAX_BUFFER_SIZE]; - private int bufpos = 0; - private boolean closed = false; - - public void close() throws IOException { - if (!closed) { - try { - flush(); - } finally { - closed = true; - } - } - } - - public void flush() throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - if (bufpos > 0) { - send(SSH_CMSG_STDIN_DATA, buffer, 0, bufpos); - bufpos = 0; - } - } - - public void write(int b) throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - buffer[bufpos++] = (byte) b; - - if (bufpos == MAX_BUFFER_SIZE) { - flush(); - } - } - - public void write(byte b[], int off, int len) throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed")); //$NON-NLS-1$ - } - - int bytesWritten = 0; - int totalBytesWritten = 0; - - if (bufpos > 0) { - bytesWritten = Math.min(MAX_BUFFER_SIZE - bufpos, len); - System.arraycopy(b, off, buffer, bufpos, bytesWritten); - bufpos += bytesWritten; - totalBytesWritten += bytesWritten; - - if (bufpos == MAX_BUFFER_SIZE) { - flush(); - } - } - - while (len - totalBytesWritten >= MAX_BUFFER_SIZE) { - send(SSH_CMSG_STDIN_DATA, b, off + totalBytesWritten, MAX_BUFFER_SIZE); - totalBytesWritten += MAX_BUFFER_SIZE; - } - - if (totalBytesWritten < len) { - bytesWritten = len - totalBytesWritten; - System.arraycopy(b, off + totalBytesWritten, buffer, 0, bytesWritten); - bufpos += bytesWritten; - } - } - } -public Client(String host, int port, String username, String password) { - this.host = host; - this.port = port; - this.username = username; - this.password = password; -} -public Client(String host, int port, String username, String password, String command) { - this(host, port, username, password); - this.command = command; -} -public Client(String host, int port, String username, String password, String command, int timeout) { - this(host, port, username, password, command); - this.timeout = timeout; -} -/** - * Close all streams and sockets. - */ -private void cleanup() throws IOException { - try { - if (is != null) - is.close(); - } finally { - try { - if (os != null) - os.close(); - } finally { - try { - if (socketIn != null) - socketIn.close(); - } finally { - try { - if (socketOut != null) - socketOut.close(); - } finally { - try { - if (socket != null) - socket.close(); - } finally { - socket = null; - } - } - } - } - } -} -/** - * Connect to the remote server. If an exception is thrown, the caller - * can asssume that all streams and sockets are closed. - */ -public void connect(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - // If we're already connected, just ignore the invokation - if (connected || monitor.isCanceled()) - return; - - // Otherwise, set up the connection - try { - PollingInputStream pollingInputStream = null; - // Create the socket (the socket should always be null here) - if (socket == null) { - try { - socket = Util.createSocket(host, port, monitor); - // Bug 36351: disable buffering and send bytes immediately - socket.setTcpNoDelay(true); - } catch (InterruptedIOException e) { - // If we get this exception, chances are the host is not responding - throw new InterruptedIOException(Policy.bind("Client.socket", new Object[] {host}));//$NON-NLS-1$ - - } - if (timeout >= 0) { - socket.setSoTimeout(1000); - } - pollingInputStream = new PollingInputStream(socket.getInputStream(), - timeout > 0 ? timeout : 1, monitor); - socketIn = new BufferedInputStream(pollingInputStream); - - socketOut = new PollingOutputStream(new TimeoutOutputStream( - socket.getOutputStream(), 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), - timeout > 0 ? timeout : 1, monitor); - } - - // read the ssh server id. The socket creation may of failed if the - // server cannot accept our connection request. We don't expect the - // socket to be closed at this point. - // Don't allow cancellation during the initial handshake and login since this - // can potentially cause the SSH server to think that it is being hacked and - // disable the account. - socketOut.setIsCancellable(false /* don't allow cancellation */); - pollingInputStream.setIsCancellable(false); - StringBuffer buf = new StringBuffer(); - int c; - while ((c = socketIn.read()) != '\n') { - if (c == -1) - throw new IOException(Policy.bind("Client.socketClosed"));//$NON-NLS-1$ - buf.append((char) c); - } - serverId = buf.toString(); - - if (Policy.DEBUG_SSH_PROTOCOL) { - System.out.println("SSH > server ID: " + serverId); //$NON-NLS-1$ - System.out.println("SSH > client ID: " + clientId); //$NON-NLS-1$ - } - - if (!serverId.startsWith("SSH-1.")) { //$NON-NLS-1$ - String sshVersion = (serverId.startsWith("SSH-")? serverId:""); //$NON-NLS-1$ //$NON-NLS-2$ - throw new IOException(Policy.bind("Client.sshProtocolVersion", sshVersion));//$NON-NLS-1$ - } - - // send our id. - socketOut.write(clientId.getBytes()); - socketOut.flush(); - - login(); - - socketOut.setIsCancellable(true /* allow cancellation */); - pollingInputStream.setIsCancellable(true); - - // start a shell and enter interactive session or start by - // executing the given command. - if( command == null ) { - startShell(); - } else { - executeCommand(); - } - - is = new StandardInputStream(); - os = new StandardOutputStream(); - connected = true; - // If an exception occurs while connected, make sure we disconnect before passing the exception on - } finally { - if (! connected) cleanup(); - } -} -/** - * Terminate the connection to the server. - */ -public void disconnect() throws IOException { - if (Policy.DEBUG_SSH_PROTOCOL) { - System.out.println("Disconnecting."); //$NON-NLS-1$ - } - if (connected) { - connected = false; - try { - send(SSH_MSG_DISCONNECT, null); - } finally { - cleanup(); - } - } -} -public InputStream getInputStream() throws IOException { - if (!connected) { - throw new IOException(Policy.bind("Client.notConnected"));//$NON-NLS-1$ - } - - return is; -} -public OutputStream getOutputStream() throws IOException { - if (!connected) { - throw new IOException(Policy.bind("Client.notConnected"));//$NON-NLS-1$ - } - - return os; -} - -private void startShell() throws IOException { - ServerPacket packet = null; - int packetType; - - send_SSH_CMSG_REQUEST_PTY(); - - try { - packet = skip_SSH_MSG_DEBUG(); - packetType = packet.getType(); - - if (packetType != SSH_SMSG_SUCCESS) { - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - } finally { - if (packet != null) { - packet.close(true /*perform crc check*/); - } - } - - send(SSH_CMSG_EXEC_SHELL, null); -} - -private void executeCommand() throws IOException { - send(SSH_CMSG_EXEC_CMD, command); -} - -private void login() throws IOException, CVSAuthenticationException { - ServerPacket packet = null; - int packetType; - - try { - packet = skip_SSH_MSG_DEBUG(); - packetType = packet.getType(); - - if (packetType != SSH_SMSG_PUBLIC_KEY) { - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - - receive_SSH_SMSG_PUBLIC_KEY(packet); - } finally { - if (packet != null) { - packet.close(true); - } - } - - try { - packet = skip_SSH_MSG_DEBUG(); - packetType = packet.getType(); - - if (packetType != SSH_SMSG_SUCCESS) { - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - } finally { - if (packet != null) { - packet.close(true); - } - } - - send(SSH_CMSG_USER, username); - - try { - packet = skip_SSH_MSG_DEBUG(); - packetType = packet.getType(); - - if (packetType != SSH_SMSG_FAILURE) { - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - } finally { - if (packet != null) { - packet.close(true); - } - } - - send(SSH_CMSG_AUTH_PASSWORD, password); - - try { - packet = skip_SSH_MSG_DEBUG(); - packetType = packet.getType(); - - if (packetType == SSH_SMSG_FAILURE) { - throw new CVSAuthenticationException(Policy.bind("Client.authenticationFailed"), CVSAuthenticationException.RETRY);//$NON-NLS-1$ - } - - if (packetType != SSH_SMSG_SUCCESS) { - throw new IOException(Policy.bind("Client.packetType", new Object[] {new Integer(packetType)} ));//$NON-NLS-1$ - } - } finally { - if (packet != null) { - packet.close(true); - } - } -} -private void receive_SSH_SMSG_PUBLIC_KEY(ServerPacket packet) throws IOException, CVSAuthenticationException { - InputStream pis = packet.getInputStream(); - - byte[] anti_spoofing_cookie = new byte[8]; - Misc.readFully(pis, anti_spoofing_cookie); - - byte[] server_key_bits = new byte[4]; - Misc.readFully(pis, server_key_bits); - - byte[] server_key_public_exponent = Misc.readMpInt(pis); - byte[] server_key_public_modulus = Misc.readMpInt(pis); - - byte[] host_key_bits = new byte[4]; - Misc.readFully(pis, host_key_bits); - - byte[] host_key_public_exponent = Misc.readMpInt(pis); - byte[] host_key_public_modulus = Misc.readMpInt(pis); - - byte[] protocol_flags = new byte[4]; - Misc.readFully(pis, protocol_flags); - - byte[] supported_ciphers_mask = new byte[4]; - Misc.readFully(pis, supported_ciphers_mask); - - byte[] supported_authentications_mask = new byte[4]; - Misc.readFully(pis, supported_authentications_mask); - - pis.close(); - - send_SSH_CMSG_SESSION_KEY(anti_spoofing_cookie, host_key_bits, server_key_public_modulus, host_key_public_modulus, supported_ciphers_mask, server_key_public_exponent, host_key_public_exponent); -} -private void send(int packetType, String s) throws IOException { - byte[] data = s == null ? new byte[0] : s.getBytes("UTF-8"); //$NON-NLS-1$ - send(packetType, data, 0, data.length); -} -private void send(int packetType, byte[] data, int off, int len) throws IOException { - data = data == null ? null : Misc.lengthEncode(data, off, len); - ClientPacket packet = new ClientPacket(packetType, data, cipher); - socketOut.write(packet.getBytes()); - socketOut.flush(); -} -private void send_SSH_CMSG_REQUEST_PTY() throws IOException { - byte packet_type = SSH_CMSG_REQUEST_PTY; - - byte[] termType = Misc.lengthEncode("dumb".getBytes(), 0, 4);//$NON-NLS-1$ - byte[] row = {0, 0, 0, 0}; - byte[] col = {0, 0, 0, 0}; - byte[] XPixels = {0, 0, 0, 0}; - byte[] YPixels = {0, 0, 0, 0}; - byte[] terminalModes = {0}; - - byte[] data = new byte[termType.length + row.length + col.length + XPixels.length + YPixels.length + terminalModes.length]; - - int offset = 0; - System.arraycopy(termType, 0, data, offset, termType.length); - - offset += termType.length; - System.arraycopy(row, 0, data, offset, row.length); - - offset += row.length; - System.arraycopy(col, 0, data, offset, col.length); - - offset += col.length; - System.arraycopy(XPixels, 0, data, offset, XPixels.length); - - offset += XPixels.length; - System.arraycopy(YPixels, 0, data, offset, YPixels.length); - - offset += YPixels.length; - System.arraycopy(terminalModes, 0, data, offset, terminalModes.length); - - ClientPacket packet = new ClientPacket(packet_type, data, cipher); - socketOut.write(packet.getBytes()); - socketOut.flush(); -} -private void send_SSH_CMSG_SESSION_KEY(byte[] anti_spoofing_cookie, byte[] host_key_bits, byte[] server_key_public_modulus, byte[] host_key_public_modulus, byte[] supported_ciphers_mask, byte[] server_key_public_exponent, byte[] host_key_public_exponent) throws IOException, CVSAuthenticationException { - byte packet_type = SSH_CMSG_SESSION_KEY; - - // session_id - byte[] session_id = new byte[host_key_public_modulus.length + server_key_public_modulus.length + anti_spoofing_cookie.length]; - - int offset = 0; - System.arraycopy(host_key_public_modulus, 0, session_id, offset, host_key_public_modulus.length); - - offset += host_key_public_modulus.length; - System.arraycopy(server_key_public_modulus, 0, session_id, offset, server_key_public_modulus.length); - - offset += server_key_public_modulus.length; - System.arraycopy(anti_spoofing_cookie, 0, session_id, offset, anti_spoofing_cookie.length); - - session_id = Misc.md5(session_id); - - // cipher_type - byte cipher_type = 0; - boolean foundSupportedCipher = false; - - for (int i = 0; i < preferredCipherTypes.length && !foundSupportedCipher; ++i) { - cipher_type = (byte) preferredCipherTypes[i]; - foundSupportedCipher = (supported_ciphers_mask[3] & (byte) (1 << cipher_type)) != 0; - } - - if (!foundSupportedCipher) { - throw new IOException(Policy.bind("Client.cipher"));//$NON-NLS-1$ - } - - // session_key - byte[] session_key = new byte[32]; - byte[] session_key_xored = new byte[32]; - byte[] session_key_encrypted = null; - - Misc.random(session_key, 0, session_key.length, true); - System.arraycopy(session_key, 0, session_key_xored, 0, session_key.length); - Misc.xor(session_key_xored, 0, session_id, 0, session_key_xored, 0, session_id.length); - - BigInteger host_e = new BigInteger(1, host_key_public_exponent); - BigInteger host_n = new BigInteger(1, host_key_public_modulus); - if (!new KnownHosts().verifyKey(host, host_key_bits, host_e, host_n)) { - throw new CVSAuthenticationException(Policy.bind("Client.hostIdChanged"), CVSAuthenticationException.NO_RETRY); //$NON-NLS-1$ - }; - byte[] result; - if (new BigInteger(1,server_key_public_modulus).compareTo(host_n) == -1) { - result = Misc.encryptRSAPkcs1(session_key_xored, server_key_public_exponent, server_key_public_modulus); - result = Misc.encryptRSAPkcs1(result, host_key_public_exponent, host_key_public_modulus); - } else { - result = Misc.encryptRSAPkcs1(session_key_xored, host_key_public_exponent, host_key_public_modulus); - result = Misc.encryptRSAPkcs1(result, server_key_public_exponent, server_key_public_modulus); - } - - session_key_encrypted = new byte[result.length + 2]; - session_key_encrypted[1] = (byte) ((8 * result.length) & 0xff); - session_key_encrypted[0] = (byte) (((8 * result.length) >> 8) & 0xff); - - for (int i = 0; i < result.length; i++) { - session_key_encrypted[i + 2] = result[i]; - } - - // protocol_flags - byte[] protocol_flags = {0, 0, 0, 0}; - - // data - byte[] data = new byte[1 + anti_spoofing_cookie.length + session_key_encrypted.length + protocol_flags.length]; - - offset = 0; - data[offset++] = cipher_type; - - System.arraycopy(anti_spoofing_cookie, 0, data, offset, anti_spoofing_cookie.length); - - offset += anti_spoofing_cookie.length; - System.arraycopy(session_key_encrypted, 0, data, offset, session_key_encrypted.length); - - offset += session_key_encrypted.length; - System.arraycopy(protocol_flags, 0, data, offset, protocol_flags.length); - - // cipher - cipher = Cipher.getInstance(cipherNames[cipher_type]); - cipher.setKey(session_key); - - // packet - ClientPacket packet = new ClientPacket(packet_type, data, null); - socketOut.write(packet.getBytes()); - socketOut.flush(); -} - -private ServerPacket skip_SSH_MSG_DEBUG() throws IOException { - ServerPacket packet = new ServerPacket(socketIn, cipher); - while (packet.getType() == SSH_MSG_DEBUG) { - packet.close(true); - packet = new ServerPacket(socketIn, cipher); - } - - return packet; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ClientPacket.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ClientPacket.java deleted file mode 100644 index 7a8a7edfb..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ClientPacket.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -class ClientPacket extends Packet { - byte[] packet; -public ClientPacket(int type, byte[] data, Cipher cipher) { - packetLength = data == null ? 5 : data.length + 5; - paddingLength = 8 - (packetLength % 8); - packetType = type; - packet = new byte[4 + paddingLength + packetLength]; - - int packetOff = 0; - Misc.writeInt(packetLength, packet, packetOff); - packetOff += 4; - - if (cipher == null) { - for (int i = 0; i < paddingLength; i++) { - packet[packetOff++] = 0; - } - } else { - Misc.random(packet, packetOff, paddingLength, false); - packetOff += paddingLength; - } - - packet[packetOff++] = (byte) packetType; - - if (data != null) { - for (int i = 0; i < data.length; ++i) { - packet[packetOff++] = data[i]; - } - } - - long crc = Misc.crc32(packet, 4, packet.length - 8, 0); - Misc.writeInt((int) crc, packet, packetOff); - packetOff += 4; - - if (cipher != null) { - cipher.encipher(packet, 4, packet, 4, packet.length - 4); - } -} -public byte[] getBytes() { - return packet; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/KnownHosts.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/KnownHosts.java deleted file mode 100644 index a38c670aa..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/KnownHosts.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.team.internal.ccvs.ssh; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.math.BigInteger; -import java.util.Vector; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.team.internal.ccvs.ssh.Policy; - -/** - * I represent a database of known hosts usually placed in ~/.ssh/known_hosts - * on Unix/Linux systems. - * Currently, only RSA keys are supported, as these are the only keys we - * have to deal with during SSH1 key exchange. - */ -public class KnownHosts { - - private String filename; - - public KnownHosts(String filename) { - this.filename = filename; - } - - public KnownHosts() { - this.filename = KnownHosts.defaultFilename(); - } - - static String defaultFilename() { - if (!Platform.getOS().equals(Platform.OS_LINUX)) return internalFilename(); - String HOME = System.getProperty("user.home"); //$NON-NLS-1$ - if (HOME==null) return internalFilename(); - return HOME+"/.ssh/known_hosts"; //$NON-NLS-1$ - } - - private static String internalFilename() { - return SSHPlugin.getPlugin().getStateLocation().append("known_hosts").toOSString(); //$NON-NLS-1$ - } - - /** - * Verify if the public key for the specified host is known. - * If the public key matches, return true. - * If the key does not match, return false. - * If the key is not listed in known_hosts, or - * known_hosts does not exist, assume we are connecting - * to the authentic server, add the key, and return true. - * @param e key exponent - * @param n key modulus - * @return boolean whether the key is correct - */ - public boolean verifyKey(String hostname, byte[] host_key_bits, BigInteger e, BigInteger n) { - FileReader f; - BigInteger nbits = new BigInteger(1, host_key_bits); - try { - f= new FileReader(filename); - } catch (FileNotFoundException ex) { - createHostFile(); - addHost(hostname, nbits, e, n); - return true; - } - BufferedReader r = new BufferedReader(f); - try { - String line; - while ((line = r.readLine()) != null) { - if (line.trim().length()==0) continue; - if (line.startsWith("#")) continue; //$NON-NLS-1$ - String[] tokens=subStrings(line); - if (tokens.length==4 && Character.isDigit(tokens[1].charAt(0)) && tokens[0].equalsIgnoreCase(hostname)) { - if (nbits.equals(new BigInteger(tokens[1])) && e.equals(new BigInteger(tokens[2])) && n.equals(new BigInteger(tokens[3]))) { - f.close(); - return true; - } else { - f.close(); - return false; - } - } - } - f.close(); - addHost(hostname, nbits, e, n); - return true; - } catch (IOException ex) { - SSHPlugin.log(IStatus.ERROR, Policy.bind("KnownHosts.8"), ex); //$NON-NLS-1$ - return false; - } - } - - /* - * Append the host key information to known_hosts. - * Always assume the file exists. - */ - void addHost(String hostname, BigInteger key_bits, BigInteger e, BigInteger n) { - try { - FileWriter w = new FileWriter(defaultFilename(), true); - w.write(Character.LINE_SEPARATOR); - w.write(hostname + " " + key_bits.toString(10) + " " + e.toString(10) + " " + n.toString(10)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - w.close(); - String message = Policy.bind("Client.addedHostKey", new String[] {hostname, defaultFilename()}); //$NON-NLS-1$ - SSHPlugin.log(IStatus.INFO, message, null); - } catch (IOException ex) { - SSHPlugin.log(IStatus.ERROR, Policy.bind("KnownHosts.9"), ex); //$NON-NLS-1$ - } - } - - /* - * Create the known_hosts file in the default location. - * Fail if the file can not be created (issue a warning in the log). - */ - void createHostFile() { - try { - File file = new File(defaultFilename()); - // Ensure the parent directory exists - File parentDir = file.getParentFile(); - parentDir.mkdirs(); - // Create the file - file.createNewFile(); - } catch (IOException ee) { - SSHPlugin.log(IStatus.ERROR, Policy.bind("KnownHosts.10"), ee); //$NON-NLS-1$ - } - - } - private static String[] subStrings(String s) { - Vector v = subStringsVector(s); - String[] substrings = new String[v.size()]; - v.copyInto(substrings); - return substrings; - } - private static Vector subStringsVector(String s) { - Vector v = new Vector(); - s = s.trim(); - if (s.length()==0) return v; - int first1 = s.indexOf(' '); - int first2 = s.indexOf('\t'); - int first; - if ((first1==-1)&&(first2==-1)) first=-1; - else if ((first1!=-1)&&(first2!=-1)) first = Math.min(first1, first2); - else if (first1!=-1) first=first1; else first=first2; - if (first==-1) { - v.add(s); - return v; - } - v.add(s.substring(0,first)); - v.addAll(subStringsVector(s.substring(first+1))); - return v; - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Misc.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Misc.java deleted file mode 100644 index c769d35f4..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Misc.java +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -class Misc { - private static MessageDigest md5 = null; - private static SecureRandom random = null; - private static long crc32_tab[] = { - 0x00000000L, - 0x77073096L, - 0xee0e612cL, - 0x990951baL, - 0x076dc419L, - 0x706af48fL, - 0xe963a535L, - 0x9e6495a3L, - 0x0edb8832L, - 0x79dcb8a4L, - 0xe0d5e91eL, - 0x97d2d988L, - 0x09b64c2bL, - 0x7eb17cbdL, - 0xe7b82d07L, - 0x90bf1d91L, - 0x1db71064L, - 0x6ab020f2L, - 0xf3b97148L, - 0x84be41deL, - 0x1adad47dL, - 0x6ddde4ebL, - 0xf4d4b551L, - 0x83d385c7L, - 0x136c9856L, - 0x646ba8c0L, - 0xfd62f97aL, - 0x8a65c9ecL, - 0x14015c4fL, - 0x63066cd9L, - 0xfa0f3d63L, - 0x8d080df5L, - 0x3b6e20c8L, - 0x4c69105eL, - 0xd56041e4L, - 0xa2677172L, - 0x3c03e4d1L, - 0x4b04d447L, - 0xd20d85fdL, - 0xa50ab56bL, - 0x35b5a8faL, - 0x42b2986cL, - 0xdbbbc9d6L, - 0xacbcf940L, - 0x32d86ce3L, - 0x45df5c75L, - 0xdcd60dcfL, - 0xabd13d59L, - 0x26d930acL, - 0x51de003aL, - 0xc8d75180L, - 0xbfd06116L, - 0x21b4f4b5L, - 0x56b3c423L, - 0xcfba9599L, - 0xb8bda50fL, - 0x2802b89eL, - 0x5f058808L, - 0xc60cd9b2L, - 0xb10be924L, - 0x2f6f7c87L, - 0x58684c11L, - 0xc1611dabL, - 0xb6662d3dL, - 0x76dc4190L, - 0x01db7106L, - 0x98d220bcL, - 0xefd5102aL, - 0x71b18589L, - 0x06b6b51fL, - 0x9fbfe4a5L, - 0xe8b8d433L, - 0x7807c9a2L, - 0x0f00f934L, - 0x9609a88eL, - 0xe10e9818L, - 0x7f6a0dbbL, - 0x086d3d2dL, - 0x91646c97L, - 0xe6635c01L, - 0x6b6b51f4L, - 0x1c6c6162L, - 0x856530d8L, - 0xf262004eL, - 0x6c0695edL, - 0x1b01a57bL, - 0x8208f4c1L, - 0xf50fc457L, - 0x65b0d9c6L, - 0x12b7e950L, - 0x8bbeb8eaL, - 0xfcb9887cL, - 0x62dd1ddfL, - 0x15da2d49L, - 0x8cd37cf3L, - 0xfbd44c65L, - 0x4db26158L, - 0x3ab551ceL, - 0xa3bc0074L, - 0xd4bb30e2L, - 0x4adfa541L, - 0x3dd895d7L, - 0xa4d1c46dL, - 0xd3d6f4fbL, - 0x4369e96aL, - 0x346ed9fcL, - 0xad678846L, - 0xda60b8d0L, - 0x44042d73L, - 0x33031de5L, - 0xaa0a4c5fL, - 0xdd0d7cc9L, - 0x5005713cL, - 0x270241aaL, - 0xbe0b1010L, - 0xc90c2086L, - 0x5768b525L, - 0x206f85b3L, - 0xb966d409L, - 0xce61e49fL, - 0x5edef90eL, - 0x29d9c998L, - 0xb0d09822L, - 0xc7d7a8b4L, - 0x59b33d17L, - 0x2eb40d81L, - 0xb7bd5c3bL, - 0xc0ba6cadL, - 0xedb88320L, - 0x9abfb3b6L, - 0x03b6e20cL, - 0x74b1d29aL, - 0xead54739L, - 0x9dd277afL, - 0x04db2615L, - 0x73dc1683L, - 0xe3630b12L, - 0x94643b84L, - 0x0d6d6a3eL, - 0x7a6a5aa8L, - 0xe40ecf0bL, - 0x9309ff9dL, - 0x0a00ae27L, - 0x7d079eb1L, - 0xf00f9344L, - 0x8708a3d2L, - 0x1e01f268L, - 0x6906c2feL, - 0xf762575dL, - 0x806567cbL, - 0x196c3671L, - 0x6e6b06e7L, - 0xfed41b76L, - 0x89d32be0L, - 0x10da7a5aL, - 0x67dd4accL, - 0xf9b9df6fL, - 0x8ebeeff9L, - 0x17b7be43L, - 0x60b08ed5L, - 0xd6d6a3e8L, - 0xa1d1937eL, - 0x38d8c2c4L, - 0x4fdff252L, - 0xd1bb67f1L, - 0xa6bc5767L, - 0x3fb506ddL, - 0x48b2364bL, - 0xd80d2bdaL, - 0xaf0a1b4cL, - 0x36034af6L, - 0x41047a60L, - 0xdf60efc3L, - 0xa867df55L, - 0x316e8eefL, - 0x4669be79L, - 0xcb61b38cL, - 0xbc66831aL, - 0x256fd2a0L, - 0x5268e236L, - 0xcc0c7795L, - 0xbb0b4703L, - 0x220216b9L, - 0x5505262fL, - 0xc5ba3bbeL, - 0xb2bd0b28L, - 0x2bb45a92L, - 0x5cb36a04L, - 0xc2d7ffa7L, - 0xb5d0cf31L, - 0x2cd99e8bL, - 0x5bdeae1dL, - 0x9b64c2b0L, - 0xec63f226L, - 0x756aa39cL, - 0x026d930aL, - 0x9c0906a9L, - 0xeb0e363fL, - 0x72076785L, - 0x05005713L, - 0x95bf4a82L, - 0xe2b87a14L, - 0x7bb12baeL, - 0x0cb61b38L, - 0x92d28e9bL, - 0xe5d5be0dL, - 0x7cdcefb7L, - 0x0bdbdf21L, - 0x86d3d2d4L, - 0xf1d4e242L, - 0x68ddb3f8L, - 0x1fda836eL, - 0x81be16cdL, - 0xf6b9265bL, - 0x6fb077e1L, - 0x18b74777L, - 0x88085ae6L, - 0xff0f6a70L, - 0x66063bcaL, - 0x11010b5cL, - 0x8f659effL, - 0xf862ae69L, - 0x616bffd3L, - 0x166ccf45L, - 0xa00ae278L, - 0xd70dd2eeL, - 0x4e048354L, - 0x3903b3c2L, - 0xa7672661L, - 0xd06016f7L, - 0x4969474dL, - 0x3e6e77dbL, - 0xaed16a4aL, - 0xd9d65adcL, - 0x40df0b66L, - 0x37d83bf0L, - 0xa9bcae53L, - 0xdebb9ec5L, - 0x47b2cf7fL, - 0x30b5ffe9L, - 0xbdbdf21cL, - 0xcabac28aL, - 0x53b39330L, - 0x24b4a3a6L, - 0xbad03605L, - 0xcdd70693L, - 0x54de5729L, - 0x23d967bfL, - 0xb3667a2eL, - 0xc4614ab8L, - 0x5d681b02L, - 0x2a6f2b94L, - 0xb40bbe37L, - 0xc30c8ea1L, - 0x5a05df1bL, - 0x2d02ef8dL - }; -static public long crc32(byte[] b, int off, int len) { - return crc32(b, off, len, 0); -} -/** - * Compute the crc Cyclic Redundancy Check, with the polynomial 0xedb88320, - * The polynomial is X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 - * We take it "backwards" and put the highest-order term in the lowest-order bit. - * The X^32 term is "implied"; the LSB is the X^31 term, etc. - * The X^0 term (usually shown as "+1") results in the MSB being 1. - * so the poly is 0x04c11db7 (used for Ethernet) - * The buf will be the Padding, Packet type, and Data fields. - * The crc is computed before any encryption. - * R =X^n * M rem P M message P polynomial crc R : crc calculated. - * T(x) = x^n * M(x) + R(x) property: T rem P = 0 - */ -static public long crc32(byte[] b, int off, int len, long crc32val) { - for (int i = 0; i < len; i++) { - crc32val = crc32_tab[(int) ((crc32val ^ b[off + i]) & 0xff)] ^ (crc32val >> 8); - } - - return crc32val; -} -static public byte[] lengthEncode(byte[] b, int off, int len) { - byte[] result = new byte[len + 4]; - writeInt(len, result, 0); - System.arraycopy(b, off, result, 4, len); - return result; -} -static public byte[] readMpInt(InputStream is) throws IOException { - int a = is.read(); - int b = is.read(); - - if(a == -1 || b == -1){ - throw new IOException(Policy.bind("stream"));//$NON-NLS-1$ - } - - int bits = ((a & 0xFF) << 8) + (b & 0xFF); - int bytes = (bits + 7) / 8; - - byte[] result = new byte[bytes]; - - readFully(is, result); - - return result; -} -public static byte[] md5(byte[] b) throws IOException { - if (md5 == null) { - try { - md5 = MessageDigest.getInstance("MD5");//$NON-NLS-1$ - } catch (NoSuchAlgorithmException e) { - throw new IOException(Policy.bind("Misc.missingMD5", e.getMessage())); //$NON-NLS-1$ - } - } - - return md5.digest(b); -} -public static byte[] md5(String s) throws IOException { - return md5(s.getBytes()); -} -public static void readFully(InputStream is, byte[] b) throws IOException { - readFully(is, b, 0, b.length); -} -public static void readFully(InputStream is, byte[] b, int off, int len) throws IOException { - int bytesRead = 0; - int totalBytesRead = 0; - - while (totalBytesRead < len) { - bytesRead = is.read(b, totalBytesRead + off, len - totalBytesRead); - - if (bytesRead == -1) { - throw new IOException(Policy.bind("stream"));//$NON-NLS-1$ - } - - totalBytesRead += bytesRead; - } -} -public static int readInt(byte[] arr, int off) { - int a = arr[off] & 0xff; - int b = arr[off + 1] & 0xff; - int c = arr[off + 2] & 0xff; - int d = arr[off + 3] & 0xff; - - return (a << 24) + (b << 16) + (c << 8) + d; -} -public static int readInt(InputStream is) throws IOException { - int a = is.read(); - int b = is.read(); - int c = is.read(); - int d = is.read(); - - if (a == -1 || b == -1 || c == -1 || d == -1) { - throw new IOException(Policy.bind("stream"));//$NON-NLS-1$ - } - - return (a << 24) + (b << 16) + (c << 8) + d; -} -public static String readString(InputStream is) throws IOException { - int size = Misc.readInt(is); - byte[] buffer = new byte[size]; - for (int i = 0; i < buffer.length; i++) { - int next = is.read(); - if (next == -1) { - throw new IOException(Policy.bind("stream")); //$NON-NLS-1$ - } else { - buffer[i] = (byte)next; - } - } - return new String(buffer); -} -public static void skipFully(InputStream is, long n) throws IOException { - while (n != 0) { - int b = is.read(); - - if (b == -1) { - if (n > 0) { - throw new IOException(Policy.bind("stream"));//$NON-NLS-1$ - } - - return; - } - - --n; - } -} -public static void writeInt(int i, byte[] b, int off) { - b[off] = (byte) ((i >> 24) & 0xff); - b[off + 1] = (byte) ((i >> 16) & 0xff); - b[off + 2] = (byte) ((i >> 8) & 0xff); - b[off + 3] = (byte) (i & 0xff); -} -static public void xor(byte[] src_a, int off_a, byte[] src_b, int off_b, byte[] dst, int dst_off, int len) { - for(int i = 0; i < len; ++i){ - dst[i + dst_off] = (byte) (src_a[i + off_a] ^ src_b[i + off_b]); - } -} -static public void random(byte[] b, int off, int len, boolean allowZeroBytes) { - if (random == null) { - try { - random = SecureRandom.getInstance("SHA1PRNG");//$NON-NLS-1$ - } catch (NoSuchAlgorithmException e) { - // If SHA1PRNG is not available, just use the default - random = new SecureRandom(); - } - } - - for(int i = off; i < off + len; ++i){ - do { - b[i] = (byte) random.nextInt(); - } while(!allowZeroBytes && b[i] == 0); - } -} -static public byte[] encryptRSAPkcs1(byte[] data, byte[] public_key_exponent, byte[] public_key_modulus) { - byte[] block; - - int offset = 0; - block = new byte[public_key_modulus.length]; - block[offset++] = 0; - block[offset++] = 2; - - Misc.random(block, offset, block.length - data.length - 3, false); - offset += block.length - data.length - 3; - - block[offset++] = 0; - - for (int i = 0; i < data.length; i++){ - block[offset++] = data[i]; - } - - BigInteger m, e, message; - byte[] messageByte; - - m = new BigInteger(1, public_key_modulus); - e = new BigInteger(1, public_key_exponent); - message = new BigInteger(1, block); - message = message.modPow(e, m); - - byte[] messageByteTemp = message.toByteArray(); - messageByte = new byte[public_key_modulus.length]; - - int tempOffset = 0; - while (messageByteTemp[tempOffset] == 0){ - tempOffset++; - } - - for (int i = messageByte.length - messageByteTemp.length + tempOffset; i < messageByte.length; i++){ - messageByte[i] = messageByteTemp[tempOffset++]; - } - - return messageByte; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Packet.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Packet.java deleted file mode 100644 index b810ded94..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Packet.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -class Packet { - protected int packetLength; - protected int paddingLength; - protected int packetType; -public int getType() { - return packetType; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Policy.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Policy.java deleted file mode 100644 index 112db9ac4..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/Policy.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.Platform; - -public class Policy { - protected static ResourceBundle bundle = null; - - //debug constants - public static boolean DEBUG_SSH_PROTOCOL = false; - - static { - //init debug options - if (SSHPlugin.getPlugin().isDebugging()) { - DEBUG_SSH_PROTOCOL = "true".equalsIgnoreCase(Platform.getDebugOption(SSHPlugin.ID + "/ssh_protocol"));//$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHMethod.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHMethod.java deleted file mode 100644 index 1c94171a6..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHMethod.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IConnectionMethod; -import org.eclipse.team.internal.ccvs.core.IServerConnection; - -public class SSHMethod implements IConnectionMethod { - /** - * @see IConnectionMethod#getName - */ - public String getName() { - return "extssh";//$NON-NLS-1$ - } - - /** - * @see IConnectionMethod#createConnection - */ - public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) { - return new SSHServerConnection(repositoryRoot, password); - } - - public void disconnect(ICVSRepositoryLocation location) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHPlugin.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHPlugin.java deleted file mode 100644 index 1ba80a2ff..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHPlugin.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.BundleContext; -public class SSHPlugin extends Plugin { - - public static String ID = "org.eclipse.team.cvs.ssh"; //$NON-NLS-1$ - - private static SSHPlugin instance; - - /** - * Log the given exception along with the provided message and severity indicator - */ - public static void log(int severity, String message, Throwable e) { - getPlugin().getLog().log(new Status(severity, ID, 0, message, e)); - } - - /** - * Constructor for SSHPlugin - */ - public SSHPlugin() { - super(); - instance = this; - } - - /** - * @see Plugin#start(BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - Policy.localize("org.eclipse.team.internal.ccvs.ssh.messages"); //$NON-NLS-1$ - } - - /** - * Method getPlugin. - */ - public static SSHPlugin getPlugin() { - return instance; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHServerConnection.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHServerConnection.java deleted file mode 100644 index 98e1d1904..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/SSHServerConnection.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IServerConnection; -import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; - -public class SSHServerConnection implements IServerConnection { - - // command to start remote cvs in server mode - private static final String INVOKE_SVR_CMD = "cvs server"; //$NON-NLS-1$ - - private static final int DEFAULT_PORT = 22; - - // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo) - private ICVSRepositoryLocation location; - - // password for user specified in repository location string - private String password; - - // incoming from remote host - InputStream inputStream; - - // outgoing to remote host - OutputStream outputStream; - - // ssh client - Client client; - - public SSHServerConnection(ICVSRepositoryLocation location, String password) { - this.location = location; - this.password = password; - } - - public void close() throws IOException { - client.disconnect(); - } - /** - * Returns the InputStream used to read data from the - * server. - */ - public InputStream getInputStream() { - return inputStream; - } - /** - * Returns the OutputStream used to send data to the - * server. - */ - public OutputStream getOutputStream() { - return outputStream; - } - - /** - * Opens the connection and invokes cvs in server mode. - * - * @see Connection.open() - */ - public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - monitor.subTask(Policy.bind("SSHServerConnection.authenticating")); //$NON-NLS-1$ - monitor.worked(1); - String hostname = location.getHost(); - String username = location.getUsername(); - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) - port = DEFAULT_PORT; - // create the connection using host, username, and password - client = new Client(hostname, port, username, password, INVOKE_SVR_CMD, location.getTimeout()); - client.connect(monitor); - inputStream = client.getInputStream(); - outputStream = client.getOutputStream(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ServerPacket.java b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ServerPacket.java deleted file mode 100644 index 9985a2f2e..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/ServerPacket.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -class ServerPacket extends Packet { - private PacketInputStream pis = null; - - private static class PacketInputStream extends FilterInputStream { - private static int MAX_BUFFER_SIZE = 1024; - - private byte[] buffer = new byte[MAX_BUFFER_SIZE]; - private int bufpos = 0; - private int buflen = 0; - private int bufrem = 0; - - private long remaining = 0; - private Cipher cipher = null; - - private long crc = 0; - private boolean closed = false; - - public PacketInputStream(InputStream in, long length, Cipher cipher) { - super(in); - - this.remaining = length; - this.cipher = cipher; - } - - public int available() throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - return (int) Math.min(remaining - 4, Integer.MAX_VALUE); - } - - public void close() throws IOException { - close(true); - } - - public void close(boolean doCrcCheck) throws IOException { - if (!closed) { - try { - long toRead = doCrcCheck ? remaining - 4 : remaining; - - try { - Misc.skipFully(this, toRead); - } catch(IOException e) { - // we tried our best, keep going - } - - if(doCrcCheck) { - if ((int) crc != Misc.readInt(buffer, bufpos)) { - throw new IOException(Policy.bind("ServerPacket.crc"));//$NON-NLS-1$ - } - } - } finally { - closed = true; - } - } - } - - private void fill() throws IOException { - if (bufrem > 0) { - System.arraycopy(buffer, bufpos, buffer, 0, bufrem); - } - - int totalBytesRead = bufrem; - int read = 0; - int toRead = (int)Math.min(remaining - totalBytesRead, MAX_BUFFER_SIZE - totalBytesRead); - - while (toRead > 0) { - read = in.read(buffer, totalBytesRead, toRead); - - if (read == -1) { - throw new IOException(Policy.bind("stream"));//$NON-NLS-1$ - } - - totalBytesRead += read; - toRead -= read; - } - - bufpos = 0; - - buflen = (totalBytesRead / 8) * 8; - bufrem = totalBytesRead - buflen; - - if (cipher != null) { - cipher.decipher(buffer, 0, buffer, 0, buflen); - } - - crc = Misc.crc32(buffer, 0, buflen == remaining ? buflen - 4 : buflen, crc); - } - - public int read() throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - if (remaining - 4 == 0) { - return -1; - } - - if (bufpos == buflen) { - fill(); - } - - int b = buffer[bufpos] & 0xff; - - ++bufpos; - --remaining; - - return b; - } - - public int read(byte b[], int off, int len) throws IOException { - if (closed) { - throw new IOException(Policy.bind("closed"));//$NON-NLS-1$ - } - - if (remaining - 4 == 0) { - return -1; - } - - if (bufpos == buflen) { - fill(); - } - - len = Math.min(len, (buflen == remaining + bufpos ? buflen - 4 : buflen) - bufpos); - - System.arraycopy(buffer, bufpos, b, off, len); - - bufpos += len; - remaining -= len; - - return len; - } - } -public ServerPacket(InputStream is, Cipher cipher) throws java.io.IOException { - packetLength = Misc.readInt(is); - paddingLength = 8 - (packetLength % 8); - pis = new PacketInputStream(is, packetLength + paddingLength, cipher); - Misc.skipFully(pis, paddingLength); - packetType = (byte) pis.read(); -} -public void close(boolean doCrcCheck) throws IOException { - pis.close(doCrcCheck); -} -public InputStream getInputStream() { - return pis; -} -} diff --git a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/messages.properties b/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/messages.properties deleted file mode 100644 index 7cc4673a9..000000000 --- a/bundles/org.eclipse.team.cvs.ssh/src/org/eclipse/team/internal/ccvs/ssh/messages.properties +++ /dev/null @@ -1,39 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# String resources for vcm.core.cvs.ssh -########################### - -closed=Closed -stream=Unexpected end of stream - -Client.packetType=unexpected packet type: {0} -Client.notConnected=Not connected -Client.cipher=Supported cipher not found -Client.socketClosed=Connection closed by server -Client.authenticationFailed=Invalid username, password, host or repository -Client.socket=Cannot connect to host: {0} -Client.disconnectDescription=SSH server disconnected: {0} -Client.noDisconnectDescription=No reason could be obtained. -Client.sshProtocolVersion=Unsupported SSH protocol version: {0} -Client.hostIdChanged=The server host key does not match the key previously stored. Either the host key has changed or there is a man-in-the-middle attack. Contact the server administrator -Client.addedHostKey=Host key for {0} was not found in the list of known hosts stored in {1}. The key is being automatically added to the known_hosts file for you. This key, which is like a personal signature, is used by Eclipse to guarantee that the host it is communicating with is the correct one. If the Eclipse client detects a change in this key you will be notified. -Client.sshProtocolVersion=Unsupported SSH protocol version: {0} - -ServerPacket.crc=crc error - -SSHServerConnection.authenticating=Authenticating over extssh - -Misc.missingMD5=The MD5 encryption algorithm is required but not available: {0} - -KnownHosts.8=Error reading host key file -KnownHosts.9=Error writing host key file -KnownHosts.10=Error creating host key file diff --git a/bundles/org.eclipse.team.cvs.ssh2/.classpath b/bundles/org.eclipse.team.cvs.ssh2/.classpath deleted file mode 100644 index b0c00e5a6..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ssh2/.cvsignore b/bundles/org.eclipse.team.cvs.ssh2/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/bundles/org.eclipse.team.cvs.ssh2/.project b/bundles/org.eclipse.team.cvs.ssh2/.project deleted file mode 100644 index 571866b71..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/.project +++ /dev/null @@ -1,35 +0,0 @@ - - - org.eclipse.team.cvs.ssh2 - - - org.eclipse.core.boot - org.eclipse.core.resources - org.eclipse.core.runtime - org.eclipse.team.core - org.eclipse.team.cvs.core - org.eclipse.team.cvs.ssh - org.eclipse.ui - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.team.cvs.ssh2/about.html b/bundles/org.eclipse.team.cvs.ssh2/about.html deleted file mode 100644 index 5fdd811f2..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/about.html +++ /dev/null @@ -1,76 +0,0 @@ - - - -About - - - -

              About This Content

              - -

              20th November, 2003

              -

              License

              -

              Eclipse.org makes available all content in this plug-in ("Content"). With the exception of the files listed below, all Content should be defined as the "SWT" and -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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" shall mean the SWT.

              - -

              Third Party Content

              - -

              The Content includes items that have been sourced from third parties as follows:

              - -

              JSch 0.1.18

              - -

              The plug-in is based on software developed by Atsuhiko Yamanaka, JCraft, Inc., and others and -made available at http://www.jcraft.com/. - -

              The following files shall be defined as the "JSch": -

                -
              • jsch-0.1.18.jar
              • -
              - -

              Use of JSch is governed by the terms and conditions of the following license:

              - -
              Copyright (c) 2002,2003 ymnk, JCraft,Inc. All rights reserved.
              -
              -Redistribution and use in source and binary forms, with or without
              -modification, are permitted provided that the following conditions are met:
              -
              - 1. Redistributions of source code must retain the above copyright notice,
              - this list of conditions and the following disclaimer.
              -
              - 2. Redistributions in binary form must reproduce the above copyright
              - notice, this list of conditions and the following disclaimer in
              - the documentation and/or other materials provided with the distribution.
              -
              - 3. The names of the authors may not be used to endorse or promote products
              - derived from this software without specific prior written permission.
              -
              -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
              -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
              -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
              -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
              -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
              -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
              -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
              -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
              -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
              -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
              - -

              NOTE: Although the SSH2 protocol depends on cryptographic algorithms, JSch relies on a Java(TM) Cryptography Extension (JCE) -to provide this functionality and does not in itself contain any cryptographic code.

              - -

              Contributions

              - -

              If you wish to provide modifications, enhancements and/or other code and/or documentation ("Contributions") related to the JSch, such Contributions -should be made to JCraft at http://www.jcraft.com/.

              - -

              If you wish to provide Contributions related to any other part of the plug-in, any Contributions 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 the plug-in (but not to JSch) are -provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.

              - -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. - - - - diff --git a/bundles/org.eclipse.team.cvs.ssh2/build.properties b/bundles/org.eclipse.team.cvs.ssh2/build.properties deleted file mode 100644 index 6ddeea4bb..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/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 -############################################################################### -# Eclipse build contribution -bin.includes = about.html,\ - plugin.xml,\ - plugin.properties,\ - *.jar -src.includes = about.html -source.cvsssh2.jar = src/ -extra.cvsssh2.jar=jsch-0.1.18.jar diff --git a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar b/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar deleted file mode 100644 index 3f77d8988..000000000 Binary files a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.16.jar and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar b/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar deleted file mode 100644 index 51ed673c8..000000000 Binary files a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.17.jar and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar b/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar deleted file mode 100755 index d809be68a..000000000 Binary files a/bundles/org.eclipse.team.cvs.ssh2/jsch-0.1.18.jar and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ssh2/plugin.properties b/bundles/org.eclipse.team.cvs.ssh2/plugin.properties deleted file mode 100644 index 02b9439ce..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/plugin.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation. -# IBM Corporation - implementation -############################################################################### -providerName=Eclipse.org -pluginName=CVS SSH2 -ssh2PreferencePage.name=SSH2 Connection Method diff --git a/bundles/org.eclipse.team.cvs.ssh2/plugin.xml b/bundles/org.eclipse.team.cvs.ssh2/plugin.xml deleted file mode 100644 index 4b014129d..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/plugin.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java deleted file mode 100644 index afbafa5a3..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import org.eclipse.team.internal.ccvs.core.*; - -/** - * SSH2 will hijack the 'extssh' method and use the SSH2 protocol instead - * of SSH1. If the server doesn't support SSH2, the server connection method - * will try connecting with SSH1. - * - * @since 3.0 - */ -public class CVSSSH2Method implements IConnectionMethod { - - public String getName() { - return "extssh"; //$NON-NLS-1$ - } - - public IServerConnection createConnection(ICVSRepositoryLocation root, String password) { - return new CVSSSH2ServerConnection(root, password); - } - - public void disconnect(ICVSRepositoryLocation location) { - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java deleted file mode 100644 index 7caa88bba..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java +++ /dev/null @@ -1,80 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -public class CVSSSH2Plugin extends AbstractUIPlugin { - - public static String ID = "org.eclipse.team.cvs.ssh2"; //$NON-NLS-1$ - private static CVSSSH2Plugin plugin; - - static String SSH_HOME_DEFAULT = null; - static { - String ssh_dir_name = ".ssh"; //$NON-NLS-1$ - - // Windows doesn't like files or directories starting with a dot. - if (Platform.getOS().equals(Platform.OS_WIN32)) { - ssh_dir_name = "ssh"; //$NON-NLS-1$ - } - SSH_HOME_DEFAULT = System.getProperty("user.home"); //$NON-NLS-1$ - if (SSH_HOME_DEFAULT != null) { - SSH_HOME_DEFAULT = SSH_HOME_DEFAULT + java.io.File.separator + ssh_dir_name; - } else { - - } - } - - public CVSSSH2Plugin() { - super(); - plugin = this; - } - - public static CVSSSH2Plugin getPlugin() { - return plugin; - } - - public void stop(BundleContext context) throws Exception { - try { - JSchSession.shutdown(); - } finally { - super.stop(context); - } - } - - public static CVSSSH2Plugin getDefault() { - return plugin; - } - - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - private void initializeDefaultPreferences() { - IPreferenceStore store = getPreferenceStore(); - store.setDefault(ISSHContants.KEY_SSH2HOME, SSH_HOME_DEFAULT); - store.setDefault(ISSHContants.KEY_PRIVATEKEY, ISSHContants.PRIVATE_KEYS_DEFAULT); - store.setDefault(ISSHContants.KEY_PROXY_TYPE, ISSHContants.HTTP); - store.setDefault(ISSHContants.KEY_PROXY_PORT, ISSHContants.HTTP_DEFAULT_PORT); - store.setDefault(ISSHContants.KEY_PROXY_AUTH, "false"); //$NON-NLS-1$ - } - - public void start(BundleContext context) throws Exception { - super.start(context); - Policy.localize("org.eclipse.team.internal.ccvs.ssh2.messages"); //$NON-NLS-1$ - initializeDefaultPreferences(); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java deleted file mode 100644 index e74d163bf..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java +++ /dev/null @@ -1,1350 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/********************************************************************** -Copyright (c) 2003,2004 Atsuhiko Yamanaka, JCraft,Inc. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation. -**********************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; -import java.util.Map; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.custom.TableEditor; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import com.jcraft.jsch.*; - -public class CVSSSH2PreferencePage extends PreferencePage - implements IWorkbenchPreferencePage { - -// private DirectoryFieldEditor ssh2homeEditor; - - private Label ssh2HomeLabel; - private Label proxyTypeLabel; - private Label proxyHostLabel; - private Label proxyPortLabel; - private Label proxyUserLabel; - private Label proxyPassLabel; - private Label privateKeyLabel; - private Combo proxyTypeCombo; - private Text ssh2HomeText; - private Text proxyHostText; - private Text proxyPortText; - private Text proxyUserText; - private Text proxyPassText; - private Text privateKeyText; - private Button enableProxy; - private Button enableAuth; - private Button privateKeyAdd; - private boolean useProxy; - private boolean useAuth; - - private Button ssh2HomeBrowse; - private Button keyGenerateDSA; - private Button keyGenerateRSA; - private Button keyLoad; - private Button keyExport; - private Button saveKeyPair; - private Label keyCommentLabel; - private Text keyCommentText; - private Label keyFingerPrintLabel; - private Text keyFingerPrintText; - private Label keyPassphrase1Label; - private Text keyPassphrase1Text; - private Label keyPassphrase2Label; - private Text keyPassphrase2Text; - private Label publicKeylabel; - private Text publicKeyText; - private KeyPair kpair=null; - private String kpairComment; - - public static final String AUTH_SCHEME = "";//$NON-NLS-1$ - public static final URL FAKE_URL; - - static { - URL temp = null; - try{ - temp = new URL("http://org.eclipse.team.cvs.ssh2");//$NON-NLS-1$ - }catch (MalformedURLException e){} - FAKE_URL = temp; - } - - public CVSSSH2PreferencePage() { -// super(GRID); - IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore(); - setPreferenceStore(store); - setDescription(Policy.bind("CVSSSH2PreferencePage.18")); //$NON-NLS-1$ - } - - protected Control createContents(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - initializeDialogUnits(container); - - TabFolder tabFolder = new TabFolder(container, SWT.NONE); - tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("CVSSSH2PreferencePage.19")); //$NON-NLS-1$ - tabItem.setControl(createGeneralPage(tabFolder)); - - tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("CVSSSH2PreferencePage.20")); //$NON-NLS-1$ - tabItem.setControl(createProxyPage(tabFolder)); - - tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("CVSSSH2PreferencePage.21")); //$NON-NLS-1$ - tabItem.setControl(createKeyManagementPage(tabFolder)); - - tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("CVSSSH2PreferencePage.133")); //$NON-NLS-1$ - tabItem.setControl(createHostKeyManagementPage(tabFolder)); - - initControls(); - - Dialog.applyDialogFont(parent); - return container; - } - - private Control createGeneralPage(Composite parent) { - Composite group=new Composite(parent, SWT.NULL); - GridLayout layout=new GridLayout(); - layout.numColumns=3; - group.setLayout(layout); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - group.setLayoutData(data); - - createSpacer(group, 3); - - ssh2HomeLabel=new Label(group, SWT.NONE); - ssh2HomeLabel.setText(Policy.bind("CVSSSH2PreferencePage.23")); //$NON-NLS-1$ - - ssh2HomeText=new Text(group, SWT.SINGLE | SWT.BORDER); - ssh2HomeText.setFont(group.getFont()); - GridData gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=1; - ssh2HomeText.setLayoutData(gd); - - ssh2HomeBrowse=new Button(group, SWT.NULL); - ssh2HomeBrowse.setText(Policy.bind("CVSSSH2PreferencePage.24")); //$NON-NLS-1$ - gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan=1; - ssh2HomeBrowse.setLayoutData(gd); - - createSpacer(group, 3); - - privateKeyLabel=new Label(group, SWT.NONE); - privateKeyLabel.setText(Policy.bind("CVSSSH2PreferencePage.25")); //$NON-NLS-1$ - - privateKeyText=new Text(group, SWT.SINGLE | SWT.BORDER); - privateKeyText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=1; - privateKeyText.setLayoutData(gd); - - privateKeyAdd=new Button(group, SWT.NULL); - privateKeyAdd.setText(Policy.bind("CVSSSH2PreferencePage.26")); //$NON-NLS-1$ - gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan=1; - privateKeyAdd.setLayoutData(gd); - - ssh2HomeBrowse.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e){ - String home=ssh2HomeText.getText(); - - if(!new File(home).exists()){ - while(true){ - int foo=home.lastIndexOf(java.io.File.separator, home.length()); - if(foo==-1)break; - home=home.substring(0, foo); - if(new File(home).exists())break; - } - } - - DirectoryDialog dd=new DirectoryDialog(getShell()); - dd.setFilterPath(home); - dd.setMessage(Policy.bind("CVSSSH2PreferencePage.27")); //$NON-NLS-1$ - String dir=dd.open(); - if(dir==null){ // cancel - return; - } - ssh2HomeText.setText(dir); - } - }); - - privateKeyAdd.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e){ - String home=ssh2HomeText.getText(); - - FileDialog fd=new FileDialog(getShell(), SWT.OPEN|SWT.MULTI); - fd.setFilterPath(home); - Object o=fd.open(); - if(o==null){ // cancel - return; - } - String[] files=fd.getFileNames(); - String keys=privateKeyText.getText(); - String dir=fd.getFilterPath(); - if(dir.equals(home)){dir="";} //$NON-NLS-1$ - else{dir+=java.io.File.separator;} - - for(int i=0; i0){ - user=target[0].substring(0, target[0].indexOf('@')); - host=target[0].substring(target[0].indexOf('@')+1); - } - if(host.indexOf(':')>0){ - try{port=Integer.parseInt(host.substring(host.indexOf(':')+1));} - catch(NumberFormatException ee) { - port=-1; - } - host=host.substring(0, host.indexOf(':')); - } - - if(user.length()==0 || - host.length()==0 || - port==-1){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.108", target[0])); //$NON-NLS-1$ - return; - } - - String options=""; //$NON-NLS-1$ - try{ - ByteArrayOutputStream bos=new ByteArrayOutputStream(); - if(options.length()!=0){ - try{bos.write((options+" ").getBytes());} //$NON-NLS-1$ - catch(IOException eeee){} - } - kpair.writePublicKey(bos, kpairComment); - bos.close(); - export_via_sftp(user, host, port, - ".ssh/authorized_keys", //$NON-NLS-1$ - bos.toByteArray()); - } - catch(IOException ee){ - } - catch(JSchException ee){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.111")); //$NON-NLS-1$ - } - }}); - - saveKeyPair.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e){ - if(kpair==null)return; - - String pass=keyPassphrase1Text.getText(); - /* - if(!pass.equals(keyPassphrase2Text.getText())){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$ - return; - } - */ - if(pass.length()==0){ - if(!MessageDialog.openConfirm(getShell(), - Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.49") //$NON-NLS-1$ - )){ - return ; - } - } - - kpair.setPassphrase(pass); - - IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore(); - String home=ssh2HomeText.getText(); - - File _home=new File(home); - - if(!_home.exists()){ - if(!MessageDialog.openConfirm(getShell(), - Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.50",home) //$NON-NLS-1$ - )){ - return ; - } - if(!_home.mkdirs()){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100")+home); //$NON-NLS-1$ - return; - } - } - - FileDialog fd=new FileDialog(getShell(), SWT.SAVE); - fd.setFilterPath(home); - String file=(kpair.getKeyType()==KeyPair.RSA) ? "id_rsa" : "id_dsa"; //$NON-NLS-1$ //$NON-NLS-2$ - fd.setFileName(file); - file=fd.open(); - if(file==null){ // cancel - return; - } - - if(new File(file).exists()){ - if(!MessageDialog.openConfirm(getShell(), - Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.53", file) //$NON-NLS-1$ - )){ - return; - } - } - - boolean ok=true; - try{ - kpair.writePrivateKey(file); - kpair.writePublicKey(file+".pub", kpairComment); //$NON-NLS-1$ - } - catch(Exception ee){ - ok=false; - } - - if(ok){ - MessageDialog.openInformation(getShell(), - Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.55")+ //$NON-NLS-1$ - "\n"+ //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.57")+file+ //$NON-NLS-1$ - "\n"+ //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.59")+ //$NON-NLS-1$ - file+ - ".pub"); //$NON-NLS-1$ - } - } - }); - - return group; - } - - private TableViewer viewer; - private Button addHostKeyButton; - private Button removeHostKeyButton; - class TableLabelProvider extends LabelProvider implements ITableLabelProvider { - public String getColumnText(Object element, int columnIndex) { - HostKey entry = (HostKey)element; - switch (columnIndex) { - case 0: - return entry.getHost(); - case 1: - return entry.getType(); - case 2: - return entry.getFingerPrint(JSchSession.getJSch()); - default: - return null; - } - } - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - }; - - private Control createHostKeyManagementPage(Composite parent) { - int columnSpan=3; - Composite group=new Composite(parent, SWT.NULL); - GridLayout layout=new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - group.setLayout(layout); - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.FILL; - group.setLayoutData(gd); - - Label label=new Label(group, SWT.NONE); - label.setText(Policy.bind("CVSSSH2PreferencePage.139")); //$NON-NLS-1$ - gd=new GridData(); - gd.horizontalSpan=2; - label.setLayoutData(gd); - - viewer = new TableViewer(group, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - Table table = viewer.getTable(); - new TableEditor(table); - table.setHeaderVisible(true); - table.setLinesVisible(true); - gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = convertWidthInCharsToPixels(30); - /* - * The hardcoded hint does not look elegant, but in reality - * it does not make anything bound to this 100-pixel value, - * because in any case the tree on the left is taller and - * that's what really determines the height. - */ - gd.heightHint = 100; - table.setLayoutData(gd); - table.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - handleSelection(); - } - }); - // Create the table columns - new TableColumn(table, SWT.NULL); - new TableColumn(table, SWT.NULL); - new TableColumn(table, SWT.NULL); - TableColumn[] columns = table.getColumns(); - columns[0].setText(Policy.bind("CVSSSH2PreferencePage.134")); //$NON-NLS-1$ - columns[1].setText(Policy.bind("CVSSSH2PreferencePage.135")); //$NON-NLS-1$ - columns[2].setText(Policy.bind("CVSSSH2PreferencePage.136")); //$NON-NLS-1$ - viewer.setColumnProperties(new String[] { - Policy.bind("CVSSSH2PreferencePage.134"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.135"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.136")}); //$NON-NLS-1$ - viewer.setLabelProvider(new TableLabelProvider()); - viewer.setContentProvider(new IStructuredContentProvider() { - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - public Object[] getElements(Object inputElement) { - if (inputElement == null) return null; - return (Object[])inputElement; - } - }); - TableLayout tl = new TableLayout(); - tl.addColumnData(new ColumnWeightData(20)); - tl.addColumnData(new ColumnWeightData(10)); - tl.addColumnData(new ColumnWeightData(70)); - table.setLayout(tl); - - Composite buttons = new Composite(group, SWT.NULL); - buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - buttons.setLayout(layout); - - addHostKeyButton = new Button(buttons, SWT.PUSH); - addHostKeyButton.setText(Policy.bind("CVSSSH2PreferencePage.137")); //$NON-NLS-1$ - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - gd.widthHint = Math.max(widthHint, addHostKeyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - addHostKeyButton.setLayoutData(gd); - addHostKeyButton.setEnabled(false); - addHostKeyButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - //addHostKey(); - } - }); - removeHostKeyButton = new Button(buttons, SWT.PUSH); - removeHostKeyButton.setText(Policy.bind("CVSSSH2PreferencePage.138")); //$NON-NLS-1$ - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - gd.widthHint = Math.max(widthHint, addHostKeyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - removeHostKeyButton.setLayoutData(gd); - removeHostKeyButton.setEnabled(false); - removeHostKeyButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - removeHostKey(); - } - }); - - Dialog.applyDialogFont(parent); - - JSchSession.loadKnownHosts(); - HostKeyRepository hkr=JSchSession.getJSch().getHostKeyRepository(); - viewer.setInput(hkr.getHostKey()); - handleSelection(); - - return group; - } - - private void handleSelection() { - boolean empty = viewer.getSelection().isEmpty(); - removeHostKeyButton.setEnabled(!empty); - } - private void removeHostKey(){ - JSch jsch=JSchSession.getJSch(); - IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - HostKeyRepository hkr=JSchSession.getJSch().getHostKeyRepository(); - for (Iterator iterator = selection.iterator(); iterator.hasNext();) { - HostKey hostkey = (HostKey) iterator.next(); - hkr.remove(hostkey.getHost(), hostkey.getType()); - viewer.remove(hostkey); - } - } - private void export_via_sftp(String user, String host, int port, String target, byte[] pkey) throws JSchException{ - try{ - - /* - int i=0; - String authorized_keys=target; - String dir=""; - String separator="/"; - i=target.lastIndexOf("/"); - if(i<0){ - i=target.lastIndexOf("\\"); - if(i>=0){ separator="\\"; } - } - else{ - } - if(i>=0){ - authorized_keys=target.substring(i+1); - dir=target.substring(0, i+1); - } - */ - - IProgressMonitor pm=new org.eclipse.core.runtime.NullProgressMonitor(); - Session session=JSchSession.getSession(null, user, "", host, port, new JSchSession.ResponsiveSocketFacory(pm)); //$NON-NLS-1$ - if(session.getServerVersion().indexOf("OpenSSH")==-1){ //$NON-NLS-1$ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.110")); //$NON-NLS-1$ - return; - } - Channel channel=session.openChannel("sftp"); //$NON-NLS-1$ - channel.connect(); - ChannelSftp c=(ChannelSftp)channel; - - String pwd=c.pwd(); - SftpATTRS attr=null; - - try{ attr=c.stat(".ssh"); } //$NON-NLS-1$ - catch(SftpException ee){ } - if(attr==null){ - try{ c.mkdir(".ssh"); } //$NON-NLS-1$ - catch(SftpException ee){ - setErrorMessage(ee.message); - return; - } - } - try{ c.cd(".ssh"); } //$NON-NLS-1$ - catch(SftpException ee){ - setErrorMessage(ee.message); - return; - } - - try{ - ByteArrayInputStream bis=new ByteArrayInputStream(pkey); - c.put(bis, "authorized_keys", null, ChannelSftp.APPEND); //$NON-NLS-1$ - bis.close(); - checkPermission(c, "authorized_keys"); //$NON-NLS-1$ - checkPermission(c, "."); // .ssh //$NON-NLS-1$ - c.cd(".."); //$NON-NLS-1$ - checkPermission(c, "."); // home directory //$NON-NLS-1$ - } - catch(SftpException ee){ - //setErrorMessage(debug+ee.message); - } - - MessageDialog.openInformation(getShell(), - Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.109")+ //$NON-NLS-1$ - (user+"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - - c.disconnect(); - //session.disconnect(); - } - catch(IOException eee){ - setErrorMessage(eee.toString()); - } - } - - private void checkPermission(ChannelSftp c, String path) throws SftpException{ - SftpATTRS attr=c.stat(path); - int permissions=attr.getPermissions(); - if((permissions&00022)!=0){ - permissions&=~00022; - c.chmod(permissions,path); - } - } - private void updateControls() { - boolean enable=enableProxy.getSelection(); - proxyTypeLabel.setEnabled(enable); - proxyTypeCombo.setEnabled(enable); - proxyPortLabel.setEnabled(enable); - proxyPortText.setEnabled(enable); - proxyHostLabel.setEnabled(enable); - proxyHostText.setEnabled(enable); - - enableAuth.setEnabled(enable); - enable&=enableAuth.getSelection(); - proxyUserLabel.setEnabled(enable); - proxyUserText.setEnabled(enable); - proxyPassLabel.setEnabled(enable); - proxyPassText.setEnabled(enable); - - enable=(kpair!=null); - publicKeylabel.setEnabled(enable); - publicKeyText.setEnabled(enable); - keyFingerPrintLabel.setEnabled(enable); - keyFingerPrintText.setEnabled(enable); - keyCommentLabel.setEnabled(enable); - keyCommentText.setEnabled(enable); - keyPassphrase1Label.setEnabled(enable); - keyPassphrase1Text.setEnabled(enable); - keyPassphrase2Label.setEnabled(enable); - keyPassphrase2Text.setEnabled(enable); - keyExport.setEnabled(enable); - saveKeyPair.setEnabled(enable); - } - - public void init(IWorkbench workbench) { -// super.init(workbench); -// initControls(); - } - - public void initialize() { - initControls(); - } - - private void initControls(){ - IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore(); - ssh2HomeText.setText(store.getString(ISSHContants.KEY_SSH2HOME)); - privateKeyText.setText(store.getString(ISSHContants.KEY_PRIVATEKEY)); - useProxy=store.getString(ISSHContants.KEY_PROXY).equals("true"); //$NON-NLS-1$ - enableProxy.setSelection(useProxy); - proxyHostText.setText(store.getString(ISSHContants.KEY_PROXY_HOST)); - proxyTypeCombo.select(store.getString(ISSHContants.KEY_PROXY_TYPE).equals(ISSHContants.HTTP)?0:1); - proxyPortText.setText(store.getString(ISSHContants.KEY_PROXY_PORT)); - useAuth=store.getString(ISSHContants.KEY_PROXY_AUTH).equals("true"); //$NON-NLS-1$ - enableAuth.setSelection(useAuth); - - Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$ - if(map!=null){ - String username=(String) map.get(ISSHContants.KEY_PROXY_USER); - if(username!=null) proxyUserText.setText(username); - String password=(String) map.get(ISSHContants.KEY_PROXY_PASS); - if(password!=null) proxyPassText.setText(password); - } - - proxyPassText.setEchoChar('*'); - updateControls(); - } - public boolean performOk() { - boolean result = super.performOk(); - if (result) { - setErrorMessage(null); - String home = ssh2HomeText.getText(); - File _home = new File(home); - if (!_home.exists()) { - if (MessageDialog.openQuestion(getShell(), Policy.bind("CVSSSH2PreferencePage.question"), //$NON-NLS-1$ - Policy.bind("CVSSSH2PreferencePage.99", home) //$NON-NLS-1$ - )) { - if (!(_home.mkdirs())) { - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100") + home); //$NON-NLS-1$ - return false; - } - } - } - if (enableProxy.getSelection() && !isValidPort(proxyPortText.getText())) { - return false; - } - IPreferenceStore store = CVSSSH2Plugin.getDefault().getPreferenceStore(); - store.setValue(ISSHContants.KEY_SSH2HOME, home); - store.setValue(ISSHContants.KEY_PRIVATEKEY, privateKeyText.getText()); - store.setValue(ISSHContants.KEY_PROXY, enableProxy.getSelection()); - store.setValue(ISSHContants.KEY_PROXY_TYPE, proxyTypeCombo.getText()); - store.setValue(ISSHContants.KEY_PROXY_HOST, proxyHostText.getText()); - store.setValue(ISSHContants.KEY_PROXY_PORT, proxyPortText.getText()); - store.setValue(ISSHContants.KEY_PROXY_AUTH, enableAuth.getSelection()); - - // Store proxy username and password in the keyring file for now. This is - // not ultra secure, but at least it will be saved between sessions. - Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$ - if (map == null) - map = new java.util.HashMap(10); - map.put(ISSHContants.KEY_PROXY_USER, proxyUserText.getText()); - map.put(ISSHContants.KEY_PROXY_PASS, proxyPassText.getText()); - try { - Platform.addAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME, map); //$NON-NLS-1$ - } catch (CoreException e) { - Util.logError("Cannot save ssh2 proxy authentication information to keyring file", e); //$NON-NLS-1$ - } - } - CVSSSH2Plugin.getDefault().savePluginPreferences(); - return result; - } - - private boolean isValidPort(String port){ - int i=-1; - try { - i=Integer.parseInt(port); - } - catch (NumberFormatException ee) { -// setErrorMessage(Policy.bind("CVSSSH2PreferencePage.103")); //$NON-NLS-1$ -// return false; - } - if((i < 0) || (i > 65535)){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.104")); //$NON-NLS-1$ - return false; - } - return true; - } - - public void performApply() { - performOk(); - } - - protected void performDefaults(){ - super.performDefaults(); - enableProxy.setSelection(false); - proxyHostText.setText(""); //$NON-NLS-1$ - proxyPortText.setText(ISSHContants.HTTP_DEFAULT_PORT); - proxyTypeCombo.select(0); - enableAuth.setSelection(false); - proxyUserText.setText(""); //$NON-NLS-1$ - proxyPassText.setText(""); //$NON-NLS-1$ - updateControls(); - } - - protected void createSpacer(Composite composite, int columnSpan) { - Label label=new Label(composite, SWT.NONE); - GridData gd=new GridData(); - gd.horizontalSpan=columnSpan; - label.setLayoutData(gd); - } -} - -class ExportDialog extends Dialog { - protected Text field; - protected String target=null; - protected String title=null; - protected String message=null; - - public ExportDialog(Shell parentShell, String title, String message) { - super(parentShell); - this.title=title; - this.message=message; - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(title); - } - - public void create() { - super.create(); - field.setFocus(); - } - - protected Control createDialogArea(Composite parent) { - - parent = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite main=new Composite(parent, SWT.NONE); - layout=new GridLayout(); - layout.numColumns=3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_BOTH)); - - if (message!=null) { - Label messageLabel=new Label(main, SWT.WRAP); - messageLabel.setText(message); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=3; - messageLabel.setLayoutData(data); - } - - createTargetFields(main); - Dialog.applyDialogFont(main); - return main; - } - - protected void createTargetFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Policy.bind("CVSSSH2PreferencePage.125")); //$NON-NLS-1$ - - field=new Text(parent, SWT.BORDER); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - data.horizontalSpan=2; - field.setLayoutData(data); - } - - public String getTarget() { - return target; - } - - protected void okPressed() { - String _target=field.getText(); - if(_target==null || _target.length()==0){ - return; - } - target=_target; - super.okPressed(); - } - - protected void cancelPressed() { - target=null; - super.cancelPressed(); - } -} - -class PassphrasePrompt implements Runnable{ - private String message; - private String passphrase; - PassphrasePrompt(String message){ - this.message=message; - } - public void run(){ - Display display=Display.getCurrent(); - Shell shell=new Shell(display); - PassphraseDialog dialog=new PassphraseDialog(shell, message); - dialog.open(); - shell.dispose(); - passphrase=dialog.getPassphrase(); - } - public String getPassphrase(){ - return passphrase; - } -} - -class PassphraseDialog extends Dialog { - protected Text passphraseField; - protected String passphrase = null; - protected String message = null; - - public PassphraseDialog(Shell parentShell, String message) { - super(parentShell); - this.message = message; - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(message); - } - - public void create() { - super.create(); - passphraseField.setFocus(); - } - - protected Control createDialogArea(Composite parent) { - Composite main=new Composite(parent, SWT.NONE); - - GridLayout layout=new GridLayout(); - layout.numColumns=3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_BOTH)); - - if (message!=null) { - Label messageLabel=new Label(main, SWT.WRAP); - messageLabel.setText(message); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=3; - messageLabel.setLayoutData(data); - } - - createPassphraseFields(main); - return main; - } - - protected void createPassphraseFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Policy.bind("CVSSSH2PreferencePage.127")); //$NON-NLS-1$ - passphraseField=new Text(parent, SWT.BORDER); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - passphraseField.setLayoutData(data); - passphraseField.setEchoChar('*'); - - new Label(parent, SWT.NONE); - } - - public String getPassphrase() { - return passphrase; - } - - protected void okPressed() { - String _passphrase = passphraseField.getText(); - if(_passphrase==null || _passphrase.length()==0){ - return; - } - passphrase=_passphrase; - super.okPressed(); - } - protected void cancelPressed() { - passphrase=null; - super.cancelPressed(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java deleted file mode 100644 index ea787fba3..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java +++ /dev/null @@ -1,175 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; -import java.io.*; -import java.net.NoRouteToHostException; -import java.net.UnknownHostException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IServerConnection; -import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; -import org.eclipse.team.internal.ccvs.ssh.SSHServerConnection; -import org.eclipse.team.internal.core.streams.*; - -import com.jcraft.jsch.*; - -/** - * SSH2 connection method. Has the property of defaulting to SSH1 if the server - * doesn't support SSH2. - */ -public class CVSSSH2ServerConnection implements IServerConnection { - private static final String COMMAND = "cvs server"; //$NON-NLS-1$ - private ICVSRepositoryLocation location; - private String password; - private InputStream inputStream; - private OutputStream outputStream; - private Session session; - private Channel channel; - private IServerConnection ssh1; - - protected CVSSSH2ServerConnection(ICVSRepositoryLocation location, String password) { - this.location = location; - this.password = password; - } - public void close() throws IOException { - if (ssh1 != null) { - ssh1.close(); - ssh1 = null; - return; - } - try { - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException e) { - // Ignore I/O Exception on close - } - } - } finally { - try { - if (outputStream != null) { - try { - outputStream.close(); - } catch (IOException e) { - // Ignore I/O Exception on close - } - } - } finally { - if (channel != null) - channel.disconnect(); - } - } - } - public InputStream getInputStream() { - if (ssh1 != null) { - return ssh1.getInputStream(); - } - return inputStream; - } - public OutputStream getOutputStream() { - if (ssh1 != null) { - return ssh1.getOutputStream(); - } - return outputStream; - } - public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - if (ssh1 != null) { - ssh1.open(monitor); - return; - } - monitor.subTask(Policy.bind("CVSSSH2ServerConnection.open", location.getHost())); //$NON-NLS-1$ - monitor.worked(1); - internalOpen(monitor); - } - /** - * @param monitor - * @throws IOException - * @throws CVSAuthenticationException - */ - private void internalOpen(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - try { - String hostname = location.getHost(); - String username = location.getUsername(); - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) - port = 0; - int retry = 1; - OutputStream channel_out; - InputStream channel_in; - while (true) { - session = JSchSession.getSession(location, username, password, hostname, port, new JSchSession.ResponsiveSocketFacory(monitor)); - channel = session.openChannel("exec"); //$NON-NLS-1$ - ((ChannelExec) channel).setCommand(COMMAND); - channel_out = channel.getOutputStream(); - channel_in = channel.getInputStream(); - try { - channel.connect(); - } catch (JSchException ee) { - retry--; - if(retry<0){ - throw new CVSAuthenticationException(Policy.bind("CVSSSH2ServerConnection.3"), CVSAuthenticationException.NO_RETRY); //$NON-NLS-1$ - } - if(session.isConnected()){ - session.disconnect(); - } - continue; - } - break; - } - int timeout = location.getTimeout(); - inputStream = new PollingInputStream(new TimeoutInputStream(new FilterInputStream(channel_in) { - public void close() throws IOException { - // Don't close the underlying stream as it belongs to the session - } - }, - 8192 /*bufferSize*/, 1000 /*readTimeout*/, -1 /*closeTimeout*/, true /* growWhenFull */), timeout > 0 ? timeout : 1, monitor); - outputStream = new PollingOutputStream(new TimeoutOutputStream(new FilterOutputStream(channel_out) { - public void close() throws IOException { - // Don't close the underlying stream as it belongs to the session - } - }, - 8192 /*buffersize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), timeout > 0 ? timeout : 1, monitor); - } catch (JSchException e) { - if (e.toString().indexOf("invalid server's version string") == -1) { //$NON-NLS-1$ - String message = e.getMessage(); - if (message.equals("Auth fail")) { //$NON-NLS-1$ - message = Policy.bind("CVSSSH2ServerConnection.0"); //$NON-NLS-1$ - // Could possibly retry below but wont just in case - } else if (message.startsWith("Session.connect: ")) { //$NON-NLS-1$ - // Jsh has messages formatted like "Session.connect: java.net.NoRouteToHostException: ..." - // Strip of the exception and try to convert it to a more meaningfull string - int start = message.indexOf(": ") + 1; //$NON-NLS-1$ - if (start != -1) { - int end = message.indexOf(": ", start); //$NON-NLS-1$ - if (end != -1) { - String exception = message.substring(start, end).trim(); - if (exception.indexOf("NoRouteToHostException") != -1) { //$NON-NLS-1$ - message = Policy.bind("CVSSSH2ServerConnection.1", location.getHost()); //$NON-NLS-1$ - throw new NoRouteToHostException(message); - } else if (exception.indexOf("java.net.UnknownHostException") != -1) { //$NON-NLS-1$ - throw new UnknownHostException(location.getHost()); - } else { - message = message.substring(end + 1).trim(); - } - } - } - } - throw new CVSAuthenticationException(message, CVSAuthenticationException.NO_RETRY); - } - ssh1 = new SSHServerConnection(location, password); - if (ssh1 == null) { - throw new CVSAuthenticationException(e.toString(), CVSAuthenticationException.NO_RETRY); - } - ssh1.open(monitor); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java deleted file mode 100644 index 771ad006d..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - - -/** - * Defines the constants used by the SSH2 Plugin - */ -public interface ISSHContants { - - public static String KEY_PROXY="CVSSSH2PreferencePage.PROXY"; //$NON-NLS-1$ - public static String KEY_PROXY_TYPE="CVSSSH2PreferencePage.PROXY_TYPE"; //$NON-NLS-1$ - public static String KEY_PROXY_HOST="CVSSSH2PreferencePage.PROXY_HOST"; //$NON-NLS-1$ - public static String KEY_PROXY_PORT="CVSSSH2PreferencePage.PROXY_PORT"; //$NON-NLS-1$ - public static String KEY_PROXY_AUTH="CVSSSH2PreferencePage.PROXY_AUTH"; //$NON-NLS-1$ - public static String KEY_PROXY_USER="CVSSSH2PreferencePage.PROXY_USER"; //$NON-NLS-1$ - public static String KEY_PROXY_PASS="CVSSSH2PreferencePage.PROXY_PASS"; //$NON-NLS-1$ - public static String KEY_SSH2HOME="CVSSSH2PreferencePage.SSH2HOME"; //$NON-NLS-1$ - public static String KEY_KEYFILE="CVSSSH2PreferencePage.KEYFILE"; //$NON-NLS-1$ - public static String KEY_PRIVATEKEY="CVSSSH2PreferencePage.PRIVATEKEY"; //$NON-NLS-1$ - - static String SOCKS5="SOCKS5"; //$NON-NLS-1$ - static String HTTP="HTTP"; //$NON-NLS-1$ - static String HTTP_DEFAULT_PORT="80"; //$NON-NLS-1$ - static String SOCKS5_DEFAULT_PORT="1080"; //$NON-NLS-1$ - static String PRIVATE_KEYS_DEFAULT="id_dsa,id_rsa"; //$NON-NLS-1$ - - static String DSA="DSA"; //$NON-NLS-1$ - static String RSA="RSA"; //$NON-NLS-1$ - -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java deleted file mode 100644 index b9077da96..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java +++ /dev/null @@ -1,361 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import java.io.*; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.Util; - -import com.jcraft.jsch.*; - -class JSchSession { - private static final int SSH_DEFAULT_PORT = 22; - private static JSch jsch=new JSch(); - private static java.util.Hashtable pool = new java.util.Hashtable(); - - private static String current_ssh_home = null; - - public static class SimpleSocketFactory implements SocketFactory { - InputStream in = null; - OutputStream out = null; - public Socket createSocket(String host, int port) throws IOException, UnknownHostException { - Socket socket = null; - socket = new Socket(host, port); - return socket; - } - public InputStream getInputStream(Socket socket) throws IOException { - if (in == null) - in = socket.getInputStream(); - return in; - } - public OutputStream getOutputStream(Socket socket) throws IOException { - if (out == null) - out = socket.getOutputStream(); - return out; - } - } - - public static class ResponsiveSocketFacory extends SimpleSocketFactory { - private IProgressMonitor monitor; - public ResponsiveSocketFacory(IProgressMonitor monitor) { - this.monitor = monitor; - } - public Socket createSocket(String host, int port) throws IOException, UnknownHostException { - Socket socket = null; - socket = Util.createSocket(host, port, monitor); - // Null out the monitor so we don't hold onto anything - // (i.e. the SSH2 session will keep a handle to the socket factory around - monitor = new NullProgressMonitor(); - // Set the socket timeout - socket.setSoTimeout(CVSProviderPlugin.getPlugin().getTimeout() * 1000); - return socket; - } - } - - /** - * User information delegates to the IUserAuthenticator. This allows - * headless access to the connection method. - */ - private static class MyUserInfo implements UserInfo, UIKeyboardInteractive { - private String username; - private String password; - private String passphrase; - private ICVSRepositoryLocation location; - private IUserAuthenticator authenticator; - private int attemptCount; - private boolean passwordChanged; - - MyUserInfo(String username, String password, ICVSRepositoryLocation location) { - this.location = location; - this.username = username; - this.password = password; - ICVSRepositoryLocation _location=location; - if(_location==null){ - String dummy=":extssh:dummy@dummy:/"; //$NON-NLS-1$ - try{ - _location=CVSRepositoryLocation.fromString(dummy); - } - catch(CVSException e){ - } - } - authenticator = _location.getUserAuthenticator(); - - } - public String getPassword() { - return password; - } - public String getPassphrase() { - return passphrase; - } - public boolean promptYesNo(String str) { - int prompt = authenticator.prompt( - location, - IUserAuthenticator.QUESTION, - Policy.bind("JSchSession.5"), //$NON-NLS-1$ - str, - new int[] {IUserAuthenticator.YES_ID, IUserAuthenticator.NO_ID}, - 0 //yes the default - ); - return prompt == 0; - } - private String promptSecret(String message, boolean includeLocation) throws CVSException{ - final String[] _password = new String[1]; - IUserInfo info = new IUserInfo() { - public String getUsername() { - return username; - } - public boolean isUsernameMutable() { - return false; - } - public void setPassword(String password) { - _password[0] = password; - } - public void setUsername(String username) { - } - }; - try{ - authenticator.promptForUserInfo(includeLocation ? location : null, info, message); - } - catch(OperationCanceledException e){ - _password[0]=null; - } - return _password[0]; - } - public boolean promptPassphrase(String message) { - try{ - String _passphrase=promptSecret(message, false); - if(_passphrase!=null){ - passphrase=_passphrase; - } - return _passphrase!=null; - } - catch(CVSException e){ - return false; - } - } - public boolean promptPassword(String message) { - try{ - String _password=promptSecret(message, true); - if(_password!=null){ - password=_password; - // Cache the password with the repository location on the memory. - if(location!=null) - ((CVSRepositoryLocation)location).setPassword(password); - } - return _password!=null; - } - catch(CVSException e){ - return false; - } - } - public void showMessage(String message) { - authenticator.prompt( - location, - IUserAuthenticator.INFORMATION, - Policy.bind("JSchSession.5"), //$NON-NLS-1$ - message, - new int[] {IUserAuthenticator.OK_ID}, - IUserAuthenticator.OK_ID - ); - } - public String[] promptKeyboardInteractive(String destination, - String name, - String instruction, - String[] prompt, - boolean[] echo){ - if (prompt.length == 0) { - // No need to prompt, just return an empty String array - return new String[0]; - } - try{ - if (attemptCount == 0 && password != null && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$ - // Return the provided password the first time but always prompt on subsequent tries - attemptCount++; - return new String[] { password }; - } - String[] result= - authenticator.promptForKeyboradInteractive(location, - destination, - name, - instruction, - prompt, - echo); - if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$ - password = result[0]; - passwordChanged = true; - } - attemptCount++; - return result; - } - catch(OperationCanceledException e){ - return null; - } - catch(CVSException e){ - return null; - } - } - - /** - * Callback to indicate that a connection is about to be attempted - */ - public void aboutToConnect() { - attemptCount = 0; - passwordChanged = false; - } - - /** - * Callback to indicate that a connection was made - */ - public void connectionMade() { - attemptCount = 0; - if (passwordChanged && password != null) { - // We were prompted for and returned a password so record it with the location - location.setPassword(password); - } - } - } - - static Session getSession(ICVSRepositoryLocation location, String username, String password, String hostname, int port, SocketFactory socketFactory) throws JSchException { - if (port == 0) - port = SSH_DEFAULT_PORT; - - IPreferenceStore store = CVSSSH2Plugin.getDefault().getPreferenceStore(); - String ssh_home = store.getString(ISSHContants.KEY_SSH2HOME); - - if (current_ssh_home == null || - !current_ssh_home.equals(ssh_home)) { - current_ssh_home = ssh_home; - if (ssh_home.length() == 0) - ssh_home = CVSSSH2Plugin.SSH_HOME_DEFAULT; - - try { - loadKnownHosts(); - - java.io.File file; - String pkeys=store.getString(ISSHContants.KEY_PRIVATEKEY); - String[] pkey=pkeys.split(","); //$NON-NLS-1$ - for(int i=0; i 0) { - for (Enumeration e = pool.elements(); e.hasMoreElements(); ) { - Session session = (Session) (e.nextElement()); - try { - session.disconnect(); - } catch (Exception ee) { - } - } - pool.clear(); - } - } - static JSch getJSch(){ - return jsch; - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java deleted file mode 100644 index 54d4baf6d..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java +++ /dev/null @@ -1,26 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IConnectionMethod; -import org.eclipse.team.internal.ccvs.core.IServerConnection; - -public class PServerSSH2Method implements IConnectionMethod { - public String getName() { - return "pserverssh2"; //$NON-NLS-1$ - } - public IServerConnection createConnection(ICVSRepositoryLocation root, String password) { - return new PServerSSH2ServerConnection(root, password); - } - public void disconnect(ICVSRepositoryLocation location) { - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java deleted file mode 100644 index 066bda254..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java +++ /dev/null @@ -1,142 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/******************************************************************************* - * Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others. All rights - * reserved. This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 which accompanies this - * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Atsuhiko Yamanaka, JCraft,Inc. - initial API and - * implementation. - ******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - -import java.io.*; -import java.util.Properties; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; - -import com.jcraft.jsch.*; - -public class PServerSSH2ServerConnection implements IServerConnection { - - private ICVSRepositoryLocation location; - private String password; - private Session session; - private static int localport = 2403; - private IServerConnection psc = null; - - protected PServerSSH2ServerConnection(ICVSRepositoryLocation location, String password) { - this.location = location; - this.password = password; - } - - public void close() throws IOException { - psc.close(); - } - - public InputStream getInputStream() { - return psc.getInputStream(); - } - public OutputStream getOutputStream() { - return psc.getOutputStream(); - } - - public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { - monitor.subTask("PServerSSH2ServerConnection.open"); //$NON-NLS-1$ - monitor.worked(1); - String cvs_root = location.getRootDirectory(); - int cvs_port = location.getPort(); - if (cvs_port == 0) - cvs_port = 2401; - String cvs_host = location.getHost(); - String ssh_host = cvs_host; - String ssh_user = location.getUsername(); - - String host = cvs_host; - if (host.indexOf('@') != -1) { - cvs_host = host.substring(host.lastIndexOf('@') + 1); - host = host.substring(0, host.lastIndexOf('@')); - if (host.indexOf('@') != -1) { - ssh_host = host.substring(host.lastIndexOf('@') + 1); - if (ssh_host.length() == 0) - ssh_host = cvs_host; - ssh_user = host.substring(0, host.lastIndexOf('@')); - } else { - ssh_host = host; - } - } - - int ssh_port = 0; - if (ssh_host.indexOf('#') != -1) { - try { - ssh_port = Integer.parseInt(ssh_host.substring(ssh_host.lastIndexOf('#') + 1)); - ssh_host = ssh_host.substring(0, ssh_host.lastIndexOf('#')); - } catch (Exception e) { - } - } - - int lport = cvs_port; - String rhost = (cvs_host.equals(ssh_host) ? "localhost" : cvs_host); //$NON-NLS-1$ - int rport = cvs_port; - - // ssh -L lport:rhost:rport ssh_user@ssh_host - int retry = 1; - while (true) { - try { - session = JSchSession.getSession(location, ssh_user, "", ssh_host, ssh_port, new JSchSession.ResponsiveSocketFacory(monitor)); //$NON-NLS-1$ - String[] list = session.getPortForwardingL(); - String name = ":" + rhost + ":" + rport; //$NON-NLS-1$ //$NON-NLS-2$ - boolean done = false; - for (int i = 0; i < list.length; i++) { - if (list[i].endsWith(name)) { - try { - String foo = list[i].substring(0, list[i].indexOf(':')); - lport = Integer.parseInt(foo); - } catch (Exception ee) { - } - done = true; - break; - } - } - if (!done) { - lport = localport++; - session.setPortForwardingL(lport, rhost, rport); - } - } catch (JSchException ee) { - retry--; - if(retry<0){ - throw new CVSAuthenticationException(Policy.bind("CVSSSH2ServerConnection.3"), CVSAuthenticationException.NO_RETRY); //$NON-NLS-1$ - } - if(session.isConnected()){ - session.disconnect(); - } - continue; - } - break; - } - // password for location will be over-written in JSchSession ;-< - ((CVSRepositoryLocation)location).setPassword(password); - - // CVSROOT=":pserver:localhost:"+lport+""cvs_root - try { - Properties prop = new Properties(); - prop.put("connection", "pserver"); //$NON-NLS-1$ //$NON-NLS-2$ - prop.put("user", location.getUsername()); //$NON-NLS-1$ - prop.put("password", password); //$NON-NLS-1$ - prop.put("host", "localhost"); //$NON-NLS-1$ //$NON-NLS-2$ - prop.put("port", Integer.toString(lport)); //$NON-NLS-1$ - prop.put("root", cvs_root); //$NON-NLS-1$ - - CVSRepositoryLocation cvsrl = CVSRepositoryLocation.fromProperties(prop); - - IConnectionMethod method = cvsrl.getMethod(); - psc = method.createConnection(cvsrl, password); - } catch (Exception e) { - throw new CVSAuthenticationException(e.toString(), CVSAuthenticationException.NO_RETRY); - } - psc.open(monitor); - } -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java deleted file mode 100644 index 93fcbd228..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ssh2; - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -public class Policy { - protected static ResourceBundle bundle = null; - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor != null && monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties deleted file mode 100644 index 675bd9412..000000000 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties +++ /dev/null @@ -1,105 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -JSchSession.5=SSH2 Client -CVSSSH2ServerConnection.open=Connecting via SSH to {0}... -CVSSSH2PreferencePage.18=Configuration options for SSH2: -CVSSSH2PreferencePage.19=&General -CVSSSH2PreferencePage.20=&Proxy -CVSSSH2PreferencePage.21=&Key Management -CVSSSH2PreferencePage.22=&Enable SSH protocol version 2 support (temporary until version 2 fully tested) -CVSSSH2PreferencePage.23=SSH2 &Home: -CVSSSH2PreferencePage.24=&Browse... -CVSSSH2PreferencePage.25=P&rivate key: -CVSSSH2PreferencePage.26=Add Pr&ivate Key... -CVSSSH2PreferencePage.27=SSH Home: -CVSSSH2PreferencePage.30=&Enable proxy connection -CVSSSH2PreferencePage.31=Proxy &type: -CVSSSH2PreferencePage.32=Proxy host add&ress: -CVSSSH2PreferencePage.33=Proxy host p&ort: -CVSSSH2PreferencePage.34=E&nable proxy authentication -CVSSSH2PreferencePage.35=Proxy &user name: -CVSSSH2PreferencePage.36=Proxy pa&ssword: -CVSSSH2PreferencePage.37=Key &type: -CVSSSH2PreferencePage.38=G&enerate -CVSSSH2PreferencePage.39=&You can paste this public key into the remote authorized_keys file: -CVSSSH2PreferencePage.41=&Fingerprint: -CVSSSH2PreferencePage.42=&Comment: -CVSSSH2PreferencePage.43=Passp&hrase: -CVSSSH2PreferencePage.44=C&onfirm passphrase: -CVSSSH2PreferencePage.45=&Save Private Key... -CVSSSH2PreferencePage.47=The key was not generated. -CVSSSH2PreferencePage.48=The passphrases entered do not match. -CVSSSH2PreferencePage.49=Are you sure you want to save this private key without passphrase protection? -CVSSSH2PreferencePage.50={0} does not exsit.\nAre you sure you want to create it? -CVSSSH2PreferencePage.53={0} has already existed.\nAre you sure you want to over write it? -CVSSSH2PreferencePage.55=Successfully saved. -CVSSSH2PreferencePage.57=Private key: -CVSSSH2PreferencePage.59=Public key: -CVSSSH2PreferencePage.66=Proxy settings -CVSSSH2PreferencePage.67=Enable proxy connection -CVSSSH2PreferencePage.68=Proxy type -CVSSSH2PreferencePage.69=Proxy host address -CVSSSH2PreferencePage.70=Proxy host port -CVSSSH2PreferencePage.71=Enable proxy authentication -CVSSSH2PreferencePage.72=Proxy user name -CVSSSH2PreferencePage.73=Proxy password -CVSSSH2PreferencePage.74=Key Management -CVSSSH2PreferencePage.75=Key type -CVSSSH2PreferencePage.76=Generate -CVSSSH2PreferencePage.77=&You can paste this public key into the remote authorized_keys file: -CVSSSH2PreferencePage.79=&Fingerprint -CVSSSH2PreferencePage.80=Comment -CVSSSH2PreferencePage.81=Passphrase -CVSSSH2PreferencePage.82=Confirm passphrase -CVSSSH2PreferencePage.83=Save -CVSSSH2PreferencePage.86=The passphrases entered do not match. -CVSSSH2PreferencePage.87=Are you sure you want to save this private key without the passphrase protection? -CVSSSH2PreferencePage.93=Successfully saved. -CVSSSH2PreferencePage.95=Private key: -CVSSSH2PreferencePage.97=Public key: -CVSSSH2PreferencePage.99={0} does not exist.\nAre you sure you want to create it? -CVSSSH2PreferencePage.100=Failed to create -CVSSSH2PreferencePage.101={0} does not exist.\nAre you sure you want to create it? -CVSSSH2PreferencePage.102=Failed to create -CVSSSH2PreferencePage.103=Proxy host port is not a number. -CVSSSH2PreferencePage.104=Proxy host port must be a number between 0 and 65535. -CVSSSH2PreferencePage.105=E&xport via sftp... -CVSSSH2PreferencePage.106=Export ssh key to remote server via sftp. -CVSSSH2PreferencePage.107=Specify a target site(in user@host[:port] format) where your public key should be installed.\nYour key will be stored in user@host[:port]:~/.ssh/authorized_keys -CVSSSH2PreferencePage.108={0} is not valid site. -CVSSSH2PreferencePage.109=Your public key has been successfully installed to -CVSSSH2PreferencePage.110=Remote sshd is not from OpenSSH. -CVSSSH2PreferencePage.111=Failed to export ssh key to remote server. -CVSSSH2ServerConnection.3=session is down -CVSSSH2ServerConnection.0=An undetermined authentication failure has occurred -CVSSSH2ServerConnection.1=No route to host {0} could be found -CVSSSH2PreferencePage.info=Information -CVSSSH2PreferencePage.warning=Warning -CVSSSH2PreferencePage.information=Information -CVSSSH2PreferencePage.error=Error -CVSSSH2PreferencePage.confirmation=Confirmation -CVSSSH2PreferencePage.question=Question -CVSSSH2PreferencePage.125=Target site: -CVSSSH2PreferencePage.126=Enter passphrase for {0} -CVSSSH2PreferencePage.127=Passphrase: -CVSSSH2PreferencePage.128=&Load existing key... -CVSSSH2PreferencePage.129=failed to decrypt {0} -CVSSSH2PreferencePage.130=failed to load given file. -CVSSSH2PreferencePage.131=G&enerate DSA key... -CVSSSH2PreferencePage.132=Ge&nerate RSA key... -CVSSSH2PreferencePage.133=Kno&wnHosts -CVSSSH2PreferencePage.134=Hostname -CVSSSH2PreferencePage.135=Type -CVSSSH2PreferencePage.136=Fingerprint -CVSSSH2PreferencePage.137=Add... -CVSSSH2PreferencePage.138=Remove -CVSSSH2PreferencePage.139=Host Keys included in known_hosts. -Util.timeout=A timeout occurred connecting to host {0} diff --git a/bundles/org.eclipse.team.cvs.ui/.classpath b/bundles/org.eclipse.team.cvs.ui/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ui/.cvsignore b/bundles/org.eclipse.team.cvs.ui/.cvsignore deleted file mode 100644 index fe99505dc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bin - diff --git a/bundles/org.eclipse.team.cvs.ui/.options b/bundles/org.eclipse.team.cvs.ui/.options deleted file mode 100644 index 6c209bcfb..000000000 --- a/bundles/org.eclipse.team.cvs.ui/.options +++ /dev/null @@ -1,7 +0,0 @@ -# Debugging options for the org.eclipse.team.cvs.ui plugin. - -# Turn on debugging for the plugin. -org.eclipse.team.cvs.ui/debug=false - -# Shows buffering and flushing of CVS console info to the console document -org.eclipse.team.cvs.ui/consolebuffering=false diff --git a/bundles/org.eclipse.team.cvs.ui/.project b/bundles/org.eclipse.team.cvs.ui/.project deleted file mode 100644 index d2ad7be17..000000000 --- a/bundles/org.eclipse.team.cvs.ui/.project +++ /dev/null @@ -1,42 +0,0 @@ - - - org.eclipse.team.cvs.ui - - - org.eclipse.compare - org.eclipse.core.resources - org.eclipse.core.resources.spysupport - org.eclipse.core.runtime - org.eclipse.jface.text - org.eclipse.team.core - org.eclipse.team.cvs.core - org.eclipse.team.ui - org.eclipse.ui - org.eclipse.ui.console - org.eclipse.ui.editors - org.eclipse.ui.ide - org.eclipse.ui.views - org.eclipse.ui.workbench.texteditor - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/bundles/org.eclipse.team.cvs.ui/about.html b/bundles/org.eclipse.team.cvs.ui/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/bundles/org.eclipse.team.cvs.ui/about.html +++ /dev/null @@ -1,30 +0,0 @@ - - - -About - - - -

              About This Content

              - -

              20th June, 2002

              -

              License

              -

              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 http://www.eclipse.org/legal/cpl-v10.html. -For purposes of the CPL, "Program" will mean the Content.

              - -

              Contributions

              - -

              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.

              - -

              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.

              - - - \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/build.properties b/bundles/org.eclipse.team.cvs.ui/build.properties deleted file mode 100644 index 405e31126..000000000 --- a/bundles/org.eclipse.team.cvs.ui/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# Eclipse build contribution -source.teamcvsui.jar=src/ -src.includes=about.html -bin.includes=about.html,icons/,plugin.xml,plugin.properties,*.jar \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/clear_co.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/clear_co.gif deleted file mode 100644 index 9ff641606..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/clear_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/collapseall.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/collapseall.gif deleted file mode 100644 index 7dc0de513..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/collapseall.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/filter_history.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/filter_history.gif deleted file mode 100644 index f6142713a..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/filter_history.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/newstream_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/newstream_wiz.gif deleted file mode 100644 index 6e8d4be05..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/newstream_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/refresh.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/refresh.gif deleted file mode 100644 index 1f551897c..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/refresh.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/synced.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/synced.gif deleted file mode 100644 index 4f6e43a52..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dlcl16/synced.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/annotate.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/annotate.gif deleted file mode 100644 index e137ea0ab..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/annotate.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/checkout.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/checkout.gif deleted file mode 100644 index 6bf2ccfb9..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/checkout.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/cvs_synch.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/cvs_synch.gif deleted file mode 100644 index 14a075e1e..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/cvs_synch.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/history.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/history.gif deleted file mode 100644 index 6f0d73b77..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/history.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/ignorefiles.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/ignorefiles.gif deleted file mode 100644 index 75879af82..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/ignorefiles.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newconnect_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newconnect_wiz.gif deleted file mode 100644 index 28fe673ac..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newconnect_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newlocation_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newlocation_wiz.gif deleted file mode 100644 index 495e14552..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/newlocation_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/share_prj_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/share_prj_wiz.gif deleted file mode 100644 index 246a9e856..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/dtool16/share_prj_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/clear_co.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/clear_co.gif deleted file mode 100644 index 6bc10f9d0..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/clear_co.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/collapseall.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/collapseall.gif deleted file mode 100644 index a2d80a904..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/collapseall.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/filter_history.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/filter_history.gif deleted file mode 100644 index 6fe6f0e10..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/filter_history.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/newstream_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/newstream_wiz.gif deleted file mode 100644 index 045e32c58..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/newstream_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/refresh.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/refresh.gif deleted file mode 100644 index 3ca04d06f..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/refresh.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/synced.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/synced.gif deleted file mode 100644 index 870934b69..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/elcl16/synced.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/annotate.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/annotate.gif deleted file mode 100644 index 40afd5bfd..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/annotate.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/checkout.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/checkout.gif deleted file mode 100644 index 00e63af3c..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/checkout.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/cvs_synch.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/cvs_synch.gif deleted file mode 100644 index b4fa052de..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/cvs_synch.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/history.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/history.gif deleted file mode 100644 index 07b60c873..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/history.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newconnect_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newconnect_wiz.gif deleted file mode 100644 index 565a80028..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newconnect_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newlocation_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newlocation_wiz.gif deleted file mode 100644 index 672b57e78..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/newlocation_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/share_prj_wiz.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/share_prj_wiz.gif deleted file mode 100644 index d546965fc..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/etool16/share_prj_wiz.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/annotate_view.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/annotate_view.gif deleted file mode 100644 index d2108c036..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/annotate_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/compare_view.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/compare_view.gif deleted file mode 100644 index dc549bce8..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/compare_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/console_view.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/console_view.gif deleted file mode 100644 index 6ef3bca66..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/console_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/cvs_persp.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/cvs_persp.gif deleted file mode 100644 index c3d56a253..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/cvs_persp.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/history_view.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/history_view.gif deleted file mode 100644 index c5f904abb..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/history_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/rep_editors_view.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/rep_editors_view.gif deleted file mode 100644 index d28c326de..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/rep_editors_view.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/repo_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/repo_rep.gif deleted file mode 100644 index c13bea1ca..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/eview16/repo_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph1.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph1.gif deleted file mode 100644 index 28466aad2..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph1.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph2.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph2.gif deleted file mode 100644 index ef51bd544..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph2.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph3.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph3.gif deleted file mode 100644 index f53f01bc3..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph3.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph4.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph4.gif deleted file mode 100644 index 27506f6d7..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph4.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph5.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph5.gif deleted file mode 100644 index 1bccaf868..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph5.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph6.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph6.gif deleted file mode 100644 index 07164754e..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph6.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph7.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph7.gif deleted file mode 100644 index 32b655e46..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph7.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph8.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph8.gif deleted file mode 100644 index 5952ed975..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/glyphs/glyph8.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/branches_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/branches_rep.gif deleted file mode 100644 index 717f3b5b6..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/branches_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/changelog_obj.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/changelog_obj.gif deleted file mode 100644 index f98800321..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/changelog_obj.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/date.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/date.gif deleted file mode 100644 index 96aae05cb..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/date.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/dates.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/dates.gif deleted file mode 100644 index 96aae05cb..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/dates.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/module_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/module_rep.gif deleted file mode 100644 index 6372db4fa..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/module_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/prjversions_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/prjversions_rep.gif deleted file mode 100644 index ba5e76f2d..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/prjversions_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/repository_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/repository_rep.gif deleted file mode 100644 index 0470e1588..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/repository_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/tag.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/tag.gif deleted file mode 100644 index cded25d29..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/tag.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/versions_rep.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/versions_rep.gif deleted file mode 100644 index fbe33daa0..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/obj16/versions_rep.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/confauto_ov.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/confauto_ov.gif deleted file mode 100644 index e1fd67f06..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/confauto_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/edited_ov.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/edited_ov.gif deleted file mode 100644 index 48526ac8b..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/edited_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/merged_ov.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/merged_ov.gif deleted file mode 100644 index 186345711..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/merged_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/no_remotedir_ov.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/no_remotedir_ov.gif deleted file mode 100644 index 131fd63c1..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/no_remotedir_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/question_ov.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/question_ov.gif deleted file mode 100644 index 45ca32060..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/ovr16/question_ov.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/createpatch_wizban.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/createpatch_wizban.gif deleted file mode 100644 index 0fe7d238e..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/createpatch_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/keywordsub_wizban.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/keywordsub_wizban.gif deleted file mode 100644 index 27b2b6eaa..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/keywordsub_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/mergestream_wizban.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/mergestream_wizban.gif deleted file mode 100644 index 33dabf352..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/mergestream_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newconnect_wizban.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newconnect_wizban.gif deleted file mode 100644 index 859786bf2..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newconnect_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newlocation_wizban.gif b/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newlocation_wizban.gif deleted file mode 100644 index f612ef3fa..000000000 Binary files a/bundles/org.eclipse.team.cvs.ui/icons/full/wizban/newlocation_wizban.gif and /dev/null differ diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties deleted file mode 100644 index 2f4b128c7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/plugin.properties +++ /dev/null @@ -1,203 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -providerName=Eclipse.org -pluginName=CVS Team Provider UI - -CVS=CVS -ServerEncoding=Server Encoding - -CVSRepositoryExploring=CVS Repository Exploring -CVSRepositoryExploring.openPerspectiveDescription=Open the CVS Repository Exploring Perspective - -CVSGroupMenu.label=C&VS - -SharingWizard.name=CVS - -WorkspaceSynchronizeWizard.name=CVS -WorkspaceSynchronizeWizard.description=Synchronize resources in the workspace with their associated remote CVS repository. -CVSWorkspaceParticipant=CVS -CVSMergeParticipant=CVS Merge -CVSCompareParticipant=CVS Compare - -PreferencePage.name=CVS -ConsolePreferencePage.name=Console -DecoratorPreferencePage.name=Label Decorations -ExtMethodPreferencePage.name=Ext Connection Method -WatchEditPreferencePage.name=Watch/Edit -ComparePreferencePage.name=Synchronize/Compare -WorkInProgressPreferencePage.name=Work in Progress - -newWizardCategoryName=CVS -newProjectCheckoutWizard=Checkout Projects from CVS -DecoratorStandard.name=CVS -DecoratorStandard.desc=Shows CVS specific information on resources in projects under CVS control. Information includes the revision number, branch or version name, etc. - -AddAction.label=Add to &Version Control -AddAction.tooltip=Add the Selected Resources to Version Control - -MergeAction.label=&Merge... -MergeAction.tooltip=Merge - -BranchAction.label=&Branch... -BranchAction.tooltip=Branch - -CompareRemoteResourcesAction.label=Com&pare -CompareRemoteResourcesAction.tooltip=Compare the Remote Resources with Each Other - -CompareRemoteWithTagAction.label=Compare &With... -CompareRemoteWithTagAction.tooltip=Compare with a Branch or a Version - -CompareWithRemoteAction.label=&Latest from Repository -CompareWithRemoteAction.tooltip=Compare with Content on CVS Server - -CompareWithRevisionAction.label=&Revision... -CompareWithRevisionAction.tooltip=Compare with Revision on CVS Server - -CompareWithTagAction.label=Another &Branch or Version... -CompareWithTagAction.tooltip=Compare with a Branch or a Version on the CVS Server - -ContentAction.label=Compare File Contents -ContentAction.tooltip=Use File Contents Instead of Timestamps When Comparing - -ConvertNature.label=Convert Provider from Nature -ConvertNature.tooltip=Converts a CVS project from using natures to using properties - -CopyRepositoryNameAction.label=&Copy to Clipboard -CopyRepositoryNameAction.tooltip=Copy Repository Names to Clipboard - -IgnoreAction.label=A&dd to .cvsignore... -IgnoreAction.tooltip=Ignore the Selected Resources when Synchronizing - -RefreshTagsAction.label=Refresh &Branches... -RefreshTagsAction.tooltip=Refresh the branch tags and their members using the auto-refresh files associated with each remote folder - -RemoveRootAction.label=Discard &Location -RemoveRootAction.tooltip=Discard Location - -ReplaceWithRevisionAction.label=&Revision... -ReplaceWithRevisionAction.tooltip=Replace with Revision on CVS Server - -ReplaceWithTagAction.label=&Another Branch or Version... -ReplaceWithTagAction.tooltip=Replace with Branch or Version on the CVS Server - -TagAction.label=&Tag as Version... -TagAction.tooltip=Tag the resources with a CVS version tag - -TagInRepositoryAction.label=&Tag as Version... -TagInRepositoryAction.tooltip=Tag the resources with a CVS version tag - -MoveTagAction.label=Tag with &Existing... -MoveTagAction.tooltip=Tag the selected resources with an existing tag - -SetKeywordSubstitutionAction.label=Cha&nge ASCII/Binary Property... -SetKeywordSubstitutionAction.tooltip=Change whether the selected resources should be treated as ASCII or binary on the CVS Server - -UpdateAction.label=&Update -UpdateAction.tooltip=Update - -UpdateActionSwitch.label=S&witch to another branch or version... -UpdateActionSwitch.tooltip=Switch to another branch or version - -ReplaceWithAction.label=&Latest from Repository -ReplaceWithAction.tooltip=Replace with last committed content from CVS Server - -ConfigureTags.label=Configure &Branches and Versions... -ConfigureTags.tooltip=Configure the branch and version tags shown in the workbench - -AddToBranch.label=Add &to Branch List... -AddToBranch.tooltip=Add the selected remote folder to a branch - -CommitAction.label=&Commit... -CommitAction.tooltip=Commit - -CheckoutAction.label=&Check Out -CheckoutAction.tooltip=Check out a module from the repository to the workspace - -CheckoutAsAction.label=Check Out &As... -CheckoutAsAction.tooltip=Check out a module from the repository to the workspace - -OpenLogEntryAction.label=&Open -OpenLogEntryAction.tooltip=Open Remote File - -OpenRemoteFileAction.label=&Open -OpenRemoteFileAction.tooltip=Open Remote File - -ShowHistoryAction.label=Show in Resource &History -ShowHistoryAction.tooltip=Show in Resource History - -ShowAnnotationAction.label=Show &Annotation -ShowAnnotationAction.tooltip=Show Annotation - -GenerateDiff.label=Create &Patch... -GenerateDiff.tooltip=Compare your workspace contents with the server and generate a diff file that can be used as a patch file. - -RefreshFromLocal.label=&Refresh from local CVS state -RefreshFromLocal.tooltip=Refresh the workbench with changes made to CVS projects from outside the workbench. - -Synchronize.label=&Synchronize with Repository -Synchronize.tooltip=Synchronize the workspace resources with those in the repository - -EditAction.label=&Edit -EditAction.tooltip=Perform a ''cvs edit'' on the selected files - -UneditAction.label=U&nedit -UneditAction.tooltip=Perform a ''cvs unedit'' on the selected files - -viewCategory=CVS - -Console.name=CVS Console - -RepositoriesView.name=CVS Repositories - -HistoryFilter.label=&Filter History -HistoryFilter.tooltip=Filter History - -HistoryView.name=CVS Resource History - -UnmanageFolder.label=&Disconnect... -UnmanageFolder.tooltip=Disconnect from the CVS repository. - -CVSActionSet.categoryName=CVS -CVSActionSet.description=Actions that apply when working with CVS repositories -CVSActionSet.newLabel=Add CVS Repository -CVSActionSet.newTooltip=Add CVS Repository -CVSActionSet.checkoutLabel=Checkout from CVS -CVSActionSet.checkoutTooltip=Checkout from CVS - -RestoreFromRepositoryAction.label=&Restore from Repository... -RestoreFromRepositoryAction.tooltip=Restore resources that have been deleted from the remote folder. - -ShowEditorsAction.label=Show &Editors -ShowEditorsAction.tooltip=Perform a ''cvs editors'' on the selected file - -EditorsView.name=CVS Editors -AnnotateView.name=CVS Annotate -CVSConsoleFont.label=CVS Console Font -CVSConsoleFont.description=The font for the CVS console. - -WorkInProgress.name=Work In Progress -CVSRemoteQuickDiffProvider.label=&Latest CVS Revision - -NewDateTagAction.label=&Date Tag... -NewDateTagAction.tooltip=Add new date tag - -ViewCommand.repositoriesView.name=CVS Repositories -ViewCommand.repositoriesView.description=Show the CVS Repositories view -ViewCommand.historyView.name=CVS Resource History -ViewCommand.historyView.description=Show the CVS Resource History view -ViewCommand.editorsView.name=CVS Editors -ViewCommand.editorsView.description=Show the CVS Editors view -ViewCommand.annotateView.name=CVS Annotate -ViewCommand.annotateView.description=Show the CVS Annotate view - -newProjectCheckoutWizardDescription=Import a project from a CVS Repository. -newProjectCheckoutWizardDescription2=Create a new project by checking out an existing project from a CVS repository. -PasswordManagement=Password Management diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml deleted file mode 100644 index aac414c42..000000000 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ /dev/null @@ -1,1066 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %DecoratorStandard.desc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %CVSConsoleFont.description - - - - - This color is used for the foreground color for resources that have outgoing changes. - - - - - This color is used for the background color for resources that have outgoing changes. - - - - - The font used to display outgoing changes. - - - - - This color is used for the foreground color for resources that are ignored from CVS. - - - - - This color is used for the background color for resources that are ignored from CVS. - - - - - The font used to display resources that are ignored from CVS. - - - - - - - - - - - - - - - - - %newProjectCheckoutWizardDescription2 - - - - - - - - - %newProjectCheckoutWizardDescription - - - - - - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableHierarchicalResourceList.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableHierarchicalResourceList.java deleted file mode 100644 index 537a367c7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableHierarchicalResourceList.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.ui.model.WorkbenchContentProvider; - -/** - * This class acts as an adaptable list that will return the resources in the - * hierarchy indicated by their paths - */ -public class AdaptableHierarchicalResourceList extends AdaptableResourceList { - private IContainer root; - - /** - * Constructor for AdaptableHierarchicalResourceList. - * @param resources - */ - public AdaptableHierarchicalResourceList(IContainer root, IResource[] resources) { - super(resources); - this.root = root; - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - return getChildenFor(root); - } - - private IResource[] getChildenFor(IContainer parent) { - Set children = new HashSet(); - IPath parentPath = parent.getFullPath(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IPath resourcePath = resource.getFullPath(); - if (parent instanceof IWorkspaceRoot) { - children.add(((IWorkspaceRoot)parent).getProject(resourcePath.segment(0))); - } else if (parentPath.isPrefixOf(resourcePath)) { - IPath parentRelativePath = resourcePath.removeFirstSegments(parentPath.segmentCount()); - if (parentRelativePath.segmentCount() == 1) { - children.add(resource); - } else if (parentRelativePath.segmentCount() > 1) { - children.add(parent.getFolder(new Path(null, parentRelativePath.segment(0)))); - } - } - } - return (IResource[]) children.toArray(new IResource[children.size()]); - } - - /** - * Returns a content provider for IResources that returns - * only children of the given resource type. - */ - public ITreeContentProvider getTreeContentProvider() { - return new WorkbenchContentProvider() { - public Object[] getChildren(Object o) { - if (o instanceof IContainer) { - return getChildenFor((IContainer) o); - } else { - return super.getChildren(o); - } - } - }; - } - - public void setResources(IResource[] resources) { - this.resources = resources; - } - /** - * Returns the root. - * @return IContainer - */ - public IContainer getRoot() { - return root; - } - - /** - * Sets the root. - * @param root The root to set - */ - public void setRoot(IContainer root) { - this.root = root; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableResourceList.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableResourceList.java deleted file mode 100644 index d8179f457..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AdaptableResourceList.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * This class acts as a resource list that can be used in table widgets. - */ -public class AdaptableResourceList implements IAdaptable, IWorkbenchAdapter { - - IResource[] resources; - - public AdaptableResourceList(IResource[] resources) { - this.resources = resources; - } - - /** - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(Object) - */ - public Object[] getChildren(Object o) { - return resources; - } - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return o == null ? "" : o.toString();//$NON-NLS-1$ - } - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java deleted file mode 100644 index a6d7d48d3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * This dialog allows the user to add a set of resources to version control. - * They can either all be added or the user can choose which to add from a - * details list. - */ -public class AddToVersionControlDialog extends DetailsDialog { - - private static final int WIDTH_HINT = 350; - private final static int SELECTION_HEIGHT_HINT = 100; - - private IResource[] unaddedResources; - private Object[] resourcesToAdd; - - private CheckboxTableViewer listViewer; - /** - * Constructor for AddToVersionControlDialog. - * @param parentShell - */ - public AddToVersionControlDialog(Shell parentShell, IResource[] unaddedResources) { - super(parentShell, Policy.bind("AddToVersionControlDialog.title")); //$NON-NLS-1$ - this.unaddedResources = unaddedResources; - } - - /** - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected void createMainDialogArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG); - - // add a description label - if (unaddedResources.length==1) { - createWrappingLabel(composite, Policy.bind("AddToVersionControlDialog.thereIsAnUnaddedResource", new Integer(unaddedResources.length).toString())); //$NON-NLS-1$ - } else { - createWrappingLabel(composite, Policy.bind("AddToVersionControlDialog.thereAreUnaddedResources", new Integer(unaddedResources.length).toString())); //$NON-NLS-1$ - } - } - - /** - * @see org.eclipse.team.internal.ui.DetailsDialog#createDropDownDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - addUnaddedResourcesArea(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG); - - return composite; - } - - private void addUnaddedResourcesArea(Composite composite) { - - // add a description label - createWrappingLabel(composite, Policy.bind("ReleaseCommentDialog.unaddedResources")); //$NON-NLS-1$ - - // add the selectable checkbox list - listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = SELECTION_HEIGHT_HINT; - data.widthHint = WIDTH_HINT; - listViewer.getTable().setLayoutData(data); - - // set the contents of the list - listViewer.setLabelProvider(new WorkbenchLabelProvider() { - protected String decorateText(String input, Object element) { - if (element instanceof IResource) - return ((IResource)element).getFullPath().toString(); - else - return input; - } - }); - listViewer.setContentProvider(new WorkbenchContentProvider()); - listViewer.setInput(new AdaptableResourceList(unaddedResources)); - if (resourcesToAdd == null) { - listViewer.setAllChecked(true); - } else { - listViewer.setCheckedElements(resourcesToAdd); - } - listViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - resourcesToAdd = listViewer.getCheckedElements(); - } - }); - - addSelectionButtons(composite); - } - - /** - * Add the selection and deselection buttons to the dialog. - * @param composite org.eclipse.swt.widgets.Composite - */ - private void addSelectionButtons(Composite composite) { - - Composite buttonComposite = new Composite(composite, SWT.RIGHT); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - buttonComposite.setLayout(layout); - GridData data = - new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); - data.grabExcessHorizontalSpace = true; - composite.setData(data); - - Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, Policy.bind("ReleaseCommentDialog.selectAll"), false); //$NON-NLS-1$ - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(true); - resourcesToAdd = null; - } - }; - selectButton.addSelectionListener(listener); - - Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, Policy.bind("ReleaseCommentDialog.deselectAll"), false); //$NON-NLS-1$ - listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(false); - resourcesToAdd = new Object[0]; - - } - }; - deselectButton.addSelectionListener(listener); - } - - /** - * @see org.eclipse.team.internal.ui.DetailsDialog#updateEnablements() - */ - protected void updateEnablements() { - } - - /** - * Returns the resourcesToAdd. - * @return IResource[] - */ - public IResource[] getResourcesToAdd() { - if (resourcesToAdd == null) { - return unaddedResources; - } else { - List result = Arrays.asList(resourcesToAdd); - return (IResource[]) result.toArray(new IResource[result.size()]); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); - createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); - super.createButtonsForButtonBar(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.DetailsDialog#includeOkButton() - */ - protected boolean includeOkButton() { - return false; - } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int id) { - // hijack yes and no buttons to set the correct return - // codes. - if(id == IDialogConstants.YES_ID || id == IDialogConstants.NO_ID) { - setReturnCode(id); - close(); - } else { - super.buttonPressed(id); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java deleted file mode 100644 index 3aa447ee1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.FontData; -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.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -public class AlternateUserValidationDialog extends Dialog { - String user; - String password = ""; //$NON-NLS-1$ - List numXs = new ArrayList(); - Label icon1; - Label icon2; - Label icon3; - Label icon4; - Text passwordText; - boolean inUpdate = false; - - Image[] images; - - public AlternateUserValidationDialog(Shell parentShell, String user) { - super(parentShell); - this.user = user; - initializeImages(); - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Policy.bind("AlternateUserValidationDialog.Enter_Password_2")); //$NON-NLS-1$ - } - - protected Control createContents(Composite parent) { - Composite main = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite iconComposite = new Composite(main, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - iconComposite.setLayout(layout); - iconComposite.setLayoutData(new GridData()); - - icon1 = createLabel(iconComposite); - icon2 = createLabel(iconComposite); - icon3 = createLabel(iconComposite); - icon4 = createLabel(iconComposite); - - Composite middleComposite = new Composite(main, SWT.NONE); - middleComposite.setLayout(new GridLayout()); - middleComposite.setLayoutData(new GridData()); - - Label l = new Label(middleComposite, SWT.NULL); - l.setText(Policy.bind("AlternateUserValidationDialog.message", user)); //$NON-NLS-1$ - l.setLayoutData(new GridData()); - l = new Label(middleComposite, SWT.NULL); - l.setText(""); //$NON-NLS-1$ - l.setLayoutData(new GridData()); - passwordText = new Text(middleComposite, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(); - data.widthHint = 250; - passwordText.setLayoutData(data); - - passwordText.addVerifyListener(new VerifyListener() { - public void verifyText(VerifyEvent e) { - if (inUpdate) return; - e.doit = false; - inUpdate = true; - switch (e.character) { - case 8: { - // backspace pressed - if (password.length() > 0) { - password = password.substring(0, password.length() - 1); - } - // get rid of bogus Xs - int numX = ((Integer)numXs.get(numXs.size() - 1)).intValue(); - numXs.remove(numXs.size() - 1); - String oldText = passwordText.getText(); - String newText = oldText.substring(0, oldText.length() - numX); - passwordText.setText(newText); - passwordText.setSelection(newText.length()); - break; - } - default: { - String oldText = passwordText.getText(); - String x = getXs(); - numXs.add(numXs.size(), new Integer(x.length())); - String newText = oldText + x; - passwordText.setText(newText); - passwordText.setSelection(newText.length()); - password += e.character; - } - } - inUpdate = false; - updateImages(); - } - }); - /*passwordText.addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent e) { - switch (e.detail) { - case SWT.TRAVERSE_ARROW_NEXT: - case SWT.TRAVERSE_ARROW_PREVIOUS: - e.detail = SWT.TRAVERSE_NONE; - e.doit = false; - break; - } - } - });*/ - Composite buttonComposite = new Composite(main, SWT.NONE); - buttonComposite.setLayout(new GridLayout()); - buttonComposite.setLayoutData(new GridData()); - Button b = new Button(buttonComposite, SWT.PUSH); - b.setText(Policy.bind("AlternateUserValidationDialog.OK_6")); //$NON-NLS-1$ - data = new GridData(); - data.widthHint = 70; - b.setLayoutData(data); - b.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - okPressed(); - } - }); - buttonComposite.getShell().setDefaultButton(b); - b = new Button(buttonComposite, SWT.PUSH); - b.setText(Policy.bind("AlternateUserValidationDialog.Cancel_7")); //$NON-NLS-1$ - data = new GridData(); - data.widthHint = 70; - b.setLayoutData(data); - b.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - cancelPressed(); - } - }); - Dialog.applyDialogFont(parent); - return main; - } - - public boolean close() { - boolean result = super.close(); - if (images != null) { - for (int i = 0; i < images.length; i++) { - images[i].dispose(); - images[i] = null; - } - images = null; - } - return result; - } - public String getPassword() { - return password; - } - - Label createLabel(Composite parent) { - Label result = new Label(parent, SWT.NULL); - GridData data = new GridData(); - data.widthHint = 22; - data.heightHint = 22; - result.setLayoutData(data); - result.setImage(getImage()); - return result; - } - Image getImage() { - double random = Math.random(); - random *= 7; // Random number between 0.0 and 7.0 - long num = Math.round(random); - return images[(int)num]; - } - void initializeImages() { - images = new Image[8]; - for (int i = 0; i < images.length; i++) { - images[i] = CVSUIPlugin.getPlugin().getImageDescriptor("glyphs/glyph" + (i+1) + ".gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$ - } - FontData fd = new FontData(); - fd.setStyle(SWT.BOLD); - fd.setHeight(10); - // On Windows, set the font to Sans Serif for an authentic look - if (System.getProperty("os.name").indexOf("Windows") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ - fd.setName("Microsoft Sans Serif"); //$NON-NLS-1$ - } - } - void updateImages() { - icon1.setImage(getImage()); - icon2.setImage(getImage()); - icon3.setImage(getImage()); - icon4.setImage(getImage()); - } - public void setUsername(String user) { - this.user = user; - } - String getXs() { - double random = Math.random(); - random *= 2; - random += 2; - long num = Math.round(random); - // Random number between 2 and 4 - switch ((int)num) { - case 2: - return "XX"; //$NON-NLS-1$ - case 3: - return "XXX"; //$NON-NLS-1$ - case 4: - return "XXXX"; //$NON-NLS-1$ - } - return "X"; //$NON-NLS-1$ - } - protected void cancelPressed() { - password = null; - super.cancelPressed(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java deleted file mode 100644 index bbc7c2280..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java +++ /dev/null @@ -1,396 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.team.internal.ccvs.core.CVSAnnotateBlock; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.registry.EditorDescriptor; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * A view showing the results of the CVS Annotate Command. A linked - * combination of a View of annotations, a source editor and the - * Resource History View - */ -public class AnnotateView extends ViewPart implements ISelectionChangedListener { - - ITextEditor editor; - HistoryView historyView; - IWorkbenchPage page; - - ListViewer viewer; - IDocument document; - Collection cvsAnnotateBlocks; - ICVSResource cvsResource; - InputStream contents; - - IStructuredSelection previousListSelection; - ITextSelection previousTextSelection; - boolean lastSelectionWasText = false; - - - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.AnnotateView"; //$NON-NLS-1$ - private Composite top; - - private IPartListener partListener = new IPartListener() { - public void partActivated(IWorkbenchPart part) { - } - public void partBroughtToTop(IWorkbenchPart part) { - } - public void partClosed(IWorkbenchPart part) { - if (editor != null && part == editor) { - disconnect(); - } - } - public void partDeactivated(IWorkbenchPart part) { - } - public void partOpened(IWorkbenchPart part) { - } - }; - - public AnnotateView() { - super(); - } - - public void createPartControl(Composite parent) { - - this.top = parent; - - // Create default contents - Label label = new Label(top, SWT.WRAP); - label.setText(Policy.bind("CVSAnnotateView.viewInstructions")); //$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.FILL_BOTH)); - top.layout(); - } - - /** - * Show the annotation view. - * @param cvsResource - * @param cvsAnnotateBlocks - * @param contents - * @throws PartInitException, CVSException - */ - public void showAnnotations(ICVSResource cvsResource, Collection cvsAnnotateBlocks, InputStream contents) throws PartInitException, CVSException { - showAnnotations(cvsResource, cvsAnnotateBlocks, contents, true); - } - - /** - * Show the annotation view. - * @param cvsResource - * @param cvsAnnotateBlocks - * @param contents - * @param useHistoryView - * @throws PartInitException, CVSException - */ - public void showAnnotations(ICVSResource cvsResource, Collection cvsAnnotateBlocks, InputStream contents, boolean useHistoryView) throws PartInitException, CVSException { - - // Disconnect from old annotation editor - disconnect(); - - // Remove old viewer - Control[] oldChildren = top.getChildren(); - if (oldChildren != null) { - for (int i = 0; i < oldChildren.length; i++) { - oldChildren[i].dispose(); - } - } - - viewer = new ListViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setContentProvider(new ArrayContentProvider()); - viewer.setLabelProvider(new LabelProvider()); - viewer.addSelectionChangedListener(this); - viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - - WorkbenchHelp.setHelp(viewer.getControl(), IHelpContextIds.ANNOTATE_VIEW); - - top.layout(); - - this.cvsResource = cvsResource; - this.contents = contents; - this.cvsAnnotateBlocks = cvsAnnotateBlocks; - page = CVSUIPlugin.getActivePage(); - viewer.setInput(cvsAnnotateBlocks); - editor = (ITextEditor) openEditor(); - IDocumentProvider provider = editor.getDocumentProvider(); - document = provider.getDocument(editor.getEditorInput()); - - setPartName(Policy.bind("CVSAnnotateView.showFileAnnotation", new Object[] {cvsResource.getName()})); //$NON-NLS-1$ - try { - IResource localResource = cvsResource.getIResource(); - if (localResource != null) { - setTitleToolTip(localResource.getFullPath().toString()); - } else { - setTitleToolTip(cvsResource.getName()); - } - } catch (CVSException e) { - setTitleToolTip(cvsResource.getName()); - } - - if (!useHistoryView) { - return; - } - - // Get hook to the HistoryView - - historyView = (HistoryView) page.showView(HistoryView.VIEW_ID); - historyView.showHistory((ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(cvsResource), false /* don't refetch */); - } - - protected void disconnect() { - if(editor != null) { - if (editor.getSelectionProvider() instanceof IPostSelectionProvider) { - ((IPostSelectionProvider) editor.getSelectionProvider()).removePostSelectionChangedListener(this); - } - editor.getSite().getPage().removePartListener(partListener); - editor = null; - document = null; - } - } - - /** - * Makes the view visible in the active perspective. If there - * isn't a view registered null is returned. - * Otherwise the opened view part is returned. - */ - public static AnnotateView openInActivePerspective() throws PartInitException { - return (AnnotateView) CVSUIPlugin.getActivePage().showView(VIEW_ID); - } - - /** - * Selection changed in either the Annotate List View or the - * Source editor. - */ - public void selectionChanged(SelectionChangedEvent event) { - - if (event.getSelection() instanceof IStructuredSelection) { - listSelectionChanged((IStructuredSelection) event.getSelection()); - } else if (event.getSelection() instanceof ITextSelection) { - textSelectionChanged((ITextSelection) event.getSelection()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - disconnect(); - } - - /** - * A selection event in the Annotate Source Editor - * @param event - */ - private void textSelectionChanged(ITextSelection selection) { - - // Track where the last selection event came from to avoid - // a selection event loop. - lastSelectionWasText = true; - - // Locate the annotate block containing the selected line number. - CVSAnnotateBlock match = null; - for (Iterator iterator = cvsAnnotateBlocks.iterator(); iterator.hasNext();) { - CVSAnnotateBlock block = (CVSAnnotateBlock) iterator.next(); - if (block.contains(selection.getStartLine())) { - match = block; - break; - } - } - - // Select the annotate block in the List View. - if (match == null) { - return; - } - - StructuredSelection listSelection = new StructuredSelection(match); - viewer.setSelection(listSelection, true); - } - - /** - * A selection event in the Annotate List View - * @param selection - */ - private void listSelectionChanged(IStructuredSelection selection) { - - // If the editor was closed, reopen it. - if (editor == null || editor.getSelectionProvider() == null) { - try { - contents.reset(); - showAnnotations(cvsResource, cvsAnnotateBlocks, contents, false); - } catch (CVSException e) { - return; - } catch (PartInitException e) { - return; - } catch (IOException e) { - return; - } - } - - ISelectionProvider selectionProvider = editor.getSelectionProvider(); - if (selectionProvider == null) { - // Failed to open the editor but what else can we do. - return; - } - - ITextSelection textSelection = (ITextSelection) selectionProvider.getSelection(); - CVSAnnotateBlock listSelection = (CVSAnnotateBlock) selection.getFirstElement(); - - /** - * Ignore event if the current text selection is already equal to the corresponding - * list selection. Nothing to do. This prevents infinite event looping. - * - * Extra check to handle single line deltas - */ - - if (textSelection.getStartLine() == listSelection.getStartLine() && textSelection.getEndLine() == listSelection.getEndLine() && selection.equals(previousListSelection)) { - return; - } - - // If the last selection was a text selection then bale to prevent a selection loop. - if (!lastSelectionWasText) { - try { - int start = document.getLineOffset(listSelection.getStartLine()); - int end = document.getLineOffset(listSelection.getEndLine() + 1); - editor.selectAndReveal(start, end - start); - if (editor != null && !page.isPartVisible(editor)) { - page.activate(editor); - } - - } catch (BadLocationException e) { - // Ignore - nothing we can do. - } - } - - - // Select the revision in the history view. - if(historyView != null) { - historyView.selectRevision(listSelection.getRevision()); - } - lastSelectionWasText = false; - } - - /** - * Try and open the correct registered editor type for the file. - * @throws CVSException, PartInitException - */ - private IEditorPart openEditor() throws CVSException, PartInitException { - ICVSRemoteFile file = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(cvsResource); - - // Determine if the registered editor is an ITextEditor. - // There is currently no support from UI to determine this information. This - // problem has been logged in: https://bugs.eclipse.org/bugs/show_bug.cgi?id=47362 - // For now, use internal classes. - String id = getEditorId(file); - ITextEditor editor = getEditor(id, file); - - // Hook Editor post selection listener. - if (editor.getSelectionProvider() instanceof IPostSelectionProvider) { - ((IPostSelectionProvider) editor.getSelectionProvider()).addPostSelectionChangedListener(this); - } - editor.getSite().getPage().addPartListener(partListener); - return editor; - } - - private ITextEditor getEditor(String id, ICVSRemoteFile file) throws PartInitException { - // Either reuse an existing editor or open a new editor of the correct type. - if (editor != null && editor instanceof IReusableEditor && page.isPartVisible(editor) && editor.getSite().getId().equals(id)) { - // We can reuse the editor - ((IReusableEditor) editor).setInput(new RemoteAnnotationEditorInput(file, contents)); - return editor; - } else { - // We can not reuse the editor so close the existing one and open a new one. - if (editor != null) { - page.closeEditor(editor, false); - editor = null; - } - IEditorPart part = page.openEditor(new RemoteAnnotationEditorInput(file, contents), id); - if (part instanceof ITextEditor) { - return (ITextEditor)part; - } else { - // We asked for a text editor but didn't get one - // so open a vanilla text editor - page.closeEditor(part, false); - part = page.openEditor(new RemoteAnnotationEditorInput(file, contents), IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID); - if (part instanceof ITextEditor) { - return (ITextEditor)part; - } else { - // There is something really wrong so just bail - throw new PartInitException(Policy.bind("AnnotateView.0")); //$NON-NLS-1$ - } - } - } - } - - private String getEditorId(ICVSRemoteFile file) { - String id; - IEditorRegistry registry = CVSUIPlugin.getPlugin().getWorkbench().getEditorRegistry(); - IEditorDescriptor descriptor = registry.getDefaultEditor(file.getName()); - if (descriptor == null || !(descriptor instanceof EditorDescriptor) || !(((EditorDescriptor)descriptor).isInternal())) { - id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID; //$NON-NLS-1$ - } else { - try { - Object obj = IDEWorkbenchPlugin.createExtension(((EditorDescriptor) descriptor).getConfigurationElement(), "class"); //$NON-NLS-1$ - if (obj instanceof ITextEditor) { - id = descriptor.getId(); - } else { - id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID; - } - } catch (CoreException e) { - id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID; - } - } - return id; - } - - // This method implemented to be an ISelectionChangeListener but we - // don't really care when the List or Editor get focus. - public void setFocus() { - return; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java deleted file mode 100644 index 3259f7911..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -public class AvoidableMessageDialog extends MessageDialog { - Button dontShowAgain; - boolean dontShow; - boolean showOption; - - public AvoidableMessageDialog(Shell shell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { - this(shell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex, true); - } - - public AvoidableMessageDialog(Shell shell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, boolean showOption) { - super(shell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); - this.showOption = showOption; - } - - protected Control createCustomArea(Composite composite) { - if ( ! showOption) return null; - dontShow = false; - dontShowAgain = new Button(composite, SWT.CHECK); - GridData data = new GridData(); - data.horizontalIndent = 50; - dontShowAgain.setLayoutData(data); - dontShowAgain.setText(Policy.bind("AvoidableMessageDialog.dontShowAgain")); //$NON-NLS-1$ - dontShowAgain.setSelection(dontShow); - dontShowAgain.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - dontShow = dontShowAgain.getSelection(); - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - }); - return dontShowAgain; - } - - public boolean isDontShowAgain() { - return dontShow; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java deleted file mode 100644 index f1a012da7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java +++ /dev/null @@ -1,457 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.Differencer; -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; -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.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * A compare input for comparing remote resources. Use CVSLocalCompareInput - * when comparing resources in the workspace to remote resources. - */ -public class CVSCompareEditorInput extends CompareEditorInput { - private ITypedElement left; - private ITypedElement right; - private ITypedElement ancestor; - private Image leftImage; - private Image rightImage; - private Image ancestorImage; - - // comparison constants - private static final int NODE_EQUAL = 0; - private static final int NODE_NOT_EQUAL = 1; - private static final int NODE_UNKNOWN = 2; - - String toolTipText; - private String title; - - /** - * Creates a new CVSCompareEditorInput. - */ - public CVSCompareEditorInput(ResourceEditionNode left, ResourceEditionNode right) { - this(left, right, null); - } - - public CVSCompareEditorInput(String title, String toolTip, ResourceEditionNode left, ResourceEditionNode right) { - this(left, right, null); - this.title = title; - this.toolTipText = toolTip; - } - - /** - * Creates a new CVSCompareEditorInput. - */ - public CVSCompareEditorInput(ResourceEditionNode left, ResourceEditionNode right, ResourceEditionNode ancestor) { - super(new CompareConfiguration()); - // TODO: Invokers of this method should ensure that trees and contents are prefetched - this.left = left; - this.right = right; - this.ancestor = ancestor; - if (left != null) { - this.leftImage = left.getImage(); - } - if (right != null) { - this.rightImage = right.getImage(); - } - if (ancestor != null) { - this.ancestorImage = ancestor.getImage(); - } - } - - /** - * Returns the label for the given input element. - */ - private String getLabel(ITypedElement element) { - if (element instanceof ResourceEditionNode) { - ICVSRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource(); - ICVSResource resource = edition; - if (edition instanceof ICVSRemoteFile) { - try { - return Policy.bind("nameAndRevision", resource.getName(), ((ICVSRemoteFile)edition).getRevision()); //$NON-NLS-1$ - } catch (TeamException e) { - // fall through - } - } - try { - if (edition.isContainer()) { - CVSTag tag = ((ICVSRemoteFolder)edition).getTag(); - if (tag == null) { - return Policy.bind("CVSCompareEditorInput.inHead", edition.getName()); //$NON-NLS-1$ - } else if (tag.getType() == CVSTag.BRANCH) { - return Policy.bind("CVSCompareEditorInput.inBranch", new Object[] {edition.getName(), tag.getName()}); //$NON-NLS-1$ - } else { - return Policy.bind("CVSCompareEditorInput.repository", new Object[] {edition.getName(), tag.getName()}); //$NON-NLS-1$ - } - } else { - return Policy.bind("CVSCompareEditorInput.repository", new Object[] {edition.getName(), resource.getSyncInfo().getRevision()}); //$NON-NLS-1$ - } - } catch (TeamException e) { - handle(e); - // Fall through and get the default label - } - } - return element.getName(); - } - - /** - * Returns the label for the given input element. - */ - private String getVersionLabel(ITypedElement element) { - if (element instanceof ResourceEditionNode) { - ICVSRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource(); - ICVSResource resource = edition; - try { - if (edition.isContainer()) { - CVSTag tag = ((ICVSRemoteFolder)resource).getTag(); - if (tag == null) { - return Policy.bind("CVSCompareEditorInput.headLabel"); //$NON-NLS-1$ - } else if (tag.getType() == CVSTag.BRANCH) { - return Policy.bind("CVSCompareEditorInput.branchLabel", tag.getName()); //$NON-NLS-1$ - } else { - return tag.getName(); - } - } else { - return resource.getSyncInfo().getRevision(); - } - } catch (TeamException e) { - handle(e); - // Fall through and get the default label - } - } - return element.getName(); - } - - /* - * Returns a guess of the resource name being compared, for display - * in the title. - */ - private String guessResourceName() { - if (left != null) { - return left.getName(); - } - if (right != null) { - return right.getName(); - } - if (ancestor != null) { - return ancestor.getName(); - } - return ""; //$NON-NLS-1$ - } - - /* - * Returns a guess of the resource path being compared, for display - * in the tooltip. - */ - private Object guessResourcePath() { - if (left != null && left instanceof ResourceEditionNode) { - return ((ResourceEditionNode)left).getRemoteResource().getRepositoryRelativePath(); - } - if (right != null && right instanceof ResourceEditionNode) { - return ((ResourceEditionNode)right).getRemoteResource().getRepositoryRelativePath(); - } - if (ancestor != null && ancestor instanceof ResourceEditionNode) { - return ((ResourceEditionNode)ancestor).getRemoteResource().getRepositoryRelativePath(); - } - return guessResourceName(); - } - - /** - * Handles a random exception and sanitizes it into a reasonable - * error message. - */ - private void handle(Exception e) { - // create a status - Throwable t = e; - // unwrap the invocation target exception - if (t instanceof InvocationTargetException) { - t = ((InvocationTargetException)t).getTargetException(); - } - IStatus error; - if (t instanceof CoreException) { - error = ((CoreException)t).getStatus(); - } else if (t instanceof TeamException) { - error = ((TeamException)t).getStatus(); - } else { - error = new Status(IStatus.ERROR, CVSUIPlugin.ID, 1, Policy.bind("internal"), t); //$NON-NLS-1$ - } - setMessage(error.getMessage()); - if (!(t instanceof TeamException)) { - CVSUIPlugin.log(error.getSeverity(), error.getMessage(), t); - } - } - - /** - * Sets up the title and pane labels for the comparison view. - */ - private void initLabels() { - CompareConfiguration cc = getCompareConfiguration(); - setLabels(cc, new StructuredSelection()); - - if (title == null) { - if (ancestor != null) { - title = Policy.bind("CVSCompareEditorInput.titleAncestor", new Object[] {guessResourceName(), getVersionLabel(ancestor), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ - toolTipText = Policy.bind("CVSCompareEditorInput.titleAncestor", new Object[] {guessResourcePath(), getVersionLabel(ancestor), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ - } else { - String leftName = null; - if (left != null) leftName = left.getName(); - String rightName = null; - if (right != null) rightName = right.getName(); - if (leftName != null && !leftName.equals(rightName)) { - title = Policy.bind("CVSCompareEditorInput.titleNoAncestorDifferent", new Object[] {leftName, getVersionLabel(left), rightName, getVersionLabel(right)} ); //$NON-NLS-1$ - } else { - title = Policy.bind("CVSCompareEditorInput.titleNoAncestor", new Object[] {guessResourceName(), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ - title = Policy.bind("CVSCompareEditorInput.titleNoAncestor", new Object[] {guessResourcePath(), getVersionLabel(left), getVersionLabel(right)} ); //$NON-NLS-1$ - } - } - } - setTitle(title); - } - - private void setLabels(CompareConfiguration cc, IStructuredSelection selection) { - ITypedElement left = this.left; - ITypedElement right = this.right; - ITypedElement ancestor = this.ancestor; - - if (left != null) { - cc.setLeftLabel(getLabel(left)); - cc.setLeftImage(leftImage); - } - - if (right != null) { - cc.setRightLabel(getLabel(right)); - cc.setRightImage(rightImage); - } - - if (ancestor != null) { - cc.setAncestorLabel(getLabel(ancestor)); - cc.setAncestorImage(ancestorImage); - } - } - - /* (Non-javadoc) - * Method declared on CompareEditorInput - */ - public boolean isSaveNeeded() { - return false; - } - - /* (non-Javadoc) - * Method declared on CompareEditorInput - */ - protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - final boolean threeWay = ancestor != null; - if (right == null || left == null) { - setMessage(Policy.bind("CVSCompareEditorInput.different")); //$NON-NLS-1$ - return null; - } - - initLabels(); - - final Differencer d = new Differencer() { - protected boolean contentsEqual(Object input1, Object input2) { - int compare = teamEqual(input1, input2); - if (compare == NODE_EQUAL) { - return true; - } - if (compare == NODE_NOT_EQUAL) { - return false; - } - //revert to slow content comparison - return super.contentsEqual(input1, input2); - } - protected void updateProgress(IProgressMonitor progressMonitor, Object node) { - if (node instanceof ITypedElement) { - ITypedElement element = (ITypedElement)node; - progressMonitor.subTask(Policy.bind("CompareEditorInput.fileProgress", new String[] {element.getName()})); //$NON-NLS-1$ - progressMonitor.worked(1); - } - } - protected Object[] getChildren(Object input) { - if (input instanceof IStructureComparator) { - Object[] children= ((IStructureComparator)input).getChildren(); - if (children != null) - return children; - } - return null; - } - protected Object visit(Object data, int result, Object ancestor, Object left, Object right) { - return new DiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); - } - }; - - try { - // do the diff - Object result = null; - monitor.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 30); //$NON-NLS-1$ - IProgressMonitor sub = new SubProgressMonitor(monitor, 30); - sub.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 100); //$NON-NLS-1$ - try { - result = d.findDifferences(threeWay, sub, null, ancestor, left, right); - } finally { - sub.done(); - } - return result; - } catch (OperationCanceledException e) { - throw new InterruptedException(e.getMessage()); - } catch (RuntimeException e) { - handle(e); - return null; - } finally { - monitor.done(); - } - } - - /** - * Compares two nodes to determine if they are equal. Returns NODE_EQUAL - * of they are the same, NODE_NOT_EQUAL if they are different, and - * NODE_UNKNOWN if comparison was not possible. - */ - protected int teamEqual(Object left, Object right) { - // calculate the type for the left contribution - ICVSRemoteResource leftEdition = null; - if (left instanceof ResourceEditionNode) { - leftEdition = ((ResourceEditionNode)left).getRemoteResource(); - } - - // calculate the type for the right contribution - ICVSRemoteResource rightEdition = null; - if (right instanceof ResourceEditionNode) - rightEdition = ((ResourceEditionNode)right).getRemoteResource(); - - - // compare them - - if (leftEdition == null || rightEdition == null) { - return NODE_UNKNOWN; - } - // if they're both non-files, they're the same - if (leftEdition.isContainer() && rightEdition.isContainer()) { - return NODE_EQUAL; - } - // if they have different types, they're different - if (leftEdition.isContainer() != rightEdition.isContainer()) { - return NODE_NOT_EQUAL; - } - - String leftLocation = leftEdition.getRepository().getLocation(); - String rightLocation = rightEdition.getRepository().getLocation(); - if (!leftLocation.equals(rightLocation)) { - return NODE_UNKNOWN; - } - try { - ResourceSyncInfo leftInfo = ((ICVSResource)leftEdition).getSyncInfo(); - ResourceSyncInfo rightInfo = ((ICVSResource)rightEdition).getSyncInfo(); - - if (leftEdition.getRepositoryRelativePath().equals(rightEdition.getRepositoryRelativePath()) && - leftInfo.getRevision().equals(rightInfo.getRevision())) { - return NODE_EQUAL; - } else { - if(considerContentIfRevisionOrPathDiffers()) { - return NODE_UNKNOWN; - } else { - return NODE_NOT_EQUAL; - } - } - } catch (TeamException e) { - handle(e); - return NODE_UNKNOWN; - } - } - - private boolean considerContentIfRevisionOrPathDiffers() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS); - } - - public Viewer createDiffViewer(Composite parent) { - Viewer viewer = super.createDiffViewer(parent); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - CompareConfiguration cc = getCompareConfiguration(); - setLabels(cc, (IStructuredSelection)event.getSelection()); - } - }); - ((StructuredViewer)viewer).addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - ISelection selection = event.getSelection(); - if (! selection.isEmpty() && selection instanceof IStructuredSelection) { - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o instanceof DiffNode) { - updateLabelsFor((DiffNode)o); - } - } - } - }); - return viewer; - } - - /* - * Update the labels for the given DiffNode - */ - protected void updateLabelsFor(DiffNode node) { - CompareConfiguration cc = getCompareConfiguration(); - ITypedElement l = node.getLeft(); - if (l == null) { - cc.setLeftLabel(Policy.bind("CVSCompareEditorInput.0")); //$NON-NLS-1$ - cc.setLeftImage(null); - } else { - cc.setLeftLabel(getLabel(l)); - cc.setLeftImage(l.getImage()); - } - ITypedElement r = node.getRight(); - if (r == null) { - cc.setRightLabel(Policy.bind("CVSCompareEditorInput.1")); //$NON-NLS-1$ - cc.setRightImage(null); - } else { - cc.setRightLabel(getLabel(r)); - cc.setRightImage(r.getImage()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#getToolTipText() - */ - public String getToolTipText() { - if (toolTipText != null) { - return toolTipText; - } - return super.getToolTipText(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java deleted file mode 100644 index fe20f0053..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java +++ /dev/null @@ -1,453 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.CompareUI; -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.ResourceNode; -import org.eclipse.compare.structuremergeviewer.DiffContainer; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.Differencer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.ISaveableWorkbenchPart; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.help.WorkbenchHelp; - -public class CVSCompareRevisionsInput extends CompareEditorInput implements ISaveableWorkbenchPart { - IFile resource; - ILogEntry[] editions; - TableViewer viewer; - Action getRevisionAction; - Action getContentsAction; - Shell shell; - - // Provide the widget for the history table - private HistoryTableProvider historyTableProvider; - - /** - * Provide a wrapper for a resource node that doesn't buffer. Changes are saved directly to the - * underlying file. - */ - class TypedBufferedContent extends ResourceNode { - public TypedBufferedContent(IFile resource) { - super(resource); - } - protected InputStream createStream() throws CoreException { - return ((IFile)getResource()).getContents(); - } - public void setContent(byte[] contents) { - if (contents == null) contents = new byte[0]; - final InputStream is = new ByteArrayInputStream(contents); - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - IFile file = resource; - if (is != null) { - if (!file.exists()) { - file.create(is, false, monitor); - } else { - file.setContents(is, false, true, monitor); - } - } else { - file.delete(false, true, monitor); - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }; - try { - new ProgressMonitorDialog(shell).run(false, false, runnable); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(CVSUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell(), Policy.bind("TeamFile.saveChanges", resource.getName()), null, e); //$NON-NLS-1$ - } catch (InterruptedException e) { - // Ignore - } - fireContentChanged(); - } - public ITypedElement replace(ITypedElement child, ITypedElement other) { - return null; - } - public void fireChange() { - fireContentChanged(); - } - } - - /** - * This class is an edition node which knows the log entry it came from. - */ - class ResourceRevisionNode extends ResourceEditionNode { - ILogEntry entry; - public ResourceRevisionNode(ILogEntry entry) { - super(entry.getRemoteFile()); - this.entry = entry; - } - public ILogEntry getLogEntry() { - return entry; - } - public String getName() { - String revisionName = entry.getRevision(); - if (revisionName != null) { - IResource resource = CVSCompareRevisionsInput.this.resource; - try { - ICVSRemoteFile currentEdition = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(resource); - if (currentEdition != null && currentEdition.getRevision().equals(revisionName)) { - Policy.bind("currentRevision", revisionName); //$NON-NLS-1$ - } else { - return revisionName; - } - } catch (TeamException e) { - handle(e); - } - } - return super.getName(); - } - } - - /** - * A compare node that gets its label from the right element - */ - class VersionCompareDiffNode extends DiffNode implements IAdaptable { - public VersionCompareDiffNode(ITypedElement left, ITypedElement right) { - super(left, right); - } - public String getName() { - return getRight().getName(); - } - public Object getAdapter(Class adapter) { - if (adapter == ILogEntry.class) { - return ((ResourceRevisionNode)getRight()).getLogEntry(); - } - return null; - } - public void fireContentChanges() { - fireChange(); - } - } - /** - * A content provider which knows how to get the children of the diff container - */ - class VersionCompareContentProvider implements IStructuredContentProvider { - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - public Object[] getElements(Object inputElement) { - if (inputElement instanceof DiffContainer) { - return ((DiffContainer)inputElement).getChildren(); - } - return null; - } - } - - public CVSCompareRevisionsInput(IFile resource, ILogEntry[] editions) { - super(new CompareConfiguration()); - this.resource = resource; - this.editions = editions; - updateCurrentEdition(); - initializeActions(); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#createContents(org.eclipse.swt.widgets.Composite) - */ - public Control createContents(Composite parent) { - Control c = super.createContents(parent); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - return c; - } - - public Viewer createDiffViewer(Composite parent) { - this.shell = parent.getShell(); - viewer = getHistoryTableProvider().createTable(parent); - Table table = viewer.getTable(); - table.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); //$NON-NLS-1$ - - viewer.setContentProvider(new VersionCompareContentProvider()); - - MenuManager mm = new MenuManager(); - mm.setRemoveAllWhenShown(true); - mm.addMenuListener( - new IMenuListener() { - public void menuAboutToShow(IMenuManager mm) { - mm.add(getContentsAction); - mm.add(getRevisionAction); - } - } - ); - table.setMenu(mm.createContextMenu(table)); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (!(selection instanceof IStructuredSelection)) { - getRevisionAction.setEnabled(false); - getContentsAction.setEnabled(false); - return; - } - IStructuredSelection ss = (IStructuredSelection)selection; - getRevisionAction.setEnabled(ss.size() == 1); - getContentsAction.setEnabled(ss.size() == 1); - } - }); - - // Add F1 help. - WorkbenchHelp.setHelp(table, IHelpContextIds.COMPARE_REVISIONS_VIEW); - return viewer; - } - - private void initLabels() { - CompareConfiguration cc = getCompareConfiguration(); - cc.setLeftEditable(true); - cc.setRightEditable(false); - String resourceName = resource.getName(); - String leftLabel = Policy.bind("CVSCompareRevisionsInput.workspace", new Object[] {resourceName}); //$NON-NLS-1$ - cc.setLeftLabel(leftLabel); - String rightLabel = Policy.bind("CVSCompareRevisionsInput.repository", new Object[] {resourceName}); //$NON-NLS-1$ - cc.setRightLabel(rightLabel); - } - private void initializeActions() { - getRevisionAction = new Action(Policy.bind("HistoryView.getRevisionAction"), null) { //$NON-NLS-1$ - public void run() { - try { - new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation(null) { - protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - if (selection.size() != 1) return; - VersionCompareDiffNode node = (VersionCompareDiffNode)selection.getFirstElement(); - ResourceEditionNode right = (ResourceEditionNode)node.getRight(); - ICVSRemoteResource edition = right.getRemoteResource(); - // Do the load. This just consists of setting the local contents. We don't - // actually want to change the base. - try { - CVSTag revisionTag = new CVSTag(((ICVSRemoteFile)edition).getRevision(), CVSTag.VERSION); - if(CVSAction.checkForMixingTags(shell, new IResource[] {resource}, revisionTag)) { - new UpdateOperation( - null, - new IResource[] {resource}, - new Command.LocalOption[] {Update.IGNORE_LOCAL_CHANGES}, - revisionTag) - .run(monitor); - getHistoryTableProvider().setFile((ICVSFile)edition); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InterruptedException e) { - // Do nothing - return; - } catch (InvocationTargetException e) { - handle(e); - } - // fire change - IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - if (selection.size() != 1) return; - VersionCompareDiffNode node = (VersionCompareDiffNode)selection.getFirstElement(); - TypedBufferedContent left = (TypedBufferedContent)node.getLeft(); - left.fireChange(); - // recompute the labels on the viewer - viewer.refresh(); - } - }; - getContentsAction = new Action(Policy.bind("HistoryView.getContentsAction")) { //$NON-NLS-1$ - public void run() { - try { - replaceLocalWithCurrentlySelectedRevision(); - } catch (CoreException e) { - Utils.handle(e); - } - } - }; - } - protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - initLabels(); - DiffNode diffRoot = new DiffNode(Differencer.NO_CHANGE); - ITypedElement left = new TypedBufferedContent(resource); - for (int i = 0; i < editions.length; i++) { - ITypedElement right = new ResourceRevisionNode(editions[i]); - diffRoot.add(new VersionCompareDiffNode(left, right)); - } - return diffRoot; - } - private void updateCurrentEdition() { - try { - getHistoryTableProvider().setFile((ICVSFile) CVSWorkspaceRoot.getRemoteResourceFor(resource)); - } catch (TeamException e) { - handle(e); - } - } - private void handle(Exception e) { - setMessage(CVSUIPlugin.openError(shell, null, null, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS).getMessage()); - } - /** - * Returns the historyTableProvider. - * @return HistoryTableProvider - */ - public HistoryTableProvider getHistoryTableProvider() { - if (historyTableProvider == null) { - historyTableProvider = new HistoryTableProvider(); - } - return historyTableProvider; - } - - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) - */ - public void saveChanges(IProgressMonitor pm) throws CoreException { - super.saveChanges(pm); - } - - public void replaceLocalWithCurrentlySelectedRevision() throws CoreException { - IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - if (selection.size() != 1) return; - VersionCompareDiffNode node = (VersionCompareDiffNode)selection.getFirstElement(); - ResourceRevisionNode right = (ResourceRevisionNode)node.getRight(); - TypedBufferedContent left = (TypedBufferedContent)node.getLeft(); - left.setContent(Utils.readBytes(right.getContents())); - } - - public Viewer getViewer() { - return viewer; - } - - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#getTitle() - */ - public String getTitle() { - return Policy.bind("CVSCompareRevisionsInput.compareResourceAndVersions", new Object[] {resource.getFullPath().toString()}); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - public void doSave(IProgressMonitor monitor) { - try { - saveChanges(monitor); - } catch (CoreException e) { - Utils.handle(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSaveAs() - */ - public void doSaveAs() { - // noop - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isDirty() - */ - public boolean isDirty() { - return isSaveNeeded(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() - */ - public boolean isSaveAsAllowed() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() - */ - public boolean isSaveOnCloseNeeded() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void addPropertyListener(IPropertyListener listener) { - // noop - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - createContents(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getSite() - */ - public IWorkbenchPartSite getSite() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() - */ - public String getTitleToolTip() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void removePropertyListener(IPropertyListener listener) { - // noop - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java deleted file mode 100644 index 0e8caf800..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java +++ /dev/null @@ -1,427 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.swt.graphics.*; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.themes.ITheme; - -/** - * A decoration describes the annotations to a user interface element. The - * annotations can apply to text (e.g. prefix, suffix, color, font) and to an - * image (e.g. overlays). - *

              - * This class is derived from an internal workbench class - * IDecoration and is often used in conjunction with the label - * decoration APIs. As such a client can convert between them using helpers - * defined in this class. - *

              - * TODO: - * profile - * add colors and fonts to preferences instead of being hard coded - * what to do with CVSDecorationConfiguration class? - * preference page externalizations - * preference page preview should update when theme changes - * - * @since 3.1 - */ -public class CVSDecoration { - - // Decorations - private String prefix; - private String suffix; - private ImageDescriptor overlay; - private Color bkgColor; - private Color fgColor; - private Font font; - - // Properties - private int resourceType = IResource.FILE; - private boolean watchEditEnabled = false; - private boolean isDirty = false; - private boolean isIgnored = false; - private boolean isAdded = false; - private boolean isNewResource = false; - private boolean hasRemote = false; - private boolean readOnly = false; - private boolean needsMerge = false; - private boolean virtualFolder = false; - private String tag; - private String revision; - private String repository; - private ICVSRepositoryLocation location; - private String keywordSubstitution; - - // Text formatters - private String fileFormatter; - private String folderFormatter; - private String projectFormatter; - private String dirtyTextIndicator; - private String addedTextIndicator; - private String resourceName; - - // Images cached for better performance - private static ImageDescriptor dirty; - private static ImageDescriptor checkedIn; - private static ImageDescriptor noRemoteDir; - private static ImageDescriptor added; - private static ImageDescriptor merged; - private static ImageDescriptor newResource; - private static ImageDescriptor edited; - - // List of preferences used to configure the decorations that - // are applied. - private Preferences preferences; - - /* - * Define a cached image descriptor which only creates the image data once - */ - public static class CachedImageDescriptor extends ImageDescriptor { - - ImageDescriptor descriptor; - ImageData data; - - public CachedImageDescriptor(ImageDescriptor descriptor) { - Assert.isNotNull(descriptor); - this.descriptor = descriptor; - } - - public ImageData getImageData() { - if (data == null) { - data = descriptor.getImageData(); - } - return data; - } - } - - static { - dirty = new CachedImageDescriptor(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DIRTY_OVR)); - checkedIn = new CachedImageDescriptor(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CHECKEDIN_OVR)); - added = new CachedImageDescriptor(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CHECKEDIN_OVR)); - merged = new CachedImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_MERGED)); - newResource = new CachedImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_QUESTIONABLE)); - edited = new CachedImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_EDITED)); - noRemoteDir = new CachedImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_NO_REMOTEDIR)); - } - - /** - * Default constructor uses the plug-in's preferences to determine text decoration - * formatters and preferences. - */ - public CVSDecoration(String resourceName) { - // TODO: for efficiency don't look up a pref until its needed - IPreferenceStore store = getStore(); - Preferences prefs = new Preferences(); - - prefs.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION)); - prefs.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION)); - prefs.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION)); - prefs.setValue(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION)); - prefs.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY)); - prefs.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, store.getString(ICVSUIConstants.PREF_DIRTY_FLAG)); - prefs.setValue(ICVSUIConstants.PREF_ADDED_FLAG, store.getString(ICVSUIConstants.PREF_ADDED_FLAG)); - - initialize(resourceName, prefs, store.getString(ICVSUIConstants.PREF_FILETEXT_DECORATION), store.getString(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION), store.getString(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION)); - } - - public CVSDecoration(String resourceName, Preferences preferences, String fileFormater, String folderFormatter, String projectFormatter) { - initialize(resourceName, preferences, fileFormater, folderFormatter, projectFormatter); - } - - private IPreferenceStore getStore() { - return CVSUIPlugin.getPlugin().getPreferenceStore(); - } - - private void initialize(String resourceName, Preferences preferences, String fileFormater, String folderFormatter, String projectFormatter) { - this.resourceName = resourceName; - this.preferences = preferences; - this.fileFormatter = fileFormater; - this.folderFormatter = folderFormatter; - this.projectFormatter = projectFormatter; - } - - public void addPrefix(String prefix) { - this.prefix = prefix; - } - - public void addSuffix(String suffix) { - this.suffix = suffix; - } - - public void addOverlay(ImageDescriptor overlay) { - this.overlay = overlay; - } - - public void setForegroundColor(Color fgColor) { - this.fgColor = fgColor; - } - - public void setBackgroundColor(Color bkgColor) { - this.bkgColor = bkgColor; - } - - public void setFont(Font font) { - this.font = font; - } - - public Color getBackgroundColor() { - return bkgColor; - } - - public Color getForegroundColor() { - return fgColor; - } - - public Font getFont() { - return font; - } - - public ImageDescriptor getOverlay() { - return overlay; - } - - public String getPrefix() { - return prefix; - } - - public String getSuffix() { - return suffix; - } - - public void setResourceType(int type) { - this.resourceType = type; - } - - public void apply(IDecoration decoration) { - compute(); - // apply changes - String suffix = getSuffix(); - if(suffix != null) - decoration.addSuffix(suffix); - String prefix = getPrefix(); - if(prefix != null) - decoration.addPrefix(prefix); - ImageDescriptor overlay = getOverlay(); - if(overlay != null) - decoration.addOverlay(getOverlay()); - Color bc = getBackgroundColor(); - if(bc != null) - decoration.setBackgroundColor(bc); - Color fc = getForegroundColor(); - if(fc != null) - decoration.setForegroundColor(fc); - Font f = getFont(); - if(f != null) - decoration.setFont(f); - } - - public void compute() { - computeText(); - overlay = computeImage(); - computeColorsAndFonts(); - } - - private void computeText() { - Map bindings = new HashMap(); - IPreferenceStore store = getStore(); - if (isDirty()) { - bindings.put(CVSDecoratorConfiguration.DIRTY_FLAG, preferences.getString(ICVSUIConstants.PREF_DIRTY_FLAG)); - } - if (isAdded()) { - bindings.put(CVSDecoratorConfiguration.ADDED_FLAG, preferences.getString(ICVSUIConstants.PREF_ADDED_FLAG)); - } else if(isHasRemote()){ - bindings.put(CVSDecoratorConfiguration.FILE_REVISION, getRevision()); - bindings.put(CVSDecoratorConfiguration.RESOURCE_TAG, getTag()); - } - bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, getResourceName()); - bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, getKeywordSubstitution()); - if (resourceType != IResource.FILE && location != null) { - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_HOST, location.getHost()); - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_METHOD, location.getMethod().getName()); - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, location.getUsername()); - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory()); - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository); - } - CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings); - } - - private ImageDescriptor computeImage() { - // show newResource icon - if (preferences.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION) && isNewResource()) { - return newResource; - } - // show dirty icon - if (preferences.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION) && isDirty()) { - return dirty; - } - // show added - if (preferences.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION) && isAdded()) { - return added; - } - // show watch edit - if (isWatchEditEnabled() && resourceType == IResource.FILE && !isReadOnly() && isHasRemote()) { - return edited; - } - // show checked in - if (preferences.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION) && isHasRemote()) { - if (resourceType != IResource.FILE && isVirtualFolder()) { - return noRemoteDir; - } - return checkedIn; - } - //nothing matched - return null; - } - - private void computeColorsAndFonts() { - ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); - if(isIgnored()) { - setBackgroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR)); - setForegroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR)); - setFont(current.getFontRegistry().get(CVSDecoratorConfiguration.IGNORED_FONT)); - } else if(isDirty()) { - setBackgroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR)); - setForegroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR)); - setFont(current.getFontRegistry().get(CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT)); - } - } - - private String getResourceName() { - return resourceName; - } - - private String getTextFormatter() { - switch (resourceType) { - case IResource.FILE : - return fileFormatter; - case IResource.FOLDER : - return folderFormatter; - case IResource.PROJECT : - return projectFormatter; - } - return "no format specified"; //$NON-NLS-1$ - } - - public boolean isAdded() { - return isAdded; - } - - public void setAdded(boolean isAdded) { - this.isAdded = isAdded; - } - - public boolean isDirty() { - return isDirty; - } - - public void setDirty(boolean isDirty) { - this.isDirty = isDirty; - } - - public boolean isIgnored() { - return isIgnored; - } - - public void setIgnored(boolean isIgnored) { - this.isIgnored = isIgnored; - } - - public String getTag() { - return tag; - } - - public void setTag(String tag) { - this.tag = tag; - } - - public boolean isWatchEditEnabled() { - return watchEditEnabled; - } - - public void setWatchEditEnabled(boolean watchEditEnabled) { - this.watchEditEnabled = watchEditEnabled; - } - - public boolean isNewResource() { - return isNewResource; - } - - public void setNewResource(boolean isNewResource) { - this.isNewResource = isNewResource; - } - - public ICVSRepositoryLocation getLocation() { - return location; - } - - public void setLocation(ICVSRepositoryLocation location) { - this.location = location; - } - - public String getRevision() { - return revision; - } - - public void setRevision(String revision) { - this.revision = revision; - } - - public String getKeywordSubstitution() { - return keywordSubstitution; - } - - public void setKeywordSubstitution(String keywordSubstitution) { - this.keywordSubstitution = keywordSubstitution; - } - - public void setNeedsMerge(boolean needsMerge) { - this.needsMerge = needsMerge; - } - - public boolean isHasRemote() { - return hasRemote; - } - - public void setHasRemote(boolean hasRemote) { - this.hasRemote = hasRemote; - } - - public void setRepository(String repository) { - this.repository = repository; - } - - public boolean isReadOnly() { - return readOnly; - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public boolean isVirtualFolder() { - return virtualFolder; - } - - public void setVirtualFolder(boolean virtualFolder) { - this.virtualFolder = virtualFolder; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java deleted file mode 100644 index 647424147..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.util.Map; - -public class CVSDecoratorConfiguration { - - // bindings for - public static final String RESOURCE_NAME = "name"; //$NON-NLS-1$ - public static final String RESOURCE_TAG = "tag"; //$NON-NLS-1$ - public static final String FILE_REVISION = "revision"; //$NON-NLS-1$ - public static final String FILE_KEYWORD = "keyword"; //$NON-NLS-1$ - - // bindings for repository location - public static final String REMOTELOCATION_METHOD = "method"; //$NON-NLS-1$ - public static final String REMOTELOCATION_USER = "user"; //$NON-NLS-1$ - public static final String REMOTELOCATION_HOST = "host"; //$NON-NLS-1$ - public static final String REMOTELOCATION_ROOT = "root"; //$NON-NLS-1$ - public static final String REMOTELOCATION_REPOSITORY = "repository"; //$NON-NLS-1$ - - // bindings for resource states - public static final String DIRTY_FLAG = "dirty_flag"; //$NON-NLS-1$ - public static final String ADDED_FLAG = "added_flag"; //$NON-NLS-1$ - public static final String DEFAULT_DIRTY_FLAG = ">"; //$NON-NLS-1$ - public static final String DEFAULT_ADDED_FLAG = "*"; //$NON-NLS-1$ - - // default text decoration formats - public static final String DEFAULT_FILETEXTFORMAT = "{dirty_flag}{name} {revision} {tag} ({keyword})"; //$NON-NLS-1$ - public static final String DEFAULT_FOLDERTEXTFORMAT = "{dirty_flag}{name} {tag}"; //$NON-NLS-1$ - public static final String DEFAULT_PROJECTTEXTFORMAT = "{dirty_flag}{name} {tag} [{host}]"; //$NON-NLS-1$ - - // prefix characters that can be removed if the following binding is not found - private static final char KEYWORD_SEPCOLON = ':'; - private static final char KEYWORD_SEPAT = '@'; - - // font and color definition ids - public static final String OUTGOING_CHANGE_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_foreground_color"; //$NON-NLS-1$ - public static final String OUTGOING_CHANGE_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_background_color"; //$NON-NLS-1$ - public static final String OUTGOING_CHANGE_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_font"; //$NON-NLS-1$ - public static final String IGNORED_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_foreground_color"; //$NON-NLS-1$ - public static final String IGNORED_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_background_color"; //$NON-NLS-1$ - public static final String IGNORED_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_font"; //$NON-NLS-1$ - - public static void decorate(CVSDecoration decoration, String format, Map bindings) { - StringBuffer prefix = new StringBuffer(80); - StringBuffer suffix = new StringBuffer(80); - StringBuffer output = prefix; - - int length = format.length(); - int start = -1; - int end = length; - while (true) { - if ((end = format.indexOf('{', start)) > -1) { - output.append(format.substring(start + 1, end)); - if ((start = format.indexOf('}', end)) > -1) { - String key = format.substring(end + 1, start); - String s; - - //We use the RESOURCE_NAME key to determine if we are doing the prefix or suffix. The name isn't actually part of either. - if(key.equals(RESOURCE_NAME)) { - output = suffix; - s = null; - } else { - s = (String) bindings.get(key); - } - - if(s!=null) { - output.append(s); - } else { - // support for removing prefix character if binding is null - int curLength = output.length(); - if(curLength>0) { - char c = output.charAt(curLength - 1); - if(c == KEYWORD_SEPCOLON || c == KEYWORD_SEPAT) { - output.deleteCharAt(curLength - 1); - } - } - } - } else { - output.append(format.substring(end, length)); - break; - } - } else { - output.append(format.substring(start + 1, length)); - break; - } - } - - if (prefix.length() != 0) { - decoration.addPrefix(prefix.toString()); - } - if (suffix.length() != 0) { - decoration.addSuffix(suffix.toString()); - } - } - -//todo: leaving the old bind method in until senders can be fixed - - public static String bind(String format, Map bindings) { - StringBuffer output = new StringBuffer(80); - int length = format.length(); - int start = -1; - int end = length; - while (true) { - if ((end = format.indexOf('{', start)) > -1) { - output.append(format.substring(start + 1, end)); - if ((start = format.indexOf('}', end)) > -1) { - String s = (String)bindings.get(format.substring(end + 1, start)); - if(s!=null) { - output.append(s); - } else { - // support for removing prefix character if binding is null - int curLength = output.length(); - if(curLength>0) { - char c = output.charAt(curLength - 1); - if(c == KEYWORD_SEPCOLON || c == KEYWORD_SEPAT) { - output.deleteCharAt(curLength - 1); - } - } - } - } else { - output.append(format.substring(end, length)); - break; - } - } else { - output.append(format.substring(start + 1, length)); - break; - } - } - return output.toString(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java deleted file mode 100644 index 414ca7bb6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java +++ /dev/null @@ -1,619 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.util.*; -import java.util.List; - -import org.eclipse.compare.internal.TabFolderLayout; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ui.OverlayIcon; -import org.eclipse.ui.*; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.ide.IDE.SharedImages; - -public class CVSDecoratorPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage { - - private Button imageShowDirty; - private Button imageShowHasRemote; - private Button imageShowAdded; - private Button imageShowNewResource; - - private Text fileTextFormat; - private Text folderTextFormat; - private Text projectTextFormat; - - private Text dirtyFlag; - private Text addedFlag; - - private Button showDirty; - - // Cache for folder images that have been overlayed with sample CVS icons - private Map fgImageCache; - - // Tree that provides a preview of the decorations - private TreeViewer previewTree; - - /** - * Update the preview tree when a theme changes. - */ - private IPropertyChangeListener themeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - previewTree.refresh(true /* update labels */); - } - }; - - /** - * Label provider creates a dummy CVSDecoration using the preferences set - * in this page. The decoration properties are assigned to the different named - * resources in the preview tree so that most of the decoration options - * are shown - */ - private class PreviewLabelProvider extends LabelProvider implements IFontProvider, IColorProvider { - - public Color getBackground(Object element) { - CVSDecoration decoration = getDecoration(element); - return decoration.getBackgroundColor(); - } - - public Color getForeground(Object element) { - CVSDecoration decoration = getDecoration(element); - return decoration.getForegroundColor(); - } - - public Font getFont(Object element) { - CVSDecoration decoration = getDecoration(element); - return decoration.getFont(); - } - - public String getText(Object element) { - CVSDecoration decoration = getDecoration(element); - StringBuffer buffer = new StringBuffer(); - String prefix = decoration.getPrefix(); - if(prefix != null) - buffer.append(prefix); - buffer.append((String)element); - String suffix = decoration.getSuffix(); - if(suffix != null) - buffer.append(suffix); - return buffer.toString(); - } - - public CVSDecoration getDecoration(Object element) { - CVSDecoration decoration = buildDecoration((String)element); - if(element.equals("ignored.txt")) { //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setIgnored(true); - } else if(element.equals("Project")) { //$NON-NLS-1$ - decoration.setResourceType(IResource.PROJECT); - decoration.setHasRemote(true); - decoration.setTag("v1_0"); //$NON-NLS-1$ - } else if(element.equals("Folder")) { //$NON-NLS-1$ - decoration.setHasRemote(true); - decoration.setResourceType(IResource.FOLDER); - decoration.setHasRemote(true); - } else if(element.equals("dirty.cpp")){ //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setDirty(true); - decoration.setHasRemote(true); - } else if(element.equals("added.java")){ //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setAdded(true); - decoration.setDirty(true); - decoration.setHasRemote(false); - } else if(element.equals("todo.txt")){ //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setNewResource(true); - decoration.setDirty(true); - } else if(element.equals("bugs.txt")){ //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setDirty(false); - decoration.setHasRemote(true); - } else if(element.equals("archive.zip")){ //$NON-NLS-1$ - decoration.setResourceType(IResource.FILE); - decoration.setDirty(false); - decoration.setHasRemote(true); - decoration.setKeywordSubstitution(Command.KSUBST_BINARY.getShortDisplayText()); - } - decoration.compute(); - return decoration; - } - - public Image getImage(Object element) { - Image baseImage; - if(element.equals("Project")) { //$NON-NLS-1$ - baseImage= PlatformUI.getWorkbench(). - getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT); - } else if(element.equals("Folder")) { //$NON-NLS-1$ - baseImage= PlatformUI.getWorkbench(). - getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - } else { - baseImage= PlatformUI.getWorkbench(). - getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); - } - CVSDecoration decoration = getDecoration(element); - ImageDescriptor overlay = decoration.getOverlay(); - if(overlay == null) - return baseImage; - - // Otherwise - ImageDescriptor resultImageDescriptor = new OverlayIcon(baseImage, new ImageDescriptor[] {overlay}, new int[] {OverlayIcon.BOTTOM_RIGHT}, new Point(baseImage.getBounds().width, baseImage.getBounds().height)); - if (fgImageCache == null) { - fgImageCache = new HashMap(10); - } - Image image = (Image) fgImageCache.get(overlay); - if (image == null) { - image = resultImageDescriptor.createImage(); - fgImageCache.put(resultImageDescriptor, image); - } - return image; - } - }; - - /** - * Provides a fixed mock resource tree for showing the preview. - */ - private IContentProvider previewContentProvider = new ITreeContentProvider() { - public Object[] getChildren(Object parentElement) { - if(parentElement == ResourcesPlugin.getWorkspace().getRoot()) { - return new String[] { - "Project"}; //$NON-NLS-1$ - } else if(parentElement.equals("Project")) { //$NON-NLS-1$ - return new String[] { - "ignored.txt", //$NON-NLS-1$ - "dirty.cpp", //$NON-NLS-1$ - "added.java", //$NON-NLS-1$ - "todo.txt", //$NON-NLS-1$ - "bugs.txt", //$NON-NLS-1$ - "archive.zip", //$NON-NLS-1$ - "Folder" //$NON-NLS-1$ - }; - } else { - return new Object[0]; - } - } - - public Object getParent(Object element) { - return null; - } - - public boolean hasChildren(Object element) { - if(element.equals("Project") || element == ResourcesPlugin.getWorkspace().getRoot()) //$NON-NLS-1$ - return true; - else - return false; - } - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - public void dispose() { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - }; - - class StringPair { - String s1; - String s2; - } - - class TextPair { - TextPair(Text t1, Text t2) { - this.t1 = t1; - this.t2 = t2; - } - Text t1; - Text t2; - } - - /** - * Constructor for CVSDecoratorPreferencesPage. - */ - public CVSDecoratorPreferencesPage() { - setDescription(Policy.bind("CVSDecoratorPreferencesPage.description")); //$NON-NLS-1$; - } - - protected TextPair createFormatEditorControl(Composite composite, String title, String buttonText, final Map supportedBindings) { - createLabel(composite, title, 1); - Text format = new Text(composite, SWT.BORDER); - format.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - format.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - previewTree.refresh(true); - } - }); - Button b = new Button(composite, SWT.NONE); - b.setText(buttonText); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - b.setLayoutData(data); - final Text formatToInsert = format; - b.addListener(SWT.Selection, new Listener() { - public void handleEvent (Event event) { - addVariables(formatToInsert, supportedBindings); - } - }); - return new TextPair(format, null); - } - - /** - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - - // create a tab folder for the page - TabFolder tabFolder = new TabFolder(parent, SWT.NONE); - tabFolder.setLayout(new TabFolderLayout()); - tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - // text decoration options - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("Text_Labels_12"));//$NON-NLS-1$ - tabItem.setControl(createTextDecoratorPage(tabFolder)); - - // image decoration options - //tabItem = new TabItem(tabFolder, SWT.NONE); - //tabItem.setText(Policy.bind("Icon_Overlays_24"));//$NON-NLS-1$ - //tabItem.setControl(createIconDecoratorPage(tabFolder)); - - // general decoration options - tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(Policy.bind("CVSDecoratorPreferencesPage.generalTabFolder"));//$NON-NLS-1$ - tabItem.setControl(createGeneralDecoratorPage(tabFolder)); - - initializeValues(); - WorkbenchHelp.setHelp(tabFolder, IHelpContextIds.DECORATORS_PREFERENCE_PAGE); - Dialog.applyDialogFont(parent); - - previewTree.setInput(ResourcesPlugin.getWorkspace().getRoot()); - previewTree.expandAll(); - - PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener); - - return tabFolder; - } - - public void dispose() { - PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(themeListener); - } - - private Control createTextDecoratorPage(Composite parent) { - Composite top = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - top.setLayout(layout); - GridData data = new GridData(GridData.FILL, GridData.FILL, true, true); - top.setLayoutData(data); - - Group fileTextGroup = new Group(top, SWT.SHADOW_IN); - fileTextGroup.setText(Policy.bind("CVSDecoratorPreferencePage.1")); //$NON-NLS-1$ - layout = new GridLayout(); - layout.numColumns = 3; - fileTextGroup.setLayout(layout); - data = new GridData(GridData.FILL, GridData.BEGINNING, true, false); - fileTextGroup.setLayoutData(data); - - TextPair format = createFormatEditorControl(fileTextGroup, Policy.bind("&File_Format__14"), Policy.bind("Add_&Variables_15"), getFileBindingDescriptions()); //$NON-NLS-1$ //$NON-NLS-2$ - fileTextFormat = format.t1; - format = createFormatEditorControl(fileTextGroup, Policy.bind("F&older_Format__16"), Policy.bind("Add_Varia&bles_17"), getFolderBindingDescriptions()); //$NON-NLS-1$ //$NON-NLS-2$ - folderTextFormat = format.t1; - format = createFormatEditorControl(fileTextGroup, Policy.bind("&Project_Format__18"), Policy.bind("Add_Variable&s_19"), getFolderBindingDescriptions()); //$NON-NLS-1$ //$NON-NLS-2$ - projectTextFormat = format.t1; - - createLabel(fileTextGroup, Policy.bind("&Label_decoration_for_outgoing__20"), 1); //$NON-NLS-1$ - dirtyFlag = new Text(fileTextGroup, SWT.BORDER); - dirtyFlag.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dirtyFlag.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - previewTree.refresh(true); - } - }); - createLabel(fileTextGroup, "", 1); // spacer //$NON-NLS-1$ - - createLabel(fileTextGroup, Policy.bind("Label_decorat&ion_for_added__22"), 1); //$NON-NLS-1$ - addedFlag = new Text(fileTextGroup, SWT.BORDER); - addedFlag.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - addedFlag.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - previewTree.refresh(true); - } - }); - createLabel(fileTextGroup, "", 1); // spacer //$NON-NLS-1$ - - // ********** - // ICONS - // ********** - - Group iconGroup = new Group(top, SWT.SHADOW_IN); - iconGroup.setText(Policy.bind("Icon_Overlays_24")); //$NON-NLS-1$ - layout = new GridLayout(); - layout.numColumns = 3; - iconGroup.setLayout(layout); - data = data = new GridData(GridData.FILL, GridData.BEGINNING, true, false); - iconGroup.setLayoutData(data); - - createIconDecoratorPage(iconGroup); - - // ********** - // PREVIEW - // ********** - - Group previewGroup = new Group(top, SWT.SHADOW_IN); - previewGroup.setText(Policy.bind("Example__1")); //$NON-NLS-1$ - layout = new GridLayout(); - previewGroup.setLayout(layout); - data = new GridData(GridData.FILL, GridData.FILL, true, true); - previewGroup.setLayoutData(data); - - // Preview Pane - previewTree = new TreeViewer(previewGroup); - data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); - data.horizontalSpan = 2; - data.heightHint = 125; - previewTree.getTree().setLayoutData(data); - previewTree.setContentProvider(previewContentProvider); - previewTree.setLabelProvider(new PreviewLabelProvider()); - return top; - } - - private Control createIconDecoratorPage(Composite parent) { - Composite imageGroup = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - imageGroup.setLayout(layout); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - imageGroup.setLayoutData(data); - - imageShowDirty = createCheckBox(imageGroup, Policy.bind("Sho&w_outgoing_25")); //$NON-NLS-1$ - imageShowHasRemote = createCheckBox(imageGroup, Policy.bind("Show_has_&remote_26")); //$NON-NLS-1$ - imageShowAdded = createCheckBox(imageGroup, Policy.bind("S&how_is_added_27")); //$NON-NLS-1$ - imageShowNewResource = createCheckBox(imageGroup, Policy.bind("CVSDecoratorPreferencesPage.newResources")); //$NON-NLS-1$ - return imageGroup; - } - - private Control createGeneralDecoratorPage(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - createLabel(composite, Policy.bind("CVSDecoratorPreferencesPage.generalDescription"), 1); //$NON-NLS-1$ - showDirty = createCheckBox(composite, Policy.bind("&Compute_deep_outgoing_state_for_folders_(disabling_this_will_improve_decorator_performance)_28")); //$NON-NLS-1$ - return composite; - } - - private Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.BEGINNING; - label.setLayoutData(data); - return label; - } - - private Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK); - button.setText(label); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - previewTree.refresh(true); - } - }); - return button; - } - - /** - * Initializes states of the controls from the preference store. - */ - private void initializeValues() { - IPreferenceStore store = getPreferenceStore(); - - fileTextFormat.setText(store.getString(ICVSUIConstants.PREF_FILETEXT_DECORATION)); - folderTextFormat.setText(store.getString(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION)); - projectTextFormat.setText(store.getString(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION)); - - addedFlag.setText(store.getString(ICVSUIConstants.PREF_ADDED_FLAG)); - dirtyFlag.setText(store.getString(ICVSUIConstants.PREF_DIRTY_FLAG)); - - imageShowDirty.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION)); - imageShowAdded.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION)); - imageShowHasRemote.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION)); - imageShowNewResource.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION)); - - showDirty.setSelection(store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY)); - setValid(true); - } - - /** - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /** - * OK was clicked. Store the CVS preferences. - * - * @return whether it is okay to close the preference page - */ - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - store.setValue(ICVSUIConstants.PREF_FILETEXT_DECORATION, fileTextFormat.getText()); - store.setValue(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION, folderTextFormat.getText()); - store.setValue(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION, projectTextFormat.getText()); - - store.setValue(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText()); - store.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, dirtyFlag.getText()); - - store.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, imageShowDirty.getSelection()); - store.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, imageShowAdded.getSelection()); - store.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, imageShowHasRemote.getSelection()); - store.setValue(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, imageShowNewResource.getSelection()); - - store.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, showDirty.getSelection()); - - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - CVSUIPlugin.getPlugin().savePluginPreferences(); - return true; - } - - /** - * Defaults was clicked. Restore the CVS preferences to - * their default values - */ - protected void performDefaults() { - super.performDefaults(); - IPreferenceStore store = getPreferenceStore(); - - fileTextFormat.setText(store.getDefaultString(ICVSUIConstants.PREF_FILETEXT_DECORATION)); - folderTextFormat.setText(store.getDefaultString(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION)); - projectTextFormat.setText(store.getDefaultString(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION)); - - addedFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_ADDED_FLAG)); - dirtyFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_DIRTY_FLAG)); - - imageShowDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION)); - imageShowAdded.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION)); - imageShowHasRemote.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION)); - imageShowNewResource.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION)); - - showDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY)); - } - - /** - * Returns preference store that belongs to the our plugin. - * This is important because we want to store - * our preferences separately from the desktop. - * - * @return the preference store for this plugin - */ - protected IPreferenceStore doGetPreferenceStore() { - return CVSUIPlugin.getPlugin().getPreferenceStore(); - } - - /** - * Add another project to the list at the end. - */ - private void addVariables(Text target, Map bindings) { - - final List variables = new ArrayList(bindings.size()); - - ILabelProvider labelProvider = new LabelProvider() { - public String getText(Object element) { - return ((StringPair)element).s1 + " - " + ((StringPair)element).s2; //$NON-NLS-1$ - } - }; - - IStructuredContentProvider contentsProvider = new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - return variables.toArray(new StringPair[variables.size()]); - } - public void dispose() {} - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - }; - - for (Iterator it = bindings.keySet().iterator(); it.hasNext();) { - StringPair variable = new StringPair(); - variable.s1 = (String) it.next(); // variable - variable.s2 = (String) bindings.get(variable.s1); // description - variables.add(variable); - } - - ListSelectionDialog dialog = - new ListSelectionDialog( - this.getShell(), - this, - contentsProvider, - labelProvider, - Policy.bind("Select_the_&variables_to_add_to_the_decoration_format__30")); //$NON-NLS-1$ - dialog.setTitle(Policy.bind("Add_Variables_31")); //$NON-NLS-1$ - if (dialog.open() != ListSelectionDialog.OK) - return; - - Object[] result = dialog.getResult(); - - for (int i = 0; i < result.length; i++) { - target.insert("{"+((StringPair)result[i]).s1 +"}"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - protected CVSDecoration buildDecoration(String name) { - Preferences prefs = new Preferences(); - - prefs.setDefault(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, imageShowDirty.getSelection()); - prefs.setDefault(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, imageShowAdded.getSelection()); - prefs.setDefault(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, imageShowHasRemote.getSelection()); - prefs.setDefault(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, imageShowNewResource.getSelection()); - prefs.setDefault(ICVSUIConstants.PREF_CALCULATE_DIRTY, true); - prefs.setDefault(ICVSUIConstants.PREF_DIRTY_FLAG, dirtyFlag.getText()); - prefs.setDefault(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText()); - - CVSDecoration decoration = - new CVSDecoration(name, prefs, fileTextFormat.getText(), folderTextFormat.getText(), projectTextFormat.getText()); - - decoration.setKeywordSubstitution(Command.KSUBST_TEXT.getShortDisplayText()); //$NON-NLS-1$ - decoration.setRevision("1.45"); //$NON-NLS-1$ - try { - decoration.setLocation(CVSRepositoryLocation.fromString(":pserver:alize@cvs.site.org:/home/cvsroot")); //$NON-NLS-1$ - } catch (CVSException e) { - // continue without a location, since the location is hard coded an exception should never occur - } - return decoration; - } - - private Map getFolderBindingDescriptions() { - Map bindings = new HashMap(); - bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, Policy.bind("name_of_the_resource_being_decorated_34")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.RESOURCE_TAG, Policy.bind("the_tag_applied_to_the_resource_(version,_branch,_or_date)_35")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_HOST, Policy.bind("the_repository_location__s_hostname_36")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_METHOD, Policy.bind("the_connection_method_(e.g._pserver,_ssh)_37")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, Policy.bind("user_name_for_the_connection_38")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, Policy.bind("repository_home_directory_on_server_39")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, Policy.bind("root_relative_directory_40")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.DIRTY_FLAG, Policy.bind("flag_indicating_that_the_folder_has_a_child_resource_with_outgoing_changes_41")); //$NON-NLS-1$ - return bindings; - } - - private Map getFileBindingDescriptions() { - Map bindings = new HashMap(); - bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, Policy.bind("name_of_the_resource_being_decorated_42")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.RESOURCE_TAG, Policy.bind("the_tag_applied_to_the_resource_43")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, Policy.bind("keyword_substitution_rule_for_the_resource_44")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.FILE_REVISION, Policy.bind("last_revision_loaded_into_workspace_45")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.DIRTY_FLAG, Policy.bind("flag_indicating_that_the_file_has_outgoing_changes_46")); //$NON-NLS-1$ - bindings.put(CVSDecoratorConfiguration.ADDED_FLAG, Policy.bind("flag_indicating_that_the_file_has_been_added_to_the_server_47")); //$NON-NLS-1$ - return bindings; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFieldEditorPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFieldEditorPreferencePage.java deleted file mode 100644 index 3703a9ca0..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFieldEditorPreferencePage.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * This class acts as an abstract superclass for CVS preference pages that use - * field editors. - */ -public abstract class CVSFieldEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public static IPreferenceStore getCVSPreferenceStore() { - return CVSUIPlugin.getPlugin().getPreferenceStore(); - } - - /** - * Constructor for CVSFieldEditorPreferencePage. - */ - public CVSFieldEditorPreferencePage() { - super(GRID); - setPreferenceStore(getCVSPreferenceStore()); - String description = getPageDescription(); - if (description != null) - setDescription(description); - } - - /** - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control control = super.createContents(parent); - String id = getPageHelpContextId(); - if (id != null) - WorkbenchHelp.setHelp(control, id); - Dialog.applyDialogFont(control); - return control; - } - - /** - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /** - * Method getPageHelpContextId must be overridden by subclasses to provide - * the help context ID of the page. Return null for no page F1 help. - * - * @return String - */ - protected abstract String getPageHelpContextId(); - - /** - * Method getPageDescription must be overridden by subclasses to provide the - * description of the page. Return null for no description. - * @return String - */ - protected abstract String getPageDescription(); - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - if (!super.performOk()) return false; - pushPreferences(); - return true; - } - - /** - * Push the preferences to the Core plugin as required - */ - protected void pushPreferences() { - // Do nothing by default - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java deleted file mode 100644 index b700f744c..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.text.DateFormat; -import java.util.Date; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -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.Label; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.ui.help.WorkbenchHelp; - -public class CVSFilePropertiesPage extends CVSPropertiesPage { - IFile file; - - /* - * @see PreferencesPage#createContents - */ - protected Control createContents(Composite parent) { - initialize(); - noDefaultAndApplyButton(); - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - - try { - ICVSFile cvsResource = CVSWorkspaceRoot.getCVSFileFor(file); - if (!cvsResource.isManaged()) { - if (cvsResource.isIgnored()) { - createLabel(composite, Policy.bind("CVSFilePropertiesPage.ignored")); //$NON-NLS-1$ - } else { - createLabel(composite, Policy.bind("CVSFilePropertiesPage.notManaged")); //$NON-NLS-1$ - } - createLabel(composite, ""); //$NON-NLS-1$ - return composite; - } - ResourceSyncInfo syncInfo = cvsResource.getSyncInfo(); - - - - if (syncInfo.isAdded()) { - createLabel(composite, Policy.bind("CVSFilePropertiesPage.isAdded"), 2); //$NON-NLS-1$ - } else { - // Base - createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseRevision")); //$NON-NLS-1$ - createLabel(composite, syncInfo.getRevision()); - Date baseTime = syncInfo.getTimeStamp(); - if (baseTime != null) { - createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseTimestamp")); //$NON-NLS-1$ - createLabel(composite, DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(syncInfo.getTimeStamp())); - } - - // Modified - createLabel(composite, Policy.bind("CVSFilePropertiesPage.modified")); //$NON-NLS-1$ - createLabel(composite, cvsResource.isModified(null) ? Policy.bind("yes") : Policy.bind("no")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Keyword Mode - createLabel(composite, Policy.bind("CVSFilePropertiesPage.keywordMode")); //$NON-NLS-1$ - createLabel(composite, syncInfo.getKeywordMode().getLongDisplayText()); - - // Tag - createLabel(composite, Policy.bind("CVSFilePropertiesPage.tag")); //$NON-NLS-1$ - CVSTag tag = Util.getAccurateFileTag(cvsResource); - createLabel(composite, getTagLabel(tag)); - - // Permissions - createLabel(composite, Policy.bind("CVSFilePropertiesPage.permissions")); //$NON-NLS-1$ - String permissions = syncInfo.getPermissions(); - if (permissions == null) { - createLabel(composite, Policy.bind("CVSFilePropertiesPage.notAvailable")); //$NON-NLS-1$ - } else { - createLabel(composite, syncInfo.getPermissions()); - } - } catch (TeamException e) { - // Display error text - createLabel(composite, Policy.bind("CVSFilePropertiesPage.error")); //$NON-NLS-1$ - createLabel(composite, ""); //$NON-NLS-1$ - } - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.FILE_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - protected Label createLabel(Composite parent, String text) { - return createLabel(parent, text, 1); - } - /** - * Initializes the page - */ - private void initialize() { - // Get the file that is the source of this property page - file = null; - IAdaptable element = getElement(); - if (element instanceof IFile) { - file = (IFile)element; - } else { - Object adapter = element.getAdapter(IFile.class); - if (adapter instanceof IFile) { - file = (IFile)adapter; - } - } - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java deleted file mode 100644 index 400465eb8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.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.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; - -public class CVSFolderPropertiesPage extends CVSPropertiesPage { - - IFolder folder; - private Label root; - private Label repository; - - /** - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - initialize(); - noDefaultAndApplyButton(); - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - - try { - ICVSFolder cvsResource = CVSWorkspaceRoot.getCVSFolderFor(folder); - if (!cvsResource.isManaged()) { - if (cvsResource.isIgnored()) { - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.ignored"), 2); //$NON-NLS-1$ - } else { - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.notManaged"), 2); //$NON-NLS-1$ - } - } else if (!cvsResource.isCVSFolder()) { - // We have a managed folder which is not a cvs folder. - // This is really an invalid state but it does happen once in a while - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.notCVSFolder"), 2); //$NON-NLS-1$ - } else { - FolderSyncInfo syncInfo = cvsResource.getFolderSyncInfo(); - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.root")); //$NON-NLS-1$ - root = createLabel(composite, syncInfo.getRoot()); - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.repository")); //$NON-NLS-1$ - repository = createLabel(composite, syncInfo.getRepository()); - - // Tag - createLabel(composite, Policy.bind("CVSFilePropertiesPage.tag")); //$NON-NLS-1$ - CVSTag tag = syncInfo.getTag(); - - if (tag != null && tag.getType() == CVSTag.BRANCH) { - tag = Util.getAccurateFolderTag(folder, tag); - } - - createLabel(composite, getTagLabel(tag)); - - // Static-ness - if (syncInfo.getIsStatic()) { - createLabel(composite, Policy.bind("CVSFolderPropertiesPage.static")); //$NON-NLS-1$ - createLabel(composite, syncInfo.getIsStatic() ? Policy.bind("yes") : Policy.bind("no")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - createLabel(composite, "", 2); // spacer //$NON-NLS-1$ - - // Allow the folder to be disconnected from CVS control - final Button disconnect = new Button(composite, SWT.NONE); - disconnect.setText(Policy.bind("CVSFolderPropertiesPage.disconnect")); //$NON-NLS-1$ - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - data.widthHint = Math.max(widthHint, disconnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - disconnect.setLayoutData(data); - disconnect.addListener(SWT.Selection, new Listener() { - public void handleEvent (Event event) { - // perform a disconnect - if (disconnectFolder()) { - root.setText(Policy.bind("CVSFilePropertiesPage.none")); //$NON-NLS-1$ - repository.setText(Policy.bind("CVSFilePropertiesPage.none")); //$NON-NLS-1$ - disconnect.setEnabled(false); - } - } - }); - } - } catch (TeamException e) { - // Display error text - createLabel(composite, Policy.bind("CVSFilePropertiesPage.error"), 2); //$NON-NLS-1$ - } - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.FOLDER_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - protected Label createLabel(Composite parent, String text) { - return createLabel(parent, text, 1); - } - /** - * Initializes the page - */ - private void initialize() { - // Get the file that is the source of this property page - folder = null; - IAdaptable element = getElement(); - if (element instanceof IFolder) { - folder = (IFolder)element; - } else { - Object adapter = element.getAdapter(IFolder.class); - if (adapter instanceof IFolder) { - folder = (IFolder)adapter; - } - } - } - - private boolean disconnectFolder() { - if (MessageDialog.openQuestion(getShell(), Policy.bind("CVSFolderPropertiesPage.disconnectTitle"), Policy.bind("CVSFolderPropertiesPage.disconnectQuestion"))) { //$NON-NLS-1$ //$NON-NLS-2$ - final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); - try { - PlatformUI.getWorkbench().getProgressService().run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - cvsFolder.unmanage(null); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - return false; - } catch (InterruptedException e) { - // Ignore - } - return true; - } else { - return false; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java deleted file mode 100644 index 1408a89f2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java +++ /dev/null @@ -1,452 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.text.SimpleDateFormat; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners; -import org.eclipse.team.internal.core.ExceptionCollector; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.themes.ITheme; -import org.osgi.framework.Bundle; - -public class CVSLightweightDecorator extends LabelProvider implements ILightweightLabelDecorator, IResourceStateChangeListener, IPropertyChangeListener { - - // Decorator id as defined in the decorator extension point - public final static String ID = "org.eclipse.team.cvs.ui.decorator"; //$NON-NLS-1$ - - private static ExceptionCollector exceptions = new ExceptionCollector(Policy.bind("CVSDecorator.exceptionMessage"), CVSUIPlugin.ID, IStatus.ERROR, CVSUIPlugin.getPlugin().getLog()); //$NON-NLS-1$; - - private static String DECORATOR_FORMAT = "yyyy/MM/dd HH:mm:ss"; //$NON-NLS-1$ - private static SimpleDateFormat decorateFormatter = new SimpleDateFormat(DECORATOR_FORMAT, Locale.getDefault()); - - private static String[] fonts = new String[] { - CVSDecoratorConfiguration.IGNORED_FONT, - CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT}; - - private static String[] colors = new String[] { - CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR, - CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR, - CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR, - CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR}; - - public CVSLightweightDecorator() { - ResourceStateChangeListeners.getListener().addResourceStateChangeListener(this); - TeamUI.addPropertyChangeListener(this); - CVSUIPlugin.addPropertyChangeListener(this); - - // This is an optimization to ensure that while decorating our fonts and colors are - // pre-created and decoration can occur without having to syncExec. - ensureFontAndColorsCreated(fonts, colors); - - PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().addPropertyChangeListener(this); - CVSProviderPlugin.broadcastDecoratorEnablementChanged(true /* enabled */); - } - - /** - * This method will ensure that the fonts and colors used by the decorator - * are cached in the registries. This avoids having to syncExec when - * decorating since we ensure that the fonts and colors are pre-created. - * - * @param fonts fonts ids to cache - * @param colors color ids to cache - */ - private void ensureFontAndColorsCreated(final String[] fonts, final String[] colors) { - CVSUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); - for (int i = 0; i < colors.length; i++) { - theme.getColorRegistry().get(colors[i]); - - } - for (int i = 0; i < fonts.length; i++) { - theme.getFontRegistry().get(fonts[i]); - } - } - }); - } - - public static boolean isDirty(final ICVSResource cvsResource) throws CVSException { - return !cvsResource.isIgnored() && cvsResource.isModified(null); - } - - public static boolean isDirty(IResource resource) { - - // No need to decorate non-existant resources - if (!resource.exists()) return false; - - try { - return isDirty(CVSWorkspaceRoot.getCVSResourceFor(resource)); - } catch (CVSException e) { - //if we get an error report it to the log but assume dirty. - boolean accessible = resource.getProject().isAccessible(); - if (accessible) { - // We only care about the failure if the project is open - handleException(e); - } - // Return dirty if the project is open and clean otherwise - return accessible; - } - - } - - /* - * Answers null if a provider does not exist or the provider is not a CVS provider. These resources - * will be ignored by the decorator. - */ - private CVSTeamProvider getCVSProviderFor(IResource resource) { - RepositoryProvider p = - RepositoryProvider.getProvider( - resource.getProject(), - CVSProviderPlugin.getTypeId()); - if (p == null) { - return null; - } - return (CVSTeamProvider) p; - } - - /** - * Returns the resource for the given input object, or - * null if there is no resource associated with it. - * - * @param object the object to find the resource for - * @return the resource for the given object, or null - */ - private IResource getResource(Object object) { - if (object instanceof IResource) { - return (IResource) object; - } - if (object instanceof IAdaptable) { - return (IResource) ((IAdaptable) object).getAdapter( - IResource.class); - } - return null; - } - - /** - * This method should only be called by the decorator thread. - * - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) - */ - public void decorate(Object element, IDecoration decoration) { - IResource resource = getResource(element); - if (resource == null || resource.getType() == IResource.ROOT) - return; - - CVSTeamProvider cvsProvider = getCVSProviderFor(resource); - if (cvsProvider == null) - return; - - try { - CVSDecoration cvsDecoration = decorate(resource); - cvsDecoration.setWatchEditEnabled(cvsProvider.isWatchEditEnabled()); - cvsDecoration.apply(decoration); - } catch(CVSException e) { - handleException(e); - } catch (IllegalStateException e) { - // This is thrown by Core if the workspace is in an illegal state - // If we are not active, ignore it. Otherwise, propogate it. - // (see bug 78303) - if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { - throw e; - } - } - } - - public static CVSDecoration decorate(IResource resource) throws CVSException { - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - CVSDecoration cvsDecoration = new CVSDecoration(resource.getName()); - cvsDecoration.setResourceType(resource.getType()); - - if (cvsResource.isIgnored()) { - cvsDecoration.setIgnored(true); - } - if (!cvsDecoration.isIgnored()) { - // Dirty - boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); - int type = resource.getType(); - if (type == IResource.FILE || computeDeepDirtyCheck) { - cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource)); - } - // Tag - CVSTag tag = getTagToShow(resource); - if (tag != null) { - String name = tag.getName(); - if (tag.getType() == CVSTag.DATE) { - Date date = tag.asDate(); - if (date != null) { - name = decorateFormatter.format(date); - } - } - cvsDecoration.setTag(name); - } - // Has a remote - cvsDecoration.setHasRemote(CVSWorkspaceRoot.hasRemote(resource)); - // Is a new resource - if (store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION)) { - if (cvsResource.exists()) { - if (cvsResource.isFolder()) { - if (!((ICVSFolder) cvsResource).isCVSFolder()) { - cvsDecoration.setNewResource(true); - } - } else if (!cvsResource.isManaged()) { - cvsDecoration.setNewResource(true); - } - } - } - } - // Extract type specific properties - if (resource.getType() == IResource.FILE) { - extractFileProperties((IFile) resource, cvsDecoration); - } else { - extractContainerProperties((IContainer) resource, cvsDecoration); - } - return cvsDecoration; - } - - private static void extractContainerProperties(IContainer resource, CVSDecoration cvsDecoration) throws CVSException { - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource); - FolderSyncInfo folderInfo = folder.getFolderSyncInfo(); - if (folderInfo != null) { - cvsDecoration.setLocation(KnownRepositories.getInstance().getRepository(folderInfo.getRoot())); - cvsDecoration.setRepository(folderInfo.getRepository()); - cvsDecoration.setVirtualFolder(folderInfo.isVirtualDirectory()); - } - } - - private static void extractFileProperties(IFile resource, CVSDecoration cvsDecoration) throws CVSException { - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(resource); - ResourceSyncInfo fileInfo = file.getSyncInfo(); - KSubstOption option = KSubstOption.fromFile((IFile) resource); - if (fileInfo != null) { - cvsDecoration.setAdded(fileInfo.isAdded()); - cvsDecoration.setRevision(fileInfo.getRevision()); - cvsDecoration.setReadOnly(file.isReadOnly()); - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource); - cvsDecoration.setNeedsMerge(fileInfo.isNeedsMerge(file.getTimeStamp())); - option = fileInfo.getKeywordMode(); - } - cvsDecoration.setKeywordSubstitution(option.getShortDisplayText()); - } - - /** - * Only show the tag if the resources tag is different than the parents. Or else, tag - * names will clutter the text decorations. - */ - protected static CVSTag getTagToShow(IResource resource) throws CVSException { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - CVSTag tag = null; - - // for unmanaged resources don't show a tag since they will be added in - // the context of their parents tag. For managed resources only show tags - // if different than parent. - boolean managed = false; - - if(cvsResource.isFolder()) { - FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - if(folderInfo != null) { - tag = folderInfo.getTag(); - managed = true; - } - } else { - ResourceSyncInfo info = ((ICVSFile)cvsResource).getSyncInfo(); - if(info != null) { - tag = info.getTag(); - managed = true; - } - } - - ICVSFolder parent = cvsResource.getParent(); - if(parent != null && managed) { - FolderSyncInfo parentInfo = parent.getFolderSyncInfo(); - if(parentInfo != null) { - CVSTag parentTag = parentInfo.getTag(); - parentTag = (parentTag == null ? CVSTag.DEFAULT : parentTag); - tag = (tag == null ? CVSTag.DEFAULT : tag); - // must compare tags by name because CVS doesn't do a good job of - // using T and N prefixes for folders and files. - if( parentTag.getName().equals(tag.getName())) { - tag = null; - } - } - } - return tag; - } - - /* - * Add resource and its parents to the List - */ - - private void addWithParents(IResource resource, Set resources) { - IResource current = resource; - - while (current.getType() != IResource.ROOT) { - resources.add(current); - current = current.getParent(); - } - } - - /* - * Perform a blanket refresh of all CVS decorations - */ - public static void refresh() { - CVSUIPlugin.getPlugin().getWorkbench().getDecoratorManager().update(CVSUIPlugin.DECORATOR_ID); - } - - /* - * Update the decorators for every resource in project - */ - - public void refresh(IProject project) { - final List resources = new ArrayList(); - try { - project.accept(new IResourceVisitor() { - public boolean visit(IResource resource) { - resources.add(resource); - return true; - } - }); - postLabelEvent(new LabelProviderChangedEvent(this, resources.toArray())); - } catch (CoreException e) { - handleException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[]) - */ - public void resourceSyncInfoChanged(IResource[] changedResources) { - resourceStateChanged(changedResources); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#externalSyncInfoChange(org.eclipse.core.resources.IResource[]) - */ - public void externalSyncInfoChange(IResource[] changedResources) { - resourceStateChanged(changedResources); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceModificationStateChanged(org.eclipse.core.resources.IResource[]) - */ - public void resourceModified(IResource[] changedResources) { - resourceStateChanged(changedResources); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceStateChanged(org.eclipse.core.resources.IResource[]) - */ - public void resourceStateChanged(IResource[] changedResources) { - // add depth first so that update thread processes parents first. - //System.out.println(">> State Change Event"); - Set resourcesToUpdate = new HashSet(); - - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - boolean showingDeepDirtyIndicators = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); - - for (int i = 0; i < changedResources.length; i++) { - IResource resource = changedResources[i]; - - if(showingDeepDirtyIndicators) { - addWithParents(resource, resourcesToUpdate); - } else { - resourcesToUpdate.add(resource); - } - } - - postLabelEvent(new LabelProviderChangedEvent(this, resourcesToUpdate.toArray())); - } - - /** - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectConfigured(org.eclipse.core.resources.IProject) - */ - public void projectConfigured(IProject project) { - refresh(project); - } - /** - * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectDeconfigured(org.eclipse.core.resources.IProject) - */ - public void projectDeconfigured(IProject project) { - refresh(project); - } - - /** - * Post the label event to the UI thread - * - * @param events the events to post - */ - private void postLabelEvent(final LabelProviderChangedEvent event) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - fireLabelProviderChanged(event); - } - }); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - super.dispose(); - PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().removePropertyChangeListener(this); - CVSProviderPlugin.broadcastDecoratorEnablementChanged(false /* disabled */); - TeamUI.removePropertyChangeListener(this); - CVSUIPlugin.removePropertyChangeListener(this); - } - - /** - * Handle exceptions that occur in the decorator. - */ - private static void handleException(Exception e) { - exceptions.handleException(e); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (isEventOfInterest(event)) { - ensureFontAndColorsCreated(fonts, colors); - refresh(); - } - } - - private boolean isEventOfInterest(PropertyChangeEvent event) { - String prop = event.getProperty(); - return prop.equals(TeamUI.GLOBAL_IGNORES_CHANGED) - || prop.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED) - || prop.equals(CVSUIPlugin.P_DECORATORS_CHANGED) - || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR) - || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR) - || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT) - || prop.equals(CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR) - || prop.equals(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR) - || prop.equals(CVSDecoratorConfiguration.IGNORED_FONT); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java deleted file mode 100644 index 99ace83e2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.team.internal.ccvs.ui.repo.*; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.ui.*; - -public class CVSPerspective implements IPerspectiveFactory { - - public final static String ID = "org.eclipse.team.cvs.ui.cvsPerspective"; //$NON-NLS-1$ - - /* (Non-javadoc) - * Method declared on IPerpsectiveFactory - */ - public void createInitialLayout(IPageLayout layout) { - defineActions(layout); - defineLayout(layout); - } - - /** - * Defines the initial actions for a page. - */ - public void defineActions(IPageLayout layout) { - - // Add "new wizards". - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.project"); //$NON-NLS-1$ - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder"); //$NON-NLS-1$ - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file"); //$NON-NLS-1$ - - // Add "show views". - layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); - layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); - layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); - layout.addShowViewShortcut(HistoryView.VIEW_ID); - layout.addShowViewShortcut(RepositoriesView.VIEW_ID); - layout.addShowViewShortcut(ISynchronizeView.VIEW_ID); - - // Add "perspective short cut" - layout.addPerspectiveShortcut("org.eclipse.ui.resourcePerspective"); //$NON-NLS-1$ - layout.addPerspectiveShortcut("org.eclipse.team.ui.TeamSynchronizingPerspective"); //$NON-NLS-1$ - } - - /** - * Defines the initial layout for a page. - */ - public void defineLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - IFolderLayout top = - layout.createFolder("top", IPageLayout.LEFT, 0.40f, editorArea); //$NON-NLS-1$ - top.addView(RepositoriesView.VIEW_ID); - layout.addView(HistoryView.VIEW_ID, IPageLayout.BOTTOM, 0.70f, editorArea); - layout.setEditorAreaVisible(true); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java deleted file mode 100644 index d9cba7fbf..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java +++ /dev/null @@ -1,477 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.team.internal.ccvs.ui; - -import java.util.*; -import java.util.List; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * CVS Preference Page - * - * Allows the configuration of CVS specific options. - * The currently supported options are: - * - Allow loading of CVS administration directory (CVSROOT) - * - * There are currently a couple of deficiencies: - * 1. The Repository view is not refreshed when the show CVSROOT option is changed - * 2. There is no help associated with the page - */ -public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage { - - private Button pruneEmptyDirectoriesField; - private Text timeoutValue; - private Combo quietnessCombo; - private Combo compressionLevelCombo; - private Combo ksubstCombo; - private Button usePlatformLineend; - private List ksubstOptions; - private Button replaceUnmanaged; - private Button repositoriesAreBinary; - private Button determineVersionEnabled; - private Button confirmMoveTag; - private Button debugProtocol; - - private Button never; - private Button prompt; - private Button auto; - - public CVSPreferencesPage() { - // sort the options by display text - setDescription(Policy.bind("CVSPreferencePage.description")); //$NON-NLS-1$ - KSubstOption[] options = KSubstOption.getAllKSubstOptions(); - this.ksubstOptions = new ArrayList(); - for (int i = 0; i < options.length; i++) { - KSubstOption option = options[i]; - if (! option.isBinary()) { - ksubstOptions.add(option); - } - } - Collections.sort(ksubstOptions, new Comparator() { - public int compare(Object a, Object b) { - String aKey = ((KSubstOption) a).getLongDisplayText(); - String bKey = ((KSubstOption) b).getLongDisplayText(); - return aKey.compareTo(bKey); - } - }); - } - - /** - * Utility method that creates a combo box - * - * @param parent the parent for the new label - * @return the new widget - */ - protected Combo createCombo(Composite parent, int widthChars) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - GC gc = new GC(combo); - gc.setFont(combo.getFont()); - FontMetrics fontMetrics = gc.getFontMetrics(); - data.widthHint = Dialog.convertWidthInCharsToPixels(fontMetrics, widthChars); - gc.dispose(); - combo.setLayoutData(data); - return combo; - } - - /** - * Utility method that creates a combo box - * - * @param parent the parent for the new label - * @return the new widget - */ - protected Combo createCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - combo.setLayoutData(data); - return combo; - } - - /** - * Creates composite control and sets the default layout data. - * - * @param parent the parent of the new composite - * @param numColumns the number of columns for the new composite - * @return the newly-created coposite - */ - private Composite createComposite(Composite parent, int numColumns) { - Composite composite = new Composite(parent, SWT.NULL); - - //GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - layout.marginWidth = 0; - layout.marginHeight = 0; - composite.setLayout(layout); - - //GridData - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - return composite; - } - - /** - * Creates an new checkbox instance and sets the default - * layout data. - * - * @param group the composite in which to create the checkbox - * @param label the string to set into the checkbox - * @return the new checkbox - */ - private Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = 2; - button.setLayoutData(data); - return button; - } - - /** - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite composite = createComposite(parent, 2); - - pruneEmptyDirectoriesField = createCheckBox(composite, Policy.bind("CVSPreferencePage.pruneEmptyDirectories")); //$NON-NLS-1$ - replaceUnmanaged = createCheckBox(composite, Policy.bind("CVSPreferencePage.replaceUnmanaged")); //$NON-NLS-1$ - repositoriesAreBinary = createCheckBox(composite, Policy.bind("CVSPreferencePage.repositoriesAreBinary")); //$NON-NLS-1$ - determineVersionEnabled = createCheckBox(composite, Policy.bind("CVSPreferencePage.determineVersionEnabled")); //$NON-NLS-1$ - confirmMoveTag = createCheckBox(composite, Policy.bind("CVSPreferencePage.confirmMoveTag")); //$NON-NLS-1$ - debugProtocol = createCheckBox(composite, Policy.bind("CVSPreferencePage.debugProtocol")); //$NON-NLS-1$ - usePlatformLineend = createCheckBox(composite, Policy.bind("CVSPreferencePage.lineend")); //$NON-NLS-1$ - - createLabel(composite, ""); createLabel(composite, ""); //$NON-NLS-1$ //$NON-NLS-2$ - - createLabel(composite, Policy.bind("CVSPreferencePage.timeoutValue")); //$NON-NLS-1$ - timeoutValue = createTextField(composite); - timeoutValue.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - // Parse the timeout value - try { - int x = Integer.parseInt(timeoutValue.getText()); - if (x >= 0) { - setErrorMessage(null); - setValid(true); - } else { - setErrorMessage(Policy.bind("CVSPreferencesPage.Timeout_must_not_be_negative_1")); //$NON-NLS-1$ - setValid(false); - } - } catch (NumberFormatException ex) { - setErrorMessage(Policy.bind("CVSPreferencesPage.Timeout_must_be_a_number_2")); //$NON-NLS-1$ - setValid(false); - } - } - }); - - createLabel(composite, Policy.bind("CVSPreferencePage.quietness")); //$NON-NLS-1$ - quietnessCombo = createCombo(composite); - - createLabel(composite, Policy.bind("CVSPreferencePage.compressionLevel")); //$NON-NLS-1$ - compressionLevelCombo = createCombo(composite); - - createLabel(composite, Policy.bind("CVSPreferencePage.defaultTextKSubst")); //$NON-NLS-1$ - int chars = 0; - for (Iterator it = ksubstOptions.iterator(); it.hasNext();) { - KSubstOption option = (KSubstOption) it.next(); - int c = option.getLongDisplayText().length(); - if(c > chars) { - chars = c; - } - } - ksubstCombo = createCombo(composite, chars); - - createLabel(composite, ""); createLabel(composite, ""); //$NON-NLS-1$ //$NON-NLS-2$ - - createSaveCombo(composite); - - initializeValues(); - - quietnessCombo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (getQuietnessOptionFor(quietnessCombo.getSelectionIndex()).equals(Command.SILENT)) { - MessageDialog.openWarning(getShell(), Policy.bind("CVSPreferencePage.silentWarningTitle"), Policy.bind("CVSPreferencePage.silentWarningMessage")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - WorkbenchHelp.setHelp(pruneEmptyDirectoriesField, IHelpContextIds.PREF_PRUNE); - WorkbenchHelp.setHelp(compressionLevelCombo, IHelpContextIds.PREF_COMPRESSION); - WorkbenchHelp.setHelp(quietnessCombo, IHelpContextIds.PREF_QUIET); - WorkbenchHelp.setHelp(ksubstCombo, IHelpContextIds.PREF_KEYWORDMODE); - WorkbenchHelp.setHelp(usePlatformLineend, IHelpContextIds.PREF_LINEEND); - WorkbenchHelp.setHelp(timeoutValue, IHelpContextIds.PREF_COMMS_TIMEOUT); - WorkbenchHelp.setHelp(replaceUnmanaged, IHelpContextIds.PREF_REPLACE_DELETE_UNMANAGED); - WorkbenchHelp.setHelp(repositoriesAreBinary, IHelpContextIds.PREF_TREAT_NEW_FILE_AS_BINARY); - WorkbenchHelp.setHelp(determineVersionEnabled, IHelpContextIds.PREF_DETERMINE_SERVER_VERSION); - WorkbenchHelp.setHelp(confirmMoveTag, IHelpContextIds.PREF_CONFIRM_MOVE_TAG); - Dialog.applyDialogFont(parent); - return composite; - } - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - private Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - /** - * Creates an new text widget and sets the default - * layout data. - * - * @param group the composite in which to create the checkbox - * @return the new text widget - */ - private Text createTextField(Composite group) { - Text text = new Text(group, SWT.BORDER); - text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - return text; - } - /** - * Initializes states of the controls from the preference store. - */ - private void initializeValues() { - IPreferenceStore store = getPreferenceStore(); - pruneEmptyDirectoriesField.setSelection(store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); - timeoutValue.setText(new Integer(store.getInt(ICVSUIConstants.PREF_TIMEOUT)).toString()); - repositoriesAreBinary.setSelection(store.getBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); - quietnessCombo.add(Policy.bind("CVSPreferencePage.notquiet")); //$NON-NLS-1$ - quietnessCombo.add(Policy.bind("CVSPreferencePage.somewhatquiet")); //$NON-NLS-1$ - quietnessCombo.add(Policy.bind("CVSPreferencePage.reallyquiet")); //$NON-NLS-1$ - quietnessCombo.select(store.getInt(ICVSUIConstants.PREF_QUIETNESS)); - for (int i = 0; i < 10; ++i) { - compressionLevelCombo.add(Policy.bind("CVSPreferencePage.level" + i)); //$NON-NLS-1$ - } - compressionLevelCombo.select(store.getInt(ICVSUIConstants.PREF_COMPRESSION_LEVEL)); - for (Iterator it = ksubstOptions.iterator(); it.hasNext();) { - KSubstOption option = (KSubstOption) it.next(); - ksubstCombo.add(option.getLongDisplayText()); - } - ksubstCombo.select(getKSubstComboIndexFor(store.getString(ICVSUIConstants.PREF_TEXT_KSUBST))); - usePlatformLineend.setSelection(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); - replaceUnmanaged.setSelection(store.getBoolean(ICVSUIConstants.PREF_REPLACE_UNMANAGED)); - determineVersionEnabled.setSelection(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); - confirmMoveTag.setSelection(store.getBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG)); - debugProtocol.setSelection(store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); - - initializeSaveRadios(store.getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS)); - } - - /** - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /** - * OK was clicked. Store the CVS preferences. - * - * @return whether it is okay to close the preference page - */ - public boolean performOk() { - - // Parse the timeout value - int timeout = Integer.parseInt(timeoutValue.getText()); - - IPreferenceStore store = getPreferenceStore(); - - // set the provider preferences first because the preference change - // listeners invoked from the preference store change may need these - // values - - store.setValue(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES, pruneEmptyDirectoriesField.getSelection()); - store.setValue(ICVSUIConstants.PREF_TIMEOUT, timeout); - store.setValue(ICVSUIConstants.PREF_QUIETNESS, quietnessCombo.getSelectionIndex()); - store.setValue(ICVSUIConstants.PREF_COMPRESSION_LEVEL, compressionLevelCombo.getSelectionIndex()); - // Text mode processed separately to avoid empty string in properties file. - String mode =((KSubstOption)ksubstOptions.get(ksubstCombo.getSelectionIndex())).toMode(); - if (mode.length() == 0) { - mode = "-kkv"; //$NON-NLS-1$ - } - store.setValue(ICVSUIConstants.PREF_TEXT_KSUBST, mode); - store.setValue(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND, usePlatformLineend.getSelection()); - store.setValue(ICVSUIConstants.PREF_REPLACE_UNMANAGED, replaceUnmanaged.getSelection()); - store.setValue(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS, getSaveRadio()); - store.setValue(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY, repositoriesAreBinary.getSelection()); - store.setValue(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION, determineVersionEnabled.getSelection()); - store.setValue(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, confirmMoveTag.getSelection()); - store.setValue(ICVSUIConstants.PREF_DEBUG_PROTOCOL, debugProtocol.getSelection()); - - CVSProviderPlugin.getPlugin().setReplaceUnmanaged( - store.getBoolean(ICVSUIConstants.PREF_REPLACE_UNMANAGED)); - CVSProviderPlugin.getPlugin().setPruneEmptyDirectories( - store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); - CVSProviderPlugin.getPlugin().setTimeout( - store.getInt(ICVSUIConstants.PREF_TIMEOUT)); - CVSProviderPlugin.getPlugin().setQuietness( - getQuietnessOptionFor(store.getInt(ICVSUIConstants.PREF_QUIETNESS))); - CVSProviderPlugin.getPlugin().setCompressionLevel( - store.getInt(ICVSUIConstants.PREF_COMPRESSION_LEVEL)); - CVSProviderPlugin.getPlugin().setDebugProtocol( - store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); - CVSProviderPlugin.getPlugin().setRepositoriesAreBinary(store.getBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); - KSubstOption oldKSubst = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - KSubstOption newKSubst = KSubstOption.fromMode(store.getString(ICVSUIConstants.PREF_TEXT_KSUBST)); - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(newKSubst); - CVSProviderPlugin.getPlugin().setUsePlatformLineend( - store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); - CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); - CVSProviderPlugin.getPlugin().setConfirmMoveTagEnabled(store.getBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG)); - - // changing the default keyword substitution mode for text files may affect - // information displayed in the decorators - if (! oldKSubst.equals(newKSubst)) { - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - } - - CVSUIPlugin.getPlugin().savePluginPreferences(); - return true; - } - - /** - * Defaults was clicked. Restore the CVS preferences to - * their default values - */ - protected void performDefaults() { - super.performDefaults(); - IPreferenceStore store = getPreferenceStore(); - pruneEmptyDirectoriesField.setSelection( - store.getDefaultBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); - timeoutValue.setText(new Integer(store.getDefaultInt(ICVSUIConstants.PREF_TIMEOUT)).toString()); - quietnessCombo.select(store.getDefaultInt(ICVSUIConstants.PREF_QUIETNESS)); - compressionLevelCombo.select(store.getDefaultInt(ICVSUIConstants.PREF_COMPRESSION_LEVEL)); - ksubstCombo.select(getKSubstComboIndexFor(store.getDefaultString(ICVSUIConstants.PREF_TEXT_KSUBST))); - usePlatformLineend.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); - replaceUnmanaged.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_REPLACE_UNMANAGED)); - initializeSaveRadios(store.getDefaultInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS)); - repositoriesAreBinary.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); - confirmMoveTag.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG)); - debugProtocol.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); - } - - private void createSaveCombo(Composite composite) { - Group group = new Group(composite, SWT.NULL); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 2; - group.setLayoutData(data); - GridLayout layout = new GridLayout(); - group.setLayout(layout); - group.setText(Policy.bind("CVSPreferencePage.Save_dirty_editors_before_CVS_operations_1")); //$NON-NLS-1$ - - never = new Button(group, SWT.RADIO | SWT.LEFT); - never.setLayoutData(new GridData()); - never.setText(Policy.bind("CVSPreferencePage.&Never_2")); //$NON-NLS-1$ - - prompt = new Button(group, SWT.RADIO | SWT.LEFT); - prompt.setLayoutData(new GridData()); - prompt.setText(Policy.bind("CVSPreferencePage.&Prompt_3")); //$NON-NLS-1$ - - auto = new Button(group, SWT.RADIO | SWT.LEFT); - auto.setLayoutData(new GridData()); - auto.setText(Policy.bind("CVSPreferencePage.Auto-&save_4")); //$NON-NLS-1$ - - WorkbenchHelp.setHelp(group, IHelpContextIds.PREF_SAVE_DIRTY_EDITORS); - } - - /** - * Returns preference store that belongs to the our plugin. - * This is important because we want to store - * our preferences separately from the desktop. - * - * @return the preference store for this plugin - */ - protected IPreferenceStore doGetPreferenceStore() { - return CVSUIPlugin.getPlugin().getPreferenceStore(); - } - - protected static QuietOption getQuietnessOptionFor(int option) { - switch (option) { - case 0: return Command.VERBOSE; - case 1: return Command.PARTLY_QUIET; - case 2: return Command.SILENT; - } - return null; - } - - protected int getKSubstComboIndexFor(String mode) { - KSubstOption ksubst = KSubstOption.fromMode(mode); - int i = 0; - for (Iterator it = ksubstOptions.iterator(); it.hasNext();) { - KSubstOption option = (KSubstOption) it.next(); - if (ksubst.equals(option)) return i; - i++; - } - // unknown option, add it to the list - ksubstOptions.add(ksubst); - ksubstCombo.add(ksubst.getLongDisplayText()); - return i; - } - - protected void initializeSaveRadios(int option) { - auto.setSelection(false); - never.setSelection(false); - prompt.setSelection(false); - switch(option) { - case ICVSUIConstants.OPTION_AUTOMATIC: - auto.setSelection(true); break; - case ICVSUIConstants.OPTION_NEVER: - never.setSelection(true); break; - case ICVSUIConstants.OPTION_PROMPT: - prompt.setSelection(true); break; - } - } - - protected int getSaveRadio() { - if(auto.getSelection()) { - return ICVSUIConstants.OPTION_AUTOMATIC; - } else if(never.getSelection()) { - return ICVSUIConstants.OPTION_NEVER; - } else { - return ICVSUIConstants.OPTION_PROMPT; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java deleted file mode 100644 index e4948bf04..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java +++ /dev/null @@ -1,473 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; -import org.eclipse.team.internal.ccvs.core.IUserInfo; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.team.internal.ccvs.ui.Policy; - -public class CVSProjectPropertiesPage extends CVSPropertiesPage { - IProject project; - ICVSRepositoryLocation oldLocation; - ICVSRepositoryLocation newLocation = null; - - private static final int TABLE_HEIGHT_HINT = 150; - - // Widgets - Text methodText; - Text userText; - Text hostText; - Text pathText; - Text moduleText; - Text portText; - Text tagText; - private Button fetchButton; - private Button watchEditButton; - - IUserInfo info; - CVSTeamProvider provider; - private boolean fetch; - private boolean watchEdit; - - public static boolean isCompatible(ICVSRepositoryLocation location, ICVSRepositoryLocation oldLocation) { - if (!location.getHost().equals(oldLocation.getHost())) return false; - if (!location.getRootDirectory().equals(oldLocation.getRootDirectory())) return false; - if (location.equals(oldLocation)) return false; - return true; - } - - private class RepositorySelectionDialog extends Dialog { - ICVSRepositoryLocation[] allLocations; - ICVSRepositoryLocation[] compatibleLocatons; - ICVSRepositoryLocation selectedLocation; - - TableViewer viewer; - Button okButton; - boolean showCompatible = true; - - public RepositorySelectionDialog(Shell shell, ICVSRepositoryLocation oldLocation) { - super(shell); - initialize(oldLocation); - } - private void initialize(ICVSRepositoryLocation oldLocation) { - allLocations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(); - List locations = new ArrayList(); - for (int i = 0; i < allLocations.length; i++) { - ICVSRepositoryLocation location = allLocations[i]; - if (isCompatible(location, oldLocation)) { - locations.add(location); - } - } - compatibleLocatons = (ICVSRepositoryLocation[]) locations.toArray(new ICVSRepositoryLocation[locations.size()]); - } - protected void createButtonsForButtonBar(Composite parent) { - // create OK and Cancel buttons by default - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - okButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - protected Control createDialogArea(Composite parent) { - parent.getShell().setText(Policy.bind("CVSProjectPropertiesPage.Select_a_Repository_1")); //$NON-NLS-1$ - Composite composite = (Composite) super.createDialogArea(parent); - - createLabel(composite, Policy.bind("CVSProjectPropertiesPage.Select_a_CVS_repository_location_to_share_the_project_with__2"), 1); //$NON-NLS-1$ - Table table = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.heightHint = TABLE_HEIGHT_HINT; - table.setLayoutData(data); - viewer = new TableViewer(table); - viewer.setLabelProvider(new WorkbenchLabelProvider()); - viewer.setContentProvider(new WorkbenchContentProvider() { - public Object[] getElements(Object inputElement) { - if (showCompatible) { - return compatibleLocatons; - } else { - return allLocations; - } - } - }); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - if (selection.isEmpty()) { - selectedLocation = null; - okButton.setEnabled(false); - } else { - selectedLocation = (ICVSRepositoryLocation)selection.getFirstElement(); - okButton.setEnabled(true); - } - } - }); - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - okPressed(); - } - }); - viewer.setInput(compatibleLocatons); - - final Button compatibleButton = createCheckBox(composite, Policy.bind("CVSProjectPropertiesPage.31")); //$NON-NLS-1$ - compatibleButton.setSelection(showCompatible); - compatibleButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - showCompatible = compatibleButton.getSelection(); - viewer.refresh(); - } - }); - - Dialog.applyDialogFont(parent); - - return composite; - } - protected void cancelPressed() { - selectedLocation = null; - super.cancelPressed(); - } - public ICVSRepositoryLocation getLocation() { - return selectedLocation; - } - } - - /* - * @see PreferencesPage#createContents - */ - protected Control createContents(Composite parent) { - initialize(); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - - Label label = createLabel(composite, Policy.bind("CVSProjectPropertiesPage.connectionType"), 1); //$NON-NLS-1$ - methodText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSProjectPropertiesPage.user"), 1); //$NON-NLS-1$ - userText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSPropertiesPage.host"), 1); //$NON-NLS-1$ - hostText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSPropertiesPage.port"), 1); //$NON-NLS-1$ - portText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSPropertiesPage.path"), 1); //$NON-NLS-1$ - pathText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSPropertiesPage.module"), 1); //$NON-NLS-1$ - moduleText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - label = createLabel(composite, Policy.bind("CVSPropertiesPage.tag"), 1); //$NON-NLS-1$ - tagText = createReadOnlyText(composite, "", 1); //$NON-NLS-1$ - - createLabel(composite, "", 1); //$NON-NLS-1$ - - // Should absent directories be fetched on update - fetchButton = createCheckBox(composite, Policy.bind("CVSProjectPropertiesPage.fetchAbsentDirectoriesOnUpdate")); //$NON-NLS-1$ - fetchButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - fetch = fetchButton.getSelection(); - } - }); - - // Should the project be configured for watch/edit - watchEditButton = createCheckBox(composite, Policy.bind("CVSProjectPropertiesPage.configureForWatchEdit")); //$NON-NLS-1$ - watchEditButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - watchEdit = watchEditButton.getSelection(); - } - }); - - createLabel(composite, "", 1); //$NON-NLS-1$ - createLabel(composite, "", 1); //$NON-NLS-1$ - createLabel(composite, "", 1); //$NON-NLS-1$ - createLabel(composite, "", 1); //$NON-NLS-1$ - - label = new Label(composite, SWT.WRAP); - label.setText(Policy.bind("CVSProjectPropertiesPage.You_can_change_the_sharing_of_this_project_to_another_repository_location._However,_this_is_only_possible_if_the_new_location_is___compatible___(on_the_same_host_with_the_same_repository_path)._1")); //$NON-NLS-1$ - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 200; - data.horizontalSpan = 2; - label.setLayoutData(data); - - Button changeButton = new Button(composite, SWT.PUSH); - changeButton.setText(Policy.bind("CVSProjectPropertiesPage.Change_Sharing_5")); //$NON-NLS-1$ - changeButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - RepositorySelectionDialog dialog = new RepositorySelectionDialog(getShell(), oldLocation); - dialog.open(); - ICVSRepositoryLocation location = dialog.getLocation(); - if (location == null) return; - newLocation = location; - initializeValues(newLocation); - } - }); - - initializeValues(oldLocation); - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.PROJECT_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - /** - * Utility method that creates a text instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new text - * @return the new text - */ - protected Text createReadOnlyText(Composite parent, String text, int span) { - Text txt = new Text(parent, SWT.LEFT | SWT.READ_ONLY); - txt.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - txt.setLayoutData(data); - return txt; - } - /** - * Creates a new checkbox instance and sets the default layout data. - * - * @param group the composite in which to create the checkbox - * @param label the string to set into the checkbox - * @return the new checkbox - */ - protected Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = 2; - button.setLayoutData(data); - return button; - } - /** - * Initializes the page - */ - private void initialize() { - // Get the project that is the source of this property page - project = null; - IAdaptable element = getElement(); - if (element instanceof IProject) { - project = (IProject)element; - } else { - Object adapter = element.getAdapter(IProject.class); - if (adapter instanceof IProject) { - project = (IProject)adapter; - } - } - // Do some pre-checks to ensure we're in a good state - provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if (provider == null) return; - CVSWorkspaceRoot cvsRoot = provider.getCVSWorkspaceRoot(); - try { - oldLocation = cvsRoot.getRemoteLocation(); - fetch = provider.getFetchAbsentDirectories(); - watchEdit = provider.isWatchEditEnabled(); - } catch (TeamException e) { - handle(e); - } - } - /** - * Set the initial values of the widgets - */ - private void initializeValues(ICVSRepositoryLocation location) { - if (provider == null) return; - CVSWorkspaceRoot cvsRoot = provider.getCVSWorkspaceRoot(); - ICVSFolder folder = cvsRoot.getLocalRoot(); - - try { - if (!folder.isCVSFolder()) return; - methodText.setText(location.getMethod().getName()); - info = location.getUserInfo(true); - userText.setText(info.getUsername()); - hostText.setText(location.getHost()); - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { - portText.setText(Policy.bind("CVSPropertiesPage.defaultPort")); //$NON-NLS-1$ - } else { - portText.setText("" + port); //$NON-NLS-1$ - } - pathText.setText(location.getRootDirectory()); - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - if (syncInfo == null) return; - String label = syncInfo.getRepository(); - if (label.equals(FolderSyncInfo.VIRTUAL_DIRECTORY)) { - label = Policy.bind("CVSPropertiesPage.virtualModule", label); //$NON-NLS-1$ - } - moduleText.setText(label); - fetchButton.setSelection(fetch); - watchEditButton.setSelection(watchEdit); - } catch (TeamException e) { - handle(e); - } - - initializeTag(); - } - - private void initializeTag() { - provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if (provider == null) return; - try { - ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor(project); - CVSTag tag = local.getFolderSyncInfo().getTag(); - - tagText.setText(getTagLabel(tag)); - - } catch (TeamException e) { - handle(e); - } - } - /* - * @see PreferencesPage#performOk - */ - public boolean performOk() { - final boolean[] changeReadOnly = { false }; - try { - if (fetch != provider.getFetchAbsentDirectories()) - provider.setFetchAbsentDirectories(fetch); - if (watchEdit != provider.isWatchEditEnabled()) { - provider.setWatchEditEnabled(watchEdit); - changeReadOnly[0] = true; - } - } catch (CVSException e) { - handle(e); - } - if (newLocation == null && !changeReadOnly[0]) { - return true; - } - try { - if (newLocation != null && !isCompatible(newLocation, oldLocation)) { - if (!MessageDialog.openQuestion(getShell(), Policy.bind("CVSProjectPropertiesPage.32"), Policy.bind("CVSProjectPropertiesPage.33"))) { //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - } - new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(Policy.bind("CVSProjectPropertiesPage.progressTaskName"), //$NON-NLS-1$ - ((newLocation == null)?0:100) + (changeReadOnly[0]?100:0)); - if (newLocation != null) - provider.setRemoteRoot(newLocation, Policy.subMonitorFor(monitor, 100)); - if (changeReadOnly[0]) - setReadOnly(watchEdit, Policy.infiniteSubMonitorFor(monitor, 100)); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - newLocation = null; - if (changeReadOnly[0]) { - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - } - } catch (InvocationTargetException e) { - handle(e); - } catch (InterruptedException e) { - return false; - } - - return true; - } - /** - * @param watchEdit - */ - protected void setReadOnly(final boolean watchEdit, final IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 512); - String taskName = watchEdit? - Policy.bind("CVSProjectPropertiesPage.setReadOnly"): //$NON-NLS-1$ - Policy.bind("CVSProjectPropertiesPage.clearReadOnly"); //$NON-NLS-1$ - monitor.subTask(taskName); - ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project); - root.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - // only change managed, unmodified files - if (file.isManaged() && !file.isModified(null)) - file.setReadOnly(watchEdit); - monitor.worked(1); - } - - public void visitFolder(ICVSFolder folder) throws CVSException { - folder.acceptChildren(this); - } - }); - monitor.done(); - } - /** - * Shows the given errors to the user. - */ - protected void handle(Throwable t) { - CVSUIPlugin.openError(getShell(), null, null, t); - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java deleted file mode 100644 index 58c63e4aa..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.IProjectSetSerializer; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.operations.CheckoutSingleProjectOperation; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -public class CVSProjectSetSerializer implements IProjectSetSerializer { - - /** - * @see IProjectSetSerializer#asReference(IProject[]) - * - * "1.0,repoLocation,module,projectName[,tag]" - */ - public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) throws TeamException { - String[] result = new String[providerProjects.length]; - for (int i = 0; i < providerProjects.length; i++) { - StringBuffer buffer = new StringBuffer(); - buffer.append("1.0,"); //$NON-NLS-1$ - - IProject project = providerProjects[i]; - CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project); - CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot(); - CVSRepositoryLocation location = CVSRepositoryLocation.fromString(root.getRemoteLocation().getLocation()); - location.setUserMuteable(true); - String repoLocation = location.getLocation(); - buffer.append(repoLocation); - buffer.append(","); //$NON-NLS-1$ - - ICVSFolder folder = root.getLocalRoot(); - FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); - String module = syncInfo.getRepository(); - buffer.append(module); - buffer.append(","); //$NON-NLS-1$ - - String projectName = folder.getName(); - buffer.append(projectName); - CVSTag tag = syncInfo.getTag(); - if (tag != null) { - if (tag.getType() != CVSTag.DATE) { - buffer.append(","); //$NON-NLS-1$ - String tagName = tag.getName(); - buffer.append(tagName); - } - } - result[i] = buffer.toString(); - } - return result; - } - - /** - * @see IProjectSetSerializer#addToWorkspace(String[]) - */ - public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) throws TeamException { - final int size = referenceStrings.length; - final IProject[] projects = new IProject[size]; - final ICVSRepositoryLocation[] locations = new ICVSRepositoryLocation[size]; - final String[] modules = new String[size]; - final CVSTag[] tags = new CVSTag[size]; - - for (int i = 0; i < size; i++) { - StringTokenizer tokenizer = new StringTokenizer(referenceStrings[i], ","); //$NON-NLS-1$ - String version = tokenizer.nextToken(); - if (!version.equals("1.0")) { //$NON-NLS-1$ - // Bail out, this is a newer version - return null; - } - String repo = tokenizer.nextToken(); - locations[i] = getLocationFromString(repo); - modules[i] = tokenizer.nextToken(); - String projectName = tokenizer.nextToken(); - projects[i] = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (tokenizer.hasMoreTokens()) { - String tagName = tokenizer.nextToken(); - tags[i] = new CVSTag(tagName, CVSTag.BRANCH); - } - } - // Check if any projects will be overwritten, and warn the user. - boolean yesToAll = false; - int action; - final int[] num = new int[] {size}; - for (int i = 0; i < size; i++) { - Shell shell = null; - IProject project = projects[i]; - if (project.exists()) { - if (shell == null) { - if (context instanceof Shell) { - shell = (Shell)context; - } else { - return null; - } - } - action = confirmOverwrite(project, yesToAll, shell); - yesToAll = action == 2; - - // message dialog - switch (action) { - // no - case 1: - // Remove it from the set - locations[i] = null; - num[0]--; - break; - // yes to all - case 2: - // yes - case 0: - break; - // cancel - case 3: - default: - return null; - } - } - } - WorkspaceModifyOperation op = new WorkspaceModifyOperation() { - public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - monitor.beginTask("", 1000 * num[0]); //$NON-NLS-1$ - try { - for (int i = 0; i < size; i++) { - if (locations[i] != null) { - ICVSRemoteFolder remote = new RemoteFolder(null, locations[i], modules[i], tags[i]); - new CheckoutSingleProjectOperation(null /* no part */, remote, projects[i], null /* location */, true) - .run(new SubProgressMonitor(monitor, 1000)); - } - } - } finally { - monitor.done(); - } - } - }; - try { - op.run(monitor); - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (t instanceof TeamException) { - throw (TeamException)t; - } - } - List result = new ArrayList(); - for (int i = 0; i < projects.length; i++) { - if (projects[i] != null) result.add(projects[i]); - } - return (IProject[])result.toArray(new IProject[result.size()]); - } - - private ICVSRepositoryLocation getLocationFromString(String repo) throws CVSException { - // create the new location - ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo); - if (newLocation.getUsername() == null || newLocation.getUsername().length() == 0) { - // look for an existing location that matched - ICVSRepositoryLocation[] locations = KnownRepositories.getInstance().getRepositories(); - for (int i = 0; i < locations.length; i++) { - ICVSRepositoryLocation location = locations[i]; - if (location.getMethod() == newLocation.getMethod() - && location.getHost().equals(newLocation.getHost()) - && location.getPort() == newLocation.getPort() - && location.getRootDirectory().equals(newLocation.getRootDirectory())) - return location; - } - } - return newLocation; - } - - private int confirmOverwrite(IProject project, boolean yesToAll, Shell shell) { - if (yesToAll) return 2; - if (!project.exists()) return 0; - final MessageDialog dialog = - new MessageDialog(shell, Policy.bind("CVSProjectSetSerializer.Confirm_Overwrite_Project_8"), null, Policy.bind("CVSProjectSetSerializer.The_project_{0}_already_exists._Do_you_wish_to_overwrite_it__9", project.getName()), MessageDialog.QUESTION, //$NON-NLS-1$ //$NON-NLS-2$ - new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.NO_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.CANCEL_LABEL}, - 0); - final int[] result = new int[1]; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - } - }); - return result[0]; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java deleted file mode 100644 index 552c75f18..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.ui.dialogs.PropertyPage; - -public abstract class CVSPropertiesPage extends PropertyPage { - - /** - * Return the appropriate Tag label for properties pages - * based on the tag type. - * @param tag - * @return String - */ - - public static String getTagLabel(CVSTag tag) { - - if (tag == null) { - return Policy.bind("CVSFilePropertiesPage.none"); //$NON-NLS-1$ - } - - switch (tag.getType()) { - case CVSTag.HEAD: - return tag.getName(); - case CVSTag.VERSION: - return Policy.bind("CVSFilePropertiesPage.version", tag.getName()); //$NON-NLS-1$ - case CVSTag.BRANCH: - return Policy.bind("CVSFilePropertiesPage.branch", tag.getName()); //$NON-NLS-1$ - case CVSTag.DATE: - return Policy.bind("CVSFilePropertiesPage.date", tag.getName()); //$NON-NLS-1$ - default : - return tag.getName(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java deleted file mode 100644 index 0818ffb2a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ /dev/null @@ -1,756 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; -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.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.SubscriberChangeSetCollector; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole; -import org.eclipse.team.internal.ccvs.ui.model.CVSAdapterFactory; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; -import org.eclipse.ui.*; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * UI Plugin for CVS provider-specific workbench functionality. - */ -public class CVSUIPlugin extends AbstractUIPlugin { - /** - * The id of the CVS plug-in - */ - public static final String ID = "org.eclipse.team.cvs.ui"; //$NON-NLS-1$ - public static final String DECORATOR_ID = "org.eclipse.team.cvs.ui.decorator"; //$NON-NLS-1$ - - /** - * Property constant indicating the decorator configuration has changed. - */ - public static final String P_DECORATORS_CHANGED = CVSUIPlugin.ID + ".P_DECORATORS_CHANGED"; //$NON-NLS-1$ - - private Hashtable imageDescriptors = new Hashtable(20); - private static List propertyChangeListeners = new ArrayList(5); - - /** - * The singleton plug-in instance - */ - private static CVSUIPlugin plugin; - - /** - * The CVS console - */ - private CVSOutputConsole console; - - /** - * The repository manager - */ - private RepositoryManager repositoryManager; - - private SubscriberChangeSetCollector changeSetManager; - - /** - * CVSUIPlugin constructor - * - * @param descriptor the plugin descriptor - */ - public CVSUIPlugin() { - super(); - plugin = this; - } - - /** - * Returns the standard display to be used. The method first checks, if - * the thread calling this method has an associated display. If so, this - * display is returned. Otherwise the method returns the default display. - */ - public static Display getStandardDisplay() { - Display display= Display.getCurrent(); - if (display == null) { - display= Display.getDefault(); - } - return display; - } - - /** - * Creates an image and places it in the image registry. - */ - protected void createImageDescriptor(String id, URL baseURL) { - URL url = null; - try { - url = new URL(baseURL, ICVSUIConstants.ICON_PATH + id); - } catch (MalformedURLException e) { - } - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - imageDescriptors.put(id, desc); - } - - /** - * Returns the active workbench page. Note that the active page may not be - * the one that the usr perceives as active in some situations so this - * method of obtaining the activae page should only be used if no other - * method is available. - * - * @return the active workbench page - */ - public static IWorkbenchPage getActivePage() { - return TeamUIPlugin.getActivePage(); - } - - /** - * Register for changes made to Team properties. - */ - public static void addPropertyChangeListener(IPropertyChangeListener listener) { - propertyChangeListeners.add(listener); - } - - /** - * Deregister as a Team property changes. - */ - public static void removePropertyChangeListener(IPropertyChangeListener listener) { - propertyChangeListeners.remove(listener); - } - - /** - * Broadcast a Team property change. - */ - public static void broadcastPropertyChange(PropertyChangeEvent event) { - for (Iterator it = propertyChangeListeners.iterator(); it.hasNext();) { - IPropertyChangeListener listener = (IPropertyChangeListener)it.next(); - listener.propertyChange(event); - } - } - - /** - * Extract or convert to a TeamException - */ - public static TeamException asTeamException(InvocationTargetException e) { - Throwable exception = e.getTargetException(); - if (exception instanceof TeamException) { - return (TeamException)exception; - } else if (exception instanceof CoreException) { - return new TeamException(((CoreException)exception).getStatus()); - } else { - return new TeamException(new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, Policy.bind("internal"), exception)); //$NON-NLS-1$ - } - } - - /** - * Run an operation involving the given resource. If an exception is thrown - * and the code on the status is IResourceStatus.OUT_OF_SYNC_LOCAL then - * the user will be prompted to refresh and try again. If they agree, then the - * supplied operation will be run again. - */ - public static void runWithRefresh(Shell parent, IResource[] resources, - IRunnableWithProgress runnable, IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - boolean firstTime = true; - while(true) { - try { - runnable.run(monitor); - return; - } catch (InvocationTargetException e) { - if (! firstTime) throw e; - IStatus status = null; - if (e.getTargetException() instanceof CoreException) { - status = ((CoreException)e.getTargetException()).getStatus(); - } else if (e.getTargetException() instanceof TeamException) { - status = ((TeamException)e.getTargetException()).getStatus(); - } else { - throw e; - } - if (status.getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { - if (promptToRefresh(parent, resources, status)) { - try { - for (int i = 0; i < resources.length; i++) { - resources[i].refreshLocal(IResource.DEPTH_INFINITE, null); - } - } catch (CoreException coreEx) { - // Throw the original exception to the caller - log(coreEx); - throw e; - } - firstTime = false; - // Fall through and the operation will be tried again - } else { - // User chose not to continue. Treat it as a cancel. - throw new InterruptedException(); - } - } else { - throw e; - } - } - } - } - - private static boolean promptToRefresh(final Shell shell, final IResource[] resources, final IStatus status) { - final boolean[] result = new boolean[] { false}; - Runnable runnable = new Runnable() { - public void run() { - Shell shellToUse = shell; - if (shell == null) { - shellToUse = new Shell(Display.getCurrent()); - } - String question; - if (resources.length == 1) { - question = Policy.bind("CVSUIPlugin.refreshQuestion", status.getMessage(), resources[0].getFullPath().toString()); //$NON-NLS-1$ - } else { - question = Policy.bind("CVSUIPlugin.refreshMultipleQuestion", status.getMessage()); //$NON-NLS-1$ - } - result[0] = MessageDialog.openQuestion(shellToUse, Policy.bind("CVSUIPlugin.refreshTitle"), question); //$NON-NLS-1$ - } - }; - Display.getDefault().syncExec(runnable); - return result[0]; - } - - /** - * Creates a busy cursor and runs the specified runnable. - * May be called from a non-UI thread. - * - * @param parent the parent Shell for the dialog - * @param cancelable if true, the dialog will support cancelation - * @param runnable the runnable - * - * @exception InvocationTargetException when an exception is thrown from the runnable - * @exception InterruptedException when the progress monitor is cancelled - */ - public static void runWithProgress(Shell parent, boolean cancelable, - final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { - Utils.runWithProgress(parent, cancelable, runnable); - } - - /** - * Creates a busy cursor and runs the specified runnable. - * May be called from a non-UI thread. - * - * @param parent the parent Shell for the dialog - * @param cancelable if true, the dialog will support cancelation - * @param runnable the runnable - * @param flags customizing attributes for the error handling - * - * @exception InvocationTargetException when an exception is thrown from the runnable - * @exception InterruptedException when the progress monitor is cancelled - */ - public static void runWithProgress(final Shell parent, final boolean cancelable, - final IRunnableWithProgress runnable, int flags) throws InvocationTargetException, InterruptedException { - - if ((flags & PERFORM_SYNC_EXEC) > 0) { - - // create a runnable that deals with exceptions - final Exception exception[] = new Exception[] { null }; - Runnable outerRunnable = new Runnable() { - public void run() { - try { - Utils.runWithProgress(parent, cancelable, runnable); - } catch (InvocationTargetException e) { - exception[0] = e; - } catch (InterruptedException e) { - exception[0] = e; - } - } - }; - - // get a Display and perform the syncExec - Display display; - if (parent == null) { - display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - } else { - display = parent.getDisplay(); - } - display.syncExec(outerRunnable); - - // handle any exception - if (exception[0] != null) { - Exception e = exception[0]; - if (e instanceof InvocationTargetException) { - throw (InvocationTargetException) e; - } else if (e instanceof InterruptedException) { - throw (InterruptedException) e; - } else { - // impossible but we'll handle it anyway - throw new InvocationTargetException(e); - } - } - } else { - Utils.runWithProgress(parent, cancelable, runnable); - } - } - - /** - * Returns the image descriptor for the given image ID. - * Returns null if there is no such image. - */ - public ImageDescriptor getImageDescriptor(String id) { - return (ImageDescriptor)imageDescriptors.get(id); - } - - /** - * Returns the singleton plug-in instance. - * - * @return the plugin instance - */ - public static CVSUIPlugin getPlugin() { - return plugin; - } - - /** - * Returns the repository manager - * - * @return the repository manager - */ - public synchronized RepositoryManager getRepositoryManager() { - if (repositoryManager == null) { - repositoryManager = new RepositoryManager(); - repositoryManager.startup(); - } - return repositoryManager; - } - - public synchronized SubscriberChangeSetCollector getChangeSetManager() { - if (changeSetManager == null) { - changeSetManager = new SubscriberChangeSetCollector(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } - return changeSetManager; - } - - /** - * Initializes the table of images used in this plugin. - */ - private void initializeImages() { - URL baseURL = getBundle().getEntry("/"); //$NON-NLS-1$ - - // objects - createImageDescriptor(ICVSUIConstants.IMG_REPOSITORY, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_REFRESH, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_REFRESH_ENABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_REFRESH_DISABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR_ENABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL_ENABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_NEWLOCATION, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CVSLOGO, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_TAG, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_MODULE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CLEAR, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CLEAR_ENABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CLEAR_DISABLED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_SHARE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_DIFF, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_KEYWORD, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_MERGEABLE_CONFLICT, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_QUESTIONABLE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_MERGED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_EDITED, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_NO_REMOTEDIR, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CVS_CONSOLE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_DATE, baseURL); - createImageDescriptor(ICVSUIConstants.IMG_CHANGELOG, baseURL); - - // special - createImageDescriptor("glyphs/glyph1.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph2.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph3.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph4.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph5.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph6.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph7.gif", baseURL); //$NON-NLS-1$ - createImageDescriptor("glyphs/glyph8.gif", baseURL); //$NON-NLS-1$ - } - /** - * Convenience method for logging statuses to the plugin log - * - * @param status the status to log - */ - public static void log(IStatus status) { - getPlugin().getLog().log(status); - } - - public static void log(CoreException e) { - log(e.getStatus().getSeverity(), Policy.bind("simpleInternal"), e); //$NON-NLS-1$ - } - - /** - * Log the given exception along with the provided message and severity indicator - */ - public static void log(int severity, String message, Throwable e) { - log(new Status(severity, ID, 0, message, e)); - } - - // flags to tailor error reporting - public static final int PERFORM_SYNC_EXEC = 1; - public static final int LOG_TEAM_EXCEPTIONS = 2; - public static final int LOG_CORE_EXCEPTIONS = 4; - public static final int LOG_OTHER_EXCEPTIONS = 8; - public static final int LOG_NONTEAM_EXCEPTIONS = LOG_CORE_EXCEPTIONS | LOG_OTHER_EXCEPTIONS; - - /** - * Convenience method for showing an error dialog - * @param shell a valid shell or null - * @param exception the exception to be report - * @param title the title to be displayed - * @return IStatus the status that was displayed to the user - */ - public static IStatus openError(Shell shell, String title, String message, Throwable exception) { - return openError(shell, title, message, exception, LOG_OTHER_EXCEPTIONS); - } - - /** - * Convenience method for showing an error dialog - * @param shell a valid shell or null - * @param exception the exception to be report - * @param title the title to be displayed - * @param flags customizing attributes for the error handling - * @return IStatus the status that was displayed to the user - */ - public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) { - // Unwrap InvocationTargetExceptions - if (exception instanceof InvocationTargetException) { - Throwable target = ((InvocationTargetException)exception).getTargetException(); - // re-throw any runtime exceptions or errors so they can be handled by the workbench - if (target instanceof RuntimeException) { - throw (RuntimeException)target; - } - if (target instanceof Error) { - throw (Error)target; - } - return openError(providedShell, title, message, target, flags); - } - - // Determine the status to be displayed (and possibly logged) - IStatus status = null; - boolean log = false; - if (exception instanceof CoreException) { - status = ((CoreException)exception).getStatus(); - log = ((flags & LOG_CORE_EXCEPTIONS) > 0); - } else if (exception instanceof TeamException) { - status = ((TeamException)exception).getStatus(); - log = ((flags & LOG_TEAM_EXCEPTIONS) > 0); - } else if (exception instanceof InterruptedException) { - return new CVSStatus(IStatus.OK, Policy.bind("ok")); //$NON-NLS-1$ - } else if (exception != null) { - status = new CVSStatus(IStatus.ERROR, Policy.bind("internal"), exception); //$NON-NLS-1$ - log = ((flags & LOG_OTHER_EXCEPTIONS) > 0); - if (title == null) title = Policy.bind("SimpleInternal"); //$NON-NLS-1$ - } - - // Check for a build error and report it differently - if (status.getCode() == IResourceStatus.BUILD_FAILED) { - message = Policy.bind("buildError"); //$NON-NLS-1$ - log = true; - } - - // Check for multi-status with only one child - if (status.isMultiStatus() && status.getChildren().length == 1) { - status = status.getChildren()[0]; - } - if (status.isOK()) return status; - - // Log if the user requested it - if (log) CVSUIPlugin.log(status.getSeverity(), status.getMessage(), exception); - - // Create a runnable that will display the error status - final String displayTitle = title; - final String displayMessage = message; - final IStatus displayStatus = status; - final IOpenableInShell openable = new IOpenableInShell() { - public void open(Shell shell) { - if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) { - MessageDialog.openInformation(shell, Policy.bind("information"), displayStatus.getMessage()); //$NON-NLS-1$ - } else { - ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus); - } - } - }; - openDialog(providedShell, openable, flags); - - // return the status we display - return status; - } - - /** - * Interface that allows a shell to be passed to an open method. The - * provided shell can be used without sync-execing, etc. - */ - public interface IOpenableInShell { - public void open(Shell shell); - } - - /** - * Open the dialog code provided in the IOpenableInShell, ensuring that - * the provided whll is valid. This method will provide a shell to the - * IOpenableInShell if one is not provided to the method. - * - * @param providedShell - * @param openable - * @param flags - */ - public static void openDialog(Shell providedShell, final IOpenableInShell openable, int flags) { - // If no shell was provided, try to get one from the active window - if (providedShell == null) { - IWorkbenchWindow window = CVSUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - providedShell = window.getShell(); - // sync-exec when we do this just in case - flags = flags | PERFORM_SYNC_EXEC; - } - } - - // Create a runnable that will display the error status - final Shell shell = providedShell; - Runnable outerRunnable = new Runnable() { - public void run() { - Shell displayShell; - if (shell == null) { - Display display = Display.getCurrent(); - displayShell = new Shell(display); - } else { - displayShell = shell; - } - openable.open(displayShell); - if (shell == null) { - displayShell.dispose(); - } - } - }; - - // Execute the above runnable as determined by the parameters - if (shell == null || (flags & PERFORM_SYNC_EXEC) > 0) { - Display display; - if (shell == null) { - display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - } else { - display = shell.getDisplay(); - } - display.syncExec(outerRunnable); - } else { - outerRunnable.run(); - } - } - - - /** - * Initializes the preferences for this plugin if necessary. - */ - protected void initializePreferences() { - IPreferenceStore store = getPreferenceStore(); - // Get the plugin preferences for CVS Core - Preferences corePrefs = CVSProviderPlugin.getPlugin().getPluginPreferences(); - - store.setDefault(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY, false); - store.setDefault(ICVSUIConstants.PREF_SHOW_COMMENTS, true); - store.setDefault(ICVSUIConstants.PREF_SHOW_TAGS, true); - store.setDefault(ICVSUIConstants.PREF_HISTORY_VIEW_EDITOR_LINKING, false); - store.setDefault(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES, CVSProviderPlugin.DEFAULT_PRUNE); - store.setDefault(ICVSUIConstants.PREF_TIMEOUT, CVSProviderPlugin.DEFAULT_TIMEOUT); - store.setDefault(ICVSUIConstants.PREF_CONSIDER_CONTENTS, true); - store.setDefault(ICVSUIConstants.PREF_COMPRESSION_LEVEL, CVSProviderPlugin.DEFAULT_COMPRESSION_LEVEL); - store.setDefault(ICVSUIConstants.PREF_TEXT_KSUBST, CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION.toMode()); - store.setDefault(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND, true); - store.setDefault(ICVSUIConstants.PREF_REPLACE_UNMANAGED, true); - store.setDefault(ICVSUIConstants.PREF_CVS_RSH, CVSProviderPlugin.DEFAULT_CVS_RSH); - store.setDefault(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS, CVSProviderPlugin.DEFAULT_CVS_RSH_PARAMETERS); - store.setDefault(ICVSUIConstants.PREF_CVS_SERVER, CVSProviderPlugin.DEFAULT_CVS_SERVER); - store.setDefault(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY, "ext"); //$NON-NLS-1$ - store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_CHANGE_GRANULARITY, true); - store.setDefault(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION, true); - store.setDefault(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, CVSProviderPlugin.DEFAULT_CONFIRM_MOVE_TAG); - store.setDefault(ICVSUIConstants.PREF_DEBUG_PROTOCOL, false); - store.setDefault(ICVSUIConstants.PREF_WARN_REMEMBERING_MERGES, true); - store.setDefault(ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG, false); - store.setDefault(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR, false); - store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false); - - PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); - PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, new RGB(0, 0, 255)); - PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR, new RGB(255, 0, 0)); - store.setDefault(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE, false); - store.setDefault(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT, true); - store.setDefault(ICVSUIConstants.PREF_CONSOLE_HIGH_WATER_MARK, 500000); - store.setDefault(ICVSUIConstants.PREF_CONSOLE_WRAP, false); - store.setDefault(ICVSUIConstants.PREF_CONSOLE_WIDTH, 80); - - store.setDefault(ICVSUIConstants.PREF_FILETEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FILETEXTFORMAT); - store.setDefault(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FOLDERTEXTFORMAT); - store.setDefault(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_PROJECTTEXTFORMAT); - - store.setDefault(ICVSUIConstants.PREF_FIRST_STARTUP, true); - store.setDefault(ICVSUIConstants.PREF_ADDED_FLAG, CVSDecoratorConfiguration.DEFAULT_ADDED_FLAG); - store.setDefault(ICVSUIConstants.PREF_DIRTY_FLAG, CVSDecoratorConfiguration.DEFAULT_DIRTY_FLAG); - store.setDefault(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, true); - store.setDefault(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, true); - store.setDefault(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, false); - store.setDefault(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, true); - store.setDefault(ICVSUIConstants.PREF_CALCULATE_DIRTY, true); - store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS, true); - store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_SAVING_IN_SYNC, true); - store.setDefault(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS, ICVSUIConstants.OPTION_PROMPT); - - store.setDefault(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, CVSPerspective.ID); - store.setDefault(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS, MessageDialogWithToggle.PROMPT); - - // Set the watch/edit preferences defaults and values - store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY)); - store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, ICVSUIConstants.PREF_EDIT_PROMPT_EDIT); - store.setDefault(ICVSUIConstants.PREF_EDIT_PROMPT, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS); - // Ensure that the preference values in UI match Core - store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY)); - - // Forward the values to the CVS plugin - CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); - CVSProviderPlugin.getPlugin().setTimeout(store.getInt(ICVSUIConstants.PREF_TIMEOUT)); - CVSProviderPlugin.getPlugin().setCvsRshCommand(store.getString(ICVSUIConstants.PREF_CVS_RSH)); - CVSProviderPlugin.getPlugin().setCvsRshParameters(store.getString(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS)); - CVSProviderPlugin.getPlugin().setCvsServer(store.getString(ICVSUIConstants.PREF_CVS_SERVER)); - CVSRepositoryLocation.setExtConnectionMethodProxy(store.getString(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY)); - CVSProviderPlugin.getPlugin().setQuietness(CVSPreferencesPage.getQuietnessOptionFor(store.getInt(ICVSUIConstants.PREF_QUIETNESS))); - CVSProviderPlugin.getPlugin().setCompressionLevel(store.getInt(ICVSUIConstants.PREF_COMPRESSION_LEVEL)); - CVSProviderPlugin.getPlugin().setReplaceUnmanaged(store.getBoolean(ICVSUIConstants.PREF_REPLACE_UNMANAGED)); - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(KSubstOption.fromMode(store.getString(ICVSUIConstants.PREF_TEXT_KSUBST))); - CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); - CVSProviderPlugin.getPlugin().setRepositoriesAreBinary(store.getBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); - CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); - CVSProviderPlugin.getPlugin().setConfirmMoveTagEnabled(store.getBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG)); - CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); - } - - /** - * @see Plugin#start(BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - Policy.localize("org.eclipse.team.internal.ccvs.ui.messages"); //$NON-NLS-1$ - - initializeImages(); - initializePreferences(); - - CVSAdapterFactory factory = new CVSAdapterFactory(); - Platform.getAdapterManager().registerAdapters(factory, ICVSRemoteFile.class); - Platform.getAdapterManager().registerAdapters(factory, ICVSRemoteFolder.class); - Platform.getAdapterManager().registerAdapters(factory, ICVSRepositoryLocation.class); - Platform.getAdapterManager().registerAdapters(factory, RepositoryRoot.class); - - try { - console = new CVSOutputConsole(); - } catch (RuntimeException e) { - // Don't let the console bring down the CVS UI - log(IStatus.ERROR, "Errors occurred starting the CVS conbsole", e); //$NON-NLS-1$ - } - - // Must load the change set manager on startup since it listens to deltas - getChangeSetManager(); - - IPreferenceStore store = getPreferenceStore(); - if (store.getBoolean(ICVSUIConstants.PREF_FIRST_STARTUP)) { - // If we enable the decorator in the XML, the CVS plugin will be loaded - // on startup even if the user never uses CVS. Therefore, we enable the - // decorator on the first start of the CVS plugin since this indicates that - // the user has done something with CVS. Subsequent startups will load - // the CVS plugin unless the user disables the decorator. In this case, - // we will not reenable since we only enable auatomatically on the first startup. - PlatformUI.getWorkbench().getDecoratorManager().setEnabled(CVSLightweightDecorator.ID, true); - store.setValue(ICVSUIConstants.PREF_FIRST_STARTUP, false); - } - - } - - public static IWorkingSet getWorkingSet(IResource[] resources, String name) { - IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name); - if (workingSet == null) { - workingSet = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet(name, resources); - PlatformUI.getWorkbench().getWorkingSetManager().addWorkingSet(workingSet); - } else { - workingSet.setElements(resources); - } - return workingSet; - } - - /** - * @see Plugin#stop(BundleContext) - */ - public void stop(BundleContext context) throws Exception { - try { - try { - if (repositoryManager != null) - repositoryManager.shutdown(); - } catch (TeamException e) { - throw new CoreException(e.getStatus()); - } - - if (console != null) - console.shutdown(); - getChangeSetManager().dispose(); - } finally { - super.stop(context); - } - } - - /** - * @return the CVS console - */ - public CVSOutputConsole getConsole() { - return console; - } - - /** - * @return Returns the cvsWorkspaceSynchronizeViewPage. - */ - public WorkspaceSynchronizeParticipant getCvsWorkspaceSynchronizeParticipant() { - ISynchronizeParticipantReference reference = TeamUI.getSynchronizeManager().get(WorkspaceSynchronizeParticipant.ID, null); - try { - if(reference != null) { - return (WorkspaceSynchronizeParticipant)reference.getParticipant(); - } else { - return null; - } - } catch (TeamException e) { - return null; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java deleted file mode 100644 index 6bc55702a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - bug 57208 - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ui.dialogs.DialogArea; - -/** - * This area provides the widgets for providing the CVS commit comment - */ -public class CommitCommentArea extends DialogArea { - - private static final int WIDTH_HINT = 350; - private static final int HEIGHT_HINT = 50; - - private Text text; - private Combo previousCommentsCombo; - private IProject mainProject; - private String[] comments = new String[0]; - private String comment = ""; //$NON-NLS-1$ - - public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$ - public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$ - private String proposedComment; - - /** - * Constructor for CommitCommentArea. - * @param parentDialog - * @param settings - */ - public CommitCommentArea() { - comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.DialogArea#createArea(org.eclipse.swt.widgets.Composite) - */ - public void createArea(Composite parent) { - Dialog.applyDialogFont(parent); - Composite composite = createGrabbingComposite(parent, 1); - initializeDialogUnits(composite); - - Label label = new Label(composite, SWT.NULL); - label.setLayoutData(new GridData()); - label.setText(Policy.bind("ReleaseCommentDialog.enterComment")); //$NON-NLS-1$ - - text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = WIDTH_HINT; - data.heightHint = HEIGHT_HINT; - - text.setLayoutData(data); - text.selectAll(); - text.addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) { - e.doit = false; - CommitCommentArea.this.signalCtrlEnter(); - } - } - }); - text.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - String oldComment = comment; - comment = text.getText(); - CommitCommentArea.this.signalCommentModified(oldComment, comment); - } - }); - - - label = new Label(composite, SWT.NULL); - label.setLayoutData(new GridData()); - label.setText(Policy.bind("ReleaseCommentDialog.choosePrevious")); //$NON-NLS-1$ - - previousCommentsCombo = new Combo(composite, SWT.READ_ONLY); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - previousCommentsCombo.setLayoutData(data); - - // Initialize the values before we register any listeners so - // we don't get any platform specific selection behavior - // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078) - initializeValues(); - - previousCommentsCombo.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int index = previousCommentsCombo.getSelectionIndex(); - if (index != -1) - text.setText(comments[index]); - } - }); - } - - /** - * Method initializeValues. - */ - private void initializeValues() { - - // populate the previous comment list - for (int i = 0; i < comments.length; i++) { - previousCommentsCombo.add(HistoryView.flattenText(comments[i])); - } - - // We don't want to have an initial selection - // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078) - previousCommentsCombo.setText(""); //$NON-NLS-1$ - - // determine the initial comment text - String initialComment = proposedComment; - if (initialComment == null) { - try { - initialComment = getCommitTemplate(); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - if (initialComment != null && initialComment.length() != 0) { - text.setText(initialComment); - } - } - - /** - * Method signalCtrlEnter. - */ - private void signalCtrlEnter() { - firePropertyChangeChange(OK_REQUESTED, null, null); - } - - protected void signalCommentModified(String oldValue, String comment) { - firePropertyChangeChange(COMMENT_MODIFIED, oldValue, comment); - } - - private String getCommitTemplate() throws CVSException { - CVSTeamProvider provider = getProvider(); - if (provider == null) return ""; //$NON-NLS-1$ - String template = provider.getCommitTemplate(); - if (template == null) template = ""; //$NON-NLS-1$ - return template; - } - - /** - * Method getProvider. - */ - private CVSTeamProvider getProvider() { - if (mainProject == null) return null; - return (CVSTeamProvider) RepositoryProvider.getProvider(mainProject, CVSProviderPlugin.getTypeId()); - } - - /** - * Return the entered comment - * - * @return the comment - */ - public String[] getComments() { - return comments; - } - - /** - * Returns the comment. - * @return String - */ - public String getComment() { - if (comment != null && comment.length() > 0) finished(); - return comment; - } - - /** - * Method setProject. - * @param iProject - */ - public void setProject(IProject iProject) { - this.mainProject = iProject; - } - - private void finished() { - // strip template from the comment entered - try { - String commitTemplate = getCommitTemplate(); - if (comment.startsWith(commitTemplate)) { - comment = comment.substring(commitTemplate.length()); - } else if (comment.endsWith(commitTemplate)) { - comment = comment.substring(0, comment.length() - commitTemplate.length()); - } - } catch (CVSException e) { - // we couldn't get the commit template. Log the error and continue - CVSUIPlugin.log(e); - } - // if there is still a comment, remember it - if (comment.length() > 0) { - CVSUIPlugin.getPlugin().getRepositoryManager().addComment(comment); - } - } - - public void setFocus() { - if (text != null) { - text.setFocus(); - } - } - - public void setProposedComment(String proposedComment) { - this.proposedComment = proposedComment; - } - - public boolean hasCommitTemplate() { - try { - String commitTemplate = getCommitTemplate(); - return commitTemplate != null && commitTemplate.length() > 0; - } catch (CVSException e) { - CVSUIPlugin.log(e); - return false; - } - } - - public void setEnabled(boolean b) { - text.setEnabled(b); - previousCommentsCombo.setEnabled(b); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java deleted file mode 100644 index 240e63e5d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Preference page for configuring CVS comparisons - */ -public class ComparePreferencePage extends CVSFieldEditorPreferencePage { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId() - */ - protected String getPageHelpContextId() { - return IHelpContextIds.COMPARE_PREFERENCE_PAGE; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageDescription() - */ - protected String getPageDescription() { - return Policy.bind("ComparePreferencePage.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - protected void createFieldEditors() { - addField(new BooleanFieldEditor( - ICVSUIConstants.PREF_CONSIDER_CONTENTS, - Policy.bind("CVSPreferencePage.considerContentsInCompare"), //$NON-NLS-1$ - BooleanFieldEditor.DEFAULT, - getFieldEditorParent()) { - protected Button getChangeControl(Composite parent) { - Button button = super.getChangeControl(parent); - WorkbenchHelp.setHelp(button, IHelpContextIds.PREF_CONSIDER_CONTENT); - return button; - } - }); - addField(new BooleanFieldEditor( - ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG, - Policy.bind("CVSPreferencePage.showCompareMergeInSync"), //$NON-NLS-1$ - BooleanFieldEditor.DEFAULT, - getFieldEditorParent())); - addField(new BooleanFieldEditor( - ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR, - Policy.bind("ComparePreferencePage.1"), //$NON-NLS-1$ - BooleanFieldEditor.DEFAULT, - getFieldEditorParent())); - addField(new BooleanFieldEditor( - ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, - Policy.bind("ComparePreferencePage.2"), //$NON-NLS-1$ - BooleanFieldEditor.DEFAULT, - getFieldEditorParent())); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#pushPreferences() - */ - protected void pushPreferences() { - super.pushPreferences(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java deleted file mode 100644 index ef8e8e321..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java +++ /dev/null @@ -1,263 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.text.SimpleDateFormat; -import java.util.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.dialogs.DialogArea; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Dialog for obtaining a date from the user - */ -public class DateTagDialog extends Dialog { - - DateArea dateArea; - TimeArea timeArea; - IDialogSettings settings; - private Date dateEntered; - - public class DateArea extends DialogArea { - - private Combo fromDayCombo; - private Combo fromMonthCombo; - private Combo fromYearCombo; - - public void createArea(Composite parent) { - Composite composite = createComposite(parent, 4, false); - initializeDialogUnits(composite); - createLabel(composite, Policy.bind("DateTagDialog.0"), 1); //$NON-NLS-1$ - fromMonthCombo = new Combo(composite, SWT.READ_ONLY); - fromDayCombo = new Combo(composite, SWT.READ_ONLY); - fromDayCombo.setTextLimit(2); - fromYearCombo = new Combo(composite, SWT.NONE); - fromYearCombo.setTextLimit(4); - - //set day, month and year combos with numbers - //years allows a selection from the past 5 years - //or any year written in - String days[] = new String[31]; - for (int i = 0; i < 31; i++) { - days[i] = String.valueOf(i+1); - } - - String months[] = new String[12]; - SimpleDateFormat format = new SimpleDateFormat("MMMM"); //$NON-NLS-1$ - Calendar calendar = Calendar.getInstance(); - for (int i = 0; i < 12; i++) { - calendar.set(Calendar.MONTH, i); - months[i] = format.format(calendar.getTime()); - } - - String years[] = new String[5]; - Calendar calender = Calendar.getInstance(); - for (int i = 0; i < 5; i++) { - years[i] = String.valueOf(calender.get(1) - i); - } - fromDayCombo.setItems(days); - fromMonthCombo.setItems(months); - fromYearCombo.setItems(years); - } - - public void initializeValues(Calendar calendar ) { - fromDayCombo.select(calendar.get(Calendar.DATE) - 1); - fromMonthCombo.select(calendar.get(Calendar.MONTH)); - String yearValue = String.valueOf(calendar.get(Calendar.YEAR)); - int index = fromYearCombo.indexOf(yearValue); - if (index == -1) { - fromYearCombo.add(yearValue); - index = fromYearCombo.indexOf(yearValue); - } - fromYearCombo.select(index); - timeArea.initializeValues(calendar); - } - - public void updateWidgetEnablements() { - // Do nothing - } - - public void adjustCalendar(Calendar calendar) { - calendar.set( - Integer.parseInt(String.valueOf(fromYearCombo.getText())), - fromMonthCombo.getSelectionIndex(), - Integer.parseInt(String.valueOf(fromDayCombo.getText())), - 0,0,0); - } - } - public class TimeArea extends DialogArea { - - private Combo hourCombo; - private Combo minuteCombo; - private Combo secondCombo; - private Button includeTime, localTime, utcTime; - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DialogArea#createArea(org.eclipse.swt.widgets.Composite) - */ - public void createArea(Composite parent) { - Composite composite = createComposite(parent, 2, false); - initializeDialogUnits(composite); - includeTime = createCheckbox(composite, Policy.bind("DateTagDialog.1"), 2); //$NON-NLS-1$ - createLabel(composite, Policy.bind("DateTagDialog.2"), 1); //$NON-NLS-1$ - Composite dateComposite = new Composite(composite, SWT.NONE); - GridLayout dateLayout = new GridLayout(); - dateLayout.numColumns = 3; - dateComposite.setLayout(dateLayout); - hourCombo = new Combo(dateComposite, SWT.READ_ONLY); - hourCombo.setTextLimit(2); - minuteCombo = new Combo(dateComposite, SWT.READ_ONLY); - minuteCombo.setTextLimit(2); - secondCombo = new Combo(dateComposite, SWT.READ_ONLY); - secondCombo.setTextLimit(2); - localTime = createRadioButton(composite, Policy.bind("DateTagDialog.3"), 2); //$NON-NLS-1$ - utcTime = createRadioButton(composite, Policy.bind("DateTagDialog.4"), 2); //$NON-NLS-1$ - - String sixty[] = new String[60]; - for (int i = 0; i < 60; i++) { - sixty[i] = String.valueOf(i); - } - String hours[] = new String[24]; - for (int i = 0; i < 24; i++) { - hours[i] = String.valueOf(i); - } - hourCombo.setItems(hours); - minuteCombo.setItems(sixty); - secondCombo.setItems(sixty); - - includeTime.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateWidgetEnablements(); - } - }); - } - - public void initializeValues(Calendar calendar) { - hourCombo.select(calendar.get(Calendar.HOUR_OF_DAY));//24 hour clock - minuteCombo.select(calendar.get(Calendar.MINUTE)); - secondCombo.select(calendar.get(Calendar.SECOND)); - - includeTime.setSelection(settings.getBoolean("includeTime")); //$NON-NLS-1$ - localTime.setSelection(!settings.getBoolean("utcTime")); //$NON-NLS-1$ - utcTime.setSelection(settings.getBoolean("utcTime")); //$NON-NLS-1$ - } - public void updateWidgetEnablements() { - hourCombo.setEnabled(includeTime.getSelection()); - minuteCombo.setEnabled(includeTime.getSelection()); - secondCombo.setEnabled(includeTime.getSelection()); - localTime.setEnabled(includeTime.getSelection()); - utcTime.setEnabled(includeTime.getSelection()); - } - public void adjustCalendar(Calendar calendar) { - if (includeTime.getSelection()) { - calendar.set(Calendar.HOUR_OF_DAY, hourCombo.getSelectionIndex());//24 hour clock - calendar.set(Calendar.MINUTE, minuteCombo.getSelectionIndex()); - calendar.set(Calendar.SECOND, secondCombo.getSelectionIndex()); - if (utcTime.getSelection()) { - calendar.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ - } - } - } - } - - public DateTagDialog(Shell parentShell) { - super(parentShell); - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - this.settings = workbenchSettings.getSection("DateTagDialog");//$NON-NLS-1$ - if (this.settings == null) { - this.settings = workbenchSettings.addNewSection("DateTagDialog");//$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * Method declared on Window. - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Policy.bind("DateTagDialog.5")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite topLevel = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - initializeDialogUnits(topLevel); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - topLevel.setLayout(layout); - - createDateArea(topLevel); - createTimeArea(topLevel); - initializeValues(); - updateWidgetEnablements(); - - // set F1 help - WorkbenchHelp.setHelp(topLevel, IHelpContextIds.DATE_TAG_DIALOG); - Dialog.applyDialogFont(parent); - return topLevel; - } - - private void createDateArea(Composite topLevel) { - dateArea = new DateArea(); - dateArea.createArea(topLevel); - } - - private void createTimeArea(Composite topLevel) { - timeArea = new TimeArea(); - timeArea.createArea(topLevel); - } - - private void initializeValues() { - Calendar calendar = Calendar.getInstance(); - dateArea.initializeValues(calendar); - timeArea.initializeValues(calendar); - } - - private void updateWidgetEnablements() { - timeArea.updateWidgetEnablements(); - dateArea.updateWidgetEnablements(); - } - - /** - * Return the date specified by the user in UTC. - * @return the date specified by the user - */ - public Date getDate() { - return dateEntered; - } - - private Date privateGetDate() { - Calendar calendar = Calendar.getInstance(); - dateArea.adjustCalendar(calendar); - timeArea.adjustCalendar(calendar); - return calendar.getTime(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - dateEntered = privateGetDate(); - } - super.buttonPressed(buttonId); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java deleted file mode 100644 index 4a770a08e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.EditorsInfo; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * - * A dialog for showing the result of a cvs editors command. - * Currently not in use, but can be used before executing the edit command - * - * @author Gregor Kohlwes - */ -public class EditorsDialog extends Dialog { - /** - * Constructor EditorsDialog. - * @param shell - * @param iEditorsInfos - */ - - EditorsView editorsView; - EditorsInfo[] editorsInfo; - - public EditorsDialog(Shell shell, EditorsInfo[] infos) { - super(shell); - editorsInfo = infos; - } - - protected Control createDialogArea(Composite container) { - - Composite parent = (Composite) super.createDialogArea(container); - - getShell().setText(Policy.bind("EditorsDialog.title")); //$NON-NLS-1$ - createMessageArea(parent); - editorsView = new EditorsView(); - editorsView.createPartControl(container); - editorsView.setInput(editorsInfo); - - // set F1 help - WorkbenchHelp.setHelp(parent, IHelpContextIds.EDITORS_DIALOG); - - Dialog.applyDialogFont(parent); - - return parent; - } - /** - * Method createMessageArea. - * @param parent - */ - private void createMessageArea(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(Policy.bind("EditorsDialog.question")); //$NON-NLS-1$ - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java deleted file mode 100644 index fece678db..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.team.internal.ccvs.core.EditorsInfo; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.ViewPart; - -/** - * - * The EditorsView shows the result of cvs editors command - * - * @author Gregor Kohlwes - * @see org.eclipse.team.internal.ccvs.ui.actions.ShowEditorsAction - */ -public class EditorsView extends ViewPart { - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.EditorsView"; //$NON-NLS-1$ - - private Table table; - private TableViewer tableViewer; - - class EditorsContentProvider implements IStructuredContentProvider { - - /** - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - return (EditorsInfo[]) inputElement; - } - - /** - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } - - /** - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged( - Viewer viewer, - Object oldInput, - Object newInput) { - } - - } - - class EditorsLabelProvider 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) { - if (element == null) - return ""; //$NON-NLS-1$ - EditorsInfo info = (EditorsInfo) element; - - String result = null; - switch (columnIndex) { - case 0 : - result = info.getFileName(); - break; - case 1 : - result = info.getUserName(); - break; - case 2 : - result = info.getDateString(); - break; - case 3 : - result = info.getComputerName(); - break; - } - // This method must not return null - if (result == null) result = ""; //$NON-NLS-1$ - return result; - - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - } - - } - - /** - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint=500; - gridData.heightHint=100; - table.setLayoutData(gridData); - - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - tableViewer = new TableViewer(table); - createColumns(table, layout); - - tableViewer.setContentProvider(new EditorsContentProvider()); - tableViewer.setLabelProvider(new EditorsLabelProvider()); - // set F1 help - WorkbenchHelp.setHelp(tableViewer.getControl(), IHelpContextIds.CVS_EDITORS_VIEW); - } - public void setInput(EditorsInfo[] infos) { - tableViewer.setInput(infos); - } - /** - * Method createColumns. - * @param table - * @param layout - * @param viewer - */ - private void createColumns(Table table, TableLayout layout) { - - TableColumn col; - // file name - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("EditorsView.file")); //$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(30, true)); - - // user name - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("EditorsView.user")); //$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(20, true)); - - // creation date - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("EditorsView.date")); //$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(30, true)); - - // computer name - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("EditorsView.computer")); //$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(20, true)); - - } - - /** - * @see org.eclipse.ui.IWorkbenchPart#setFocus() - */ - public void setFocus() { - } - /** - * Method getTable. - */ - public Table getTable() { - return table; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java deleted file mode 100644 index 7ff41d56f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -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.Text; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.IConnectionMethod; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - - Text cvsRsh; - Text cvsServer; - Text cvsRshParameters; - private Button useExternal; - private Button useInternal; - private Combo methodType; - private Control internal, external; - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 1; - composite.setLayout(layout); - composite.setLayoutData(new GridData()); - - SelectionAdapter selectionListener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateEnablements(); - } - }; - - useExternal = createRadioButton(composite, Policy.bind("ExtMethodPreferencePage.0"), 1); //$NON-NLS-1$ - useExternal.addSelectionListener(selectionListener); - external = createExternalArea(composite); - - useInternal = createRadioButton(composite, Policy.bind("ExtMethodPreferencePage.1"), 1); //$NON-NLS-1$ - useInternal.addSelectionListener(selectionListener); - internal = createInternalArea(composite); - - initializeDefaults(); - WorkbenchHelp.setHelp(composite, IHelpContextIds.EXT_PREFERENCE_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - - private void updateEnablements() { - external.setEnabled(useExternal.getSelection()); - cvsRsh.setEnabled(useExternal.getSelection()); - cvsRshParameters.setEnabled(useExternal.getSelection()); - cvsServer.setEnabled(useExternal.getSelection()); - internal.setEnabled(!useExternal.getSelection()); - methodType.setEnabled(!useExternal.getSelection()); - } - - private Control createInternalArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - layout.numColumns = 2; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label intro = new Label(composite, SWT.LEFT | SWT.WRAP); - intro.setText(Policy.bind("ExtMethodPreferencePage.2")); //$NON-NLS-1$ - GridData data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - intro.setLayoutData(data); - - createLabel(composite, Policy.bind("CVSPropertiesPage.connectionType"), 1); //$NON-NLS-1$ - methodType = createCombo(composite); - return composite; - } - protected Control createExternalArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - layout.numColumns = 3; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label intro = new Label(composite, SWT.LEFT | SWT.WRAP); - intro.setText(Policy.bind("ExtMethodPreferencePage_message")); //$NON-NLS-1$ - GridData data = new GridData(); - data.horizontalSpan = 3; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - intro.setLayoutData(data); - - new Label(composite, SWT.LEFT).setText(Policy.bind("ExtMethodPreferencePage_CVS_RSH")); //$NON-NLS-1$ - cvsRsh = new Text(composite, SWT.BORDER); - cvsRsh.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - final Button b = new Button(composite, SWT.NONE); - b.setText(Policy.bind("ExtMethodPreferencePage_Browse")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - data.widthHint = Math.max(widthHint, b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - b.setLayoutData(data); - b.addListener(SWT.MouseDown, new Listener() { - public void handleEvent (Event event) { - FileDialog d = new FileDialog(getShell()); - d.setText(Policy.bind("ExtMethodPreferencePage_Details")); //$NON-NLS-1$ - String file = d.open(); - if(file!=null) { - setCvsRshText(file); - } - } - }); - - new Label(composite, SWT.LEFT).setText(Policy.bind("ExtMethodPreferencePage_CVS_RSH_Parameters")); //$NON-NLS-1$ - cvsRshParameters = new Text(composite, SWT.BORDER); - data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - cvsRshParameters.setLayoutData(data); - - new Label(composite, SWT.LEFT).setText(Policy.bind("ExtMethodPreferencePage_CVS_SERVER__7")); //$NON-NLS-1$ - cvsServer = new Text(composite, SWT.BORDER); - data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - cvsServer.setLayoutData(data); - - WorkbenchHelp.setHelp(cvsRsh, IHelpContextIds.EXT_PREFERENCE_RSH); - WorkbenchHelp.setHelp(cvsRshParameters, IHelpContextIds.EXT_PREFERENCE_PARAM); - WorkbenchHelp.setHelp(cvsServer, IHelpContextIds.EXT_PREFERENCE_SERVER); - return composite; - } - - private void initializeDefaults() { - IPreferenceStore store = getPreferenceStore(); - String rsh = store.getString(ICVSUIConstants.PREF_CVS_RSH); - String parameter = store.getString(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS); - String server = store.getString(ICVSUIConstants.PREF_CVS_SERVER); - String method = store.getString(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY); - initializeDefaults(rsh, parameter, server, method); - } - - /* - * Set CVS_RSH program - */ - protected void setCvsRshText(String s) { - cvsRsh.setText(s); - } - - /* - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /* - * @see IPreferencePage#performOk() - */ - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - String method; - if (useExternal.getSelection()) { - method = "ext"; //$NON-NLS-1$ - store.setValue(ICVSUIConstants.PREF_CVS_RSH, cvsRsh.getText()); - store.setValue(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS, cvsRshParameters.getText()); - store.setValue(ICVSUIConstants.PREF_CVS_SERVER, cvsServer.getText()); - CVSProviderPlugin.getPlugin().setCvsRshCommand(cvsRsh.getText()); - CVSProviderPlugin.getPlugin().setCvsRshParameters(cvsRshParameters.getText()); - CVSProviderPlugin.getPlugin().setCvsServer(cvsServer.getText()); - } else { - method = methodType.getText(); - } - store.setValue(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY, method); - CVSRepositoryLocation.setExtConnectionMethodProxy(method); - CVSUIPlugin.getPlugin().savePluginPreferences(); - return super.performOk(); - } - - /* - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() { - IPreferenceStore store = getPreferenceStore(); - String rsh = store.getDefaultString(ICVSUIConstants.PREF_CVS_RSH); - String parameter = store.getDefaultString(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS); - String server = store.getDefaultString(ICVSUIConstants.PREF_CVS_SERVER); - String method = store.getDefaultString(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY); - initializeDefaults(rsh, parameter, server, method); - super.performDefaults(); - } - - private void initializeDefaults(String rsh, String parameters, String server, String method) { - cvsRsh.setText(rsh); - cvsRshParameters.setText(parameters); - cvsServer.setText(server); - IConnectionMethod[] methods = CVSRepositoryLocation.getPluggedInConnectionMethods(); - for (int i = 0; i < methods.length; i++) { - String name = methods[i].getName(); - if (!name.equals("ext")) { //$NON-NLS-1$ - methodType.add(name); - } - } - if (method.equals("ext")) { //$NON-NLS-1$ - methodType.select(0); - } else { - methodType.select(methodType.indexOf(method)); - } - useExternal.setSelection(method.equals("ext")); //$NON-NLS-1$ - useInternal.setSelection(!method.equals("ext")); //$NON-NLS-1$ - updateEnablements(); - } - - /* - * @see PreferencePage#doGetPreferenceStore() - */ - protected IPreferenceStore doGetPreferenceStore() { - return CVSUIPlugin.getPlugin().getPreferenceStore(); - } - - protected Button createRadioButton(Composite parent, String label, int span) { - Button button = new Button(parent, SWT.RADIO); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = span; - button.setLayoutData(data); - return button; - } - - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - protected Combo createCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - data.horizontalSpan = 1; - combo.setLayoutData(data); - return combo; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java deleted file mode 100644 index 45c3eabb4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSCoreFileModificationValidator; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.ui.actions.EditorsAction; - -/** - * IFileModificationValidator that is pluged into the CVS Repository Provider - */ -public class FileModificationValidator extends CVSCoreFileModificationValidator { - - public FileModificationValidator() { - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.CVSCoreFileModificationValidator#edit(org.eclipse.core.resources.IFile[], java.lang.Object) - */ - protected IStatus edit(IFile[] readOnlyFiles, Object context) { - return edit(readOnlyFiles, getShell(context)); - } - - private Shell getShell(Object context) { - if (context instanceof Shell) - return (Shell)context; - return null; - } - - private IStatus getStatus(InvocationTargetException e) { - Throwable target = e.getTargetException(); - if (target instanceof TeamException) { - return ((TeamException) target).getStatus(); - } else if (target instanceof CoreException) { - return ((CoreException) target).getStatus(); - } - return new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, Policy.bind("internal"), target); //$NON-NLS-1$ - } - - private IStatus edit(final IFile[] files, final Shell shell) { - if (isPerformEdit()) { - try { - if (shell != null && !promptToEditFiles(files, shell)) { - // The user didn't want to edit. - // OK is returned but the file remains read-only - throw new InterruptedException(); - } - - // Run the edit in a runnable in order to get a busy cursor. - // This runnable is syncExeced in order to get a busy cursor - IRunnableWithProgress editRunnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - performEdit(files, monitor); - } catch (CVSException e) { - new InvocationTargetException(e); - } - } - }; - if (isRunningInUIThread()) { - // Only show a busy cursor if validate edit is blocking the UI - CVSUIPlugin.runWithProgress(shell, false, editRunnable); - } else { - // We can't show a busy cursor (i.e., run in the UI thread) - // since this thread may hold locks and - // running an edit in the UI thread could try to obtain the - // same locks, resulting in a deadlock. - editRunnable.run(new NullProgressMonitor()); - } - } catch (InvocationTargetException e) { - return getStatus(e); - } catch (InterruptedException e) { - // Must return an error to indicate that it is not OK to edit the files - return new Status(IStatus.CANCEL, CVSUIPlugin.ID, 0, Policy.bind("FileModificationValidator.vetoMessage"), null); //$NON-NLS-1$; - } - } else { - // Allow the files to be edited without notifying the server - return setWritable(files); - } - - return Status.OK_STATUS; - - } - - private boolean isRunningInUIThread() { - return Display.getCurrent() != null; - } - - private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { - if (files.length == 0) - return true; - - if(isNeverPrompt()) - return true; - - // Contact the server to see if anyone else is editing the files - EditorsAction editors = fetchEditors(files, shell); - if (editors.isEmpty()) { - if (isAlwaysPrompt()) - return (promptEdit(shell)); - return true; - } else { - return (editors.promptToEdit(shell)); - } - } - - private boolean promptEdit(Shell shell) { - // Open the dialog using a sync exec (there are no guarentees that we - // were called from the UI thread - final boolean[] result = new boolean[] { false }; - int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - result[0] = MessageDialog.openQuestion(shell,Policy.bind("FileModificationValidator.3"),Policy.bind("FileModificationValidator.4")); //$NON-NLS-1$ //$NON-NLS-2$ - } - }, flags); - return result[0]; - } - - private boolean isPerformEdit() { - return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); - } - - private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { - final EditorsAction editors = new EditorsAction(getProvider(files), files); - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - editors.run(monitor); - } - }; - if (isRunningInUIThread()) { - // Show a busy cursor if we are running in the UI thread - CVSUIPlugin.runWithProgress(shell, false, runnable); - } else { - // We can't show a busy cursor (i.e., run in the UI thread) - // since this thread may hold locks and - // running a CVS operation in the UI thread could try to obtain the - // same locks, resulting in a deadlock. - runnable.run(new NullProgressMonitor()); - } - return editors; - } - - private boolean isNeverPrompt() { - return ICVSUIConstants.PREF_EDIT_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT)); - } - - private boolean isAlwaysPrompt() { - return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT)); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryDropAdapter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryDropAdapter.java deleted file mode 100644 index 1e3fe6ee5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryDropAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.ViewerDropAdapter; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.ui.part.ResourceTransfer; - -public class HistoryDropAdapter extends ViewerDropAdapter { - HistoryView view; - - public HistoryDropAdapter(StructuredViewer viewer, HistoryView view) { - super(viewer); - this.view = view; - } - /* - * Override dragOver to slam the detail to DROP_LINK, as we do not - * want to really execute a DROP_MOVE, although we want to respond - * to it. - */ - public void dragOver(DropTargetEvent event) { - if ((event.operations & DND.DROP_LINK) == DND.DROP_LINK) { - event.detail = DND.DROP_LINK; - } - super.dragOver(event); - } - /* - * Override drop to slam the detail to DROP_LINK, as we do not - * want to really execute a DROP_MOVE, although we want to respond - * to it. - */ - public void drop(DropTargetEvent event) { - super.drop(event); - event.detail = DND.DROP_LINK; - } - public boolean performDrop(Object data) { - if (data == null) return false; - IResource[] sources = (IResource[])data; - if (sources.length == 0) return false; - IResource resource = sources[0]; - if (!(resource instanceof IFile)) return false; - view.showHistory(resource, true /* fetch */); - return true; - } - public boolean validateDrop(Object target, int operation, TransferData transferType) { - if (transferType != null && ResourceTransfer.getInstance().isSupportedType(transferType)) { - return true; - } - return false; - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java deleted file mode 100644 index 2be43c760..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.Date; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.team.internal.ccvs.core.ILogEntry; - -public class HistoryFilter extends ViewerFilter { - private HistoryView view; - public String author; - public Date fromDate; - public Date toDate; - public String comment; - public boolean isOr; - - public HistoryFilter(HistoryView hView, String author, String comment, Date fromDate, Date toDate, boolean isOr) { - this.view = hView; - this.author = author; - this.comment = comment; - this.fromDate = fromDate; - this.toDate = toDate; - this.isOr = isOr; - } - /** - * @see ViewerFilter#select(Viewer, Object, Object) - */ - public boolean select(Viewer aviewer, Object parentElement, Object element) { - if (element instanceof ILogEntry) { - ILogEntry entry = (ILogEntry)element; - if (isOr) { - //empty fields should be considered a non-match - return (hasAuthor() && authorMatch(entry) ) - || (hasDate() && dateMatch(entry)) - || (hasComment() && commentMatch(entry)); - } else { - //"and" search - //empty fields should be considered a match - return (!hasAuthor() || authorMatch(entry)) - && (!hasDate() || dateMatch(entry)) - && (!hasComment() || commentMatch(entry)); - } - } - return false; - } - protected boolean authorMatch(ILogEntry entry) { - return entry.getAuthor().equals(author); - } - protected boolean commentMatch(ILogEntry entry) { - return !(entry.getComment().toLowerCase().indexOf(comment.toLowerCase()) == -1); - } - protected boolean dateMatch(ILogEntry entry) { - return (fromDate.before(entry.getDate())) - && (toDate.after(entry.getDate())); - } - protected boolean hasAuthor() { - return !author.equals(""); //$NON-NLS-1$ - } - protected boolean hasComment() { - return !comment.equals(""); //$NON-NLS-1$ - } - protected boolean hasDate() { - return fromDate != null && toDate != null; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterAction.java deleted file mode 100644 index 3dda72428..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -public class HistoryFilterAction implements IViewActionDelegate { - private HistoryView view; - private HistoryFilter filter; - - /** - * @see IViewActionDelegate#init(IViewPart) - */ - public void init(IViewPart view) { - this.view = (HistoryView)view; - } - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - HistoryFilterDialog historyDialog = new HistoryFilterDialog(view); - if (filter != null) { - historyDialog.setFilter(filter); - } - if (historyDialog.open() == Window.CANCEL) { - return; - } - if (filter != null) { - view.getViewer().removeFilter(filter); - } - filter = historyDialog.getFilter(); - //don't add the filter if it is blank - if (!(filter.hasAuthor() || filter.hasDate() || filter.hasComment())) { - return; - } - view.getViewer().addFilter(filter); - } - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java deleted file mode 100644 index 1e27ea851..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.help.WorkbenchHelp; - -public class HistoryFilterDialog extends Dialog { - - private HistoryView historyView; - private HistoryFilter historyFilter; - - //widgets - private Button orRadio; - private Button andRadio; - private Combo fromDayCombo; - private Combo toDayCombo; - private Combo fromMonthCombo; - private Combo toMonthCombo; - private Combo fromYearCombo; - private Combo toYearCombo; - private Text author; - private Text comment; - - public HistoryFilterDialog(HistoryView view) { - super(view.getViewSite().getShell()); - this.historyView = view; - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Policy.bind("HistoryFilterDialog.title")); //$NON-NLS-1$ - } - - protected Control createDialogArea(Composite parent) { - Composite topLevel = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - topLevel.setLayout(layout); - - //"and" and "or" search radio buttons - Label label = new Label(topLevel, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setText(Policy.bind("HistoryFilterDialog.showMatching")); //$NON-NLS-1$ - - andRadio = new Button(topLevel, SWT.RADIO); - andRadio.setText(Policy.bind("HistoryFilterDialog.matchingAll")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - andRadio.setLayoutData(data); - andRadio.setSelection(true); - - orRadio = new Button(topLevel, SWT.RADIO); - orRadio.setText(Policy.bind("HistoryFilterDialog.matchingAny")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - orRadio.setLayoutData(data); - - //author - label = new Label(topLevel, SWT.NONE); - label.setText(Policy.bind("HistoryFilterDialog.author")); //$NON-NLS-1$ - author = new Text(topLevel, SWT.BORDER); - author.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - //comment - label = new Label(topLevel, SWT.NONE); - label.setText(Policy.bind("HistoryFilterDialog.comment")); //$NON-NLS-1$ - comment = new Text(topLevel, SWT.BORDER); - comment.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - //"from" date - label = new Label(topLevel, SWT.NONE); - label.setText(Policy.bind("HistoryFilterDialog.fromDate")); //$NON-NLS-1$ - Composite fdComposite = new Composite(topLevel, SWT.NONE); - GridLayout fdLayout = new GridLayout(); - fdLayout.numColumns = 3; - fdComposite.setLayout(fdLayout); - fromMonthCombo = new Combo(fdComposite, SWT.READ_ONLY); - fromDayCombo = new Combo(fdComposite, SWT.READ_ONLY); - fromYearCombo = new Combo(fdComposite, SWT.NONE); - fromYearCombo.setTextLimit(4); - - //"to" date - label = new Label(topLevel, SWT.NONE); - label.setText(Policy.bind("HistoryFilterDialog.toDate")); //$NON-NLS-1$ - Composite tdComposite = new Composite(topLevel, SWT.NONE); - GridLayout tdLayout = new GridLayout(); - tdLayout.numColumns = 3; - tdComposite.setLayout(tdLayout); - toMonthCombo = new Combo(tdComposite, SWT.READ_ONLY); - toDayCombo = new Combo(tdComposite, SWT.READ_ONLY); - toYearCombo = new Combo(tdComposite, SWT.NONE); - toYearCombo.setTextLimit(4); - - //set day, month and year combos with numbers - //years allows a selection from the past 5 years - //or any year written in - String days[] = new String[32]; - days[0] = "---"; //$NON-NLS-1$ - for (int i = 1; i < 32; i++) { - days[i] = String.valueOf(i); - } - - String months[] = new String[13]; - months[0] = "---"; //$NON-NLS-1$ - SimpleDateFormat format = new SimpleDateFormat("MMMM"); //$NON-NLS-1$ - Calendar calendar = Calendar.getInstance(); - for (int i = 1; i < 13; i++) { - calendar.set(Calendar.MONTH, i - 1); - months[i] = format.format(calendar.getTime()); - } - - String years[] = new String[5]; - Calendar calender = Calendar.getInstance(); - for (int i = 0; i < 5; i++) { - years[i] = String.valueOf(calender.get(1) - i); - } - fromDayCombo.setItems(days); - fromDayCombo.select(0); - toDayCombo.setItems(days); - toDayCombo.select(0); - fromMonthCombo.setItems(months); - fromMonthCombo.select(0); - toMonthCombo.setItems(months); - toMonthCombo.select(0); - fromYearCombo.setItems(years); - toYearCombo.setItems(years); - fromYearCombo.select(0); - toYearCombo.select(0); - - initializeValues(); - - // set F1 help - WorkbenchHelp.setHelp(topLevel, IHelpContextIds.HISTORY_FILTER_DIALOG); - Dialog.applyDialogFont(parent); - return topLevel; - } - void initializeValues() { - if (historyFilter == null) return; - if (historyFilter.author != null) { - author.setText(historyFilter.author); - } - if (historyFilter.comment != null) { - comment.setText(historyFilter.comment); - } - orRadio.setSelection(historyFilter.isOr); - andRadio.setSelection(!historyFilter.isOr); - Calendar calendar = Calendar.getInstance(); - if (historyFilter.fromDate != null) { - calendar.setTime(historyFilter.fromDate); - fromDayCombo.select(calendar.get(Calendar.DATE)); - fromMonthCombo.select(calendar.get(Calendar.MONTH) + 1); - String yearValue = String.valueOf(calendar.get(Calendar.YEAR)); - int index = fromYearCombo.indexOf(yearValue); - if (index == -1) { - fromYearCombo.add(yearValue); - index = fromYearCombo.indexOf(yearValue); - } - fromYearCombo.select(index); - } - if (historyFilter.toDate != null) { - calendar.setTime(historyFilter.toDate); - toDayCombo.select(calendar.get(Calendar.DATE)); - toMonthCombo.select(calendar.get(Calendar.MONTH) + 1); - String yearValue = String.valueOf(calendar.get(Calendar.YEAR)); - int index = toYearCombo.indexOf(yearValue); - if (index == -1) { - toYearCombo.add(yearValue); - index = toYearCombo.indexOf(yearValue); - } - toYearCombo.select(index); - } - } - /** - * A button has been pressed. Process the dialog contents. - */ - protected void buttonPressed(int buttonId) { - if (IDialogConstants.CANCEL_ID == buttonId) { - super.buttonPressed(buttonId); - return; - } - Date fromDate = null, toDate = null; - - if ((fromMonthCombo.getSelectionIndex() > 0) - && (toMonthCombo.getSelectionIndex() > 0) - && (fromDayCombo.getSelectionIndex() > 0) - && (toDayCombo.getSelectionIndex() > 0) - && (fromYearCombo.getText().length() > 0) - && (toYearCombo.getText().length() > 0)) { - - //set the calendar with the user input - //set the hours, minutes and seconds to 00 - //so as to cover the whole day - Calendar calendar = Calendar.getInstance(); - calendar.set( - Integer.parseInt(String.valueOf(fromYearCombo.getText())), - fromMonthCombo.getSelectionIndex() - 1, - Integer.parseInt(String.valueOf(fromDayCombo.getText())), - 00, 00, 00); - fromDate = calendar.getTime(); - - //set the calendar with the user input - //set the hours, minutes and seconds to 23, 59, 59 - //so as to cover the whole day - calendar.set( - Integer.parseInt(String.valueOf(toYearCombo.getText())), - toMonthCombo.getSelectionIndex() - 1, - Integer.parseInt(String.valueOf(toDayCombo.getText())), - 23, 59, 59); - toDate = calendar.getTime(); - } - - //create the filter - historyFilter = new HistoryFilter( - historyView, - author.getText(), - comment.getText(), - fromDate, - toDate, - orRadio.getSelection()); - - super.buttonPressed(buttonId); - } - - /** - * Returns the filter that was created from the provided - * user input. - */ - public HistoryFilter getFilter() { - return historyFilter; - } - /** - * Set the intial value of the dialog to the given filter. - */ - public void setFilter(HistoryFilter filter) { - this.historyFilter = filter; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java deleted file mode 100644 index 528977f13..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java +++ /dev/null @@ -1,428 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.text.DateFormat; -import java.util.Date; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; - -/** - * This class provides the table and it's required components for a file's revision - * history - */ -public class HistoryTableProvider { - - private ICVSFile currentFile; - private String currentRevision; - private TableViewer viewer; - private Font currentRevisionFont; - - /** - * Constructor for HistoryTableProvider. - */ - public HistoryTableProvider() { - super(); - } - - //column constants - private static final int COL_REVISION = 0; - private static final int COL_TAGS = 1; - private static final int COL_DATE = 2; - private static final int COL_AUTHOR = 3; - private static final int COL_COMMENT = 4; - - /** - * The history label provider. - */ - class HistoryLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider, IFontProvider { - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - public String getColumnText(Object element, int columnIndex) { - ILogEntry entry = adaptToLogEntry(element); - if (entry == null) return ""; //$NON-NLS-1$ - switch (columnIndex) { - case COL_REVISION: - String revision = entry.getRevision(); - String currentRevision = getCurrentRevision(); - if (currentRevision != null && currentRevision.equals(revision)) { - revision = Policy.bind("currentRevision", revision); //$NON-NLS-1$ - } - return revision; - case COL_TAGS: - CVSTag[] tags = entry.getTags(); - StringBuffer result = new StringBuffer(); - for (int i = 0; i < tags.length; i++) { - result.append(tags[i].getName()); - if (i < tags.length - 1) { - result.append(", "); //$NON-NLS-1$ - } - } - return result.toString(); - case COL_DATE: - Date date = entry.getDate(); - if (date == null) return Policy.bind("notAvailable"); //$NON-NLS-1$ - return DateFormat.getInstance().format(date); - case COL_AUTHOR: - return entry.getAuthor(); - case COL_COMMENT: - String comment = entry.getComment(); - int index = comment.indexOf("\n"); //$NON-NLS-1$ - switch (index) { - case -1: - return comment; - case 0: - return Policy.bind("HistoryView.[...]_4"); //$NON-NLS-1$ - default: - return Policy.bind("CVSCompareRevisionsInput.truncate", comment.substring(0, index)); //$NON-NLS-1$ - } - } - return ""; //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ - public Color getForeground(Object element) { - ILogEntry entry = adaptToLogEntry(element); - if (entry.isDeletion()) { - return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); - } else { - return null; - } - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ - public Color getBackground(Object element) { - return null; - } - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) - */ - public Font getFont(Object element) { - ILogEntry entry = adaptToLogEntry(element); - if (entry == null) - return null; - String revision = entry.getRevision(); - String currentRevision = getCurrentRevision(); - if (currentRevision != null && currentRevision.equals(revision)) { - if (currentRevisionFont == null) { - Font defaultFont = JFaceResources.getDefaultFont(); - FontData[] data = defaultFont.getFontData(); - for (int i = 0; i < data.length; i++) { - data[i].setStyle(SWT.BOLD); - } - currentRevisionFont = new Font(viewer.getTable().getDisplay(), data); - } - return currentRevisionFont; - } - return null; - } - } - - /** - * The history sorter - */ - class HistorySorter extends ViewerSorter { - private boolean reversed = false; - private int columnNumber; - - private VersionCollator versionCollator = new VersionCollator(); - - // column headings: "Revision" "Tags" "Date" "Author" "Comment" - private int[][] SORT_ORDERS_BY_COLUMN = { - {COL_REVISION, COL_DATE, COL_AUTHOR, COL_COMMENT, COL_TAGS}, /* revision */ - {COL_TAGS, COL_REVISION, COL_DATE, COL_AUTHOR, COL_COMMENT}, /* tags */ - {COL_DATE, COL_REVISION, COL_AUTHOR, COL_COMMENT, COL_TAGS}, /* date */ - {COL_AUTHOR, COL_REVISION, COL_DATE, COL_COMMENT, COL_TAGS}, /* author */ - {COL_COMMENT, COL_REVISION, COL_DATE, COL_AUTHOR, COL_TAGS} /* comment */ - }; - - /** - * The constructor. - */ - public HistorySorter(int columnNumber) { - this.columnNumber = columnNumber; - } - /** - * Compares two log entries, sorting first by the main column of this sorter, - * then by subsequent columns, depending on the column sort order. - */ - public int compare(Viewer viewer, Object o1, Object o2) { - ILogEntry e1 = adaptToLogEntry(o1); - ILogEntry e2 = adaptToLogEntry(o2); - int result = 0; - if (e1 == null || e2 == null) { - result = super.compare(viewer, o1, o2); - } else { - int[] columnSortOrder = SORT_ORDERS_BY_COLUMN[columnNumber]; - for (int i = 0; i < columnSortOrder.length; ++i) { - result = compareColumnValue(columnSortOrder[i], e1, e2); - if (result != 0) - break; - } - } - if (reversed) - result = -result; - return result; - } - /** - * Compares two markers, based only on the value of the specified column. - */ - int compareColumnValue(int columnNumber, ILogEntry e1, ILogEntry e2) { - switch (columnNumber) { - case 0: /* revision */ - return versionCollator.compare(e1.getRevision(), e2.getRevision()); - case 1: /* tags */ - CVSTag[] tags1 = e1.getTags(); - CVSTag[] tags2 = e2.getTags(); - if (tags2.length == 0) { - return -1; - } - if (tags1.length == 0) { - return 1; - } - return getCollator().compare(tags1[0].getName(), tags2[0].getName()); - case 2: /* date */ - Date date1 = e1.getDate(); - Date date2 = e2.getDate(); - return date1.compareTo(date2); - case 3: /* author */ - return getCollator().compare(e1.getAuthor(), e2.getAuthor()); - case 4: /* comment */ - return getCollator().compare(e1.getComment(), e2.getComment()); - default: - return 0; - } - } - /** - * Returns the number of the column by which this is sorting. - */ - public int getColumnNumber() { - return columnNumber; - } - /** - * Returns true for descending, or false - * for ascending sorting order. - */ - public boolean isReversed() { - return reversed; - } - /** - * Sets the sorting order. - */ - public void setReversed(boolean newReversed) { - reversed = newReversed; - } - } - - protected ILogEntry adaptToLogEntry(Object element) { - // Get the log entry for the provided object - ILogEntry entry = null; - if (element instanceof ILogEntry) { - entry = (ILogEntry) element; - } else if (element instanceof IAdaptable) { - entry = (ILogEntry)((IAdaptable)element).getAdapter(ILogEntry.class); - } - return entry; - } - - /** - * Create a TableViewer that can be used to display a list of ILogEntry instances. - * Ths method provides the labels and sorter but does not provide a content provider - * - * @param parent - * @return TableViewer - */ - public TableViewer createTable(Composite parent) { - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); - table.setHeaderVisible(true); - table.setLinesVisible(true); - GridData data = new GridData(GridData.FILL_BOTH); - table.setLayoutData(data); - - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableViewer viewer = new TableViewer(table); - - createColumns(table, layout, viewer); - - viewer.setLabelProvider(new HistoryLabelProvider()); - - // By default, reverse sort by revision. - HistorySorter sorter = new HistorySorter(COL_REVISION); - sorter.setReversed(true); - viewer.setSorter(sorter); - - table.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if(currentRevisionFont != null) { - currentRevisionFont.dispose(); - } - } - }); - - this.viewer = viewer; - return viewer; - } - - /** - * Create a CheckBoxTableViewer that can be used to display a list of ILogEntry instances. - * Ths method provides the labels and sorter but does not provide a content provider - * - * @param parent - * @return TableViewer - */ - public CheckboxTableViewer createCheckBoxTable(Composite parent) { - Table table = new Table(parent, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); - table.setHeaderVisible(true); - table.setLinesVisible(true); - GridData data = new GridData(GridData.FILL_BOTH); - table.setLayoutData(data); - - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - CheckboxTableViewer viewer = new CheckboxTableViewer(table); - - createColumns(table, layout, viewer); - - viewer.setLabelProvider(new HistoryLabelProvider()); - - // By default, reverse sort by revision. - HistorySorter sorter = new HistorySorter(COL_REVISION); - sorter.setReversed(true); - viewer.setSorter(sorter); - - table.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if(currentRevisionFont != null) { - currentRevisionFont.dispose(); - } - } - }); - - this.viewer = viewer; - return viewer; - } - - /** - * Creates the columns for the history table. - */ - private void createColumns(Table table, TableLayout layout, TableViewer viewer) { - SelectionListener headerListener = getColumnListener(viewer); - // revision - TableColumn col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("HistoryView.revision")); //$NON-NLS-1$ - col.addSelectionListener(headerListener); - layout.addColumnData(new ColumnWeightData(20, true)); - - // tags - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("HistoryView.tags")); //$NON-NLS-1$ - col.addSelectionListener(headerListener); - layout.addColumnData(new ColumnWeightData(20, true)); - - // creation date - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("HistoryView.date")); //$NON-NLS-1$ - col.addSelectionListener(headerListener); - layout.addColumnData(new ColumnWeightData(20, true)); - - // author - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("HistoryView.author")); //$NON-NLS-1$ - col.addSelectionListener(headerListener); - layout.addColumnData(new ColumnWeightData(20, true)); - - //comment - col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - col.setText(Policy.bind("HistoryView.comment")); //$NON-NLS-1$ - col.addSelectionListener(headerListener); - layout.addColumnData(new ColumnWeightData(50, true)); - } - - /** - * Adds the listener that sets the sorter. - */ - private SelectionListener getColumnListener(final TableViewer tableViewer) { - /** - * This class handles selections of the column headers. - * Selection of the column header will cause resorting - * of the shown tasks using that column's sorter. - * Repeated selection of the header will toggle - * sorting order (ascending versus descending). - */ - return new SelectionAdapter() { - /** - * Handles the case of user selecting the - * header area. - *

              If the column has not been selected previously, - * it will set the sorter of that column to be - * the current tasklist sorter. Repeated - * presses on the same column header will - * toggle sorting order (ascending/descending). - */ - public void widgetSelected(SelectionEvent e) { - // column selected - need to sort - int column = tableViewer.getTable().indexOf((TableColumn) e.widget); - HistorySorter oldSorter = (HistorySorter)tableViewer.getSorter(); - if (oldSorter != null && column == oldSorter.getColumnNumber()) { - oldSorter.setReversed(!oldSorter.isReversed()); - tableViewer.refresh(); - } else { - tableViewer.setSorter(new HistorySorter(column)); - } - } - }; - } - - public String getCurrentRevision() { - return currentRevision; - } - - /** - * Method getRevision. - * @param currentEdition - */ - private String getRevision(ICVSFile currentEdition) throws CVSException { - if (currentEdition == null) return ""; //$NON-NLS-1$ - ResourceSyncInfo info = currentEdition.getSyncInfo(); - if (info == null) return ""; //$NON-NLS-1$ - return info.getRevision(); - } - - public void setFile(ICVSFile file) throws CVSException { - this.currentFile = file; - this.currentRevision = getRevision(this.currentFile); - } - - public ICVSFile getICVSFile() { - return this.currentFile; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java deleted file mode 100644 index 6943cc18d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java +++ /dev/null @@ -1,880 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.*; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.actions.*; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; -import org.eclipse.ui.*; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; - -/** - * The history view allows browsing of an array of resource revisions - */ -public class HistoryView extends ViewPart { - private IFile file; - // cached for efficiency - private ILogEntry[] entries; - - private HistoryTableProvider historyTableProvider; - - private TableViewer tableViewer; - private TextViewer textViewer; - private TableViewer tagViewer; - - private OpenLogEntryAction openAction; - private IAction toggleTextAction; - private IAction toggleListAction; - private TextViewerAction copyAction; - private TextViewerAction selectAllAction; - private Action getContentsAction; - private Action getRevisionAction; - private Action refreshAction; - private Action tagWithExistingAction; - private Action linkWithEditorAction; - - private SashForm sashForm; - private SashForm innerSashForm; - - private Image branchImage; - private Image versionImage; - - private ILogEntry currentSelection; - private boolean linkingEnabled; - - private IPreferenceStore settings; - - private FetchLogEntriesJob fetchLogEntriesJob; - - private boolean shutdown = false; - - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.HistoryView"; //$NON-NLS-1$ - - private IPartListener partListener = new IPartListener() { - public void partActivated(IWorkbenchPart part) { - if (part instanceof IEditorPart) - editorActivated((IEditorPart) part); - } - public void partBroughtToTop(IWorkbenchPart part) { - if(part == HistoryView.this) - editorActivated(getViewSite().getPage().getActiveEditor()); - } - public void partOpened(IWorkbenchPart part) { - if(part == HistoryView.this) - editorActivated(getViewSite().getPage().getActiveEditor()); - } - public void partClosed(IWorkbenchPart part) { - } - public void partDeactivated(IWorkbenchPart part) { - } - }; - - private IPartListener2 partListener2 = new IPartListener2() { - public void partActivated(IWorkbenchPartReference ref) { - } - public void partBroughtToTop(IWorkbenchPartReference ref) { - } - public void partClosed(IWorkbenchPartReference ref) { - } - public void partDeactivated(IWorkbenchPartReference ref) { - } - public void partOpened(IWorkbenchPartReference ref) { - } - public void partHidden(IWorkbenchPartReference ref) { - } - public void partVisible(IWorkbenchPartReference ref) { - if(ref.getPart(true) == HistoryView.this) - editorActivated(getViewSite().getPage().getActiveEditor()); - } - public void partInputChanged(IWorkbenchPartReference ref) { - } - }; - - - private class FetchLogEntriesJob extends Job { - public ICVSRemoteFile remoteFile; - public FetchLogEntriesJob() { - super(Policy.bind("HistoryView.fetchHistoryJob")); //$NON-NLS-1$; - } - public void setRemoteFile(ICVSRemoteFile file) { - this.remoteFile = file; - } - public IStatus run(IProgressMonitor monitor) { - try { - if(remoteFile != null && !shutdown) { - entries = remoteFile.getLogEntries(monitor); - final String revisionId = remoteFile.getRevision(); - getSite().getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - if(entries != null && tableViewer != null && ! tableViewer.getTable().isDisposed()) { - tableViewer.add(entries); - selectRevision(revisionId); - } - } - }); - } - return Status.OK_STATUS; - } catch (TeamException e) { - return e.getStatus(); - } - } - }; - - /** - * Adds the action contributions for this view. - */ - protected void contributeActions() { - // Refresh (toolbar) - CVSUIPlugin plugin = CVSUIPlugin.getPlugin(); - refreshAction = new Action(Policy.bind("HistoryView.refreshLabel"), plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH_ENABLED)) { //$NON-NLS-1$ - public void run() { - refresh(); - } - }; - refreshAction.setToolTipText(Policy.bind("HistoryView.refresh")); //$NON-NLS-1$ - refreshAction.setDisabledImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH_DISABLED)); - refreshAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH)); - - // Link with Editor (toolbar) - linkWithEditorAction = new Action(Policy.bind("HistoryView.linkWithLabel"), plugin.getImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR_ENABLED)) { //$NON-NLS-1$ - public void run() { - setLinkingEnabled(isChecked()); - } - }; - linkWithEditorAction.setToolTipText(Policy.bind("HistoryView.linkWithLabel")); //$NON-NLS-1$ - linkWithEditorAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_LINK_WITH_EDITOR)); - linkWithEditorAction.setChecked(isLinkingEnabled()); - - // Double click open action - openAction = new OpenLogEntryAction(); - tableViewer.getTable().addListener(SWT.DefaultSelection, new Listener() { - public void handleEvent(Event e) { - openAction.selectionChanged(null, tableViewer.getSelection()); - openAction.run(null); - } - }); - - getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), true /* needs progress */, new IWorkspaceRunnable() { //$NON-NLS-1$ - public void run(IProgressMonitor monitor) throws CoreException { - ICVSRemoteFile remoteFile = currentSelection.getRemoteFile(); - monitor.beginTask(null, 100); - try { - if(confirmOverwrite()) { - InputStream in = remoteFile.getContents(new SubProgressMonitor(monitor, 50)); - file.setContents(in, false, true, new SubProgressMonitor(monitor, 50)); - } - } catch (TeamException e) { - throw new CoreException(e.getStatus()); - } finally { - monitor.done(); - } - } - }); - WorkbenchHelp.setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION); - - getRevisionAction = getContextMenuAction(Policy.bind("HistoryView.getRevisionAction"), true /* needs progress */, new IWorkspaceRunnable() { //$NON-NLS-1$ - public void run(IProgressMonitor monitor) throws CoreException { - ICVSRemoteFile remoteFile = currentSelection.getRemoteFile(); - try { - if(confirmOverwrite()) { - CVSTag revisionTag = new CVSTag(remoteFile.getRevision(), CVSTag.VERSION); - - if(CVSAction.checkForMixingTags(getSite().getShell(), new IResource[] {file}, revisionTag)) { - new UpdateOperation( - null, - new IResource[] {file}, - new Command.LocalOption[] {Update.IGNORE_LOCAL_CHANGES}, - revisionTag) - .run(monitor); - historyTableProvider.setFile(remoteFile); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - tableViewer.refresh(); - } - }); - } - } - } catch (InvocationTargetException e) { - CVSException.wrapException(e); - } catch (InterruptedException e) { - // Cancelled by user - } - } - }); - WorkbenchHelp.setHelp(getRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION); - - // Override MoveRemoteTagAction to work for log entries - final IActionDelegate tagActionDelegate = new MoveRemoteTagAction() { - protected ICVSResource[] getSelectedCVSResources() { - ICVSResource[] resources = super.getSelectedCVSResources(); - if (resources == null || resources.length == 0) { - ArrayList logEntrieFiles = null; - if (!selection.isEmpty()) { - logEntrieFiles = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ILogEntry) { - logEntrieFiles.add(((ILogEntry)next).getRemoteFile()); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ICVSResource.class); - if (adapter instanceof ICVSResource) { - logEntrieFiles.add(((ILogEntry)adapter).getRemoteFile()); - continue; - } - } - } - } - if (logEntrieFiles != null && !logEntrieFiles.isEmpty()) { - return (ICVSResource[])logEntrieFiles.toArray(new ICVSResource[logEntrieFiles.size()]); - } - } - return resources; - } - }; - tagWithExistingAction = getContextMenuAction(Policy.bind("HistoryView.tagWithExistingAction"), false /* no progress */, new IWorkspaceRunnable() { //$NON-NLS-1$ - public void run(IProgressMonitor monitor) throws CoreException { - tagActionDelegate.selectionChanged(tagWithExistingAction, tableViewer.getSelection()); - tagActionDelegate.run(tagWithExistingAction); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if( ! ((MoveRemoteTagAction)tagActionDelegate).wasCancelled()) { - refresh(); - } - } - }); - } - }); - WorkbenchHelp.setHelp(getRevisionAction, IHelpContextIds.TAG_WITH_EXISTING_ACTION); - - // Toggle text visible action - final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - toggleTextAction = new Action(Policy.bind("HistoryView.showComment")) { //$NON-NLS-1$ - public void run() { - setViewerVisibility(); - store.setValue(ICVSUIConstants.PREF_SHOW_COMMENTS, toggleTextAction.isChecked()); - } - }; - toggleTextAction.setChecked(store.getBoolean(ICVSUIConstants.PREF_SHOW_COMMENTS)); - WorkbenchHelp.setHelp(toggleTextAction, IHelpContextIds.SHOW_COMMENT_IN_HISTORY_ACTION); - // Toggle list visible action - toggleListAction = new Action(Policy.bind("HistoryView.showTags")) { //$NON-NLS-1$ - public void run() { - setViewerVisibility(); - store.setValue(ICVSUIConstants.PREF_SHOW_TAGS, toggleListAction.isChecked()); - } - }; - toggleListAction.setChecked(store.getBoolean(ICVSUIConstants.PREF_SHOW_TAGS)); - WorkbenchHelp.setHelp(toggleListAction, IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION); - - // Contribute actions to popup menu - MenuManager menuMgr = new MenuManager(); - Menu menu = menuMgr.createContextMenu(tableViewer.getTable()); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager menuMgr) { - fillTableMenu(menuMgr); - } - }); - menuMgr.setRemoveAllWhenShown(true); - tableViewer.getTable().setMenu(menu); - getSite().registerContextMenu(menuMgr, tableViewer); - - // Contribute toggle text visible to the toolbar drop-down - IActionBars actionBars = getViewSite().getActionBars(); - IMenuManager actionBarsMenu = actionBars.getMenuManager(); - actionBarsMenu.add(toggleTextAction); - actionBarsMenu.add(toggleListAction); - - // Create the local tool bar - IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); - tbm.add(refreshAction); - tbm.add(linkWithEditorAction); - tbm.update(false); - - // Create actions for the text editor - copyAction = new TextViewerAction(textViewer, ITextOperationTarget.COPY); - copyAction.setText(Policy.bind("HistoryView.copy")); //$NON-NLS-1$ - actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, copyAction); - - selectAllAction = new TextViewerAction(textViewer, ITextOperationTarget.SELECT_ALL); - selectAllAction.setText(Policy.bind("HistoryView.selectAll")); //$NON-NLS-1$ - actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, selectAllAction); - - actionBars.updateActionBars(); - - menuMgr = new MenuManager(); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager menuMgr) { - fillTextMenu(menuMgr); - } - }); - StyledText text = textViewer.getTextWidget(); - menu = menuMgr.createContextMenu(text); - text.setMenu(menu); - } - private void setViewerVisibility() { - boolean showText = toggleTextAction.isChecked(); - boolean showList = toggleListAction.isChecked(); - if (showText && showList) { - sashForm.setMaximizedControl(null); - innerSashForm.setMaximizedControl(null); - } else if (showText) { - sashForm.setMaximizedControl(null); - innerSashForm.setMaximizedControl(textViewer.getTextWidget()); - } else if (showList) { - sashForm.setMaximizedControl(null); - innerSashForm.setMaximizedControl(tagViewer.getTable()); - } else { - sashForm.setMaximizedControl(tableViewer.getControl()); - } - } - /* - * Method declared on IWorkbenchPart - */ - public void createPartControl(Composite parent) { - settings = CVSUIPlugin.getPlugin().getPreferenceStore(); - this.linkingEnabled = settings.getBoolean(ICVSUIConstants.PREF_HISTORY_VIEW_EDITOR_LINKING); - - initializeImages(); - - sashForm = new SashForm(parent, SWT.VERTICAL); - sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - - tableViewer = createTable(sashForm); - innerSashForm = new SashForm(sashForm, SWT.HORIZONTAL); - tagViewer = createTagTable(innerSashForm); - textViewer = createText(innerSashForm); - sashForm.setWeights(new int[] { 70, 30 }); - innerSashForm.setWeights(new int[] { 50, 50 }); - - contributeActions(); - - setViewerVisibility(); - - // set F1 help - WorkbenchHelp.setHelp(sashForm, IHelpContextIds.RESOURCE_HISTORY_VIEW); - initDragAndDrop(); - - // add listener for editor page activation - this is to support editor linking - getSite().getPage().addPartListener(partListener); - getSite().getPage().addPartListener(partListener2); - } - private void initializeImages() { - CVSUIPlugin plugin = CVSUIPlugin.getPlugin(); - versionImage = plugin.getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION).createImage(); - branchImage = plugin.getImageDescriptor(ICVSUIConstants.IMG_TAG).createImage(); - } - /** - * Creates the group that displays lists of the available repositories - * and team streams. - * - * @param the parent composite to contain the group - * @return the group control - */ - protected TableViewer createTable(Composite parent) { - - historyTableProvider = new HistoryTableProvider(); - TableViewer viewer = historyTableProvider.createTable(parent); - - viewer.setContentProvider(new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - // Short-circuit to optimize - if (entries != null) return entries; - - if (!(inputElement instanceof ICVSRemoteFile)) return null; - final ICVSRemoteFile remoteFile = (ICVSRemoteFile)inputElement; - if(fetchLogEntriesJob == null) { - fetchLogEntriesJob = new FetchLogEntriesJob(); - } - if(fetchLogEntriesJob.getState() != Job.NONE) { - fetchLogEntriesJob.cancel(); - try { - fetchLogEntriesJob.join(); - } catch (InterruptedException e) { - CVSUIPlugin.log(new CVSException(Policy.bind("HistoryView.errorFetchingEntries", remoteFile.getName()), e)); //$NON-NLS-1$ - } - } - fetchLogEntriesJob.setRemoteFile(remoteFile); - Utils.schedule(fetchLogEntriesJob, getViewSite()); - return new Object[0]; - } - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - entries = null; - } - }); - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - textViewer.setDocument(new Document("")); //$NON-NLS-1$ - tagViewer.setInput(null); - return; - } - IStructuredSelection ss = (IStructuredSelection)selection; - if (ss.size() != 1) { - textViewer.setDocument(new Document("")); //$NON-NLS-1$ - tagViewer.setInput(null); - return; - } - ILogEntry entry = (ILogEntry)ss.getFirstElement(); - textViewer.setDocument(new Document(entry.getComment())); - tagViewer.setInput(entry.getTags()); - } - }); - - return viewer; - } - - private TableViewer createTagTable(Composite parent) { - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); - TableViewer result = new TableViewer(table); - TableLayout layout = new TableLayout(); - layout.addColumnData(new ColumnWeightData(100)); - table.setLayout(layout); - result.setContentProvider(new SimpleContentProvider() { - public Object[] getElements(Object inputElement) { - if (inputElement == null) return new Object[0]; - CVSTag[] tags = (CVSTag[])inputElement; - return tags; - } - }); - result.setLabelProvider(new LabelProvider() { - public Image getImage(Object element) { - if (element == null) return null; - CVSTag tag = (CVSTag)element; - switch (tag.getType()) { - case CVSTag.BRANCH: - case CVSTag.HEAD: - return branchImage; - case CVSTag.VERSION: - return versionImage; - } - return null; - } - public String getText(Object element) { - return ((CVSTag)element).getName(); - } - }); - result.setSorter(new ViewerSorter() { - public int compare(Viewer viewer, Object e1, Object e2) { - if (!(e1 instanceof CVSTag) || !(e2 instanceof CVSTag)) return super.compare(viewer, e1, e2); - CVSTag tag1 = (CVSTag)e1; - CVSTag tag2 = (CVSTag)e2; - int type1 = tag1.getType(); - int type2 = tag2.getType(); - if (type1 != type2) { - return type2 - type1; - } - return super.compare(viewer, tag1, tag2); - } - }); - return result; - } - protected TextViewer createText(Composite parent) { - TextViewer result = new TextViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY); - result.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - copyAction.update(); - } - }); - return result; - } - public void dispose() { - shutdown = true; - if (branchImage != null) { - branchImage.dispose(); - branchImage = null; - } - if (versionImage != null) { - versionImage.dispose(); - versionImage = null; - } - - if(fetchLogEntriesJob != null) { - if(fetchLogEntriesJob.getState() != Job.NONE) { - fetchLogEntriesJob.cancel(); - try { - fetchLogEntriesJob.join(); - } catch (InterruptedException e) { - CVSUIPlugin.log(new CVSException(Policy.bind("HistoryView.errorFetchingEntries", ""), e)); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - getSite().getPage().removePartListener(partListener); - getSite().getPage().removePartListener(partListener2); - } - /** - * Returns the table viewer contained in this view. - */ - protected TableViewer getViewer() { - return tableViewer; - } - /** - * Adds drag and drop support to the history view. - */ - void initDragAndDrop() { - int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] {ResourceTransfer.getInstance()}; - tableViewer.addDropSupport(ops, transfers, new HistoryDropAdapter(tableViewer, this)); - } - private void fillTableMenu(IMenuManager manager) { - // file actions go first (view file) - manager.add(new Separator(IWorkbenchActionConstants.GROUP_FILE)); - if (file != null) { - // Add the "Add to Workspace" action if 1 revision is selected. - ISelection sel = tableViewer.getSelection(); - if (!sel.isEmpty()) { - if (sel instanceof IStructuredSelection) { - if (((IStructuredSelection)sel).size() == 1) { - manager.add(getContentsAction); - manager.add(getRevisionAction); - manager.add(new Separator()); - manager.add(tagWithExistingAction); - } - } - } - } - manager.add(new Separator("additions")); //$NON-NLS-1$ - manager.add(refreshAction); - manager.add(new Separator("additions-end")); //$NON-NLS-1$ - } - private void fillTextMenu(IMenuManager manager) { - manager.add(copyAction); - manager.add(selectAllAction); - } - /** - * Makes the history view visible in the active perspective. If there - * isn't a history view registered null is returned. - * Otherwise the opened view part is returned. - */ - public static HistoryView openInActivePerspective() { - try { - return (HistoryView)CVSUIPlugin.getActivePage().showView(VIEW_ID); - } catch (PartInitException pe) { - return null; - } - } - /** (Non-javadoc) - * Method declared on IWorkbenchPart - */ - public void setFocus() { - if (tableViewer != null) { - Table control = tableViewer.getTable(); - if (control != null && !control.isDisposed()) { - control.setFocus(); - } - } - } - - /** - * Shows the history for the given IResource in the view. - * - * Only files are supported for now. - */ - public void showHistory(IResource resource, boolean refetch) { - if (resource instanceof IFile) { - IFile newfile = (IFile)resource; - if(!refetch && this.file != null && newfile.equals(this.file)) { - return; - } - this.file = newfile; - RepositoryProvider teamProvider = RepositoryProvider.getProvider(file.getProject(), CVSProviderPlugin.getTypeId()); - if (teamProvider != null) { - try { - // for a file this will return the base - ICVSRemoteFile remoteFile = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(file); - if(remoteFile != null) { - historyTableProvider.setFile(remoteFile); - // input is set asynchronously so we can't assume that the view - // has been populated until the job that queries for the history - // has completed. - tableViewer.setInput(remoteFile); - setContentDescription(remoteFile.getName()); - setTitleToolTip(resource.getFullPath().toString()); - } - } catch (TeamException e) { - CVSUIPlugin.openError(getViewSite().getShell(), null, null, e); - } - } - } else { - this.file = null; - tableViewer.setInput(null); - setContentDescription(""); //$NON-NLS-1$ - setTitleToolTip(""); //$NON-NLS-1$ - } - } - - /** - * An editor has been activated. Fetch the history if it is shared with CVS and the history view - * is visible in the current page. - * - * @param editor the active editor - * @since 3.0 - */ - protected void editorActivated(IEditorPart editor) { - // Only fetch contents if the view is shown in the current page. - if (editor == null || !isLinkingEnabled() || !checkIfPageIsVisible()) { - return; - } - IEditorInput input = editor.getEditorInput(); - // Handle compare editors opened from the Synchronize View - if (input instanceof SyncInfoCompareInput) { - SyncInfoCompareInput syncInput = (SyncInfoCompareInput) input; - SyncInfo info = syncInput.getSyncInfo(); - if(info instanceof CVSSyncInfo && info.getLocal().getType() == IResource.FILE) { - ICVSRemoteFile remote = (ICVSRemoteFile)info.getRemote(); - ICVSRemoteFile base = (ICVSRemoteFile)info.getBase(); - if(remote != null) { - showHistory(remote, false); - } else if(base != null) { - showHistory(base, false); - } - } - // Handle editors opened on remote files - } else if(input instanceof RemoteFileEditorInput) { - ICVSRemoteFile remote = ((RemoteFileEditorInput)input).getCVSRemoteFile(); - if(remote != null) { - showHistory(remote, false); - } - // Handle regular file editors - } else if (input instanceof IFileEditorInput) { - IFileEditorInput fileInput = (IFileEditorInput) input; - IFile file = fileInput.getFile(); - showHistory(file, false /* don't fetch if already cached */); - } - } - - private boolean checkIfPageIsVisible() { - return getViewSite().getPage().isPartVisible(this); - } - /** - * Shows the history for the given ICVSRemoteFile in the view. - */ - public void showHistory(ICVSRemoteFile remoteFile, boolean refetch) { - try { - if (remoteFile == null) { - tableViewer.setInput(null); - setContentDescription(""); //$NON-NLS-1$ - setTitleToolTip(""); //$NON-NLS-1$ - return; - } - ICVSFile existingFile = historyTableProvider.getICVSFile(); - if(!refetch && existingFile != null && existingFile.equals(remoteFile)) return; - this.file = null; - historyTableProvider.setFile(remoteFile); - tableViewer.setInput(remoteFile); - setContentDescription(remoteFile.getName()); - setTitleToolTip(remoteFile.getRepositoryRelativePath()); - } catch (TeamException e) { - CVSUIPlugin.openError(getViewSite().getShell(), null, null, e); - } - } - - private Action getContextMenuAction(String title, final boolean needsProgressDialog, final IWorkspaceRunnable action) { - return new Action(title) { - public void run() { - try { - if (file == null) return; - ISelection selection = tableViewer.getSelection(); - if (!(selection instanceof IStructuredSelection)) return; - IStructuredSelection ss = (IStructuredSelection)selection; - Object o = ss.getFirstElement(); - currentSelection = (ILogEntry)o; - if(needsProgressDialog) { - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - action.run(monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }); - } else { - try { - action.run(null); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getViewSite().getShell(), null, null, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); - } catch (InterruptedException e) { - // Do nothing - } - } - - public boolean isEnabled() { - ISelection selection = tableViewer.getSelection(); - if (!(selection instanceof IStructuredSelection)) return false; - IStructuredSelection ss = (IStructuredSelection)selection; - if(ss.size() != 1) return false; - return true; - } - }; - } - - private boolean confirmOverwrite() { - if (file!=null && file.exists()) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - try { - if(cvsFile.isModified(null)) { - String title = Policy.bind("HistoryView.overwriteTitle"); //$NON-NLS-1$ - String msg = Policy.bind("HistoryView.overwriteMsg"); //$NON-NLS-1$ - final MessageDialog dialog = new MessageDialog(getViewSite().getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); - final int[] result = new int[1]; - getViewSite().getShell().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - }}); - if (result[0] != 0) { - // cancel - return false; - } - } - } catch(CVSException e) { - CVSUIPlugin.log(e); - } - } - return true; - } - - /* - * Refresh the view by refetching the log entries for the remote file - */ - private void refresh() { - entries = null; - BusyIndicator.showWhile(tableViewer.getTable().getDisplay(), new Runnable() { - public void run() { - // if a local file was fed to the history view then we will have to refetch the handle - // to properly display the current revision marker. - if(file != null) { - ICVSRemoteFile remoteFile; - try { - remoteFile = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(file); - historyTableProvider.setFile(remoteFile); - } catch (CVSException e) { - // use previously fetched remote file, but log error - CVSUIPlugin.log(e); - } - } - tableViewer.refresh(); - } - }); - } - - /** - * Select the revision in the receiver. - */ - public void selectRevision(String revision) { - if (entries == null) { - return; - } - - ILogEntry entry = null; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getRevision().equals(revision)) { - entry = entries[i]; - break; - } - } - - if (entry != null) { - IStructuredSelection selection = new StructuredSelection(entry); - tableViewer.setSelection(selection, true); - } - } - - /** - * Enabled linking to the active editor - * @since 3.0 - */ - public void setLinkingEnabled(boolean enabled) { - this.linkingEnabled = enabled; - - // remember the last setting in the dialog settings - settings.setValue(ICVSUIConstants.PREF_HISTORY_VIEW_EDITOR_LINKING, enabled); - - // if turning linking on, update the selection to correspond to the active editor - if (enabled) { - editorActivated(getSite().getPage().getActiveEditor()); - } - } - - /** - * Returns if linking to the ative editor is enabled or disabled. - * @return boolean indicating state of editor linking. - */ - private boolean isLinkingEnabled() { - return linkingEnabled; - } - - /* - * Flatten the text in the multiline comment - */ - public static String flattenText(String string) { - StringBuffer buffer = new StringBuffer(string.length() + 20); - boolean skipAdjacentLineSeparator = true; - for (int i = 0; i < string.length(); i++) { - char c = string.charAt(i); - if (c == '\r' || c == '\n') { - if (!skipAdjacentLineSeparator) - buffer.append(Policy.bind("separator")); //$NON-NLS-1$ - skipAdjacentLineSeparator = true; - } else { - buffer.append(c); - skipAdjacentLineSeparator = false; - } - } - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java deleted file mode 100644 index 8ac63fa4d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.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.team.internal.ccvs.ui; - -public interface ICVSUIConstants { - public final String PREFIX = CVSUIPlugin.ID + "."; //$NON-NLS-1$ - - // image path - public final String ICON_PATH = "icons/full/"; //$NON-NLS-1$ - - // images - public final String IMG_CVS_CONSOLE = "eview16/console_view.gif"; //$NON-NLS-1$ - public final String IMG_CVS_PERSPECTIVE = "eview16/cvs_persp.gif"; //$NON-NLS-1$ - - // overlays - public final String IMG_MERGEABLE_CONFLICT = "ovr16/confauto_ov.gif"; //$NON-NLS-1$ - public final String IMG_QUESTIONABLE = "ovr16/question_ov.gif"; //$NON-NLS-1$ - public final String IMG_MERGED = "ovr16/merged_ov.gif"; //$NON-NLS-1$ - public final String IMG_EDITED = "ovr16/edited_ov.gif"; //$NON-NLS-1$ - public final String IMG_NO_REMOTEDIR = "ovr16/no_remotedir_ov.gif"; //$NON-NLS-1$ - - // objects - public final String IMG_REPOSITORY = "obj16/repository_rep.gif"; //$NON-NLS-1$ - public final String IMG_TAG = "obj16/tag.gif"; //$NON-NLS-1$ - public final String IMG_BRANCHES_CATEGORY = "obj16/branches_rep.gif"; //$NON-NLS-1$ - public final String IMG_VERSIONS_CATEGORY = "obj16/versions_rep.gif"; //$NON-NLS-1$ - public final String IMG_DATES_CATEGORY = "obj16/dates.gif"; //$NON-NLS-1$ - - public final String IMG_MODULE = "obj16/module_rep.gif"; //$NON-NLS-1$ - public final String IMG_PROJECT_VERSION = "obj16/prjversions_rep.gif"; //$NON-NLS-1$ - public final String IMG_DATE = "obj16/date.gif"; //$NON-NLS-1$ - public final String IMG_CHANGELOG = "obj16/changelog_obj.gif"; //$NON-NLS-1$ - - // toolbar - public final String IMG_REFRESH = "elcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_CLEAR = "elcl16/clear_co.gif"; //$NON-NLS-1$ - public final String IMG_COLLAPSE_ALL = "elcl16/collapseall.gif"; //$NON-NLS-1$ - public final String IMG_LINK_WITH_EDITOR = "elcl16/synced.gif"; //$NON-NLS-1$ - public final String IMG_REMOVE_CONSOLE = "elcl16/console_rem.gif"; //$NON-NLS-1$ - - // toolbar (disabled) - public final String IMG_REFRESH_DISABLED = "dlcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_CLEAR_DISABLED = "dlcl16/clear_co.gif"; //$NON-NLS-1$ - public final String IMG_REMOVE_CONSOLE_DISABLED = "dlcl16/console_rem.gif"; //$NON-NLS-1$ - - // toolbar (enabled) - public final String IMG_REFRESH_ENABLED = "elcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_CLEAR_ENABLED = "elcl16/clear_co.gif"; //$NON-NLS-1$ - public final String IMG_COLLAPSE_ALL_ENABLED = "elcl16/collapseall.gif"; //$NON-NLS-1$ - public final String IMG_LINK_WITH_EDITOR_ENABLED = "elcl16/synced.gif"; //$NON-NLS-1$ - - // wizards - public final String IMG_NEWLOCATION = "etool16/newlocation_wiz.gif"; //$NON-NLS-1$ - public final String IMG_CVSLOGO = "etool16/newconnect_wiz.gif"; //$NON-NLS-1$ - - // preferences - public final String PREF_SHOW_COMMENTS = "pref_show_comments"; //$NON-NLS-1$ - public final String PREF_SHOW_TAGS = "pref_show_tags"; //$NON-NLS-1$ - public final String PREF_HISTORY_VIEW_EDITOR_LINKING = "pref_history_view_linking"; //$NON-NLS-1$ - public final String PREF_PRUNE_EMPTY_DIRECTORIES = "pref_prune_empty_directories"; //$NON-NLS-1$ - public final String PREF_TIMEOUT = "pref_timeout"; //$NON-NLS-1$ - public final String PREF_QUIETNESS = "pref_quietness"; //$NON-NLS-1$ - public final String PREF_CVS_RSH = "pref_cvs_rsh"; //$NON-NLS-1$ - public final String PREF_CVS_RSH_PARAMETERS = "pref_cvs_rsh_parameters"; //$NON-NLS-1$ - public final String PREF_CVS_SERVER = "pref_cvs_server"; //$NON-NLS-1$ - public final String PREF_CONSIDER_CONTENTS = "pref_consider_contents"; //$NON-NLS-1$ - public final String PREF_REPLACE_UNMANAGED = "pref_replace_unmanaged"; //$NON-NLS-1$ - public final String PREF_COMPRESSION_LEVEL = "pref_compression_level"; //$NON-NLS-1$ - public final String PREF_TEXT_KSUBST = "pref_text_ksubst"; //$NON-NLS-1$ - public final String PREF_USE_PLATFORM_LINEEND = "pref_lineend"; //$NON-NLS-1$ - public final String PREF_PROMPT_ON_MIXED_TAGS = "pref_prompt_on_mixed_tags"; //$NON-NLS-1$ - public final String PREF_PROMPT_ON_SAVING_IN_SYNC = "pref_prompt_on_saving_in_sync"; //$NON-NLS-1$ - public final String PREF_SAVE_DIRTY_EDITORS = "pref_save_dirty_editors"; //$NON-NLS-1$ - public final String PREF_PROMPT_ON_CHANGE_GRANULARITY = "pref_prompt_on_change_granularity"; //$NON-NLS-1$ - public final String PREF_REPOSITORIES_ARE_BINARY = "pref_repositories_are_binary"; //$NON-NLS-1$ - public final String PREF_DETERMINE_SERVER_VERSION = "pref_determine_server_version"; //$NON-NLS-1$ - public final String PREF_CONFIRM_MOVE_TAG = "pref_confirm_move_tag"; //$NON-NLS-1$ - public final String PREF_DEBUG_PROTOCOL = "pref_debug_protocol"; //$NON-NLS-1$ - public final String PREF_WARN_REMEMBERING_MERGES = "pref_remember_merges"; //$NON-NLS-1$ - public final String PREF_FIRST_STARTUP = "pref_first_startup"; //$NON-NLS-1$ - public final String PREF_EXT_CONNECTION_METHOD_PROXY = "pref_ext_connection_method_proxy"; //$NON-NLS-1$ - public final String PREF_SHOW_COMPARE_REVISION_IN_DIALOG = "pref_show_compare_revision_in_dialog"; //$NON-NLS-1$ - public final String PREF_SHOW_AUTHOR_IN_EDITOR = "pref_show_author_in_editor"; //$NON-NLS-1$ - public final String PREF_COMMIT_SET_DEFAULT_ENABLEMENT = "pref_enable_commit_sets"; //$NON-NLS-1$ - - // console preferences - public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$ - public final String PREF_CONSOLE_MESSAGE_COLOR = "pref_console_message_color"; //$NON-NLS-1$ - public final String PREF_CONSOLE_ERROR_COLOR = "pref_console_error_color"; //$NON-NLS-1$ - public final String PREF_CONSOLE_FONT = "pref_console_font"; //$NON-NLS-1$ - public final String PREF_CONSOLE_SHOW_ON_MESSAGE = "pref_console_show_on_message"; //$NON-NLS-1$ - public final String PREF_CONSOLE_LIMIT_OUTPUT = "pref_console_limit_output"; //$NON-NLS-1$ - public final String PREF_CONSOLE_HIGH_WATER_MARK = "pref_console_high_water_mark"; //$NON-NLS-1$ - public final String PREF_CONSOLE_WRAP = "pref_console_wrap"; //$NON-NLS-1$ - public final String PREF_CONSOLE_WIDTH = "pref_console_width"; //$NON-NLS-1$ - - // decorator preferences - public final String PREF_FILETEXT_DECORATION = "pref_filetext_decoration"; //$NON-NLS-1$ - public final String PREF_FOLDERTEXT_DECORATION = "pref_foldertext_decoration"; //$NON-NLS-1$ - public final String PREF_PROJECTTEXT_DECORATION = "pref_projecttext_decoration"; //$NON-NLS-1$ - - public final String PREF_SHOW_DIRTY_DECORATION = "pref_show_overlaydirty"; //$NON-NLS-1$ - public final String PREF_SHOW_ADDED_DECORATION = "pref_show_added"; //$NON-NLS-1$ - public final String PREF_SHOW_HASREMOTE_DECORATION = "pref_show_hasremote"; //$NON-NLS-1$ - public final String PREF_SHOW_NEWRESOURCE_DECORATION = "pref_show_newresource"; //$NON-NLS-1$ - - public final String PREF_DIRTY_FLAG = "pref_dirty_flag"; //$NON-NLS-1$ - public final String PREF_ADDED_FLAG = "pref_added_flag"; //$NON-NLS-1$ - - public final String PREF_CALCULATE_DIRTY = "pref_calculate_dirty"; //$NON-NLS-1$ - - // watch/edit preferences - public final String PREF_CHECKOUT_READ_ONLY = "pref_checkout_read_only"; //$NON-NLS-1$ - public final String PREF_EDIT_ACTION = "pref_edit_action"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT_EDIT = "edit"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT_HIGHJACK = "highjack"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT = "pref_edit_prompt"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT_NEVER = "never"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT_ALWAYS = "always"; //$NON-NLS-1$ - public final String PREF_EDIT_PROMPT_IF_EDITORS = "only"; //$NON-NLS-1$ - - // Repositories view preferences - public final String PREF_GROUP_VERSIONS_BY_PROJECT = "pref_group_versions_by_project"; //$NON-NLS-1$ - - // Work in Progress preferences - public final String PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS= "pref_change_perspective_on_show_annotations"; //$NON-NLS-1$ - public final String PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS= "pref_default_perspective_for_show_annotations"; //$NON-NLS-1$ - - // Wizard banners - public final String IMG_WIZBAN_SHARE = "wizban/newconnect_wizban.gif"; //$NON-NLS-1$ - public final String IMG_WIZBAN_MERGE = "wizban/mergestream_wizban.gif"; //$NON-NLS-1$ - public final String IMG_WIZBAN_DIFF = "wizban/createpatch_wizban.gif"; //$NON-NLS-1$ - public final String IMG_WIZBAN_KEYWORD = "wizban/keywordsub_wizban.gif"; //$NON-NLS-1$ - public final String IMG_WIZBAN_NEW_LOCATION = "wizban/newlocation_wizban.gif"; //$NON-NLS-1$ - public final String IMG_WIZBAN_CHECKOUT = "wizban/newconnect_wizban.gif"; //$NON-NLS-1$ - - // Properties - public final String PROP_NAME = "cvs.name"; //$NON-NLS-1$ - public final String PROP_REVISION = "cvs.revision"; //$NON-NLS-1$ - public final String PROP_AUTHOR = "cvs.author"; //$NON-NLS-1$ - public final String PROP_COMMENT = "cvs.comment"; //$NON-NLS-1$ - public final String PROP_DATE = "cvs.date"; //$NON-NLS-1$ - public final String PROP_DIRTY = "cvs.dirty"; //$NON-NLS-1$ - public final String PROP_MODIFIED = "cvs.modified"; //$NON-NLS-1$ - public final String PROP_KEYWORD = "cvs.date"; //$NON-NLS-1$ - public final String PROP_TAG = "cvs.tag"; //$NON-NLS-1$ - public final String PROP_PERMISSIONS = "cvs.permissions"; //$NON-NLS-1$ - public final String PROP_HOST = "cvs.host"; //$NON-NLS-1$ - public final String PROP_USER = "cvs.user"; //$NON-NLS-1$ - public final String PROP_METHOD = "cvs.method"; //$NON-NLS-1$ - public final String PROP_PORT = "cvs.port"; //$NON-NLS-1$ - public final String PROP_ROOT = "cvs.root"; //$NON-NLS-1$ - - // preference options - public final int OPTION_NEVER = 1; - public final int OPTION_PROMPT = 2; - public final int OPTION_AUTOMATIC = 3; - - public final String OPTION_NO_PERSPECTIVE= "none"; //$NON-NLS-1$ -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java deleted file mode 100644 index 5088907cd..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -/** - * Here's how to reference the help context in code: - * - * WorkbenchHelp.setHelp(actionOrControl, IHelpContextIds.NAME_DEFIED_BELOW); - */ -public interface IHelpContextIds { - - public static final String PREFIX = CVSUIPlugin.ID + "."; //$NON-NLS-1$ - - // Dialogs - public static final String TAG_CONFIGURATION_OVERVIEW = PREFIX + "tag_configuration_overview"; //$NON-NLS-1$ - public static final String TAG_CONFIGURATION_REFRESHLIST = PREFIX + "tag_configuration_refreshlist"; //$NON-NLS-1$ - public static final String TAG_CONFIGURATION_REFRESHACTION = PREFIX + "tag_configuration_refreshaction"; //$NON-NLS-1$ - public static final String USER_VALIDATION_DIALOG = PREFIX + "user_validation_dialog_context"; //$NON-NLS-1$ - public static final String RELEASE_COMMENT_DIALOG = PREFIX + "release_comment_dialog_context"; //$NON-NLS-1$ - public static final String BRANCH_DIALOG = PREFIX + "branch_dialog_context"; //$NON-NLS-1$ - public static final String ADD_TO_VERSION_CONTROL_DIALOG = PREFIX + "add_to_version_control_dialog_context"; //$NON-NLS-1$ - public static final String EDITORS_DIALOG = PREFIX + "editors_dialog_context"; //$NON-NLS-1$ - public static final String HISTORY_FILTER_DIALOG = PREFIX + "history_filter_dialog_context"; //$NON-NLS-1$ - public static final String DATE_TAG_DIALOG = PREFIX + "date_tag_dialog_context"; //$NON-NLS-1$ - public static final String KEYBOARD_INTERACTIVE_DIALOG = PREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$ - public static final String COMMIT_SET_DIALOG = PREFIX + "commit_set_dialog_context"; //$NON-NLS-1$ - - // Different uses of the TagSelectionDialog - public static final String REPLACE_TAG_SELECTION_DIALOG = PREFIX + "replace_tag_selection_dialog_context"; //$NON-NLS-1$ - public static final String COMPARE_TAG_SELECTION_DIALOG = PREFIX + "compare_tag_selection_dialog_context"; //$NON-NLS-1$ - public static final String TAG_REMOTE_WITH_EXISTING_DIALOG = PREFIX + "tag_remote_with_existing_dialog_context"; //$NON-NLS-1$ - - // Different uses of the TagAsVersionDialog - public static final String TAG_AS_VERSION_DIALOG = PREFIX + "tag_as_version_dialog_context"; //$NON-NLS-1$ - - // Wizard Pages - public static final String SHARING_AUTOCONNECT_PAGE = PREFIX + "sharing_autoconnect_page_context"; //$NON-NLS-1$ - public static final String SHARING_SELECT_REPOSITORY_PAGE = PREFIX + "sharing_select_repository_page_context"; //$NON-NLS-1$ - public static final String SHARING_NEW_REPOSITORY_PAGE = PREFIX + "sharing_new_repository_page_context"; //$NON-NLS-1$ - public static final String SHARING_MODULE_PAGE = PREFIX + "sharing_module_page_context"; //$NON-NLS-1$ - public static final String SHARING_TAG_SELETION_PAGE = PREFIX + "sharing_tag_selection_page_context"; //$NON-NLS-1$ - public static final String SHARING_SYNC_PAGE = PREFIX + "sharing_sync_page_context"; //$NON-NLS-1$ - - public static final String PATCH_SELECTION_PAGE = PREFIX + "patch_selection_page_context"; //$NON-NLS-1$ - public static final String PATCH_OPTIONS_PAGE = PREFIX + "patch_options_page_context"; //$NON-NLS-1$ - - public static final String KEYWORD_SUBSTITUTION_SELECTION_PAGE = PREFIX + "keyword_substituton_selection_page_context"; //$NON-NLS-1$ - public static final String KEYWORD_SUBSTITUTION_SUMMARY_PAGE = PREFIX + "keyword_substituton_summary_page_context"; //$NON-NLS-1$ - public static final String KEYWORD_SUBSTITUTION_SHARED_PAGE = PREFIX + "keyword_substituton_shared_page_context"; //$NON-NLS-1$ - public static final String KEYWORD_SUBSTITUTION_CHANGED_PAGE = PREFIX + "keyword_substituton_changed_page_context"; //$NON-NLS-1$ - public static final String KEYWORD_SUBSTITUTION_COMMIT_COMMENT_PAGE = PREFIX + "keyword_substituton_commit_comment_page_context"; //$NON-NLS-1$ - - public static final String MERGE_START_PAGE = PREFIX + "merge_start_page_context"; //$NON-NLS-1$ - public static final String MERGE_END_PAGE = PREFIX + "merge_end_page_context"; //$NON-NLS-1$ - - public static final String CHECKOUT_MODULE_SELECTION_PAGE = PREFIX + "checkout_module_selection_context"; //$NON-NLS-1$ - public static final String CHECKOUT_CONFIGURATION_PAGE = PREFIX + "checkout_configuration_context"; //$NON-NLS-1$ - public static final String CHECKOUT_LOCATION_SELECTION_PAGE = PREFIX + "checkout_location_selection_context"; //$NON-NLS-1$ - public static final String CHECKOUT_PROJECT_SELECTION_PAGE = PREFIX + "checkout_into_resource_selection_page_context"; //$NON-NLS-1$ - public static final String CHECKOUT_TAG_SELETION_PAGE = PREFIX + "checkout_tag_selection_page_context"; //$NON-NLS-1$ - - public static final String UPDATE_TAG_SELETION_PAGE = PREFIX + "update_tag_selection_page_context"; //$NON-NLS-1$ - - public static final String RESTORE_FROM_REPOSITORY_FILE_SELECTION_PAGE = PREFIX + "restore_from_repository_file_selection_page_context"; //$NON-NLS-1$ - public static final String REFRESH_REMOTE_PROJECT_SELECTION_PAGE = PREFIX + "refresh_remote_project_selection_page_context"; //$NON-NLS-1$ - - // Preference Pages - public static final String PREF_PRUNE = PREFIX + "prune_empty_directories_pref"; //$NON-NLS-1$ - public static final String PREF_QUIET = PREFIX + "quietness_level_pref"; //$NON-NLS-1$ - public static final String PREF_COMPRESSION = PREFIX + "compression_level_pref"; //$NON-NLS-1$ - public static final String PREF_KEYWORDMODE = PREFIX + "default_keywordmode_pref"; //$NON-NLS-1$ - public static final String PREF_LINEEND = PREFIX + "line_end_pref"; //$NON-NLS-1$ - public static final String PREF_COMMS_TIMEOUT = PREFIX + "comms_timeout_pref"; //$NON-NLS-1$ - public static final String PREF_CONSIDER_CONTENT = PREFIX + "consider_content_pref"; //$NON-NLS-1$ - public static final String PREF_REPLACE_DELETE_UNMANAGED = PREFIX + "replace_deletion_of_unmanaged_pref"; //$NON-NLS-1$ - public static final String PREF_SAVE_DIRTY_EDITORS = PREFIX + "save_dirty_editors_pref"; //$NON-NLS-1$ - - public static final String PREF_TREAT_NEW_FILE_AS_BINARY = PREFIX + "treat_new_files_as_binary_pref"; //$NON-NLS-1$ - public static final String PREF_DETERMINE_SERVER_VERSION = PREFIX + "determine_server_version"; //$NON-NLS-1$ - public static final String PREF_CONFIRM_MOVE_TAG = PREFIX + "confirm_move_tag"; //$NON-NLS-1$ - - public static final String CONSOLE_PREFERENCE_PAGE = PREFIX + "console_preference_page_context"; //$NON-NLS-1$ - public static final String EXT_PREFERENCE_PAGE = PREFIX + "ext_preference_page_context"; //$NON-NLS-1$ - public static final String EXT_PREFERENCE_RSH = PREFIX + "ext_preference_rsh_context"; //$NON-NLS-1$ - public static final String EXT_PREFERENCE_PARAM = PREFIX + "ext_preference_param_context"; //$NON-NLS-1$ - public static final String EXT_PREFERENCE_SERVER = PREFIX + "ext_preference_server_context"; //$NON-NLS-1$ - public static final String DECORATORS_PREFERENCE_PAGE = PREFIX + "decorators_preference_page_context"; //$NON-NLS-1$ - public static final String WATCH_EDIT_PREFERENCE_PAGE = PREFIX + "watch_edit_preference_page_context"; //$NON-NLS-1$ - public static final String PASSWORD_MANAGEMENT_PAGE = PREFIX + "password_management_preference_page_context"; //$NON-NLS-1$ - public static final String COMPARE_PREFERENCE_PAGE = PREFIX + "cvs_compare_preference_page_context"; //$NON-NLS-1$ - - // Views - public static final String CONSOLE_VIEW = PREFIX + "console_view_context"; //$NON-NLS-1$ - public static final String REPOSITORIES_VIEW = PREFIX + "repositories_view_context"; //$NON-NLS-1$ - public static final String RESOURCE_HISTORY_VIEW = PREFIX + "resource_history_view_context"; //$NON-NLS-1$ - public static final String COMPARE_REVISIONS_VIEW = PREFIX + "compare_revision_view_context"; //$NON-NLS-1$ - - public static final String CVS_EDITORS_VIEW = PREFIX + "cvs_editors_view_context"; //$NON-NLS-1$ - public static final String ANNOTATE_VIEW = PREFIX + "annotate_view_context"; //$NON-NLS-1$ - - // Viewers - public static final String CATCHUP_RELEASE_VIEWER = PREFIX + "catchup_release_viewer_context"; //$NON-NLS-1$ - - // Add to .cvsignore dialog - public static final String ADD_TO_CVSIGNORE = PREFIX + "add_to_cvsignore_context"; //$NON-NLS-1$ - - // Actions - public static final String GET_ANNOTATE_ACTION = PREFIX + "get_annotate_action_context"; //$NON-NLS-1$ - public static final String GET_FILE_REVISION_ACTION = PREFIX + "get_file_revision_action_context"; //$NON-NLS-1$ - public static final String GET_FILE_CONTENTS_ACTION = PREFIX + "get_file_contents_action_context"; //$NON-NLS-1$ - public static final String TAG_WITH_EXISTING_ACTION = PREFIX + "tag_with_existing_action_context"; //$NON-NLS-1$ - public static final String NEW_REPOSITORY_LOCATION_ACTION = PREFIX + "new_repository_location_action_context"; //$NON-NLS-1$ - public static final String NEW_DEV_ECLIPSE_REPOSITORY_LOCATION_ACTION = PREFIX + "new_dev_eclipse repository_location_action_context"; //$NON-NLS-1$ - public static final String SHOW_COMMENT_IN_HISTORY_ACTION = PREFIX + "show_comment_in_history_action_context"; //$NON-NLS-1$ - public static final String SHOW_TAGS_IN_HISTORY_ACTION = PREFIX + "show_tag_in_history_action_context"; //$NON-NLS-1$ - public static final String SELECT_WORKING_SET_ACTION = PREFIX + "select_working_set_action_context"; //$NON-NLS-1$ - public static final String DESELECT_WORKING_SET_ACTION = PREFIX + "deselect_working_set_action_context"; //$NON-NLS-1$ - public static final String EDIT_WORKING_SET_ACTION = PREFIX + "edit_working_set_action_context"; //$NON-NLS-1$ - public static final String REMOVE_REPOSITORY_LOCATION_ACTION = PREFIX + "remove_root_action_context"; //$NON-NLS-1$ - public static final String SHOW_IN_RESOURCE_HISTORY = PREFIX + "show_in_history_action_context"; //$NON-NLS-1$ - public static final String SELECT_NEW_RESOURCES_ACTION = PREFIX + "select_new_action_context"; //$NON-NLS-1$ - public static final String CONFIRM_MERGE_ACTION = PREFIX + "confirm_merge_action_context"; //$NON-NLS-1$; - public static final String DISCONNECT_ACTION = PREFIX + "disconnect_action_context"; //$NON-NLS-1$; - - // Sync view menu actions - public static final String SYNC_COMMIT_ACTION = PREFIX + "sync_commit_action_context"; //$NON-NLS-1$ - public static final String SYNC_FORCED_COMMIT_ACTION = PREFIX + "sync_forced_commit_action_context"; //$NON-NLS-1$ - public static final String SYNC_UPDATE_ACTION = PREFIX + "sync_update_action_context"; //$NON-NLS-1$ - public static final String SYNC_FORCED_UPDATE_ACTION = PREFIX + "sync_forced_update_action_context"; //$NON-NLS-1$ - public static final String SYNC_ADD_ACTION = PREFIX + "sync_add_action_context"; //$NON-NLS-1$ - public static final String SYNC_IGNORE_ACTION = PREFIX + "sync_ignore_action_context"; //$NON-NLS-1$ - public static final String MERGE_UPDATE_ACTION = PREFIX + "merge_update_action_context"; //$NON-NLS-1$ - public static final String MERGE_FORCED_UPDATE_ACTION = PREFIX + "merge_forced_update_action_context"; //$NON-NLS-1$ - public static final String MERGE_UPDATE_WITH_JOIN_ACTION = PREFIX + "merge_update_with_joinaction_context"; //$NON-NLS-1$ - - // properties pages - public static final String REPOSITORY_LOCATION_PROPERTY_PAGE = PREFIX + "repository_location_property_page_context"; //$NON-NLS-1$ - public static final String REPOSITORY_ENCODING_PROPERTY_PAGE = PREFIX + "repository_encoding_property_page_context"; //$NON-NLS-1$ - public static final String PROJECT_PROPERTY_PAGE = PREFIX + "project_property_page_context"; //$NON-NLS-1$ - public static final String FOLDER_PROPERTY_PAGE = PREFIX + "folder_property_page_context"; //$NON-NLS-1$ - public static final String FILE_PROPERTY_PAGE = PREFIX + "file_property_page_context"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java deleted file mode 100644 index e488cdf7f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; - -public interface IRepositoryListener { - public void repositoryAdded(ICVSRepositoryLocation root); - public void repositoryRemoved(ICVSRepositoryLocation root); - public void repositoriesChanged(ICVSRepositoryLocation[] roots); -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java deleted file mode 100644 index 6348357fb..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher; -import org.eclipse.ui.help.WorkbenchHelp; - -public class IgnoreResourcesDialog extends Dialog { - // resources that should be ignored - private IResource[] resources; - - // preference keys - private final String ACTION_KEY = "Action"; //$NON-NLS-1$ - private static final int ADD_NAME_ENTRY = 0; - private static final int ADD_EXTENSION_ENTRY = 1; - private static final int ADD_CUSTOM_ENTRY = 2; - - // dialogs settings that are persistent between workbench sessions - private IDialogSettings settings; - - // buttons - private Button addNameEntryButton; - private Button addExtensionEntryButton; - private Button addCustomEntryButton; - private Text customEntryText; - private Label statusMessageLabel; - - private int selectedAction; - private String customPattern; - - // layout controls - private static final int LABEL_INDENT_WIDTH = 32; - - /** - * Creates a new dialog for ignoring resources. - * @param shell the parent shell - * @param resources the array of resources to be ignored - */ - public IgnoreResourcesDialog(Shell shell, IResource[] resources) { - super(shell); - this.resources = resources; - - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - this.settings = workbenchSettings.getSection("IgnoreResourcesDialog");//$NON-NLS-1$ - if (settings == null) { - this.settings = workbenchSettings.addNewSection("IgnoreResourcesDialog");//$NON-NLS-1$ - } - - try { - selectedAction = settings.getInt(ACTION_KEY); - } catch (NumberFormatException e) { - selectedAction = ADD_NAME_ENTRY; - } - } - - /** - * Determines the ignore pattern to use for a resource given the selected action. - * - * @param resource the resource - * @return the ignore pattern for the specified resource - */ - public String getIgnorePatternFor(IResource resource) { - switch (selectedAction) { - case ADD_NAME_ENTRY: - return resource.getName(); - case ADD_EXTENSION_ENTRY: { - String extension = resource.getFileExtension(); - return (extension == null) ? resource.getName() : "*." + extension; //$NON-NLS-1$ - } - case ADD_CUSTOM_ENTRY: - return customPattern; - } - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (resources.length == 1) { - newShell.setText(Policy.bind("IgnoreResourcesDialog.titleSingle", resources[0].getName())); //$NON-NLS-1$ - } else { - newShell.setText(Policy.bind("IgnoreResourcesDialog.titleMany", Integer.toString(resources.length))); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createContents(Composite parent) { - Control control = super.createContents(parent); - updateEnablements(); - return control; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - - WorkbenchHelp.setHelp(top, IHelpContextIds.ADD_TO_CVSIGNORE); - - createIndentedLabel(top, Policy.bind("IgnoreResourcesDialog.prompt"), 0); //$NON-NLS-1$ - - Listener selectionListener = new Listener() { - public void handleEvent(Event event) { - updateEnablements(); - } - }; - Listener modifyListener = new Listener() { - public void handleEvent(Event event) { - validate(); - } - }; - - addNameEntryButton = createRadioButton(top, Policy.bind("IgnoreResourcesDialog.addNameEntryButton")); //$NON-NLS-1$ - addNameEntryButton.addListener(SWT.Selection, selectionListener); - addNameEntryButton.setSelection(selectedAction == ADD_NAME_ENTRY); - createIndentedLabel(top, Policy.bind("IgnoreResourcesDialog.addNameEntryExample"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - addExtensionEntryButton = createRadioButton(top, Policy.bind("IgnoreResourcesDialog.addExtensionEntryButton")); //$NON-NLS-1$ - addExtensionEntryButton.addListener(SWT.Selection, selectionListener); - addExtensionEntryButton.setSelection(selectedAction == ADD_EXTENSION_ENTRY); - createIndentedLabel(top, Policy.bind("IgnoreResourcesDialog.addExtensionEntryExample"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - addCustomEntryButton = createRadioButton(top, Policy.bind("IgnoreResourcesDialog.addCustomEntryButton")); //$NON-NLS-1$ - addCustomEntryButton.addListener(SWT.Selection, selectionListener); - addCustomEntryButton.setSelection(selectedAction == ADD_CUSTOM_ENTRY); - createIndentedLabel(top, Policy.bind("IgnoreResourcesDialog.addCustomEntryExample"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - customEntryText = createIndentedText(top, resources[0].getName(), LABEL_INDENT_WIDTH); - customEntryText.addListener(SWT.Modify, modifyListener); - - statusMessageLabel = createIndentedLabel(top, "", 0); //$NON-NLS-1$ - Dialog.applyDialogFont(parent); - return top; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void okPressed() { - settings.put(ACTION_KEY, selectedAction); - super.okPressed(); - } - - private Label createIndentedLabel(Composite parent, String text, int indent) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL); - data.horizontalIndent = indent; - label.setLayoutData(data); - return label; - } - - private Text createIndentedText(Composite parent, String text, int indent) { - Text textbox = new Text(parent, SWT.BORDER); - textbox.setText(text); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalIndent = indent; - textbox.setLayoutData(data); - return textbox; - } - - private Button createRadioButton(Composite parent, String text) { - Button button = new Button(parent, SWT.RADIO); - button.setText(text); - button.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL)); - return button; - } - - private void updateEnablements() { - if (addNameEntryButton.getSelection()) { - selectedAction = ADD_NAME_ENTRY; - } else if (addExtensionEntryButton.getSelection()) { - selectedAction = ADD_EXTENSION_ENTRY; - } else if (addCustomEntryButton.getSelection()) { - selectedAction = ADD_CUSTOM_ENTRY; - } - customEntryText.setEnabled(selectedAction == ADD_CUSTOM_ENTRY); - validate(); - } - - private void validate() { - if (selectedAction == ADD_CUSTOM_ENTRY) { - customPattern = customEntryText.getText(); - if (customPattern.length() == 0) { - setError(Policy.bind("IgnoreResourcesDialog.patternMustNotBeEmpty")); //$NON-NLS-1$ - return; - } - FileNameMatcher matcher = new FileNameMatcher(new String[] { customPattern }); - for (int i = 0; i < resources.length; i++) { - String name = resources[i].getName(); - if (! matcher.match(name)) { - setError(Policy.bind("IgnoreResourcesDialog.patternDoesNotMatchFile", name)); //$NON-NLS-1$ - return; - } - } - } - setError(null); - } - - private void setError(String text) { - if (text == null) { - statusMessageLabel.setText(""); //$NON-NLS-1$ - getButton(IDialogConstants.OK_ID).setEnabled(true); - } else { - statusMessageLabel.setText(text); - statusMessageLabel.setForeground(JFaceColors.getErrorText(getShell().getDisplay())); - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java deleted file mode 100644 index 5add39551..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java +++ /dev/null @@ -1,177 +0,0 @@ -/* -*-mode:java; c-basic-offset:2; -*- */ -/********************************************************************** -Copyright (c) 2004, Atsuhiko Yamanaka, JCraft,Inc. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation. -**********************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * A dialog for keyboad-interactive authentication for the ssh2 connection. - */ -public class KeyboardInteractiveDialog extends Dialog { - // widgets - private Text[] texts; - - protected String domain; - protected String destination; - protected String name; - protected String instruction; - protected String lang; - protected String[] prompt; - protected boolean[] echo; - private String message; - private String[] result; - - /** - * Creates a nwe KeyboardInteractiveDialog. - * - * @param parentShell the parent shell - * @param destication the location - * @param name the name - * @param instruction the instruction - * @param prompt the titles for textfields - * @param echo '*' should be used or not - */ - public KeyboardInteractiveDialog(Shell parentShell, - String location, - String destination, - String name, - String instruction, - String[] prompt, - boolean[] echo){ - super(parentShell); - this.domain=location; - this.destination=destination; - this.name=name; - this.instruction=instruction; - this.prompt=prompt; - this.echo=echo; - this.message=Policy.bind("KeyboradInteractiveDialog.message", destination+(name!=null && name.length()>0 ? ": "+name : "")); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - /** - * @see Window#configureShell - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(message); - } - /** - * @see Window#create - */ - public void create() { - super.create(); - if(texts.length>0){ - texts[0].setFocus(); - } - } - /** - * @see Dialog#createDialogArea - */ - protected Control createDialogArea(Composite parent) { - Composite main=new Composite(parent, SWT.NONE); - GridLayout layout=new GridLayout(); - layout.numColumns=3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_BOTH)); - - // set F1 help - WorkbenchHelp.setHelp(main, IHelpContextIds.KEYBOARD_INTERACTIVE_DIALOG); - - if (message!=null) { - Label messageLabel=new Label(main, SWT.WRAP); - messageLabel.setText(message); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=3; - messageLabel.setLayoutData(data); - } - if(domain!=null){ - Label label = new Label(main, SWT.WRAP); - label.setText(Policy.bind("KeyboardInteractiveDialog.labelRepository", domain)); //$NON-NLS-1$ - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=3; - label.setLayoutData(data); - } - if (instruction!=null && instruction.length()>0) { - Label messageLabel=new Label(main, SWT.WRAP); - messageLabel.setText(instruction); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=3; - messageLabel.setLayoutData(data); - } - createPasswordFields(main); - return main; - } - /** - * Creates the widgets that represent the entry area. - * - * @param parent the parent of the widgets - */ - protected void createPasswordFields(Composite parent) { - texts=new Text[prompt.length]; - - for(int i=0; i - * The default implementation of this framework method sets - * this dialog's return code to Window.OK - * and closes the dialog. Subclasses may override. - *

              - */ - protected void okPressed() { - result=new String[prompt.length]; - for(int i=0; i - * The default implementation of this framework method sets - * this dialog's return code to Window.CANCEL - * and closes the dialog. Subclasses may override. - *

              - */ - protected void cancelPressed() { - result=null; - super.cancelPressed(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java deleted file mode 100644 index 73bc6d5c3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.internal.ui.dialogs.DialogArea; - -/** - * Reusable area that provides a list to select from and a select all and - * deselect all button. - */ -public class ListSelectionArea extends DialogArea { - private Object inputElement; - private IStructuredContentProvider contentProvider; - private ILabelProvider labelProvider; - private String message; - private List initialSelections; - - // the visual selection widget group - private CheckboxTableViewer listViewer; - - private Object[] previousCheckedElements; - - public static final String LIST_SELECTION = "ListSelection"; //$NON-NLS-1$ - - /** - * Constructor for ListSelectionArea. - * @param parentDialog - * @param settings - */ - public ListSelectionArea( - Object input, - IStructuredContentProvider contentProvider, - ILabelProvider labelProvider, - String message) { - this.inputElement = input; - this.contentProvider = contentProvider; - this.labelProvider = labelProvider; - this.message = message; - this.initialSelections = new ArrayList(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.DialogArea#createArea(org.eclipse.swt.widgets.Composite) - */ - public void createArea(Composite parent) { - - Dialog.applyDialogFont(parent); - - final Composite composite = createComposite(parent, 1, true); - - initializeDialogUnits(composite); - - if (message != null) - createWrappingLabel(composite, message, 1); - - listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.heightHint = 0; // It will expand to the size of the wizard page! - data.widthHint = 0; - listViewer.getTable().setLayoutData(data); - - listViewer.setLabelProvider(labelProvider); - listViewer.setContentProvider(contentProvider); - - listViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - Object[] checkedElements = getViewer().getCheckedElements(); - firePropertyChangeChange(LIST_SELECTION, previousCheckedElements, checkedElements); - previousCheckedElements = checkedElements; - } - }); - - addSelectionButtons(composite); - - initializeViewer(); - - // initialize page - if (!getInitialElementSelections().isEmpty()) - checkInitialSelections(); - } - - /** - * Initializes this dialog's viewer after it has been laid out. - */ - private void initializeViewer() { - listViewer.setInput(inputElement); - } - - /** - * Visually checks the previously-specified elements in this dialog's list - * viewer. - */ - private void checkInitialSelections() { - Iterator itemsToCheck = getInitialElementSelections().iterator(); - - while (itemsToCheck.hasNext()) - listViewer.setChecked(itemsToCheck.next(),true); - } - - /** - * Add the selection and deselection buttons to the dialog. - * @param composite org.eclipse.swt.widgets.Composite - */ - private void addSelectionButtons(Composite composite) { - Composite buttonComposite = new Composite(composite, SWT.RIGHT); - buttonComposite.setLayout(new GridLayout(2, false)); - buttonComposite.setData(new GridData(SWT.END, SWT.BEGINNING, true, false)); - - Button selectButton = createButton(buttonComposite, Policy.bind("ListSelectionArea.selectAll"), GridData.HORIZONTAL_ALIGN_FILL); //$NON-NLS-1$ - - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(true); - } - }; - selectButton.addSelectionListener(listener); - - - Button deselectButton = createButton(buttonComposite, Policy.bind("ListSelectionArea.deselectAll"), GridData.HORIZONTAL_ALIGN_FILL); //$NON-NLS-1$ - - listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(false); - - } - }; - deselectButton.addSelectionListener(listener); - } - - /** - * Returns the list of initial element selections. - * @return List - */ - protected List getInitialElementSelections(){ - return initialSelections; - } - - /** - * Sets the initial selection in this selection dialog to the given elements. - * - * @param selectedElements the array of elements to select - */ - public void setInitialSelections(Object[] selectedElements) { - initialSelections = new ArrayList(selectedElements.length); - for (int i = 0; i < selectedElements.length; i++) - initialSelections.add(selectedElements[i]); - } - - /** - * Sets the initial selection in this selection dialog to the given elements. - * - * @param selectedElements the List of elements to select - */ - public void setInitialElementSelections(List selectedElements) { - initialSelections = selectedElements; - } - /** - * Returns the listViewer. - * @return CheckboxTableViewer - */ - public CheckboxTableViewer getViewer() { - return listViewer; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/OverlayIconCache.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/OverlayIconCache.java deleted file mode 100644 index c6c06b12f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/OverlayIconCache.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.internal.ui.*; - -/** - * Maintains a cache of OverlayIcons. - */ -public class OverlayIconCache { - private Map /*from OverlayIcon to Image*/ cache = new HashMap(); - - /** - * Returns and caches an image corresponding to the specified icon. - * @param icon the icon - * @return the image - */ - public Image getImageFor(OverlayIcon icon) { - Image image = (Image) cache.get(icon); - if (image == null) { - image = icon.createImage(); - cache.put(icon, image); - } - return image; - } - - /** - * Disposes of all images in the cache. - */ - public void disposeAll() { - for (Iterator it = cache.values().iterator(); it.hasNext();) { - Image image = (Image) it.next(); - image.dispose(); - } - cache.clear(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java deleted file mode 100644 index 813ad1b95..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.util.*; -import java.util.List; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.TableEditor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -public class PasswordManagementPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - private TableViewer viewer; - private Button removeButton; - private Button removeAllButton; - - class TableLabelProvider extends LabelProvider implements ITableLabelProvider { - public String getColumnText(Object element, int columnIndex) { - ICVSRepositoryLocation entry = (ICVSRepositoryLocation)element; - switch (columnIndex) { - case 0: - return entry.toString(); - case 1: - return entry.getUsername(); - default: - return null; - } - } - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - }; - - public void init(IWorkbench workbench) { - setDescription(Policy.bind("PasswordManagementPreferencePage.2")); //$NON-NLS-1$ - } - - /** - * Creates preference page controls on demand. - * - * @param parent the parent for the preference page - */ - protected Control createContents(Composite ancestor) { - - Composite parent = new Composite(ancestor, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - parent.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - parent.setLayoutData(data); - - viewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - Table table = viewer.getTable(); - new TableEditor(table); - table.setHeaderVisible(true); - table.setLinesVisible(true); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = convertWidthInCharsToPixels(30); - /* - * The hardcoded hint does not look elegant, but in reality - * it does not make anything bound to this 100-pixel value, - * because in any case the tree on the left is taller and - * that's what really determines the height. - */ - gd.heightHint = 100; - table.setLayoutData(gd); - table.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - handleSelection(); - } - }); - // Create the table columns - new TableColumn(table, SWT.NULL); - new TableColumn(table, SWT.NULL); - TableColumn[] columns = table.getColumns(); - columns[0].setText(Policy.bind("PasswordManagementPreferencePage.3")); //$NON-NLS-1$ - columns[1].setText(Policy.bind("PasswordManagementPreferencePage.4")); //$NON-NLS-1$ - viewer.setColumnProperties(new String[] {"location", "username"}); //$NON-NLS-1$ //$NON-NLS-2$ - viewer.setLabelProvider(new TableLabelProvider()); - viewer.setContentProvider(new IStructuredContentProvider() { - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - public Object[] getElements(Object inputElement) { - if (inputElement == null) return null; - ICVSRepositoryLocation[] locations = ((KnownRepositories)inputElement).getRepositories(); - List repos = new ArrayList(); - for (int i = 0; i < locations.length; i++) { - ICVSRepositoryLocation l = locations[i]; - if(l.getUserInfoCached()) - repos.add(l); - } - return (ICVSRepositoryLocation[]) repos.toArray(new ICVSRepositoryLocation[repos.size()]); - } - }); - TableLayout tl = new TableLayout(); - tl.addColumnData(new ColumnWeightData(15)); - tl.addColumnData(new ColumnWeightData(1, 100)); - table.setLayout(tl); - - Composite buttons = new Composite(parent, SWT.NULL); - buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - buttons.setLayout(layout); - - removeButton = new Button(buttons, SWT.PUSH); - removeButton.setText(Policy.bind("PasswordManagementPreferencePage.5")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - removeButton.setLayoutData(data); - removeButton.setEnabled(false); - removeButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - remove(); - } - }); - removeAllButton = new Button(buttons, SWT.PUSH); - removeAllButton.setText(Policy.bind("PasswordManagementPreferencePage.6")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - removeAllButton.setLayoutData(data); - removeAllButton.setEnabled(true); - removeAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - removeAll(); - } - }); - Dialog.applyDialogFont(ancestor); - viewer.setInput(KnownRepositories.getInstance()); - handleSelection(); - - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.PASSWORD_MANAGEMENT_PAGE); - - return parent; - } - - public boolean performOk() { - return true; - } - - protected void performDefaults() { - super.performDefaults(); - } - - private void remove() { - IStructuredSelection s = (IStructuredSelection)viewer.getSelection(); - for (Iterator it = s.iterator(); it.hasNext();) { - ICVSRepositoryLocation location = (ICVSRepositoryLocation) it.next(); - location.flushUserInfo(); - } - viewer.refresh(); - handleSelection(); - } - - private void removeAll() { - ICVSRepositoryLocation[] locations = KnownRepositories.getInstance().getRepositories(); - for (int i = 0; i < locations.length; i++) { - ICVSRepositoryLocation l = locations[i]; - if(l.getUserInfoCached()) - l.flushUserInfo(); - } - viewer.refresh(); - handleSelection(); - } - - private void handleSelection() { - if (viewer.getTable().getSelectionCount() > 0) { - removeButton.setEnabled(true); - } else { - removeButton.setEnabled(false); - } - removeAllButton.setEnabled(viewer.getTable().getItemCount() > 0); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java deleted file mode 100644 index a3cee4bad..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; - -public class Policy { - public static boolean DEBUG_CONSOLE_BUFFERING = false; - - static { - //init debug options - if (CVSUIPlugin.getPlugin().isDebugging()) { - DEBUG_CONSOLE_BUFFERING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSUIPlugin.ID + "/consolebuffering")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - protected static ResourceBundle bundle = null; - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - */ - public static String bind(String id, String binding1, String binding2) { - return bind(id, new String[] { binding1, binding2 }); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Progress monitor helpers - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor.isCanceled()) - cancelOperation(); - } - public static void cancelOperation() { - throw new OperationCanceledException(); - } - public static IProgressMonitor monitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks, style); - } - - public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new InfiniteSubProgressMonitor(monitor, ticks); - } - - public static ResourceBundle getBundle() { - return bundle; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java deleted file mode 100644 index c92c5b583..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.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.team.internal.ccvs.ui; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -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.*; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Prompts the user for a multi-line comment for releasing to CVS. - */ -public class ReleaseCommentDialog extends DetailsDialog { - - CommitCommentArea commitCommentArea; - // dialogs settings that are persistent between workbench sessions - private IDialogSettings settings; - private static final String HEIGHT_KEY = "width-key"; //$NON-NLS-1$ - private static final String WIDTH_KEY = "height-key"; //$NON-NLS-1$ - - /** - * ReleaseCommentDialog constructor. - * - * @param parentShell the parent of this dialog - * @param proposedComment - */ - public ReleaseCommentDialog(Shell parentShell, IResource[] resourcesToCommit, String proposedComment, int depth) { - super(parentShell, Policy.bind("ReleaseCommentDialog.title")); //$NON-NLS-1$ - int shellStyle = getShellStyle(); - setShellStyle(shellStyle | SWT.RESIZE | SWT.MAX); - commitCommentArea = new CommitCommentArea(); - // Get a project from which the commit template can be obtained - if (resourcesToCommit.length > 0) - commitCommentArea.setProject(resourcesToCommit[0].getProject()); - commitCommentArea.setProposedComment(proposedComment); - - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - this.settings = workbenchSettings.getSection("ReleaseCommentDialog");//$NON-NLS-1$ - if (settings == null) { - this.settings = workbenchSettings.addNewSection("ReleaseCommentDialog");//$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeDetailsButton() - */ - protected boolean includeDetailsButton() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeErrorMessage() - */ - protected boolean includeErrorMessage() { - return false; - } - - /* - * @see Dialog#createDialogArea(Composite) - */ - protected void createMainDialogArea(Composite parent) { - getShell().setText(Policy.bind("ReleaseCommentDialog.title")); //$NON-NLS-1$ - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - commitCommentArea.createArea(composite); - commitCommentArea.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty() == CommitCommentArea.OK_REQUESTED) - okPressed(); - } - }); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.RELEASE_COMMENT_DIALOG); - Dialog.applyDialogFont(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - int width, height; - try { - height = settings.getInt(HEIGHT_KEY); - width = settings.getInt(WIDTH_KEY); - } catch(NumberFormatException e) { - return super.getInitialSize(); - } - Point p = super.getInitialSize(); - return new Point(width, p.y); - } - - public String getComment() { - return commitCommentArea.getComment(); - } - - public IResource[] getResourcesToCommit() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#createDropDownDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#updateEnablements() - */ - protected void updateEnablements() { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#close() - */ - public boolean close() { - Rectangle bounds = getShell().getBounds(); - settings.put(HEIGHT_KEY, bounds.height); - settings.put(WIDTH_KEY, bounds.width); - return super.close(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control c = super.createContents(parent); - commitCommentArea.setFocus(); - return c; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationEditorInput.java deleted file mode 100644 index 2935d8903..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationEditorInput.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * An editor input for a cvs annotation response - */ -public class RemoteAnnotationEditorInput extends RemoteFileEditorInput implements IWorkbenchAdapter, IStorageEditorInput { - - InputStream contents; - - public RemoteAnnotationEditorInput(ICVSRemoteFile file, InputStream contents) { - super(file, new NullProgressMonitor()); - this.contents = contents; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.RemoteFileEditorInput#initializeStorage(org.eclipse.team.internal.ccvs.core.ICVSRemoteFile, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void initializeStorage(ICVSRemoteFile file, IProgressMonitor monitor) throws TeamException { - if (contents != null) { - storage = new RemoteAnnotationStorage(file, contents); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationStorage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationStorage.java deleted file mode 100644 index fdbc38ab3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteAnnotationStorage.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.team.internal.ccvs.ui; - -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; - -public class RemoteAnnotationStorage extends PlatformObject implements IEncodedStorage { - - private InputStream contents; - private ICVSRemoteFile file; - - public RemoteAnnotationStorage(ICVSRemoteFile file, InputStream contents) { - this.file = file; - this.contents = contents; - } - - public InputStream getContents() throws CoreException { - try { - // Contents are a ByteArrayInputStream which can be reset to the beginning - contents.reset(); - } catch (IOException e) { - CVSUIPlugin.log(CVSException.wrapException(e)); - } - return contents; - } - - public String getCharset() throws CoreException { - InputStream contents = getContents(); - try { - String charSet = TeamPlugin.getCharset(getName(), contents); - return charSet; - } catch (IOException e) { - throw new CVSException(new Status(IStatus.ERROR, CVSUIPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, Policy.bind("RemoteAnnotationStorage.1", getFullPath().toString()), e)); //$NON-NLS-1$ - } finally { - try { - contents.close(); - } catch (IOException e1) { - // Ignore - } - } - } - - public IPath getFullPath() { - ICVSRepositoryLocation location = file.getRepository(); - IPath path = new Path(null, location.getRootDirectory()); - path = path.setDevice(location.getHost() + Path.DEVICE_SEPARATOR); - path = path.append(file.getRepositoryRelativePath()); - return path; - } - public String getName() { - return file.getName(); - } - public boolean isReadOnly() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java deleted file mode 100644 index 14412b245..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * An editor input for a file in a repository. - */ -public class RemoteFileEditorInput implements IWorkbenchAdapter, IStorageEditorInput { - ICVSRemoteFile file; - IStorage storage; - - /** - * Creates FileEditionEditorInput on the given file. - */ - public RemoteFileEditorInput(ICVSRemoteFile file, IProgressMonitor monitor) { - this.file = file; - try { - initializeStorage(file, monitor); - } catch (TeamException e) { - // Log and continue - CVSUIPlugin.log(e); - } - } - - /** - * Initialize the strogae of this instance from the given file. - * @param file the file being displayed - * @param monitor a progress monitor - */ - protected void initializeStorage(ICVSRemoteFile file, IProgressMonitor monitor) throws TeamException { - // Cache the contents of the file for use in the editor - storage = ((IResourceVariant)file).getStorage(monitor); - } - - /** - * Returns whether the editor input exists. - *

              - * This method is primarily used to determine if an editor input should - * appear in the "File Most Recently Used" menu. An editor input will appear - * in the list until the return value of exists becomes - * false or it drops off the bottom of the list. - * - * @return true if the editor input exists; false - * otherwise - */ - public boolean exists() { - return true; - } - public boolean equals(Object o) { - if (!(o instanceof RemoteFileEditorInput)) return false; - RemoteFileEditorInput input = (RemoteFileEditorInput)o; - return file.equals(input.file); - } - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns null if - * no such object can be found. - * - * @param adapter the adapter class to look up - * @return a object castable to the given class, - * or null if this object does not - * have an adapter for the given class - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) { - return this; - } - return null; - } - /** - * Returns the children of this object. When this object - * is displayed in a tree, the returned objects will be this - * element's children. Returns an empty array if this - * object has no children. - * - * @param object The object to get the children for. - */ - public Object[] getChildren(Object o) { - return new Object[0]; - } - /** - * Returns the content type of the input. For instance, if the input - * wraps an IFile the content type would be derived from - * the extension or mime type. If the input wraps another object it - * may just be the object type. The content type is used for - * editor mapping. - */ - public String getContentType() { - String name = file.getName(); - return name.substring(name.lastIndexOf('.')+1); - } - /** - * Returns the fully qualified path name of the input. - */ - public String getFullPath() { - //use path to make sure slashes are correct - ICVSRepositoryLocation location = file.getRepository(); - IPath path = new Path(null, location.getRootDirectory()); - path = path.setDevice(location.getHost() + Path.DEVICE_SEPARATOR); - path = path.append(file.getRepositoryRelativePath()); - String fullPath; - try { - String revision = file.getRevision(); - fullPath = Policy.bind("RemoteFileEditorInput.fullPathAndRevision", path.toString(), revision); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - fullPath = path.toString(); - } - return fullPath; - } - /** - * Returns the image descriptor for this input. - * - * @return the image descriptor for this input - */ - public ImageDescriptor getImageDescriptor() { - IWorkbenchAdapter fileAdapter = (IWorkbenchAdapter)file.getAdapter(IWorkbenchAdapter.class); - return fileAdapter == null ? null : fileAdapter.getImageDescriptor(file); - } - /** - * @see IWorkbenchAdapter#getImageDescriptor - */ - public ImageDescriptor getImageDescriptor(Object object) { - IWorkbenchAdapter fileAdapter = (IWorkbenchAdapter)file.getAdapter(IWorkbenchAdapter.class); - return fileAdapter == null ? null : fileAdapter.getImageDescriptor(file); - } - /** - * @see IWorkbenchAdapter#getLabel - */ - public String getLabel(Object o) { - return file.getName(); - } - /** - * Returns the input name for display purposes. For instance, if - * the fully qualified input name is "a\b\MyFile.gif" the return value for - * getName is "MyFile.gif". - */ - public String getName() { - String name = file.getName(); - try { - return Policy.bind("nameAndRevision", name, file.getRevision()); //$NON-NLS-1$ - } catch (TeamException e) { - return name; - } - } - /** - * Returns the logical parent of the given object in its tree. - * Returns null if there is no parent, or if this object doesn't - * belong to a tree. - * - * @param object The object to get the parent for. - */ - public Object getParent(Object o) { - return null; - } - /* - * Returns an interface used to persist the object. If the editor input - * cannot be persisted this method returns null. - */ - public IPersistableElement getPersistable() { - //not persistable - return null; - } - /** - * Returns the underlying IStorage object. - * - * @return an IStorage object. - * @exception CoreException if this method fails - */ - public IStorage getStorage() throws CoreException { - if (storage == null) { - initializeStorage(file, new NullProgressMonitor()); - } - return storage; - } - /** - * Returns the tool tip text for this editor input. This text - * is used to differentiate between two input with the same name. - * For instance, MyClass.java in folder X and MyClass.java in folder Y. - *

              - * The format of the path will vary with each input type. For instance, - * if the editor input is of type IFileEditorInput this method - * should return the fully qualified resource path. For editor input of - * other types it may be different. - *

              - * @return the tool tip text - */ - public String getToolTipText() { - return getFullPath(); - } - - /** - * Returns the remote CVS file shown in this editor input. - * @return the remote file handle. - */ - public ICVSRemoteFile getCVSRemoteFile() { - return file; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java deleted file mode 100644 index 91e3ffff4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.io.*; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ISubscriberChangeEvent; -import org.eclipse.team.core.subscribers.ISubscriberChangeListener; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.editors.text.IStorageDocumentProvider; -import org.eclipse.ui.texteditor.*; -import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider; - -/** - * A QuickDiff provider that provides a reference to the latest revision of a file - * in the CVS repository. The provider notifies when the file's sync state changes - * and the diff should be recalculated (e.g. commit, update...) or when the file - * is changed (e.g. replace with). - * - * Here are the file states and what this provider does for each: - * - * 1. File is unmanaged : reference == empty document - * 2. Unmanaged file transitions to managed : empty reference updated with new remote revision - * 3. A managed file has new remote (commit, refresh remote) : reference updated with new - * remote revision - * 4. A managed file cleaned, remote is the same (replace with, update) : refresh diff bar - * with existing reference - * - * [Note: Currently an empty document must be returned for an unmanaged file. This - * results in the entire document appearing as outgoing changes in the quickdiff bar. - * This is required because the quickdiff support relies on IDocument change events - * to update the quickdiff, and returning null for the reference document doesn't - * allow the transition to later return a IDocument.] - * - * @since 3.0 - */ -public class RemoteRevisionQuickDiffProvider implements IQuickDiffReferenceProvider { - // The editor showing this quickdiff and provides access to the editor input and - // ultimatly the IFile. - private ITextEditor fEditor = null; - - // The document containing the remote file. Can be null if the assigned editor doesn't have - // a CVS remote resource associated with it. - private IDocument fReference = null; - - // Will be true when the document has been read and initialized. - private boolean fReferenceInitialized = false; - - // Document provider allows us to register/deregister the element state change listener. - private IDocumentProvider fDocumentProvider = null; - - // Unique id for this reference provider as set via setId(). - private String fId; - - // A handle to the remote CVS file for this provider. - private SyncInfo fLastSyncState; - - // Job that re-creates the reference document. - private Job fUpdateJob; - - private boolean DEBUG = false; - - /** - * Updates the document if a sync changes occurs to the associated CVS file. - */ - private ISubscriberChangeListener teamChangeListener = new ISubscriberChangeListener() { - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - if(fReferenceInitialized) { - for (int i = 0; i < deltas.length; i++) { - ISubscriberChangeEvent delta = deltas[i]; - IResource resource = delta.getResource(); - if(resource.getType() == IResource.FILE && - fLastSyncState != null && resource.equals(fLastSyncState.getLocal())) { - if(delta.getFlags() == ISubscriberChangeEvent.SYNC_CHANGED) { - fetchContentsInJob(); - } - } - } - } - } - }; - - /** - * Updates the document if the document is changed (e.g. replace with) - */ - private IElementStateListener documentListener = new IElementStateListener() { - public void elementDirtyStateChanged(Object element, boolean isDirty) { - } - - public void elementContentAboutToBeReplaced(Object element) { - } - - public void elementContentReplaced(Object element) { - if(fEditor != null && fEditor.getEditorInput() == element) { - fetchContentsInJob(); - } - } - - public void elementDeleted(Object element) { - } - - public void elementMoved(Object originalElement, Object movedElement) { - } - }; - - /* - * @see org.eclipse.test.quickdiff.DocumentLineDiffer.IQuickDiffReferenceProvider#getReference() - */ - public IDocument getReference(IProgressMonitor monitor) throws CoreException { - if(! fReferenceInitialized) return null; - if (fReference == null) { - readDocument(monitor); - } - return fReference; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffProviderImplementation#setActiveEditor(org.eclipse.ui.texteditor.ITextEditor) - */ - public void setActiveEditor(ITextEditor targetEditor) { - if(! (targetEditor.getEditorInput() instanceof IFileEditorInput)) return; - fEditor = targetEditor; - fDocumentProvider= fEditor.getDocumentProvider(); - - if(fDocumentProvider != null) { - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(teamChangeListener); - fDocumentProvider.addElementStateListener(documentListener); - } - fReferenceInitialized= true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffProviderImplementation#isEnabled() - */ - public boolean isEnabled() { - if (! fReferenceInitialized) - return false; - try { - return getManagedCVSFile() != null; - } catch (CVSException e) { - return false; - } - } - - /* - * @see org.eclipse.jface.text.source.diff.DocumentLineDiffer.IQuickDiffReferenceProvider#dispose() - */ - public void dispose() { - fReferenceInitialized = false; - // stop update job - if(fUpdateJob != null && fUpdateJob.getState() != Job.NONE) { - fUpdateJob.cancel(); - } - - // remove listeners - if(fDocumentProvider != null) { - fDocumentProvider.removeElementStateListener(documentListener); - } - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().removeListener(teamChangeListener); - } - - /* - * @see org.eclipse.quickdiff.QuickDiffTestPlugin.IQuickDiffProviderImplementation#setId(java.lang.String) - */ - public void setId(String id) { - fId= id; - } - - /* - * @see org.eclipse.jface.text.source.diff.DocumentLineDiffer.IQuickDiffReferenceProvider#getId() - */ - public String getId() { - return fId; - } - - /** - * Determine if the file represented by this quickdiff provider has changed with - * respect to it's remote state. Return true if the remote contents should be - * refreshed, and false if not. - */ - private boolean computeChange(IProgressMonitor monitor) throws TeamException { - boolean needToUpdateReferenceDocument = false; - if(fReferenceInitialized) { - SyncInfo info = getSyncState(getFileFromEditor()); - if(info == null && fLastSyncState != null) { - return true; - } else if(info == null) { - return false; - } - - if(fLastSyncState == null) { - needToUpdateReferenceDocument = true; - } else if(! fLastSyncState.equals(info)) { - needToUpdateReferenceDocument = true; - } - if(DEBUG) debug(fLastSyncState, info); - fLastSyncState = info; - } - return needToUpdateReferenceDocument; - } - - private void debug(SyncInfo lastSyncState, SyncInfo info) { - String last = "[none]"; //$NON-NLS-1$ - if(lastSyncState != null) { - last = lastSyncState.toString(); - } - System.out.println("+ CVSQuickDiff: was " + last + " is " + info.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - private SyncInfo getSyncState(IResource resource) throws TeamException { - if (resource == null) return null; - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().getSyncInfo(resource); - } - - /** - * Creates a document and initializes it with the contents of a CVS remote - * resource. - * @param monitor the progress monitor - * @throws CoreException - */ - private void readDocument(IProgressMonitor monitor) throws CoreException { - if(! fReferenceInitialized) return; - if(fReference == null) - fReference = new Document(); - if(computeChange(monitor)) { - ICVSRemoteFile remoteFile = (ICVSRemoteFile)fLastSyncState.getRemote(); - if (fLastSyncState.getRemote() != null && fDocumentProvider instanceof IStorageDocumentProvider) { - IStorageDocumentProvider provider= (IStorageDocumentProvider) fDocumentProvider; - String encoding= provider.getEncoding(fEditor.getEditorInput()); - if (encoding == null) { - encoding= provider.getDefaultEncoding(); - } - if(monitor.isCanceled()) return; - InputStream stream= remoteFile.getContents(monitor); - if (stream == null || monitor.isCanceled() || ! fReferenceInitialized) { - return; - } - setDocumentContent(fReference, stream, encoding); - } else { - // the remote is null, so ensure that the document is null - if(monitor.isCanceled()) return; - fReference.set(""); //$NON-NLS-1$ - } - if(DEBUG) System.out.println("+ CVSQuickDiff: updating document " + (fReference!=null ? "remote found" : "remote empty")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - - /** - * Intitializes the given document with the given stream using the given encoding. - * - * @param document the document to be initialized - * @param contentStream the stream which delivers the document content - * @param encoding the character encoding for reading the given stream - * @exception CoreException if the given stream can not be read - */ - private static void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException { - Reader in= null; - try { - final int DEFAULT_FILE_SIZE= 15 * 1024; - - in= new BufferedReader(new InputStreamReader(contentStream, encoding), DEFAULT_FILE_SIZE); - CharArrayWriter caw= new CharArrayWriter(DEFAULT_FILE_SIZE); - char[] readBuffer= new char[2048]; - int n= in.read(readBuffer); - while (n > 0) { - caw.write(readBuffer, 0, n); - n= in.read(readBuffer); - } - document.set(caw.toString()); - //System.out.println("+ CVSQuickDiff: updating document : " + caw.toString()); - } catch (IOException x) { - throw new CVSException(Policy.bind("RemoteRevisionQuickDiffProvider.readingFile"), x); //$NON-NLS-1$ - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException x) { - throw new CVSException(Policy.bind("RemoteRevisionQuickDiffProvider.closingFile"), x); //$NON-NLS-1$ - } - } - } - } - - /** - * Returns the ICVSFile associated with he active editor or null - * if the provider doesn't not have access to a CVS managed file. - * @return the handle to a CVS file - */ - private ICVSFile getManagedCVSFile() throws CVSException { - if(fEditor != null) { - IFile file = getFileFromEditor(); - if(file != null && CVSWorkspaceRoot.isSharedWithCVS(file)) { - return CVSWorkspaceRoot.getCVSFileFor(file); - } - } - return null; - } - - private IFile getFileFromEditor() { - if(fEditor != null) { - IEditorInput input= fEditor.getEditorInput(); - if (input instanceof IFileEditorInput) { - return ((IFileEditorInput)input).getFile(); - } - } - return null; - } - - /** - * Runs a job that updates the document. If a previous job is already running it - * is stopped before the new job can start. - */ - private void fetchContentsInJob() { - if(! fReferenceInitialized) return; - if(fUpdateJob != null && fUpdateJob.getState() != Job.NONE) { - fUpdateJob.cancel(); - } - fUpdateJob = new Job(Policy.bind("RemoteRevisionQuickDiffProvider.fetchingFile")) { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - try { - readDocument(monitor); - } catch (CoreException e) { - // continue and return ok for now. The error will be reported - // when the quick diff supports calls getReference() again. - // continue - } - return Status.OK_STATUS; - } - }; - fUpdateJob.schedule(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResizableWizardDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResizableWizardDialog.java deleted file mode 100644 index 2025039f5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResizableWizardDialog.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; - -public class ResizableWizardDialog extends WizardDialog { - /** - * Creates a new resizable wizard dialog. - */ - public ResizableWizardDialog(Shell parent, IWizard wizard) { - super(parent, wizard); - setShellStyle(getShellStyle() | SWT.RESIZE); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java deleted file mode 100644 index 20e229e79..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.compare.CompareUI; -import org.eclipse.compare.IEncodedStreamContentAccessor; -import org.eclipse.compare.IStreamContentAccessor; -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; -import org.eclipse.core.internal.dtree.IComparator; -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; - -/** - * A class for comparing ICVSRemoteResource objects - */ -public class ResourceEditionNode implements IStructureComparator, ITypedElement, IEncodedStreamContentAccessor { - private ICVSRemoteResource resource; - private ResourceEditionNode[] children; - - /** - * Creates a new ResourceEditionNode on the given resource edition. - */ - public ResourceEditionNode(ICVSRemoteResource resourceEdition) { - this.resource = resourceEdition; - } - - /** - * Returns true if both resources names are identical. - * The content is not considered. - * @see IComparator#equals - */ - public boolean equals(Object other) { - if (other instanceof ITypedElement) { - String otherName = ((ITypedElement)other).getName(); - return getName().equals(otherName); - } - return super.equals(other); - } - - /** - * Enumerate children of this node (if any). - */ - public Object[] getChildren() { - if (children == null) { - children = new ResourceEditionNode[0]; - if (resource != null) { - try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSRemoteResource[] members = resource.members(monitor); - children = new ResourceEditionNode[members.length]; - for (int i = 0; i < members.length; i++) { - children[i] = new ResourceEditionNode(members[i]); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InterruptedException e) { - // operation canceled - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (t instanceof TeamException) { - CVSUIPlugin.log(((TeamException) t)); - } - } - } - } - return children; - } - - /** - * @see IStreamContentAccessor#getContents() - */ - public InputStream getContents() throws CoreException { - IStorage storage = getStorage(); - if (storage != null) { - return storage.getContents(); - } - return new ByteArrayInputStream(new byte[0]); - } - - public Image getImage() { - return CompareUI.getImage(resource); - } - - /** - * Returns the name of this node. - */ - public String getName() { - return resource == null ? "" : resource.getName(); //$NON-NLS-1$ - } - - public ICVSRemoteResource getRemoteResource() { - return resource; - } - - /** - * Returns the comparison type for this node. - */ - public String getType() { - if (resource == null) { - return UNKNOWN_TYPE; - } - if (resource.isContainer()) { - return FOLDER_TYPE; - } - String name = resource.getName(); - name = name.substring(name.lastIndexOf('.') + 1); - return name.length() == 0 ? UNKNOWN_TYPE : name; - } - - /** - * @see IComparator#equals - */ - public int hashCode() { - return getName().hashCode(); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() throws CoreException { - // Use the local file encoding if there is one - IResource local = resource.getIResource(); - if (local != null && local.getType() == IResource.FILE) { - return ((IFile)local).getCharset(); - } - // See if the remote file has an encoding - IStorage storage = getStorage(); - if (storage instanceof IEncodedStorage) { - String charset = ((IEncodedStorage)storage).getCharset(); - if (charset != null) { - return charset; - } - } - return null; - } - - private IStorage getStorage() throws TeamException { - if (resource == null) { - return null; - } - final IStorage[] holder = new IStorage[1]; - try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - holder[0] = ((IResourceVariant)resource).getStorage(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InvocationTargetException e) { - throw TeamException.asTeamException(e); - } catch (InterruptedException e) { - // Shouldn't happen. Ignore - } - return holder[0]; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java deleted file mode 100644 index 35c401709..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -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.Label; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.ui.dialogs.PropertyPage; - -/** - * A property page which displays the CVS-specific properties for the - * selected resource. - */ -public class ResourcePropertiesPage extends PropertyPage { - // The resource to show properties for - IResource resource; - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - try { - IResource resource = getSelectedElement(); - if (resource != null) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (!cvsResource.isManaged()) { - createPair(composite, Policy.bind("ResourcePropertiesPage.status"), Policy.bind("ResourcePropertiesPage.notManaged")); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - boolean hasRemote = false; - if(cvsResource.isFolder()) { - hasRemote = ((ICVSFolder)cvsResource).isCVSFolder(); - } else { - ResourceSyncInfo info = cvsResource.getSyncInfo(); - if(info!=null && !info.isAdded()) { - hasRemote = true; - } - } - createPair(composite, Policy.bind("ResourcePropertiesPage.status"), hasRemote ? Policy.bind("ResourcePropertiesPage.versioned") : Policy.bind("ResourcePropertiesPage.notVersioned")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - } catch (TeamException e) { - createPair(composite, Policy.bind("ResourcePropertiesPage.error"), e.getMessage()); //$NON-NLS-1$ - } - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Creates a key-value property pair in the given parent. - * - * @param parent the parent for the labels - * @param left the string for the left label - * @param right the string for the right label - */ - protected void createPair(Composite parent, String left, String right) { - Label label = new Label(parent, SWT.NONE); - label.setText(left); - - label = new Label(parent, SWT.NONE); - label.setText(right); - label.setToolTipText(right); - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - /** - * Returns the element selected when the properties was run - * - * @return the selected element - */ - protected IResource getSelectedElement() { - // get the resource that is the source of this property page - IResource resource = null; - IAdaptable element = getElement(); - if (element instanceof IResource) { - resource = (IResource)element; - } else { - Object adapter = element.getAdapter(IResource.class); - if (adapter instanceof IResource) { - resource = (IResource)adapter; - } - } - return resource; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/SimpleContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/SimpleContentProvider.java deleted file mode 100644 index 6fa9117f8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/SimpleContentProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.jface.viewers.*; - -/** - * A default content provider to prevent subclasses from - * having to implement methods they don't need. - */ -public class SimpleContentProvider implements IStructuredContentProvider { - - /** - * SimpleContentProvider constructor. - */ - public SimpleContentProvider() { - super(); - } - - /* - * @see SimpleContentProvider#dispose() - */ - public void dispose() { - } - - /* - * @see SimpleContentProvider#getElements() - */ - public Object[] getElements(Object element) { - return new Object[0]; - } - - /* - * @see SimpleContentProvider#inputChanged() - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagetLocationSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagetLocationSelectionDialog.java deleted file mode 100644 index 5e3317424..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagetLocationSelectionDialog.java +++ /dev/null @@ -1,438 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.io.File; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.SelectionDialog; - -/** - * Select the target location that will be the parent of the selected projects. - * The behavior of the dialog differs between 1 project and multiple projects. - * For one project, the location specified is the location of the project and - * the project name can be modified. For multiple projects, it is the parent - * location which is specified. - */ -public class TagetLocationSelectionDialog extends SelectionDialog { - - // widgets - private Text projectNameField; - private Text locationPathField; - private Label locationLabel; - private Label statusMessageLabel; - private Button browseButton; - - // state - private boolean useDefaults = true; - private IProject[] targetProjects; - private String newProjectName; - private String targetLocation; - - // constants - private static final int SIZING_TEXT_FIELD_WIDTH = 250; - - /** - * Constructor. - * @param parentShell - */ - public TagetLocationSelectionDialog(Shell parentShell, String title, IProject targetProject) { - this(parentShell, title, new IProject[] { targetProject }); - } - - /** - * Constructor. - * @param parentShell - */ - public TagetLocationSelectionDialog(Shell parentShell, String title, IProject[] targetProjects) { - super(parentShell); - setTitle(title); - this.targetProjects = targetProjects; - if (targetProjects.length == 1) newProjectName = targetProjects[0].getName(); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent) { - // page group - Composite composite = (Composite) super.createDialogArea(parent); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - if (isSingleCheckout()) - createProjectNameGroup(composite); - createProjectLocationGroup(composite); - - //Add in a label for status messages if required - statusMessageLabel = new Label(composite, SWT.NONE); - statusMessageLabel.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Creates the project name specification controls. - * - * @param parent the parent composite - */ - private void createProjectNameGroup(Composite parent) { - // project specification group - Composite projectGroup = new Composite(parent,SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - projectGroup.setLayout(layout); - projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // new project label - Label projectLabel = new Label(projectGroup,SWT.NONE); - projectLabel.setText(Policy.bind("TargetLocationSelectionDialog.projectNameLabel")); //$NON-NLS-1$ - - // new project name entry field - projectNameField = new Text(projectGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - projectNameField.setLayoutData(data); - - // Set the initial value first before listener - // to avoid handling an event during the creation. - projectNameField.setText(getNewProjectName()); - projectNameField.selectAll(); - - createNameListener(); - - } - - /** - * Create the listener that is used to validate the entries for the receiver - */ - private void createNameListener() { - - Listener listener = new Listener() { - public void handleEvent(Event event) { - newProjectName = projectNameField.getText(); - setLocationForSelection(false); - applyValidationResult(checkValid()); - } - }; - - this.projectNameField.addListener(SWT.Modify, listener); - } - - /** - * Set the location to the default location if we are set to useDefaults. - */ - private void setLocationForSelection(boolean changed) { - if (useDefaults) { - IPath defaultPath = null; - if (isSingleCheckout()) { - try { - defaultPath = getSingleProject().getDescription().getLocation(); - } catch (CoreException e) { - // ignore - } - if (defaultPath == null) { - defaultPath = Platform.getLocation().append(getSingleProject().getName()); - } - } else { - defaultPath = Platform.getLocation(); - } - locationPathField.setText(defaultPath.toOSString()); - targetLocation = null; - } else if (changed) { - IPath location = null; - try { - location = this.targetProjects[0].getDescription().getLocation(); - } catch (CoreException e) { - // ignore the exception - } - if (location == null) { - targetLocation = null; - locationPathField.setText(""); //$NON-NLS-1$ - } else { - if (isSingleCheckout()) { - targetLocation = location.toOSString(); - } else { - targetLocation = location.removeLastSegments(1).toOSString(); - } - locationPathField.setText(targetLocation); - } - } - } - - /** - * Creates the project location specification controls. - * - * @param parent the parent composite - */ - private final void createProjectLocationGroup(Composite parent) { - - // project specification group - Composite projectGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - projectGroup.setLayout(layout); - projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - final Button useDefaultsButton = - new Button(projectGroup, SWT.CHECK | SWT.RIGHT); - useDefaultsButton.setText(Policy.bind("TargetLocationSelectionDialog.useDefaultLabel")); //$NON-NLS-1$ - useDefaultsButton.setSelection(this.useDefaults); - GridData buttonData = new GridData(); - buttonData.horizontalSpan = 3; - useDefaultsButton.setLayoutData(buttonData); - - createUserSpecifiedProjectLocationGroup(projectGroup, !this.useDefaults); - - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - useDefaults = useDefaultsButton.getSelection(); - browseButton.setEnabled(!useDefaults); - locationPathField.setEnabled(!useDefaults); - locationLabel.setEnabled(!useDefaults); - setLocationForSelection(true); - } - }; - useDefaultsButton.addSelectionListener(listener); - } - - /** - * Creates the project location specification controls. - * - * @return the parent of the widgets created - * @param projectGroup the parent composite - * @param enabled - sets the initial enabled state of the widgets - */ - private Composite createUserSpecifiedProjectLocationGroup(Composite projectGroup, boolean enabled) { - - // location label - locationLabel = new Label(projectGroup, SWT.NONE); - if (isSingleCheckout()) { - locationLabel.setText(Policy.bind("TargetLocationSelectionDialog.locationLabel")); //$NON-NLS-1$ - } else { - locationLabel.setText(Policy.bind("TargetLocationSelectionDialog.parentDirectoryLabel")); //$NON-NLS-1$ - } - locationLabel.setEnabled(enabled); - - // project location entry field - locationPathField = new Text(projectGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - locationPathField.setLayoutData(data); - locationPathField.setEnabled(enabled); - - // browse button - this.browseButton = new Button(projectGroup, SWT.PUSH); - this.browseButton.setText(Policy.bind("TargetLocationSelectionDialog.browseLabel")); //$NON-NLS-1$ - this.browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - handleLocationBrowseButtonPressed(); - } - }); - this.browseButton.setEnabled(enabled); - setButtonLayoutData(this.browseButton); - - // Set the initial value first before listener - // to avoid handling an event during the creation. - setLocationForSelection(true); - createLocationListener(); - return projectGroup; - - } - - /** - * Open an appropriate directory browser - */ - private void handleLocationBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell()); - if (isSingleCheckout()) { - dialog.setMessage(Policy.bind("TargetLocationSelectionDialog.messageForSingle", newProjectName)); //$NON-NLS-1$ - } else { - dialog.setMessage(Policy.bind("TargetLocationSelectionDialog.messageForMulti", new Integer(targetProjects.length).toString())); //$NON-NLS-1$ - } - - String dirName = locationPathField.getText(); - if (!dirName.equals("")) {//$NON-NLS-1$ - File path = new File(dirName); - if (path.exists()) - dialog.setFilterPath(dirName); - } - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - if (targetProjects.length == 1) { - locationPathField.setText(new Path(selectedDirectory).append(newProjectName).toOSString()); - } else { - locationPathField.setText(new Path(selectedDirectory).toOSString()); - } - } - targetLocation = locationPathField.getText(); - } - - /** - * Method isSingleCheckout. - * @return boolean - */ - private boolean isSingleCheckout() { - return targetProjects.length == 1; - } - - private IProject getSingleProject() { - if (newProjectName == null || newProjectName.length() == 0 || targetProjects[0].getName().equals(newProjectName)) - return targetProjects[0]; - else - return ResourcesPlugin.getWorkspace().getRoot().getProject(newProjectName); - } - - /** - * Create the listener that is used to validate the location entered by the iser - */ - private void createLocationListener() { - - Listener listener = new Listener() { - public void handleEvent(Event event) { - applyValidationResult(checkValid()); - } - }; - - this.locationPathField.addListener(SWT.Modify, listener); - } - - /** - * Check the message. If it is null then continue otherwise inform the user via the - * status value and disable the OK. - * @param message - the error message to show if it is not null. - */ - private void applyValidationResult(String errorMsg) { - - if (errorMsg == null) { - statusMessageLabel.setText("");//$NON-NLS-1$ - getOkButton().setEnabled(true); - } else { - statusMessageLabel.setForeground( - JFaceColors.getErrorText( - statusMessageLabel.getDisplay())); - statusMessageLabel.setText(errorMsg); - getOkButton().setEnabled(false); - } - } - /** - * Check whether the entries are valid. If so return null. Otherwise - * return a string that indicates the problem. - */ - private String checkValid() { - if (isSingleCheckout()) { - String valid = checkValidName(); - if (valid != null) - return valid; - } - return checkValidLocation(); - } - /** - * Check if the entry in the widget location is valid. If it is valid return null. Otherwise - * return a string that indicates the problem. - */ - private String checkValidLocation() { - - if (useDefaults) { - targetLocation = null; - return null; - } else { - targetLocation = locationPathField.getText(); - if (targetLocation.equals("")) {//$NON-NLS-1$ - return(Policy.bind("TagetLocationSelectionDialog.locationEmpty")); //$NON-NLS-1$ - } - else{ - IPath path = new Path("");//$NON-NLS-1$ - if (!path.isValidPath(targetLocation)) { - return Policy.bind("TagetLocationSelectionDialog.invalidLocation"); //$NON-NLS-1$ - } - } - - if (isSingleCheckout()) { - IStatus locationStatus = - ResourcesPlugin.getWorkspace().validateProjectLocation( - getSingleProject(), - new Path(targetLocation)); - - if (!locationStatus.isOK()) - return locationStatus.getMessage(); - } else { - for (int i = 0; i < targetProjects.length; i++) { - ResourcesPlugin.getWorkspace().validateProjectLocation( - targetProjects[i], - new Path(targetLocation).append(targetProjects[i].getName())); - } - } - - return null; - } - } - /** - * Check if the entries in the widget are valid. If they are return null otherwise - * return a string that indicates the problem. - */ - private String checkValidName() { - - newProjectName = this.projectNameField.getText(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus nameStatus = workspace.validateName(newProjectName, IResource.PROJECT); - if (!nameStatus.isOK()) - return nameStatus.getMessage(); -// IProject newProject = workspace.getRoot().getProject(newProjectName); -// if (newProject.exists()) { -// return Policy.bind("TagetLocationSelectionDialog.alreadyExists", newProjectName); //$NON-NLS-1$ -// } - - return null; - } - - /** - * @return String - */ - public String getNewProjectName() { - return newProjectName; - } - - /** - * @return String - */ - public String getTargetLocation() { - return targetLocation; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TextViewerAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TextViewerAction.java deleted file mode 100644 index f2491e590..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TextViewerAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.ui.texteditor.IUpdate; - -public class TextViewerAction extends Action implements IUpdate { - private int operationCode = -1; - private ITextOperationTarget operationTarget; - - public TextViewerAction(ITextViewer viewer, int operationCode) { - this.operationCode = operationCode; - operationTarget = viewer.getTextOperationTarget(); - update(); - } - public void update() { - boolean wasEnabled = isEnabled(); - boolean isEnabled = (operationTarget != null && operationTarget.canDoOperation(operationCode)); - setEnabled(isEnabled); - if (wasEnabled != isEnabled) { - firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE); - } - } - public void run() { - if (operationCode != -1 && operationTarget != null) { - operationTarget.doOperation(operationCode); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java deleted file mode 100644 index 4b7d1f0ce..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java +++ /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 - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.operation.ModalContext; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -public class TimeoutProgressMonitorDialog extends ProgressMonitorDialog { - // the timeout - private int timeout; - // the number of currently running runnables. - private int runningRunnables = 0; - - /** - * Creates a progress monitor dialog under the given shell. - * The dialog has a standard title and no image. - * open is non-blocking. - * - * @param parent the parent shell - * @param timeout the delay after which the dialog will be opened during a run() - */ - public TimeoutProgressMonitorDialog(Shell parent, int timeout) { - super(parent); - this.timeout = timeout; - } - - /* (non-Javadoc) - * Method declared on ITeamRunnableContext. - * Runs the given IRunnableWithProgress with the progress monitor for this - * progress dialog. The dialog is opened before it is run, and closed after it completes. - */ - public void run(final boolean fork, boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { - setCancelable(cancelable); - create(); // create the Shell but don't open it yet - try { - runningRunnables++; - final Display display = getShell().getDisplay(); - display.timerExec(timeout, new Runnable() { - public void run() { - Shell shell = getShell(); - if (shell != null && ! shell.isDisposed()) open(); - } - }); - - final Exception[] holder = new Exception[1]; - BusyIndicator.showWhile(display, new Runnable() { - public void run() { - try { - ModalContext.run(runnable, fork, getProgressMonitor(), display); - } catch (InvocationTargetException ite) { - holder[0] = ite; - } catch (InterruptedException ie) { - holder[0] = ie; - } - } - }); - if (holder[0] != null) { - if (holder[0] instanceof InvocationTargetException) { - throw (InvocationTargetException) holder[0]; - } else if (holder[0] instanceof InterruptedException) { - throw (InterruptedException) holder[0]; - } - } - } finally { - runningRunnables--; - close(); - } - } - - public boolean close() { - if (runningRunnables <= 0) return super.close(); - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java deleted file mode 100644 index 6aad93aed..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.ITeamUIImages; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * A dialog for prompting for a username and password - */ -public class UserValidationDialog extends Dialog { - // widgets - protected Text usernameField; - protected Text passwordField; - protected Button allowCachingButton; - - protected String domain; - protected String defaultUsername; - protected String password = null; - protected boolean allowCaching = false; - protected Image keyLockImage; - - // whether or not the username can be changed - protected boolean isUsernameMutable = true; - protected boolean showAllowCachingButton = true; - protected String username = null; - protected String message = null; - - /** - * Creates a new UserValidationDialog. - * - * @param parentShell the parent shell - * @param location the location - * @param defaultName the default user name - * @param message a mesage to display to the user - */ - public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) { - super(parentShell); - this.defaultUsername = defaultName; - this.domain = location; - this.message = message; - } - /** - * @see Window#configureShell - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Policy.bind("UserValidationDialog.required")); //$NON-NLS-1$ - // set F1 help - WorkbenchHelp.setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG); - } - /** - * @see Window#create - */ - public void create() { - super.create(); - // add some default values - usernameField.setText(defaultUsername); - - if (isUsernameMutable) { - // give focus to username field - usernameField.selectAll(); - usernameField.setFocus(); - } else { - usernameField.setEditable(false); - passwordField.setFocus(); - } - } - - /** - * @see Dialog#createDialogArea - */ - protected Control createDialogArea(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - - top.setLayout(layout); - top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite imageComposite = new Composite(top, SWT.NONE); - layout = new GridLayout(); - imageComposite.setLayout(layout); - imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - - Composite main = new Composite(top, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label imageLabel = new Label(imageComposite, SWT.NONE); - keyLockImage = TeamImages.getImageDescriptor(ITeamUIImages.IMG_KEY_LOCK).createImage(); - imageLabel.setImage(keyLockImage); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - imageLabel.setLayoutData(data); - - if (message != null) { - Label messageLabel = new Label(main, SWT.WRAP); - messageLabel.setText(message); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - data.widthHint = 300; - messageLabel.setLayoutData(data); - } - if (domain != null) { - Label d = new Label(main, SWT.WRAP); - d.setText(Policy.bind("UserValidationDialog.5")); //$NON-NLS-1$ - data = new GridData(); - d.setLayoutData(data); - Label label = new Label(main, SWT.WRAP); - if (isUsernameMutable) { - label.setText(Policy.bind("UserValidationDialog.labelUser", domain)); //$NON-NLS-1$ - } else { - label.setText(Policy.bind("UserValidationDialog.labelPassword", new Object[]{defaultUsername, domain})); //$NON-NLS-1$ - } - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = 300; - label.setLayoutData(data); - } - createUsernameFields(main); - createPasswordFields(main); - - if(domain != null && showAllowCachingButton) { - allowCachingButton = new Button(main, SWT.CHECK); - allowCachingButton.setText(Policy.bind("UserValidationDialog.6")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - allowCachingButton.setLayoutData(data); - allowCachingButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - allowCaching = allowCachingButton.getSelection(); - } - }); - Composite warningComposite = new Composite(main, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginHeight = 0; - warningComposite.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - warningComposite.setLayoutData(data); - Label warningLabel = new Label(warningComposite, SWT.NONE); - warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING)); - warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); - Label warningText = new Label(warningComposite, SWT.WRAP); - warningText.setText(Policy.bind("UserValidationDialog.7")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 300; - warningText.setLayoutData(data); - } - - Dialog.applyDialogFont(parent); - - return main; - } - /** - * Create a spacer. - */ - protected void createSpacer(Composite top, int columnSpan, int vertSpan) { - Label l = new Label(top, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = columnSpan; - data.verticalSpan = vertSpan; - l.setLayoutData(data); - } - - /** - * Creates the three widgets that represent the password entry area. - * - * @param parent the parent of the widgets - */ - protected void createPasswordFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Policy.bind("UserValidationDialog.password")); //$NON-NLS-1$ - - passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - passwordField.setLayoutData(data); - } - /** - * Creates the three widgets that represent the user name entry area. - * - * @param parent the parent of the widgets - */ - protected void createUsernameFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Policy.bind("UserValidationDialog.user")); //$NON-NLS-1$ - - usernameField = new Text(parent, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - usernameField.setLayoutData(data); - } - - /** - * Returns the password entered by the user, or null - * if the user canceled. - * - * @return the entered password - */ - public String getPassword() { - return password; - } - - /** - * Returns the username entered by the user, or null - * if the user canceled. - * - * @return the entered username - */ - public String getUsername() { - return username; - } - - /** - * Returns true if the save password checkbox was selected. - * @return true if the save password checkbox was selected and false - * otherwise. - */ - public boolean getAllowCaching() { - return allowCaching; - } - - /** - * Notifies that the ok button of this dialog has been pressed. - *

              - * The default implementation of this framework method sets - * this dialog's return code to Window.OK - * and closes the dialog. Subclasses may override. - *

              - */ - protected void okPressed() { - password = passwordField.getText(); - username = usernameField.getText(); - - super.okPressed(); - } - /** - * Sets whether or not the username field should be mutable. - * This method must be called before create(), otherwise it - * will be ignored. - * - * @param value whether the username is mutable - */ - public void setUsernameMutable(boolean value) { - isUsernameMutable = value; - } - - public void setShowAllowCachingButton(boolean value) { - showAllowCachingButton = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#close() - */ - public boolean close() { - if(keyLockImage != null) { - keyLockImage.dispose(); - } - return super.close(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/VersionCollator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/VersionCollator.java deleted file mode 100644 index 475fa5d72..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/VersionCollator.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Collator to compare two CVS revisions - */ -public class VersionCollator { - public int compare(String revision1, String revision2) { - if (revision1 == null && revision2 == null) return 0; - if (revision1 == null) return -1; - if (revision2 == null) return 1; - int[] revision1Segments = getIntSegments(revision1); - int[] revision2Segments = getIntSegments(revision2); - for (int i = 0; i < revision1Segments.length && i < revision2Segments.length; i++) { - int i1 = revision1Segments[i]; - int i2 = revision2Segments[i]; - if (i1 != i2) { - return i1 > i2 ? 1 : -1; - } - } - if (revision1Segments.length != revision2Segments.length) { - return revision1Segments.length > revision2Segments.length ? 1 : -1; - } - return 0; - } - - int[] getIntSegments(String string) { - int size = string.length(); - if (size == 0) return new int[0]; - StringBuffer buffer = new StringBuffer(); - List list = new ArrayList(); - for (int i = 0; i < size; i++) { - char ch = string.charAt(i); - if (ch == '.') { - list.add(new Integer(buffer.toString())); - buffer = new StringBuffer(); - } else { - buffer.append(ch); - } - } - list.add(new Integer(buffer.toString())); - int[] result = new int[list.size()]; - Iterator it = list.iterator(); - for (int i = 0; i < result.length; i++) { - result[i] = ((Integer)it.next()).intValue(); - } - return result; - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java deleted file mode 100644 index 4e44d34ab..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.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.team.internal.ccvs.ui; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; - -/** - * This page contains preferences related to the cvs watch/edit commands - */ -public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { - - private RadioGroupFieldEditor promptEditor; - private RadioGroupFieldEditor actionEditor; - private IPreferenceStore store; - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId() - */ - protected String getPageHelpContextId() { - return IHelpContextIds.WATCH_EDIT_PREFERENCE_PAGE; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageDescription() - */ - protected String getPageDescription() { - return Policy.bind("WatchEditPreferencePage.description"); //$NON-NLS-1$; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - protected void createFieldEditors() { - addField(new BooleanFieldEditor( - ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, - Policy.bind("WatchEditPreferencePage.checkoutReadOnly"), //$NON-NLS-1$ - BooleanFieldEditor.DEFAULT, - getFieldEditorParent())); - - actionEditor = new RadioGroupFieldEditor( - ICVSUIConstants.PREF_EDIT_ACTION, - Policy.bind("WatchEditPreferencePage.validateEditSaveAction"), //$NON-NLS-1$ - 1, - new String[][] {{Policy.bind("WatchEditPreferencePage.edit"), ICVSUIConstants.PREF_EDIT_PROMPT_EDIT}, //$NON-NLS-1$ - {Policy.bind("WatchEditPreferencePage.highjack"), ICVSUIConstants.PREF_EDIT_PROMPT_HIGHJACK}, //$NON-NLS-1$ - }, //$NON-NLS-1$ //$NON-NLS-2$ - getFieldEditorParent(), true); - addField(actionEditor); - - - promptEditor = new RadioGroupFieldEditor( - ICVSUIConstants.PREF_EDIT_PROMPT, - Policy.bind("WatchEditPreferencePage.editPrompt"), //$NON-NLS-1$ - 1, - new String[][] {{Policy.bind("WatchEditPreferencePage.alwaysPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS}, //$NON-NLS-1$ - {Policy.bind("WatchEditPreferencePage.onlyPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS}, //$NON-NLS-1$ - {Policy.bind("WatchEditPreferencePage.neverPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_NEVER}, //$NON-NLS-1$ - }, //$NON-NLS-1$ //$NON-NLS-2$ - getFieldEditorParent(), true); - store = getCVSPreferenceStore(); - addField(promptEditor); - } - - private boolean isEditEnabled() { - return store.getString(ICVSUIConstants.PREF_EDIT_ACTION).equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#pushPreferences() - */ - protected void pushPreferences() { - store = getCVSPreferenceStore(); - Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences(); - target.setValue( - CVSProviderPlugin.READ_ONLY, - store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getSource() == actionEditor) { - promptEditor.setEnabled( - event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT), - getFieldEditorParent()); - } - super.propertyChange(event); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize() - */ - protected void initialize() { - super.initialize(); - promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java deleted file mode 100644 index b97a9bf55..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.text.Collator; -import java.util.Arrays; -import java.util.Comparator; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.RadioGroupFieldEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.team.internal.ui.preferences.ComboFieldEditor; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IPerspectiveRegistry; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; - -public class WorkInProgressPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - private static class PerspectiveDescriptorComparator implements Comparator { - /* - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(Object o1, Object o2) { - if (o1 instanceof IPerspectiveDescriptor && o2 instanceof IPerspectiveDescriptor) { - String id1= ((IPerspectiveDescriptor)o1).getLabel(); - String id2= ((IPerspectiveDescriptor)o2).getLabel(); - return Collator.getInstance().compare(id1, id2); - } - return 0; - } - } - - private RadioGroupFieldEditor synchronizePerspectiveSwitch; - - public WorkInProgressPreferencePage() { - super(GRID); - setTitle(Policy.bind("WorkInProgressPreferencePage.0")); //$NON-NLS-1$ - setDescription(Policy.bind("WorkInProgressPreferencePage.1")); //$NON-NLS-1$ - setPreferenceStore(CVSUIPlugin.getPlugin().getPreferenceStore()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - public void createFieldEditors() { - - synchronizePerspectiveSwitch= new RadioGroupFieldEditor( - ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS, - Policy.bind("WorkInProgressPreferencePage.7"), //$NON-NLS-1$ - 3, - new String[][] { - {Policy.bind("WorkInProgressPreferencePage.8"), MessageDialogWithToggle.ALWAYS}, //$NON-NLS-1$ - {Policy.bind("WorkInProgressPreferencePage.2"), MessageDialogWithToggle.NEVER}, //$NON-NLS-1$ - {Policy.bind("WorkInProgressPreferencePage.3"), MessageDialogWithToggle.PROMPT} //$NON-NLS-1$ - }, - getFieldEditorParent(), true); - addField(synchronizePerspectiveSwitch); - - final Group perspectiveGroup = createGroup( - getFieldEditorParent(), - Policy.bind("WorkInProgressPreferencePage.4")); //$NON-NLS-1$ - - handleDeletedPerspectives(); - final String[][] perspectiveNamesAndIds = getPerspectiveNamesAndIds(); - - ComboFieldEditor comboEditor= new ComboFieldEditor( - ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, - Policy.bind("WorkInProgressPreferencePage.5"), //$NON-NLS-1$ - perspectiveNamesAndIds, - perspectiveGroup); - addField(comboEditor); - - Dialog.applyDialogFont(getFieldEditorParent()); - updateLayout(perspectiveGroup); - getFieldEditorParent().layout(true); - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - private Group createGroup(Composite parent, String title) { - Group display = new Group(parent, SWT.NONE); - updateLayout(display); - GridData data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - display.setLayoutData(data); - display.setText(title); - return display; - } - - private void updateLayout(Composite composite) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 5; - layout.marginHeight =5; - layout.horizontalSpacing = 5; - layout.verticalSpacing = 5; - composite.setLayout(layout); - } - - private static void handleDeletedPerspectives() { - final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); - final String id= store.getString(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS); - if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) { - store.putValue(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, ICVSUIConstants.OPTION_NO_PERSPECTIVE); - } - } - - private String[][] getPerspectiveNamesAndIds() { - - final IPerspectiveRegistry registry= PlatformUI.getWorkbench().getPerspectiveRegistry(); - final IPerspectiveDescriptor[] perspectiveDescriptors= registry.getPerspectives(); - - Arrays.sort(perspectiveDescriptors, new PerspectiveDescriptorComparator()); - - final String[][] table = new String[perspectiveDescriptors.length + 1][2]; - table[0][0] = Policy.bind("WorkInProgressPreferencePage.6"); //$NON-NLS-1$ - table[0][1] = ICVSUIConstants.OPTION_NO_PERSPECTIVE; - for (int i = 0; i < perspectiveDescriptors.length; i++) { - table[i + 1][0] = perspectiveDescriptors[i].getLabel(); - table[i + 1][1] = perspectiveDescriptors[i].getId(); - } - return table; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java deleted file mode 100644 index ba4c47376..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Atsuhiko Yamanaka, JCraft,Inc. - implementation of promptForKeyboradInteractive - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jface.dialogs.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ui.Utils; - -/** - * An authenticator that prompts the user for authentication info, - * and stores the results in the Platform's authentication keyring. - */ -public class WorkbenchUserAuthenticator implements IUserAuthenticator { - public static boolean USE_ALTERNATE_PROMPTER = false; - - /** - * WorkbenchUserAuthenticator constructor. - */ - public WorkbenchUserAuthenticator() { - super(); - // Initialize USE_ALTERNATE_PROMPTER - IIgnoreInfo[] ignores = Team.getAllIgnores(); - boolean found = false; - for (int i = 0; i < ignores.length; i++) { - if (ignores[i].getPattern().equals("*.notes")) { //$NON-NLS-1$ - found = true; - } - } - if (!found) return; - IFileTypeInfo[] types = Team.getAllTypes(); - for (int i = 0; i < types.length; i++) { - if (types[i].getExtension().equals("notes")) { //$NON-NLS-1$ - USE_ALTERNATE_PROMPTER = true; - return; - } - } - USE_ALTERNATE_PROMPTER = false; - } - /** - * @see IUserAuthenticator#authenticateUser - */ - public void promptForUserInfo(final ICVSRepositoryLocation location, final IUserInfo userinfo, final String message) throws CVSException { - if (!userinfo.isUsernameMutable() && USE_ALTERNATE_PROMPTER) { - alternatePromptForUserInfo(userinfo); - return; - } - // ask the user for a password - final String[] result = new String[2]; - Display display = Display.getCurrent(); - final boolean allowCaching[] = {false}; - if (display != null) { - allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result); - } else { - // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result); - } - }); - } - - if (result[0] == null) { - throw new OperationCanceledException(Policy.bind("WorkbenchUserAuthenticator.cancelled")); //$NON-NLS-1$ - } - - if (userinfo.isUsernameMutable()) { - userinfo.setUsername(result[0]); - - } - userinfo.setPassword(result[1]); - - if(location != null) { - if (userinfo.isUsernameMutable()) { - location.setUsername(result[0]); - } - location.setPassword(result[1]); - location.setAllowCaching(allowCaching[0]); - } - } - - /** - * Asks the user to enter a password. Places the - * results in the supplied string[]. result[0] must - * contain the username, result[1] must contain the password. - * If the user canceled, both values must be zero. - * - * @param location the location to obtain the password for - * @param username the username - * @param message a message to display to the user - * @param userMutable whether the user can be changed in the dialog - * @param result a String array of length two in which to put the result - */ - private boolean promptForPassword(final ICVSRepositoryLocation location, final String username, final String message, final boolean userMutable, final String[] result) { - Shell shell = Utils.findShell(); - if(shell == null) { - return false; - } - String domain = location == null ? null : location.getLocation(); - UserValidationDialog dialog = new UserValidationDialog(shell, domain, (username==null)?"":username, message);//$NON-NLS-1$ - dialog.setUsernameMutable(userMutable); - dialog.open(); - result[0] = dialog.getUsername(); - result[1] = dialog.getPassword(); - return dialog.getAllowCaching(); - } - - /** - * Asks the user to enter values. - * - * @param location the location to obtain the password for - * @param destication the location - * @param name the name - * @param instruction the instruction - * @param prompt the titles for textfields - * @param echo '*' should be used or not - * @param result the entered values, or null if user canceled. - */ - public String[] promptForKeyboradInteractive(final ICVSRepositoryLocation location, - final String destination, - final String name, - final String instruction, - final String[] prompt, - final boolean[] echo) throws CVSException { - final String[][] result = new String[1][]; - Display display = Display.getCurrent(); - if (display != null) { - result[0]=_promptForUserInteractive(location, destination, name, instruction, prompt, echo); - } - else { - // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - result[0]=_promptForUserInteractive(location, destination, name, instruction, prompt, echo); - } - }); - } - return result[0]; - } - - private String[] _promptForUserInteractive(final ICVSRepositoryLocation location, - final String destination, - final String name, - final String instruction, - final String[] prompt, - final boolean[] echo) { - - Shell shell = Utils.findShell(); - if(shell == null) return new String[0]; - String domain = location == null ? null : location.getLocation(); - KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(shell, - domain, - destination, - name, - instruction, - prompt, - echo); - dialog.open(); - return dialog.getResult(); - } - - /** - * Special alternate prompting. Returns the password. Username must be fixed. - */ - private String alternatePromptForPassword(final String username) { - Shell shell = Utils.findShell(); - AlternateUserValidationDialog dialog = new AlternateUserValidationDialog(shell, (username == null) ? "" : username); //$NON-NLS-1$ - dialog.setUsername(username); - int result = dialog.open(); - if (result == Dialog.CANCEL) return null; - return dialog.getPassword(); - } - - /** - * Special alternate prompting. - */ - public void alternatePromptForUserInfo(final IUserInfo userinfo) { - // ask the user for a password - final String[] result = new String[1]; - Display display = Display.getCurrent(); - if (display != null) { - result[0] = alternatePromptForPassword(userinfo.getUsername()); - } else { - // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - result[0] = alternatePromptForPassword(userinfo.getUsername()); - } - }); - } - - if (result[0] == null) { - throw new OperationCanceledException(Policy.bind("WorkbenchUserAuthenticator.The_operation_was_canceled_by_the_user_1")); //$NON-NLS-1$ - } - - userinfo.setPassword(result[0]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#prompt(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, int, java.lang.String, java.lang.String, int[], int) - */ - public int prompt(ICVSRepositoryLocation location, final int promptType, final String title, final String message, final int[] promptResponses, final int defaultResponse) { - final Display display = CVSUIPlugin.getStandardDisplay(); - final int[] retval = new int[1]; - final String[] buttons = new String[promptResponses.length]; - for (int i = 0; i < promptResponses.length; i++) { - int prompt = promptResponses[i]; - switch(prompt) { - case IUserAuthenticator.OK_ID: buttons[i] = IDialogConstants.OK_LABEL; break; - case IUserAuthenticator.CANCEL_ID: buttons[i] = IDialogConstants.CANCEL_LABEL; break; - case IUserAuthenticator.NO_ID: buttons[i] = IDialogConstants.NO_LABEL; break; - case IUserAuthenticator.YES_ID: buttons[i] = IDialogConstants.YES_LABEL; break; - } - } - - display.syncExec(new Runnable() { - public void run() { - final MessageDialog dialog = new MessageDialog( - new Shell(display), - title, - null /* title image */, - message, - promptType, - buttons, - 1 - ); - retval[0] = dialog.open(); - } - }); - return retval[0]; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java deleted file mode 100644 index 94c989180..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.dialogs.DialogArea; -import org.eclipse.ui.*; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class WorkingSetSelectionArea extends DialogArea { - - private Button noWorkingSetButton; - private Button workingSetButton; - private Combo mruList; - private Button selectButton; - private IWorkingSet workingSet, oldWorkingSet; - - private String noWorkingSetText; - private String workingSetText; - - private static final String USE_WORKING_SET = "UseWorkingSet"; //$NON-NLS-1$ - public static final String SELECTED_WORKING_SET = "SelectedWorkingSet"; //$NON-NLS-1$ - - /* - * Used to update the mru list box when working sets are - * renamed in the working set selection dialog. - */ - private IPropertyChangeListener workingSetChangeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - Object newValue = event.getNewValue(); - - if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && - newValue instanceof IWorkingSet) { - String newName = ((IWorkingSet) newValue).getName(); - int count = mruList.getItemCount(); - for (int i = 0; i < count; i++) { - String item = mruList.getItem(i); - IWorkingSet workingSet = (IWorkingSet) mruList.getData(item); - if (workingSet == newValue) { - boolean isTopItem = (mruList.getData(mruList.getText()) == workingSet); - mruList.remove(i); - mruList.add(newName, i); - mruList.setData(newName, workingSet); - if (isTopItem) { - mruList.setText(newName); - } - break; - } - } - } - } - }; - private final IDialogSettings settings; - private final Shell shell; - - public WorkingSetSelectionArea(Shell shell) { - this(shell, null, null, null); - } - - public WorkingSetSelectionArea(Shell shell, String noWorkingSetText, String workingSetText, IDialogSettings settings) { - this.shell = shell; - this.noWorkingSetText = noWorkingSetText; - this.workingSetText = workingSetText; - this.settings = settings; - } - - /** - * Overrides method in Dialog - * - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) - */ - public void createArea(Composite parent) { - Dialog.applyDialogFont(parent); - final Composite composite = createComposite(parent, 2, false); - initializeDialogUnits(composite); - composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.numColumns = 2; - composite.setLayout(layout); - - // Create the checkbox to enable/disable working set use - noWorkingSetButton = createRadioButton(composite, noWorkingSetText, 2); - workingSetButton = createRadioButton(composite, workingSetText, 2); - workingSetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleWorkingSetButtonSelection(); - } - }); - - boolean useWorkingSet = false; - if (settings != null) { - useWorkingSet = settings.getBoolean(USE_WORKING_SET); - } - noWorkingSetButton.setSelection(!useWorkingSet); - workingSetButton.setSelection(useWorkingSet); - - // Create the combo/button which allows working set selection - mruList = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); - GridData data = new GridData(SWT.FILL, SWT.CENTER, true, true); - data.horizontalIndent= 15; - mruList.setLayoutData(data); - - selectButton = createButton(composite, Policy.bind("WorkingSetSelectionArea.workingSetOther"), GridData.HORIZONTAL_ALIGN_FILL); //$NON-NLS-1$ - selectButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - handleWorkingSetSelection(); - } - }); - - initializeMru(); - initializeWorkingSet(); - - mruList.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleMruSelection(); - } - }); - } - - /** - * Method handleMruSelection. - */ - private void handleMruSelection() { - String selectedWorkingSet = mruList.getText(); - oldWorkingSet = workingSet; - workingSet = (IWorkingSet) mruList.getData(selectedWorkingSet); - if (settings != null) - settings.put(SELECTED_WORKING_SET, selectedWorkingSet); - handleWorkingSetChange(); - } - - /** - * Opens the working set selection dialog if the "Other..." item - * is selected in the most recently used working set list. - */ - private void handleWorkingSetSelection() { - IWorkingSetSelectionDialog dialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, false); - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSet workingSet = workingSetManager.getWorkingSet(mruList.getText()); - - if (workingSet != null) { - dialog.setSelection(new IWorkingSet[]{workingSet}); - } - // add a change listener to detect a working set name change - workingSetManager.addPropertyChangeListener(workingSetChangeListener); - if (dialog.open() == Window.OK) { - IWorkingSet[] result = dialog.getSelection(); - if (result != null && result.length > 0) { - workingSet = result[0]; - String workingSetName = workingSet.getName(); - if (mruList.indexOf(workingSetName) != -1) { - mruList.remove(workingSetName); - } - mruList.add(workingSetName, 0); - mruList.setText(workingSetName); - mruList.setData(workingSetName, workingSet); - handleMruSelection(); - } - else { - workingSet = null; - } - // remove deleted working sets from the mru list box - String[] mruNames = mruList.getItems(); - for (int i = 0; i < mruNames.length; i++) { - if (workingSetManager.getWorkingSet(mruNames[i]) == null) { - mruList.remove(mruNames[i]); - } - } - } - workingSetManager.removePropertyChangeListener(workingSetChangeListener); - } - - /** - * Sets the enabled state of the most recently used working set list - * based on the checked state of the working set check box. - */ - private void handleWorkingSetButtonSelection() { - boolean useWorkingSet = workingSetButton.getSelection(); - if (settings != null) - settings.put(USE_WORKING_SET, useWorkingSet); - mruList.setEnabled(useWorkingSet); - selectButton.setEnabled(useWorkingSet); - if (useWorkingSet && mruList.getSelectionIndex() >= 0) { - handleMruSelection(); - } else if (!useWorkingSet) { - handleDeselection(); - } - } - - private void handleDeselection() { - oldWorkingSet = workingSet; - workingSet = null; - handleWorkingSetChange(); - } - - private void handleWorkingSetChange() { - firePropertyChangeChange(SELECTED_WORKING_SET, oldWorkingSet, workingSet); - } - - /** - * Populates the most recently used working set list with MRU items from - * the working set manager as well as adds an item to enable selection of - * a working set not in the MRU list. - */ - private void initializeMru() { - IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets(); - - for (int i = 0; i < workingSets.length; i++) { - String workingSetName = workingSets[i].getName(); - mruList.add(workingSetName); - mruList.setData(workingSetName, workingSets[i]); - } - if (workingSets.length > 0) { - mruList.setText(workingSets[0].getName()); - } - } - - /** - * Initializes the state of the working set part of the dialog. - */ - private void initializeWorkingSet() { - if (workingSet == null && settings != null && settings.getBoolean(USE_WORKING_SET)) { - IWorkingSet mruSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(settings.get(SELECTED_WORKING_SET)); - if (mruSet != null) { - // the call to setWorkingSet will re-invoke the initializeWorkingSet method - setWorkingSet(mruSet); - return; - } - } - workingSetButton.setSelection(workingSet != null); - handleWorkingSetButtonSelection(); - if (workingSet != null && mruList.indexOf(workingSet.getName()) != -1) { - mruList.setText(workingSet.getName()); - } - handleWorkingSetChange(); - } - - /** - * Returns the selected working set or null if none is selected. - * - * @return the selected working set or null if none is selected. - */ - public IWorkingSet getWorkingSet() { - return workingSet; - } - - /** - * Indicate that the selected working set is actually being used so it can - * be added to the "most recently used" list. - */ - public void useSelectedWorkingSet() { - // Add the selected working set to the MRU list before returning it - if (workingSet != null) { - PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(workingSet); - } - } - - /** - * Sets the working set that should be selected in the most recently - * used working set list. - * - * @param workingSet the working set that should be selected. - * has to exist in the list returned by - * org.eclipse.ui.IWorkingSetManager#getRecentWorkingSets(). - * Must not be null. - */ - public void setWorkingSet(IWorkingSet workingSet) { - oldWorkingSet = this.workingSet; - this.workingSet = workingSet; - - if (workingSetButton != null && mruList != null) { - initializeWorkingSet(); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/XMLWriter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/XMLWriter.java deleted file mode 100644 index e9affe50b..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/XMLWriter.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui; - -import java.io.*; -import java.util.*; -/** - * A simple XML writer. - */ -public class XMLWriter extends PrintWriter { - protected int tab; - - /* constants */ - protected static final String XML_VERSION = ""; //$NON-NLS-1$ - -public XMLWriter(OutputStream output) throws UnsupportedEncodingException { - super(new OutputStreamWriter(output, "UTF8")); //$NON-NLS-1$ - tab = 0; - println(XML_VERSION); -} -public void endTag(String name) { - tab--; - printTag('/' + name, null); -} -public void printSimpleTag(String name, Object value) { - if (value != null) { - printTag(name, null, true, false); - print(getEscaped(String.valueOf(value))); - printTag('/' + name, null, false, true); - } -} -public void printTabulation() { - for (int i = 0; i < tab; i++) - super.print('\t'); -} -private void printTag(String name, HashMap parameters) { - printTag(name, parameters, true, true); -} -private void printTag(String name, HashMap parameters, boolean tab, boolean newLine) { - printTag(name, parameters, tab, newLine, false); -} -private void printTag(String name, HashMap parameters, boolean tab, boolean newLine, boolean end) { - StringBuffer sb = new StringBuffer(); - sb.append("<"); //$NON-NLS-1$ - sb.append(name); - if (parameters != null) - for (Enumeration e = Collections.enumeration(parameters.keySet()); e.hasMoreElements();) { - sb.append(" "); //$NON-NLS-1$ - String key = (String) e.nextElement(); - sb.append(key); - sb.append("=\""); //$NON-NLS-1$ - sb.append(getEscaped(String.valueOf(parameters.get(key)))); - sb.append("\""); //$NON-NLS-1$ - } - if (end) - sb.append('/'); - sb.append(">"); //$NON-NLS-1$ - if (tab) - printTabulation(); - if (newLine) - println(sb.toString()); - else - print(sb.toString()); -} -public void startTag(String name, HashMap parameters) { - startTag(name, parameters, true); -} -public void startTag(String name, HashMap parameters, boolean newLine) { - printTag(name, parameters, true, newLine); - tab++; -} -public void startAndEndTag(String name, HashMap parameters, boolean newLine) { - printTag(name, parameters, true, true, true); -} -private static void appendEscapedChar(StringBuffer buffer, char c) { - String replacement = getReplacement(c); - if (replacement != null) { - buffer.append('&'); - buffer.append(replacement); - buffer.append(';'); - } else { - buffer.append(c); - } -} -public static String getEscaped(String s) { - StringBuffer result = new StringBuffer(s.length() + 10); - for (int i = 0; i < s.length(); ++i) - appendEscapedChar(result, s.charAt(i)); - return result.toString(); -} -private static String getReplacement(char c) { - // Encode special XML characters into the equivalent character references. - // These five are defined by default for all XML documents. - switch (c) { - case '<' : - return "lt"; //$NON-NLS-1$ - case '>' : - return "gt"; //$NON-NLS-1$ - case '"' : - return "quot"; //$NON-NLS-1$ - case '\'' : - return "apos"; //$NON-NLS-1$ - case '&' : - return "amp"; //$NON-NLS-1$ - } - return null; -} -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java deleted file mode 100644 index 1a075d9d5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.AddOperation; - -/** - * AddAction performs a 'cvs add' command on the selected resources. If a - * container is selected, its children are recursively added. - */ -public class AddAction extends WorkspaceAction { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - if (!promptForAddOfIgnored()) return; - new AddOperation(getTargetPart(), getSelectedResources()).run(); - } - - /** - * Method promptForAddOfIgnored. - */ - private boolean promptForAddOfIgnored() { - IResource[] resources = getSelectedResources(); - boolean prompt = false; - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - try { - if (resource.isIgnored()) { - prompt = true; - break; - } - } catch (CVSException e) { - handle(e); - } - } - if (prompt) { - return MessageDialog.openQuestion(getShell(), Policy.bind("AddAction.addIgnoredTitle"), Policy.bind("AddAction.addIgnoredQuestion")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForManagedResources() - */ - protected boolean isEnabledForManagedResources() { - return false; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() - */ - protected boolean isEnabledForUnmanagedResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForIgnoredResources() - */ - protected boolean isEnabledForIgnoredResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - // Add to version control should never be enabled for linked resources - IResource resource = cvsResource.getIResource(); - if (resource.isLinked()) return false; - return super.isEnabledForCVSResource(cvsResource); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java deleted file mode 100644 index 474908630..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.ui.operations.BranchOperation; - -/** - * BranchAction tags the selected resources with a branch tag specified by the user, - * and optionally updates the local resources to point to the new branch. - */ -public class BranchAction extends WorkspaceAction { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - new BranchOperation(getTargetPart(), getSelectedResources()).run(); - } - -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java deleted file mode 100644 index 5a9b337a3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java +++ /dev/null @@ -1,483 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.AvoidableMessageDialog; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.actions.TeamAction; -import org.eclipse.team.internal.ui.dialogs.IPromptCondition; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.ide.IDE; - -/** - * CVSAction is the common superclass for all CVS actions. It provides - * facilities for enablement handling, standard error handling, selection - * retrieval and prompting. - */ -abstract public class CVSAction extends TeamAction implements IEditorActionDelegate { - - private List accumulatedStatus = new ArrayList(); - - /** - * Common run method for all CVS actions. - */ - final public void run(IAction action) { - try { - if (!beginExecution(action)) return; - execute(action); - endExecution(); - } catch (InvocationTargetException e) { - // Handle the exception and any accumulated errors - handle(e); - } catch (InterruptedException e) { - // Show any problems that have occured so far - handle(null); - } catch (TeamException e) { - // Handle the exception and any accumulated errors - handle(e); - } - } - - /** - * This method gets invoked before the CVSAction#execute(IAction) - * method. It can preform any prechecking and initialization required before - * the action is executed. Sunclasses may override but must invoke this - * inherited method to ensure proper initialization of this superclass is performed. - * These included prepartion to accumulate IStatus and checking for dirty editors. - */ - protected boolean beginExecution(IAction action) throws TeamException { - accumulatedStatus.clear(); - if(needsToSaveDirtyEditors()) { - if(!saveAllEditors()) { - return false; - } - } - return true; - } - - /** - * Actions must override to do their work. - */ - abstract protected void execute(IAction action) throws InvocationTargetException, InterruptedException; - - /** - * This method gets invoked after CVSAction#execute(IAction) - * if no exception occured. Sunclasses may override but should invoke this - * inherited method to ensure proper handling oy any accumulated IStatus. - */ - protected void endExecution() throws TeamException { - if ( ! accumulatedStatus.isEmpty()) { - handle(null); - } - } - - /** - * Add a status to the list of accumulated status. - * These will be provided to method handle(Exception, IStatus[]) - * when the action completes. - */ - protected void addStatus(IStatus status) { - accumulatedStatus.add(status); - } - - /** - * Return the list of status accumulated so far by the action. This - * will include any OK status that were added using addStatus(IStatus) - */ - protected IStatus[] getAccumulatedStatus() { - return (IStatus[]) accumulatedStatus.toArray(new IStatus[accumulatedStatus.size()]); - } - - /** - * Return the title to be displayed on error dialogs. - * Sunclasses should override to present a custon message. - */ - protected String getErrorTitle() { - return Policy.bind("CVSAction.errorTitle"); //$NON-NLS-1$ - } - - /** - * Return the title to be displayed on error dialogs when warnigns occur. - * Sunclasses should override to present a custon message. - */ - protected String getWarningTitle() { - return Policy.bind("CVSAction.warningTitle"); //$NON-NLS-1$ - } - - /** - * Return the message to be used for the parent MultiStatus when - * mulitple errors occur during an action. - * Sunclasses should override to present a custon message. - */ - protected String getMultiStatusMessage() { - return Policy.bind("CVSAction.multipleProblemsMessage"); //$NON-NLS-1$ - } - - /** - * Return the status to be displayed in an error dialog for the given list - * of non-OK status. - * - * This method can be overridden bu subclasses. Returning an OK status will - * prevent the error dialog from being shown. - */ - protected IStatus getStatusToDisplay(IStatus[] problems) { - if (problems.length == 1) { - return problems[0]; - } - MultiStatus combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, getMultiStatusMessage(), null); //$NON-NLS-1$ - for (int i = 0; i < problems.length; i++) { - combinedStatus.merge(problems[i]); - } - return combinedStatus; - } - - /** - * Method that implements generic handling of an exception. - * - * Thsi method will also use any accumulated status when determining what - * information (if any) to show the user. - * - * @param exception the exception that occured (or null if none occured) - * @param status any status accumulated by the action before the end of - * the action or the exception occured. - */ - protected void handle(Exception exception) { - // Get the non-OK statii - List problems = new ArrayList(); - IStatus[] status = getAccumulatedStatus(); - if (status != null) { - for (int i = 0; i < status.length; i++) { - IStatus iStatus = status[i]; - if ( ! iStatus.isOK() || iStatus.getCode() == CVSStatus.SERVER_ERROR) { - problems.add(iStatus); - } - } - } - // Handle the case where there are no problem statii - if (problems.size() == 0) { - if (exception == null) return; - handle(exception, getErrorTitle(), null); - return; - } - - // For now, display both the exception and the problem status - // Later, we can determine how to display both together - if (exception != null) { - handle(exception, getErrorTitle(), null); - } - - String message = null; - IStatus statusToDisplay = getStatusToDisplay((IStatus[]) problems.toArray(new IStatus[problems.size()])); - if (statusToDisplay.isOK()) return; - if (statusToDisplay.isMultiStatus() && statusToDisplay.getChildren().length == 1) { - message = statusToDisplay.getMessage(); - statusToDisplay = statusToDisplay.getChildren()[0]; - } - String title; - if (statusToDisplay.getSeverity() == IStatus.ERROR) { - title = getErrorTitle(); - } else { - title = getWarningTitle(); - } - CVSUIPlugin.openError(getShell(), title, message, new CVSException(statusToDisplay)); - } - - /** - * Convenience method for running an operation with the appropriate progress. - * Any exceptions are propogated so they can be handled by the - * CVSAction#run(IAction) error handling code. - * - * @param runnable the runnable which executes the operation - * @param cancelable indicate if a progress monitor should be cancelable - * @param progressKind one of PROGRESS_BUSYCURSOR or PROGRESS_DIALOG - */ - final protected void run(final IRunnableWithProgress runnable, boolean cancelable, int progressKind) throws InvocationTargetException, InterruptedException { - final Exception[] exceptions = new Exception[] {null}; - - // Ensure that no repository view refresh happens until after the action - final IRunnableWithProgress innerRunnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - getRepositoryManager().run(runnable, monitor); - } - }; - - switch (progressKind) { - case PROGRESS_BUSYCURSOR : - BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { - public void run() { - try { - innerRunnable.run(new NullProgressMonitor()); - } catch (InvocationTargetException e) { - exceptions[0] = e; - } catch (InterruptedException e) { - exceptions[0] = e; - } - } - }); - break; - case PROGRESS_DIALOG : - default : - new ProgressMonitorDialog(getShell()).run(cancelable, true, innerRunnable); - break; - } - if (exceptions[0] != null) { - if (exceptions[0] instanceof InvocationTargetException) - throw (InvocationTargetException)exceptions[0]; - else - throw (InterruptedException)exceptions[0]; - } - } - - /** - * Answers if the action would like dirty editors to saved - * based on the CVS preference before running the action. By - * default, CVSActions do not save dirty editors. - */ - protected boolean needsToSaveDirtyEditors() { - return false; - } - - /** - * Returns the selected CVS resources - */ - protected ICVSResource[] getSelectedCVSResources() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ICVSResource) { - resources.add(next); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ICVSResource.class); - if (adapter instanceof ICVSResource) { - resources.add(adapter); - continue; - } - } - } - } - if (resources != null && !resources.isEmpty()) { - return (ICVSResource[])resources.toArray(new ICVSResource[resources.size()]); - } - return new ICVSResource[0]; - } - - /** - * Get selected CVS remote folders - */ - protected ICVSRemoteFolder[] getSelectedRemoteFolders() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ICVSRemoteFolder) { - resources.add(next); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ICVSRemoteFolder.class); - if (adapter instanceof ICVSRemoteFolder) { - resources.add(adapter); - continue; - } - } - } - } - if (resources != null && !resources.isEmpty()) { - return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]); - } - return new ICVSRemoteFolder[0]; - } - - /** - * Returns the selected remote resources - */ - protected ICVSRemoteResource[] getSelectedRemoteResources() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ICVSRemoteResource) { - resources.add(next); - continue; - } - if (next instanceof ILogEntry) { - resources.add(((ILogEntry)next).getRemoteFile()); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ICVSRemoteResource.class); - if (adapter instanceof ICVSRemoteResource) { - resources.add(adapter); - continue; - } - } - } - } - if (resources != null && !resources.isEmpty()) { - ICVSRemoteResource[] result = new ICVSRemoteResource[resources.size()]; - resources.toArray(result); - return result; - } - return new ICVSRemoteResource[0]; - } - - /** - * A helper prompt condition for prompting for CVS dirty state. - */ - public static IPromptCondition getOverwriteLocalChangesPrompt(final IResource[] dirtyResources) { - return new IPromptCondition() { - List resources = Arrays.asList(dirtyResources); - public boolean needsPrompt(IResource resource) { - return resources.contains(resource); - } - public String promptMessage(IResource resource) { - return Policy.bind("ReplaceWithAction.localChanges", resource.getName());//$NON-NLS-1$ - } - }; - } - - /** - * Checks if a the resources' parent's tags are different then the given tag. - * Prompts the user that they are adding mixed tags and returns true if - * the user wants to continue or false otherwise. - */ - public static boolean checkForMixingTags(final Shell shell, IResource[] resources, final CVSTag tag) throws CVSException { - final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - if(!store.getBoolean(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS)) { - return true; - }; - - final boolean[] result = new boolean[] { true }; - - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.getType() != IResource.PROJECT) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - CVSTag parentTag = cvsResource.getParent().getFolderSyncInfo().getTag(); - // prompt if the tags are not equal - // consider BASE to be equal the parent tag since we don't make BASE sticky on replace - if (!CVSTag.equalTags(tag, parentTag) && !CVSTag.equalTags(tag, CVSTag.BASE)) { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - AvoidableMessageDialog dialog = new AvoidableMessageDialog( - shell, - Policy.bind("CVSAction.mixingTagsTitle"), //$NON-NLS-1$ - null, // accept the default window icon - Policy.bind("CVSAction.mixingTags", tag.getName()), //$NON-NLS-1$ - MessageDialog.QUESTION, - new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, - 0); - - result[0] = dialog.open() == 0; - if(result[0] && dialog.isDontShowAgain()) { - store.setValue(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS, false); - } - } - }); - // only prompt once - break; - } - } - } - return result[0]; - } - - /** - * Based on the CVS preference for saving dirty editors this method will either - * ignore dirty editors, save them automatically, or prompt the user to save them. - * - * @return true if the command succeeded, and false - * if at least one editor with unsaved changes was not saved - */ - private boolean saveAllEditors() { - final int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); - final boolean[] okToContinue = new boolean[] {true}; - if (option != ICVSUIConstants.OPTION_NEVER) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - boolean confirm = option == ICVSUIConstants.OPTION_PROMPT; - IResource[] selectedResources = getSelectedResources(); - if (selectedResources != null) { - okToContinue[0] = IDE.saveAllEditors(selectedResources, confirm); - } - } - }); - } - return okToContinue[0]; - } - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#handle(java.lang.Exception, java.lang.String, java.lang.String) - */ - protected void handle(Exception exception, String title, String message) { - CVSUIPlugin.openError(getShell(), title, message, exception, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); - } - - protected RepositoryManager getRepositoryManager() { - return CVSUIPlugin.getPlugin().getRepositoryManager(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamAction#getSelectedResources() - */ - protected IResource[] getSelectedResources() { - return Utils.getResources(selection.toArray()); - } - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java deleted file mode 100644 index bdd61d96f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; - -/** - * Checkout a remote module into the workspace ensuring that the user is prompted for - * any overwrites that may occur. - */ -public class CheckoutAction extends CVSAction { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFolders(), null) - .run(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); - if (folders.length == 0) return false; - // only enabled when all folders are in the same repository - ICVSRepositoryLocation location = folders[0].getRepository(); - for (int i = 1; i < folders.length; i++) { - ICVSRemoteFolder folder = folders[i]; - if (!folder.getRepository().equals(location)) { - return false; - } - } - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java deleted file mode 100644 index c06aeb4fe..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; -import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard; - -public class CheckoutAsAction extends CVSAction { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); - CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfiguration(folders)); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - - /* - * Return true if the remote project does not have a .project file - * so that the checkout wizard will give the option to launch - * the New Project wizard - */ - protected boolean allowProjectConfiguration(ICVSRemoteFolder[] folders) throws InvocationTargetException, InterruptedException { - if (folders.length != 1) return false; - return !HasProjectMetaFileOperation.hasMetaFile(getTargetPart(), folders[0]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - return getSelectedRemoteFolders().length > 0; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutWizardAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutWizardAction.java deleted file mode 100644 index 036b22c2a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutWizardAction.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutWizard; -import org.eclipse.ui.*; - -/** - * Action that launches the checkout wizard - */ -public class CheckoutWizardAction implements IWorkbenchWindowActionDelegate { - - Shell shell; - - /** - * @see IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() { - } - - /** - * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - this.shell = window.getShell(); - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - CheckoutWizard wizard = new CheckoutWizard(); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java deleted file mode 100644 index f9972b260..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation; - -/** - * Action for checking in files to a CVS provider. - * Prompts the user for a release comment. - */ -public class CommitAction extends WorkspaceAction { - - /* - * @see CVSAction#execute(IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - final CommitOperation operation = new CommitOperation(getTargetPart(), getSelectedResources(), null); - final boolean[] retVal = {true}; - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - retVal[0] = operation.performPrompting(monitor); - } catch (CVSException e) { - new InvocationTargetException(e); - } - } - }, false, PROGRESS_BUSYCURSOR); - if(retVal[0]) - operation.run(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("CommitAction.commitFailed"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() - */ - protected boolean isEnabledForUnmanagedResources() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java deleted file mode 100644 index b7bc01154..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareUI; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation; - -/** - * This action is used for comparing two arbitrary remote resources. This is - * enabled in the repository explorer. - */ -public class CompareRemoteResourcesAction extends CVSAction { - - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - ICVSRemoteResource[] editions = getSelectedRemoteResources(); - if (editions == null || editions.length != 2) { - MessageDialog.openError(getShell(), Policy.bind("CompareRemoteResourcesAction.unableToCompare"), Policy.bind("CompareRemoteResourcesAction.selectTwoResources")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - try { - if (isSameFolder(editions)) { - new RemoteCompareOperation(null, editions[0], RemoteCompareOperation.getTag(editions[1])).run(); - } else { - ResourceEditionNode left = new ResourceEditionNode(editions[0]); - ResourceEditionNode right = new ResourceEditionNode(editions[1]); - CompareUI.openCompareEditorOnPage(new CVSCompareEditorInput(left, right), getTargetPage()); - } - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - - protected boolean isSameFolder(ICVSRemoteResource[] editions) { - return editions[0].isContainer() && editions[0].getRepository().equals(editions[1].getRepository()) - && editions[0].getRepositoryRelativePath().equals(editions[1].getRepositoryRelativePath()); - } - - /* - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSRemoteResource[] resources = getSelectedRemoteResources(); - if (resources.length != 2) return false; - if (resources[0].isContainer() != resources[1].isContainer()) return false; - // Don't allow comparisons of two unrelated remote projects - return !resources[0].isContainer() || isSameFolder(resources); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java deleted file mode 100644 index cd6c7e6a3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation; -import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; - -/** - * Compare to versions of a remote resource. - */ -public class CompareRemoteWithTagAction extends CVSAction { - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - - final ICVSRemoteResource[] resources = getSelectedRemoteResources(); - if (resources.length == 0) return; - - // Obtain the tag to compare against - final ICVSRemoteResource resource = resources[0]; - final CVSTag[] tag = new CVSTag[] { null}; - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - tag[0] = TagSelectionDialog.getTagToCompareWith(getShell(), TagSource.create(resources), - TagSelectionDialog.INCLUDE_BRANCHES | - TagSelectionDialog.INCLUDE_VERSIONS | - TagSelectionDialog.INCLUDE_DATES | - TagSelectionDialog.INCLUDE_HEAD_TAG); - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - if (tag[0] == null) return; - - // Run the compare operation in the background - new RemoteCompareOperation(getTargetPart(), resource, tag[0]) - .run(); - } - - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() { - ICVSRemoteResource[] resources = getSelectedRemoteResources(); - // Only support single select for now. - // Need to avoid overlap if multi-select is supported - return resources.length == 1; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java deleted file mode 100644 index 98c59288a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; - -/** - * This action shows the CVS workspace participant into a model dialog. For single file - * selection, the compare editor is shown instead. - * - * @since 3.0 - */ -public class CompareWithRemoteAction extends SyncAction { - - /* - * Update the text label for the action based on the tags in the selection. - * @see TeamAction#setActionEnablement(org.eclipse.jface.action.IAction) - */ - protected void setActionEnablement(IAction action) { - super.setActionEnablement(action); - action.setText(calculateActionTagValue()); - } - - /** - * Enable for resources that are managed (using super) or whose parent is a CVS folder. - * - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - return super.isEnabledForCVSResource(cvsResource) || cvsResource.getParent().isCVSFolder(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java deleted file mode 100644 index ef683b19c..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareUI; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.SaveablePartDialog; - -/** - * Compare with revision will allow a user to browse the history of a file, compare with the - * other revisions and merge changes from other revisions into the workspace copy. - */ -public class CompareWithRevisionAction extends WorkspaceAction { - - /** - * Returns the selected remote file - */ - protected ICVSRemoteFile getSelectedRemoteFile() { - IResource[] resources = getSelectedResources(); - if (resources.length != 1) return null; - if (!(resources[0] instanceof IFile)) return null; - IFile file = (IFile)resources[0]; - try { - return (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(file); - } catch (TeamException e) { - handle(e, null, null); - return null; - } - } - - /* - * @see CVSAction#execute(IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - - // Setup holders - final ICVSRemoteFile[] file = new ICVSRemoteFile[] { null }; - final ILogEntry[][] entries = new ILogEntry[][] { null }; - - // Get the selected file - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - file[0] = getSelectedRemoteFile(); - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - - if (file[0] == null) { - // No revisions for selected file - MessageDialog.openWarning(getShell(), Policy.bind("CompareWithRevisionAction.noRevisions"), Policy.bind("CompareWithRevisionAction.noRevisionsLong")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - - // Fetch the log entries - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - monitor.beginTask(Policy.bind("CompareWithRevisionAction.fetching"), 100); //$NON-NLS-1$ - entries[0] = file[0].getLogEntries(Policy.subMonitorFor(monitor, 100)); - monitor.done(); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }, true /* cancelable */, PROGRESS_DIALOG); - - if (entries[0] == null) return; - - // Show the compare viewer - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - CVSCompareRevisionsInput input = new CVSCompareRevisionsInput((IFile)getSelectedResources()[0], entries[0]); - if(CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG)) { - // running with a null progress monitor is fine because we have already pre-fetched the log entries above. - input.run(new NullProgressMonitor()); - SaveablePartDialog cd = createCompareDialog(getShell(), input); - cd.setBlockOnOpen(true); - cd.open(); - } else { - CompareUI.openCompareEditor(input); - } - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - } - - /** - * Return the compare dialog to use to show the compare input. - */ - protected SaveablePartDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { - return new SaveablePartDialog(shell, input); //$NON-NLS-1$ - } - - /** - * Return the text describing this action - */ - protected String getActionTitle() { - return Policy.bind("CompareWithRevisionAction.4"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("CompareWithRevisionAction.compare"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - return (!cvsResource.isFolder() && super.isEnabledForCVSResource(cvsResource)); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() - */ - protected boolean isEnabledForMultipleResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java deleted file mode 100644 index 81c4abf7b..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant; -import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; - -public class CompareWithTagAction extends WorkspaceAction { - - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - final IResource[] resources = getSelectedResources(); - CVSTag tag = promptForTag(resources); - if (tag == null) - return; - - CVSCompareSubscriber compareSubscriber = new CVSCompareSubscriber(resources, tag); - if (SyncAction.isSingleFile(resources)) { - SyncAction.showSingleFileComparison(getShell(), compareSubscriber, resources[0]); - compareSubscriber.dispose(); - } else { - try { - compareSubscriber.primeRemoteTree(); - } catch(CVSException e) { - // ignore, the compare will fail if there is a real problem. - } - // First check if there is an existing matching participant, if so then re-use it - CompareParticipant participant = CompareParticipant.getMatchingParticipant(resources, tag); - if (participant == null) { - CVSCompareSubscriber s = compareSubscriber; - participant = new CompareParticipant(s); - TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); - } - participant.refresh(resources, null, null, null); //$NON-NLS-1$ - } - } - - protected CVSTag promptForTag(IResource[] resources) { - CVSTag tag = TagSelectionDialog.getTagToCompareWith(getShell(), TagSource.create(resources), TagSelectionDialog.INCLUDE_ALL_TAGS); - return tag; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java deleted file mode 100644 index 81c0c5b73..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.model.RemoteModule; -import org.eclipse.team.internal.ccvs.ui.tags.TagConfigurationDialog; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; -; - -/** - * DefineTagAction remembers a tag by name - */ -public class ConfigureTagsFromRepoViewOnFolder extends CVSAction { - - /** - * Returns the selected remote folders - */ - protected ICVSRemoteFolder[] getSelectedRemoteFolders() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof RemoteModule) { - next = ((RemoteModule)next).getCVSResource(); - } - if (next instanceof ICVSRemoteFolder) { - ICVSRemoteFolder folder = (ICVSRemoteFolder)next; - if (folder.isDefinedModule()) { - resources.add(next); - } else if(new Path(null, ((ICVSRemoteFolder)next).getRepositoryRelativePath()).segmentCount()==1) { - resources.add(next); - } - } - } - } - if (resources != null && !resources.isEmpty()) { - return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]); - } - return new ICVSRemoteFolder[0]; - } - - /* - * @see CVSAction@execute(IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - final ICVSRemoteFolder[] roots = getSelectedRemoteFolders(); - final Shell shell = getShell(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - ICVSFolder[] cvsFolders = new ICVSFolder[roots.length]; - for (int i = 0; i < roots.length; i++) { - cvsFolders[i] = roots[i]; - } - TagConfigurationDialog d = new TagConfigurationDialog(shell, TagSource.create(cvsFolders)); - d.open(); - } - }); - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - } - - /* - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSRemoteFolder[] roots = getSelectedRemoteFolders(); - if (roots.length != 1) return false; - return true; - } - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("ConfigureTagsFromRepoViewConfigure_Tag_Error_1"); //$NON-NLS-1$ - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java deleted file mode 100644 index e798bdb84..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.Team; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.PlatformUI; - -public class EditAction extends WorkspaceAction { - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - // Get the editors - final EditorsAction editors = new EditorsAction(); - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - executeProviderAction(editors, Policy.subMonitorFor(monitor, 25)); - - // If there are editors show them and prompt the user to execute the edit command - if (!editors.promptToEdit(shell)) { - return; - } - - executeProviderAction(new IProviderAction() { - public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { - provider.edit(resources, false /* recurse */, true /* notify server */, ICVSFile.NO_NOTIFICATION, monitor); - return Team.OK_STATUS; - } - }, Policy.subMonitorFor(monitor, 75)); - } - }); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - if (cvsResource.isFolder()) return false; - if (super.isEnabledForCVSResource(cvsResource)) { - return ((ICVSFile)cvsResource).isReadOnly(); - } else { - return false; - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java deleted file mode 100644 index 7f6d5a678..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.Team; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction.IProviderAction; - -/** - * This Action gets the EditorsInfo[] - * It is used by the ShowEditorAction - * and ShowEditorAction. - * - * @author Gregor - * Kohlwes - * - */ -public class EditorsAction implements IProviderAction, IRunnableWithProgress { - EditorsInfo[] f_editorsInfo = new EditorsInfo[0]; - CVSTeamProvider f_provider; - IResource[] f_resources; - - public EditorsAction() { - } - - public EditorsAction(CVSTeamProvider provider, IResource[] resources) { - f_provider = provider; - f_resources = resources; - } - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction.IProviderAction#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { - f_editorsInfo = provider.editors(resources, monitor); - return Team.OK_STATUS; - } - - public boolean promptToEdit(Shell shell) { - if (!isEmpty()) { - final EditorsDialog view = new EditorsDialog(shell, f_editorsInfo); - // Open the dialog using a sync exec (there are no guarentees that we - // were called from the UI thread - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - view.open(); - } - }, CVSUIPlugin.PERFORM_SYNC_EXEC); - return (view.getReturnCode() == EditorsDialog.OK); - } - return true; - } - - /** - * Contact the server to determine if there are any editors on the associatd files. - * - * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - if (f_provider == null || f_resources == null) { - throw new InvocationTargetException(new RuntimeException(Policy.bind("EditorsAction.classNotInitialized", this.getClass().getName()))); //$NON-NLS-1$ - } - try { - execute(f_provider,f_resources,monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - - /** - * Returns the f_editorsInfo. - * @return EditorsInfo[] - */ - public EditorsInfo[] getEditorsInfo() { - return f_editorsInfo; - } - - /** - * Indicates whether there are editors of any of the associated files. - * The run(IProgressMonitor) must be invoked first to - * fetch any editors from the server. - * @return boolean - */ - public boolean isEmpty() { - return f_editorsInfo.length == 0; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java deleted file mode 100644 index 21197ffe1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; - -/** - * Action to generate a patch file using the CVS diff command. - * - * NOTE: This is a temporary action and should eventually be replaced - * by a create patch command in the compare viewer. - */ -public class GenerateDiffFileAction extends WorkspaceAction { - - // The initial size of this wizard. - private final static int INITIAL_WIDTH = 300; - private final static int INITIAL_HEIGHT = 350; - - /** (Non-javadoc) - * Method declared on IActionDelegate. - */ - public void execute(IAction action) { - final String title = Policy.bind("GenerateCVSDiff.title"); //$NON-NLS-1$ - final IResource[] resources = getSelectedResources(); - final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(resources[0]); - wizard.setWindowTitle(title); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); - dialog.open(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() - */ - protected boolean isEnabledForMultipleResources() { - return false; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() - */ - protected boolean isEnabledForUnmanagedResources() { - return true; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java deleted file mode 100644 index 80dbe9fdc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.IgnoreResourcesDialog; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation; -import org.eclipse.ui.IWorkbenchPart; - -public class IgnoreAction extends WorkspaceAction { - - /** - * Define an operation that can be run in the background. - * We divide the ignores by provider to obtain project - * locks while modifying the .cvsignore files - */ - class IgnoreOperation extends RepositoryProviderOperation { - - private final IgnoreResourcesDialog dialog; - - public IgnoreOperation(IWorkbenchPart part, IResource[] resources, IgnoreResourcesDialog dialog) { - super(part, resources); - this.dialog = dialog; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("IgnoreAction.0", provider.getProject().getName()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException { - try { - monitor.beginTask(null, resources.length); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - String pattern = dialog.getIgnorePatternFor(resource); - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - cvsResource.setIgnoredAs(pattern); - monitor.worked(1); - } - } catch (TeamException e) { - collectStatus(e.getStatus()); - return; - } finally { - monitor.done(); - } - collectStatus(Status.OK_STATUS); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("IgnoreAction.1"); //$NON-NLS-1$ - } - - } - - protected void execute(final IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IResource[] resources = getSelectedResources(); - IgnoreResourcesDialog dialog = new IgnoreResourcesDialog(getShell(), resources); - if (dialog.open() != IgnoreResourcesDialog.OK) return; - new IgnoreOperation(getTargetPart(), resources, dialog).run(); - - //if (action != null) action.setEnabled(isEnabled()); - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - } - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("IgnoreAction.ignore"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForManagedResources() - */ - protected boolean isEnabledForManagedResources() { - return false; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() - */ - protected boolean isEnabledForUnmanagedResources() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - if (super.isEnabledForCVSResource(cvsResource)) { - // Perform an extra check against the subscriber to ensure there is no conflict - CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); - IResource resource = cvsResource.getIResource(); - if (resource == null) return false; - try { - SyncInfo info = subscriber.getSyncInfo(resource); - return ((info.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.OUTGOING); - } catch (TeamException e) { - // Let the enablement happen - return true; - } - } - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java deleted file mode 100644 index 795c1c833..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.ui.wizards.MergeWizard; - -public class MergeAction extends WorkspaceAction { - - /* - * @see CVSAction#execute() - */ - public void execute(IAction action) { - final Shell shell = getShell(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - MergeWizard wizard = new MergeWizard(getTargetPart(), getSelectedResources()); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - }); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java deleted file mode 100644 index 923721ca2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; -import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog; - -public class MoveRemoteTagAction extends TagInRepositoryAction { - - /** - * @see TagRemoteAction#promptForTag(ICVSFolder[]) - */ - protected ITagOperation configureOperation() { - // Allow the user to select a tag - ITagOperation operation = createTagOperation(); - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), operation.getTagSource(), - Policy.bind("MoveTagAction.title"), //$NON-NLS-1$ - Policy.bind("MoveTagAction.message"), //$NON-NLS-1$ - TagSelectionDialog.INCLUDE_BRANCHES | TagSelectionDialog.INCLUDE_VERSIONS, - isFolderSelected(), /* show recurse */ - IHelpContextIds.TAG_REMOTE_WITH_EXISTING_DIALOG); - dialog.setBlockOnOpen(true); - if (dialog.open() == Dialog.CANCEL) { - return null; - } - CVSTag tag = dialog.getResult(); - if (tag == null) return null; - operation.setTag(tag); - operation.moveTag(); - boolean recursive = dialog.getRecursive(); - if (!recursive) { - operation.recurse(); - } - return operation; - } - - private boolean isFolderSelected() { - ICVSResource[] resources = getSelectedCVSResources(); - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - if (resource.isFolder()) - return true; - } - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/NewRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/NewRepositoryAction.java deleted file mode 100644 index a1d5f2f64..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/NewRepositoryAction.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.team.internal.ccvs.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.ui.wizards.NewLocationWizard; -import org.eclipse.ui.*; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class NewRepositoryAction implements IWorkbenchWindowActionDelegate, IViewActionDelegate { - Shell shell; - - /** - * @see IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() { - } - - /** - * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - this.shell = window.getShell(); - } - - public void init(IViewPart view) { - shell = view.getSite().getShell(); - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - NewLocationWizard wizard = new NewLocationWizard(); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java deleted file mode 100644 index e3da4a6e5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.*; - -public class OpenLogEntryAction extends CVSAction { - /** - * Returns the selected remote files - */ - protected ILogEntry[] getSelectedLogEntries() { - ArrayList entries = null; - if (!selection.isEmpty()) { - entries = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ILogEntry) { - entries.add(next); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ILogEntry.class); - if (adapter instanceof ILogEntry) { - entries.add(adapter); - continue; - } - } - } - } - if (entries != null && !entries.isEmpty()) { - ILogEntry[] result = new ILogEntry[entries.size()]; - entries.toArray(result); - return result; - } - return new ILogEntry[0]; - } - /* - * @see CVSAction#execute(IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - IWorkbench workbench = CVSUIPlugin.getPlugin().getWorkbench(); - IEditorRegistry registry = workbench.getEditorRegistry(); - IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); - final ILogEntry[] entries = getSelectedLogEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].isDeletion()) { - MessageDialog.openError(getShell(), Policy.bind("OpenLogEntryAction.deletedTitle"), Policy.bind("OpenLogEntryAction.deleted")); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - ICVSRemoteFile file = entries[i].getRemoteFile(); - String filename = file.getName(); - IEditorDescriptor descriptor = registry.getDefaultEditor(filename); - String id; - if (descriptor == null) { - id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ - } else { - id = descriptor.getId(); - } - try { - try { - page.openEditor(new RemoteFileEditorInput(file, monitor), id); - } catch (PartInitException e) { - if (id.equals("org.eclipse.ui.DefaultTextEditor")) { //$NON-NLS-1$ - throw e; - } else { - page.openEditor(new RemoteFileEditorInput(file, monitor), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ - } - } - } catch (PartInitException e) { - throw new InvocationTargetException(e); - } - } - } - } - }, false, PROGRESS_BUSYCURSOR); //$NON-NLS-1$ - } - /* - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ILogEntry[] entries = getSelectedLogEntries(); - if (entries.length == 0) return false; - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java deleted file mode 100644 index 033fd3b9a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.RemoteFileEditorInput; -import org.eclipse.ui.*; - -public class OpenRemoteFileAction extends CVSAction { - /** - * Returns the selected remote files - */ - protected ICVSRemoteFile[] getSelectedRemoteFiles() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ICVSRemoteFile) { - resources.add(next); - continue; - } - if (next instanceof ILogEntry) { - resources.add(((ILogEntry)next).getRemoteFile()); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable) next; - Object adapter = a.getAdapter(ICVSRemoteFile.class); - if (adapter instanceof ICVSRemoteFile) { - resources.add(adapter); - continue; - } - } - } - } - if (resources != null && !resources.isEmpty()) { - ICVSRemoteFile[] result = new ICVSRemoteFile[resources.size()]; - resources.toArray(result); - return result; - } - return new ICVSRemoteFile[0]; - } - /* - * @see CVSAction#execute(IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - IWorkbench workbench = CVSUIPlugin.getPlugin().getWorkbench(); - IEditorRegistry registry = workbench.getEditorRegistry(); - IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); - ICVSRemoteFile[] files = getSelectedRemoteFiles(); - for (int i = 0; i < files.length; i++) { - ICVSRemoteFile file = files[i]; - String filename = file.getName(); - IEditorDescriptor descriptor = registry.getDefaultEditor(filename); - String id; - if (descriptor == null) { - id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ - } else { - id = descriptor.getId(); - } - try { - try { - page.openEditor(new RemoteFileEditorInput(files[i], monitor), id); - } catch (PartInitException e) { - if (id.equals("org.eclipse.ui.DefaultTextEditor")) { //$NON-NLS-1$ - throw e; - } else { - page.openEditor(new RemoteFileEditorInput(files[i], monitor), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ - } - } - } catch (PartInitException e) { - throw new InvocationTargetException(e); - } - } - } - }, false, PROGRESS_BUSYCURSOR); //$NON-NLS-1$ - } - /* - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSRemoteFile[] resources = getSelectedRemoteFiles(); - if (resources.length == 0) return false; - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java deleted file mode 100644 index d182ccdb5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; -import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; -import org.eclipse.team.internal.ui.dialogs.IPromptCondition; - -public class ReplaceWithRemoteAction extends WorkspaceAction { - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - - final IResource[][] resources = new IResource[][] {null}; - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - resources[0] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 100)); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - - if (resources[0] == null || resources[0].length == 0) return; - - // Peform the replace in the background - new ReplaceOperation(getTargetPart(), resources[0], null, true).run(); - } - - protected IPromptCondition getPromptCondition(IResource[] dirtyResources) { - return getOverwriteLocalChangesPrompt(dirtyResources); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("ReplaceWithRemoteAction.problemMessage"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - if (super.isEnabledForCVSResource(cvsResource)) { - // Don't enable if there are sticky file revisions in the lineup - if (!cvsResource.isFolder()) { - ResourceSyncInfo info = cvsResource.getSyncInfo(); - if (info != null && info.getTag() != null) { - String revision = info.getRevision(); - String tag = info.getTag().getName(); - if (revision.equals(tag)) return false; - } - } - return true; - } else { - return false; - } - } - - /* - * Update the text label for the action based on the tags in the - * selection. - * - * @see TeamAction#setActionEnablement(org.eclipse.jface.action.IAction) - */ - protected void setActionEnablement(IAction action) { - super.setActionEnablement(action); - - action.setText(calculateActionTagValue()); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java deleted file mode 100644 index d0fc01de5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.SaveablePartDialog; - -/** - * Displays a compare dialog and allows the same behavior as the compare. In addition - * a replace button is added to the dialog that will replace the local with the currently - * selected revision. - * - * @since 3.0 - */ -public class ReplaceWithRevisionAction extends CompareWithRevisionAction { - - protected static final int REPLACE_ID = 10; - private CVSCompareRevisionsInput input; - - protected class ReplaceCompareDialog extends SaveablePartDialog { - private Button replaceButton; - - public ReplaceCompareDialog(Shell shell, CVSCompareRevisionsInput input) { - super(shell, input); - // Don't allow editing of the merge viewers in the replace - input.getCompareConfiguration().setLeftEditable(false); - input.getCompareConfiguration().setRightEditable(false); - } - - /** - * Add the replace button to the dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - replaceButton = createButton(parent, REPLACE_ID, Policy.bind("ReplaceWithRevisionAction.0"), true); //$NON-NLS-1$ - replaceButton.setEnabled(false); - input.getViewer().addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - ISelection s= e.getSelection(); - replaceButton.setEnabled(s != null && ! s.isEmpty()); - } - } - ); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //$NON-NLS-1$ - // Don't call super because we don't want the OK button to appear - } - - /** - * If the replace button was pressed. - */ - protected void buttonPressed(int buttonId) { - if(buttonId == REPLACE_ID) { - try { - input.replaceLocalWithCurrentlySelectedRevision(); - } catch (CoreException e) { - Utils.handle(e); - } - buttonId = IDialogConstants.OK_ID; - } - super.buttonPressed(buttonId); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CompareWithRevisionAction#createCompareDialog(org.eclipse.swt.widgets.Shell, org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput) - */ - protected SaveablePartDialog createCompareDialog(Shell shell, CVSCompareRevisionsInput input) { - this.input = input; - return new ReplaceCompareDialog(shell, input); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CompareWithRevisionAction#getActionTitle() - */ - protected String getActionTitle() { - return Policy.bind("ReplaceWithRevisionAction.1"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java deleted file mode 100644 index f0d90294f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; -import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; - -/** - * Action for replace with tag. - */ -public class ReplaceWithTagAction extends WorkspaceAction { - /* - * Method declared on IActionDelegate. - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - - // Setup the holders - final IResource[][] resources = new IResource[][] {null}; - final CVSTag[] tag = new CVSTag[] {null}; - final boolean[] recurse = new boolean[] {true}; - - // Show a busy cursor while display the tag selection dialog - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - - try { - resources[0] = - checkOverwriteOfDirtyResources( - getSelectedResources(), - null /* no progress just a busy cursor for now */); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - if(resources[0].length == 0) { - // nothing to do - return; - } - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), TagSource.create(resources[0]), - Policy.bind("ReplaceWithTagAction.message"), //$NON-NLS-1$ - Policy.bind("TagSelectionDialog.Select_a_Tag_1"), //$NON-NLS-1$ - TagSelectionDialog.INCLUDE_ALL_TAGS, - true, /*show recurse*/ - IHelpContextIds.REPLACE_TAG_SELECTION_DIALOG); //$NON-NLS-1$ - dialog.setBlockOnOpen(true); - if (dialog.open() == Dialog.CANCEL) { - return; - } - tag[0] = dialog.getResult(); - recurse[0] = dialog.getRecursive(); - - // For non-projects determine if the tag being loaded is the same as the resource's parent - // If it's not, warn the user that they will have strange sync behavior - try { - if(!CVSAction.checkForMixingTags(getShell(), resources[0], tag[0])) { - tag[0] = null; - return; - } - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); //$NON-NLS-1$ - - if (resources[0] == null || resources[0].length == 0 || tag[0] == null) return; - - // Peform the replace in the background - new ReplaceOperation(getTargetPart(), resources[0], tag[0], recurse[0]).run(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("ReplaceWithTagAction.replace"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java deleted file mode 100644 index 1c9c95e02..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.ResizableWizardDialog; -import org.eclipse.team.internal.ccvs.ui.wizards.RestoreFromRepositoryWizard; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class RestoreFromRepositoryAction extends CVSAction { - - /* - * This class handles the output from "cvs log -R ..." where -R - * indicates that only the RCS file name is to be returned. Files - * that have been deleted will be in the Attic. The Attic may also - * contains files that exist on a branch but not in HEAD - */ - class AtticLogListener extends CommandOutputListener { - private static final String ATTIC = "Attic"; //$NON-NLS-1$ - private static final String RCS_FILE_POSTFIX = ",v"; //$NON-NLS-1$ - private static final String LOGGING_PREFIX = "Logging "; //$NON-NLS-1$ - ICVSFolder currentFolder; - List atticFiles = new ArrayList(); - - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Find all RCS file names that contain "Attic" - int index = line.indexOf(ATTIC); - if (index == -1) return OK; - // Extract the file name and path from the RCS path - // String filePath = line.substring(index); - int start = line.indexOf(Session.SERVER_SEPARATOR, index); - String fileName = line.substring(start + 1); - if (fileName.endsWith(RCS_FILE_POSTFIX)) { - fileName = fileName.substring(0, fileName.length() - RCS_FILE_POSTFIX.length()); - } - try { - atticFiles.add(currentFolder.getFile(fileName)); - } catch (CVSException e) { - return e.getStatus(); - } - return OK; - } - - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - CVSRepositoryLocation repo = (CVSRepositoryLocation)location; - String folderPath = repo.getServerMessageWithoutPrefix(line, SERVER_PREFIX); - if (folderPath != null) { - if (folderPath.startsWith(LOGGING_PREFIX)) { - folderPath = folderPath.substring(LOGGING_PREFIX.length()); - try { - currentFolder = commandRoot.getFolder(folderPath); - } catch (CVSException e) { - return e.getStatus(); - } - return OK; - } - } - return super.errorLine(line, location, commandRoot, monitor); - } - - public ICVSFile[] getAtticFilePaths() { - return (ICVSFile[]) atticFiles.toArray(new ICVSFile[atticFiles.size()]); - } - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - IContainer resource = (IContainer)getSelectedResources()[0]; - ICVSFile[] files = fetchDeletedFiles(resource); - if (files == null) return; - if (files.length == 0) { - MessageDialog.openInformation(getShell(), Policy.bind("RestoreFromRepositoryAction.noFilesTitle"), Policy.bind("RestoreFromRepositoryAction.noFilesMessage", resource.getName())); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - RestoreFromRepositoryWizard wizard = new RestoreFromRepositoryWizard(resource, files); - WizardDialog dialog = new ResizableWizardDialog(shell, wizard); - dialog.setMinimumPageSize(350, 250); - dialog.open(); - } - - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - IResource[] resources = getSelectedResources(); - if (resources.length != 1) return false; - if (resources[0].getType() == IResource.FILE) return false; - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resources[0]); - if (!folder.isCVSFolder()) return false; - return true; - } - - private ICVSFile[] fetchDeletedFiles(final IContainer parent) { - final ICVSFile[][] files = new ICVSFile[1][0]; - files[0] = null; - try { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(parent); - FolderSyncInfo info = folder.getFolderSyncInfo(); - ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); - files[0] = fetchFilesInAttic(location, folder, monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }, true, PROGRESS_DIALOG); - } catch (InvocationTargetException e) { - handle(e); - } catch (InterruptedException e) { - return null; - } - return files[0]; - } - - /* - * Fetch the RCS paths (minus the Attic segment) of all files in the Attic. - * This path includes the repository root path. - */ - private ICVSFile[] fetchFilesInAttic(ICVSRepositoryLocation location, ICVSFolder parent, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - AtticLogListener listener = new AtticLogListener(); - Session session = new Session(location, parent, true /* output to console */); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); - try { - CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); - IStatus status = Command.LOG.execute( - session, - Command.NO_GLOBAL_OPTIONS, - new LocalOption[] { Log.RCS_FILE_NAMES_ONLY }, - new ICVSResource[] { parent }, listener, - Policy.subMonitorFor(monitor, 90)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - } finally { - CVSProviderPlugin.getPlugin().setQuietness(quietness); - monitor.done(); - } - } finally { - session.close(); - } - return listener.getAtticFilePaths(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java deleted file mode 100644 index dffb82f44..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.ui.ResizableWizardDialog; -import org.eclipse.team.internal.ccvs.ui.wizards.KSubstWizard; - -/** - * TagAction tags the selected resources with a version tag specified by the user. - */ -public class SetKeywordSubstitutionAction extends WorkspaceAction { - private KSubstOption previousOption = null; // automatic - - /* - * @see IActionDelegate#run(IAction) - */ - public void execute(IAction action) { - final IResource[] resources = getSelectedResources(); - KSubstWizard wizard = new KSubstWizard(resources, IResource.DEPTH_INFINITE, previousOption); - WizardDialog dialog = new ResizableWizardDialog(getShell(), wizard); - wizard.setParentDialog(dialog); - dialog.setMinimumPageSize(350, 250); - dialog.open(); - previousOption = wizard.getKSubstOption(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java deleted file mode 100644 index e7e190b74..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ShowAnnotationOperation; - -public class ShowAnnotationAction extends WorkspaceAction { - - /** - * Action to open a CVS Annotate View - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - final ICVSResource resource= getSingleSelectedCVSResource(); - if (resource == null) - return; - execute(resource); - } - - /** - * Fetch the revision number of a CVS resource and perform a ShowAnnotationOperation - * in the background. - * - * @param cvsResource The CVS resource (must not be null) - * - * @throws InvocationTargetException - * @throws InterruptedException - */ - public void execute(final ICVSResource cvsResource) throws InvocationTargetException, InterruptedException { - final String revision= getRevision(cvsResource); - if (revision == null) - return; - boolean binary = isBinary(cvsResource); - if (binary) { - if (!MessageDialog.openQuestion(getShell(), Policy.bind("ShowAnnotationAction.2"), Policy.bind("ShowAnnotationAction.3", cvsResource.getName()))) { //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } - new ShowAnnotationOperation(getTargetPart(), cvsResource, revision, binary).run(); - } - - private boolean isBinary(ICVSResource cvsResource) { - if (cvsResource.isFolder()) return false; - try { - byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes(); - if (syncBytes == null) - return false; - return ResourceSyncInfo.isBinary(syncBytes); - } catch (CVSException e) { - return false; - } - } - - /** - * Ony enabled for single resource selection - */ - protected boolean isEnabled() throws TeamException { - ICVSResource resource = getSingleSelectedCVSResource(); - return (resource != null && ! resource.isFolder() && resource.isManaged()); - } - - /** - * This action is called from one of a Resource Navigator a CVS Resource - * Navigator or a History Log Viewer. Return the selected resource as an - * ICVSResource - * - * @return ICVSResource - */ - private ICVSResource getSingleSelectedCVSResource() { - // Selected from a CVS Resource Navigator - final ICVSResource[] cvsResources = getSelectedCVSResources(); - if (cvsResources.length == 1) { - return cvsResources[0]; - } - - // Selected from a History Viewer - final Object[] logEntries = getSelectedResources(LogEntry.class); - if (logEntries.length == 1) { - final LogEntry aLogEntry = (LogEntry) logEntries[0]; - final ICVSRemoteFile cvsRemoteFile = aLogEntry.getRemoteFile(); - return cvsRemoteFile; - } - - // Selected from a Resource Navigator - final IResource[] resources = getSelectedResources(); - if (resources.length == 1) { - return CVSWorkspaceRoot.getCVSResourceFor(resources[0]); - } - return null; - } - - - /** - * Get the revision for the CVS resource. Throws an InvocationTargetException - * if the revision could not be determined. - * - * @param cvsResource The CVS resource - * @return The revision of the resource. - * @throws InvocationTargetException - */ - private String getRevision(ICVSResource cvsResource) throws InvocationTargetException { - final ResourceSyncInfo info; - try { - info= cvsResource.getSyncInfo(); - if (info == null) - throw new CVSException(Policy.bind("ShowAnnotationAction.noSyncInfo", cvsResource.getName())); //$NON-NLS-1$ - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - return info.getRevision(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowCVSPerspectiveAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowCVSPerspectiveAction.java deleted file mode 100644 index 53e039ab4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowCVSPerspectiveAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -public class ShowCVSPerspectiveAction extends Action { - public void run() { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow(); - if (activeWindow == null) { - return; - } - IWorkbenchPage activePage = activeWindow.getActivePage(); - if (activePage == null) { - return; - } - IPerspectiveDescriptor cvsPerspective = workbench.getPerspectiveRegistry().findPerspectiveWithId("org.eclipse.team.cvs.ui.cvsPerspective"); //$NON-NLS-1$ - if(cvsPerspective!=null) { - activePage.setPerspective(cvsPerspective); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java deleted file mode 100644 index 92624cfe8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003 CSC SoftwareConsult GmbH & Co. OHG, Germany and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * CSC - Intial implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ccvs.core.EditorsInfo; -import org.eclipse.team.internal.ccvs.ui.EditorsView; -/** - * - * - * Action for Show Editors in popup menus - * - * @author Gregor Kohlwes - * - */ -public class ShowEditorsAction extends WorkspaceAction { - - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - final EditorsAction editorsAction = new EditorsAction(); - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - executeProviderAction(editorsAction, monitor); - } - }, true /* cancelable */ , PROGRESS_DIALOG); - EditorsInfo[] infos = editorsAction.getEditorsInfo(); - EditorsView view = (EditorsView)showView(EditorsView.VIEW_ID); - if (view != null) { - view.setInput(infos); - } - - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() - */ - protected boolean isEnabledForMultipleResources() { - // We support one selected Resource, - // because the editors command will - // show the editors of all children too. - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java deleted file mode 100644 index 47a88521a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.ui.HistoryView; -import org.eclipse.team.internal.ccvs.ui.Policy; - -public class ShowHistoryAction extends CVSAction { - /** - * Returns the selected remote files - */ - protected ICVSRemoteFile[] getSelectedRemoteFiles() { - ArrayList resources = null; - if (!selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - if (next instanceof ICVSRemoteFile) { - resources.add(next); - continue; - } - if (next instanceof IAdaptable) { - IAdaptable a = (IAdaptable)next; - Object adapter = a.getAdapter(ICVSRemoteFile.class); - if (adapter instanceof ICVSRemoteFile) { - resources.add(adapter); - continue; - } - } - } - } - if (resources != null && !resources.isEmpty()) { - ICVSRemoteFile[] result = new ICVSRemoteFile[resources.size()]; - resources.toArray(result); - return result; - } - return new ICVSRemoteFile[0]; - } - /* - * @see CVSAction#executeIAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - ICVSRemoteFile[] files = getSelectedRemoteFiles(); - HistoryView view = (HistoryView)showView(HistoryView.VIEW_ID); - if (view != null) { - view.showHistory(files[0], true /* refetch */); - } - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - } - /* - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSRemoteFile[] resources = getSelectedRemoteFiles(); - return resources.length == 1; - } - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("ShowHistoryAction.showHistory"); //$NON-NLS-1$ - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java deleted file mode 100644 index dbd91c537..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.HistoryView; -import org.eclipse.team.internal.ccvs.ui.Policy; - -public class ShowResourceInHistoryAction extends WorkspaceAction { - /* - * @see IActionDelegate#run(IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - IResource[] resources = getSelectedResources(); - if (resources.length != 1) return; - HistoryView view = (HistoryView)showView(HistoryView.VIEW_ID); - if (view != null) { - view.showHistory(resources[0], true /* fetch */); - } - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("ShowHistoryAction.showHistory"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() - */ - protected boolean isEnabledForMultipleResources() { - return false; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - return (!cvsResource.isFolder() && super.isEnabledForCVSResource(cvsResource)); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java deleted file mode 100644 index 14acbc3b1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.CompareUI; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.PlatformUI; - -/** - * Action to initiate a CVS workspace synchronize - */ -public class SyncAction extends WorkspaceAction { - - public void execute(IAction action) throws InvocationTargetException { - final IResource[] resources = getResourcesToSync(); - if (resources == null || resources.length == 0) return; - - if(isSingleFile(resources)) { - showSingleFileComparison(getShell(), CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), resources[0]); - } else { - // First check if there is an existing matching participant - WorkspaceSynchronizeParticipant participant = (WorkspaceSynchronizeParticipant)SubscriberParticipant.getMatchingParticipant(WorkspaceSynchronizeParticipant.ID, resources); - // If there isn't, create one and add to the manager - if (participant == null) { - participant = new WorkspaceSynchronizeParticipant(new ResourceScope(resources)); - TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); - } - participant.refresh(resources, getTargetPart().getSite()); - } - } - - /** - * Refresh the subscriber directly and show the resulting synchronization state in a compare editor. If there - * is no difference the user is prompted. - * - * @param resources the file to refresh and compare - */ - public static void showSingleFileComparison(final Shell shell, final Subscriber subscriber, final IResource resource) { - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - subscriber.refresh(new IResource[]{resource}, IResource.DEPTH_ZERO, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - final SyncInfo info = subscriber.getSyncInfo(resource); - if (info == null) return; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - if (info.getKind() == SyncInfo.IN_SYNC) { - MessageDialog.openInformation(shell, Policy.bind("SyncAction.noChangesTitle"), Policy.bind("SyncAction.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - SyncInfoCompareInput input = new SyncInfoCompareInput(subscriber.getName(), info); - CompareUI.openCompareEditor(input); - } - } - }); - } catch (InvocationTargetException e) { - Utils.handle(e); - } catch (InterruptedException e) { - } catch (TeamException e) { - Utils.handle(e); - } - } - - public static boolean isSingleFile(IResource[] resources) { - return resources.length == 1 && resources[0].getType() == IResource.FILE; - } - - protected IResource[] getResourcesToSync() { - return getSelectedResources(); - } - - /** - * Enable for resources that are managed (using super) or whose parent is a - * CVS folder. - * - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - return (super.isEnabledForCVSResource(cvsResource) || (cvsResource.getParent().isCVSFolder() && !cvsResource.isIgnored())); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java deleted file mode 100644 index 92a610bda..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.window.Window; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.tags.TagAsVersionDialog; - -/** - * TagAction tags the selected resources with a version tag specified by the user. - */ -public abstract class TagAction extends WorkspaceAction { - - // remember if the execute action was cancelled - private boolean wasCancelled = false; - - /** - * @see CVSAction#execute(IAction) - */ - public void execute(IAction action) throws InvocationTargetException, InterruptedException { - setWasCancelled(false); - if (!performPrompting()) { - setWasCancelled(true); - return; - } - - // Prompt for the tag name - final ITagOperation[] result = new ITagOperation[1]; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = configureOperation(); - if (result[0] == null) { - return; - } - }}); - - if (result[0] == null) { - setWasCancelled(true); - return; - } - - result[0].run(); - } - - protected boolean performPrompting() { - return true; - } - - /** - * Prompts the user for a tag name. - * Note: This method is designed to be overridden by test cases. - * @return the operation, or null to cancel - */ - protected ITagOperation configureOperation() { - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - ITagOperation operation = createTagOperation(); - if (operation.getCVSResources().length == 0) { - return null; - } - TagAsVersionDialog dialog = new TagAsVersionDialog(getShell(), - Policy.bind("TagAction.tagResources"), //$NON-NLS-1$ - operation); - if (dialog.open() != Window.OK) return null; - - // The user has indicated they want to force a move. Make sure they really do. - if (dialog.shouldMoveTag() && store.getBoolean(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG)) { - MessageDialogWithToggle confirmDialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), - Policy.bind("TagAction.moveTagConfirmTitle"), //$NON-NLS-1$ - Policy.bind("TagAction.moveTagConfirmMessage", dialog.getTagName()), //$NON-NLS-1$ - null, - false, - null, - null); - - if (confirmDialog.getReturnCode() == IDialogConstants.YES_ID) { - store.setValue(ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, !confirmDialog.getToggleState()); - } else { - return null; - } - } - - // The user is a cowboy and wants to do it. - return dialog.getOperation(); - } - - protected abstract ITagOperation createTagOperation(); - - protected String getErrorTitle() { - return Policy.bind("TagAction.tagErrorTitle"); //$NON-NLS-1$ - } - - protected String getWarningTitle() { - return Policy.bind("TagAction.tagWarningTitle"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - public boolean wasCancelled() { - return wasCancelled; - } - - public void setWasCancelled(boolean b) { - wasCancelled = b; - } - - public static void broadcastTagChange(final ICVSResource[] resources, final CVSTag tag) throws InvocationTargetException, InterruptedException { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - try { - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - // Cache the new tag creation even if the tag may have had warnings. - manager.addTags(getRootParent(resource), new CVSTag[] {tag}); - } - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - private ICVSResource getRootParent(ICVSResource resource) throws CVSException { - if (!resource.isManaged()) return resource; - ICVSFolder parent = resource.getParent(); - if (parent == null) return resource; - // Special check for a parent which is the repository itself - if (parent.getName().length() == 0) return resource; - return getRootParent(parent); - } - }, new NullProgressMonitor()); - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java deleted file mode 100644 index 14bd56d53..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.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.team.internal.ccvs.ui.actions; - -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; -import org.eclipse.team.internal.ccvs.ui.operations.TagInRepositoryOperation; - -public class TagInRepositoryAction extends TagAction { - - /** - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - ICVSResource[] resources = getSelectedCVSResources(); - if (resources.length == 0) return false; - for (int i = 0; i < resources.length; i++) { - if (resources[i] instanceof ICVSRepositoryLocation) return false; - } - return true; - } - - /** - * @see CVSAction#needsToSaveDirtyEditors() - */ - protected boolean needsToSaveDirtyEditors() { - return false; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#requiresLocalSyncInfo() - */ - protected boolean requiresLocalSyncInfo() { - return false; - } - - protected ITagOperation createTagOperation() { - return new TagInRepositoryOperation(getTargetPart(), getSelectedRemoteResources()); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java deleted file mode 100644 index 5f0a41f27..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.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.team.internal.ccvs.ui.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; -import org.eclipse.team.internal.ccvs.ui.operations.TagOperation; -import org.eclipse.team.internal.ui.dialogs.IPromptCondition; -import org.eclipse.team.internal.ui.dialogs.PromptingDialog; - -public class TagLocalAction extends TagAction { - - IResource[] resources; - - protected boolean performPrompting() { - // Prompt for any uncommitted changes - PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(), - getPromptCondition(), Policy.bind("TagAction.uncommittedChangesTitle"));//$NON-NLS-1$ - try { - resources = prompt.promptForMultiple(); - } catch(InterruptedException e) { - return false; - } - if(resources.length == 0) { - // nothing to do - return false; - } - - return true; - } - - protected ITagOperation createTagOperation() { - return new TagOperation(getTargetPart(), resources); - } - - /** - * Note: This method is designed to be overridden by test cases. - */ - protected IPromptCondition getPromptCondition() { - return new IPromptCondition() { - public boolean needsPrompt(IResource resource) { - return CVSLightweightDecorator.isDirty(resource); - } - public String promptMessage(IResource resource) { - return Policy.bind("TagAction.uncommittedChanges", resource.getName());//$NON-NLS-1$ - } - }; - } - - /** - * Return the resources that have been selected by the user. The user has been given - * a chance to remove any resources with outgoing changes so all provided resources - * are to be tagged. - * @return Returns the resources. - */ - protected IResource[] getResources() { - return resources; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UneditAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UneditAction.java deleted file mode 100644 index 2c5ac01f8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UneditAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.core.Team; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -public class UneditAction extends WorkspaceAction { - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - - if(! MessageDialog.openConfirm(getShell(), Policy.bind("Uneditaction.confirmTitle"), Policy.bind("Uneditaction.confirmMessage"))) { //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - - run(new WorkspaceModifyOperation(null) { - public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - executeProviderAction(new IProviderAction() { - public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { - provider.unedit(resources, false /* recurse */, true /* notify server */, monitor); - return Team.OK_STATUS; - } - }, monitor); - } - }, true /* cancelable */, PROGRESS_DIALOG); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - if (cvsResource.isFolder()) return false; - if (super.isEnabledForCVSResource(cvsResource)) { - return !((ICVSFile)cvsResource).isReadOnly() && ((ICVSFile)cvsResource).isEdited(); - } else { - return false; - } - } - - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java deleted file mode 100644 index 61badd0fe..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.DisconnectOperation; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Unmanage action removes the cvs feature from a project and optionally - * deletes the CVS meta information that is stored on disk. - */ -public class UnmanageAction extends WorkspaceAction { - - static class DeleteProjectDialog extends MessageDialog { - - boolean deleteContent = false; - Button radio1; - Button radio2; - - DeleteProjectDialog(Shell parentShell, IProject[] projects) { - super( - parentShell, - getTitle(projects), - null, // accept the default window icon - getMessage(projects), - MessageDialog.QUESTION, - new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, - 0); // yes is the default - } - - static String getTitle(IProject[] projects) { - if (projects.length == 1) - return Policy.bind("Unmanage.title"); //$NON-NLS-1$ - else - return Policy.bind("Unmanage.titleN"); //$NON-NLS-1$ - } - - static String getMessage(IProject[] projects) { - if (projects.length == 1) { - IProject project = projects[0]; - return Policy.bind("Unmanage.message", project.getName()); //$NON-NLS-1$ - } - else { - return Policy.bind("Unmanage.messageN", new Integer(projects.length).toString()); //$NON-NLS-1$ - } - } - - protected Control createCustomArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - radio1 = new Button(composite, SWT.RADIO); - radio1.addSelectionListener(selectionListener); - - radio1.setText(Policy.bind("Unmanage.option2")); //$NON-NLS-1$ - - radio2 = new Button(composite, SWT.RADIO); - radio2.addSelectionListener(selectionListener); - - radio2.setText(Policy.bind("Unmanage.option1")); //$NON-NLS-1$ - - // set initial state - radio1.setSelection(deleteContent); - radio2.setSelection(!deleteContent); - - WorkbenchHelp.setHelp(composite, IHelpContextIds.DISCONNECT_ACTION); - - return composite; - } - - private SelectionListener selectionListener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - Button button = (Button) e.widget; - if (button.getSelection()) { - deleteContent = (button == radio1); - } - } - }; - - public boolean getDeleteContent() { - return deleteContent; - } - } - - private boolean deleteContent = false; - - /* - * @see IActionDelegate#run(IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - if(confirmDeleteProjects()) { - new DisconnectOperation(getTargetPart(), getSelectedProjects(), deleteContent) - .run(); - } - } - - boolean confirmDeleteProjects() { - final int[] result = new int[] { MessageDialog.OK }; - IProject[] projects = getSelectedProjects(); - final DeleteProjectDialog dialog = new DeleteProjectDialog(shell, projects); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - } - }); - deleteContent = dialog.getDeleteContent(); - return result[0] == 0; // YES - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("Unmanage.unmanagingError");//$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - IResource resource = cvsResource.getIResource(); - return resource != null && resource.getType() == IResource.PROJECT; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java deleted file mode 100644 index 758d4e8f2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.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.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.internal.ccvs.ui.wizards.UpdateWizard; - -/** - * UpdateAction performs a 'cvs update' command on the selected resources. - * If conflicts are present (file has been changed both remotely and locally), - * the changes will be merged into the local file such that the user must - * resolve the conflicts. This action is temporary code; it will be removed - * when a functional synchronize view has been implemented. - */ -public class UpdateAction extends WorkspaceAction { - /* - * @see IActionDelegate#run(IAction) - */ - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - UpdateWizard wizard = new UpdateWizard(getTargetPart(), getSelectedResources()); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.open(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() - */ - protected boolean isEnabledForAddedResources() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() - */ - protected boolean isEnabledForNonExistantResources() { - return true; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java deleted file mode 100644 index ba1e4af31..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; - -/** - * Action that runs an update without prompting the user for a tag. - * - * @since 3.1 - */ -public class UpdateSilentAction extends UpdateAction { - public void execute(IAction action) throws InterruptedException, InvocationTargetException { - new UpdateOperation(getTargetPart(), getSelectedResources(), Command.NO_LOCAL_OPTIONS, null /* no tag */).run(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java deleted file mode 100644 index 0970263b0..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java +++ /dev/null @@ -1,616 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.dialogs.IPromptCondition; -import org.eclipse.team.internal.ui.dialogs.PromptingDialog; - -/** - * This class represents an action performed on a local CVS workspace - */ -public abstract class WorkspaceAction extends CVSAction { - - public interface IProviderAction { - public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#beginExecution(IAction) - */ - protected boolean beginExecution(IAction action) throws TeamException { - if (super.beginExecution(action)) { - // Ensure that the required sync info is loaded - if (requiresLocalSyncInfo()) { - // There is a possibility of the selection containing an orphaned subtree. - // If it does, they will be purged and enablement rechecked before the - // operation is performed. - handleOrphanedSubtrees(); - // Check enablement just in case the sync info wasn't loaded - if (!isEnabled()) { - MessageDialog.openInformation(getShell(), Policy.bind("CVSAction.disabledTitle"), Policy.bind("CVSAction.disabledMessage")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - } - return true; - } else { - return false; - } - } - - /* - * Determine if any of the selected resources are deascendants of - * an orphaned CVS subtree and if they are, purge the CVS folders. - */ - private boolean handleOrphanedSubtrees() { - // invoke the inherited method so that overlaps are maintained - IResource[] resources = getSelectedResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - handleOrphanedSubtree(resource); - } - return false; - } - - /* - * Determine if the resource is a descendant of an orphaned subtree. - * If it is, purge the CVS folders of the subtree. - */ - private void handleOrphanedSubtree(IResource resource) { - try { - if (!CVSWorkspaceRoot.isSharedWithCVS(resource)) return ; - ICVSFolder folder; - if (resource.getType() == IResource.FILE) { - folder = CVSWorkspaceRoot.getCVSFolderFor(resource.getParent()); - } else { - folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource); - } - handleOrphanedSubtree(folder); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - } - - /* - * Recursively check for and handle orphaned CVS folders - */ - private void handleOrphanedSubtree(final ICVSFolder folder) throws CVSException { - if (folder.getIResource().getType() == IResource.PROJECT) return; - if (CVSWorkspaceRoot.isOrphanedSubtree((IContainer)folder.getIResource())) { - try { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - folder.unmanage(null); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } - } - }, true, PROGRESS_BUSYCURSOR); - } catch (InvocationTargetException e) { - // Ignore this since we logged the one we care about above - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - } - handleOrphanedSubtree(folder.getParent()); - } - - /** - * Return true if the sync info is loaded for all selected resources. - * The purpose of this method is to allow enablement code to be as fast - * as possible. If the sync info is not loaded, the menu should be enabled - * and, if choosen, the action will verify that it is indeed enabled before - * performing the associated operation - */ - protected boolean isSyncInfoLoaded(IResource[] resources) throws CVSException { - return EclipseSynchronizer.getInstance().isSyncInfoLoaded(resources, getEnablementDepth()); - } - - /** - * Returns the resource depth of the action for use in determining if the required - * sync info is loaded. The default is IResource.DEPTH_INFINITE. Sunclasses can override - * as required. - */ - protected int getActionDepth() { - return IResource.DEPTH_INFINITE; - } - - /** - * Returns the resource depth of the action enablement for use in determining if the required - * sync info is loaded. The default is IResource.DEPTH_ZERO. Sunclasses can override - * as required. - */ - protected int getEnablementDepth() { - return IResource.DEPTH_ZERO; - } - - /** - * Ensure that the sync info for all the provided resources has been loaded. - * If an out-of-sync resource is found, prompt to refresh all the projects involved. - */ - protected boolean ensureSyncInfoLoaded(IResource[] resources) throws CVSException { - boolean keepTrying = true; - while (keepTrying) { - try { - EclipseSynchronizer.getInstance().ensureSyncInfoLoaded(resources, getActionDepth()); - keepTrying = false; - } catch (CVSException e) { - if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { - // determine the projects of the resources involved - Set projects = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - projects.add(resource.getProject()); - } - // prompt to refresh - if (promptToRefresh(getShell(), (IResource[]) projects.toArray(new IResource[projects.size()]), e.getStatus())) { - for (Iterator iter = projects.iterator();iter.hasNext();) { - IProject project = (IProject) iter.next(); - try { - project.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException coreException) { - throw CVSException.wrapException(coreException); - } - } - } else { - return false; - } - } else { - throw e; - } - } - } - return true; - } - - /** - * Override to ensure that the sync info is available before performing the - * real isEnabled() test. - * - * @see org.eclipse.team.internal.ui.actions.TeamAction#setActionEnablement(IAction) - */ - protected void setActionEnablement(IAction action) { - try { - boolean requires = requiresLocalSyncInfo(); - if (!requires || (requires && isSyncInfoLoaded(getSelectedResources()))) { - super.setActionEnablement(action); - } else { - // If the sync info is not loaded, enable the menu item - // Performing the action will ensure that the action should really - // be enabled before anything else is done - action.setEnabled(true); - } - } catch (CVSException e) { - // We couldn't determine if the sync info was loaded. - // Enable the action so that performing the action will - // reveal the error to the user. - action.setEnabled(true); - } - } - - /** - * Return true if the action requires the sync info for the selected resources. - * If the sync info is required, the real enablement code will only be run if - * the sync info is loaded from disc. Otherwise, the action is enabled and - * performing the action will load the sync info and verify that the action is truely - * enabled before doing anything else. - * - * This implementation returns true. Subclasses must override if they do - * not require the sync info of the selected resources. - * - * @return boolean - */ - protected boolean requiresLocalSyncInfo() { - return true; - } - - protected boolean promptToRefresh(final Shell shell, final IResource[] resources, final IStatus status) { - final boolean[] result = new boolean[] { false}; - Runnable runnable = new Runnable() { - public void run() { - Shell shellToUse = shell; - if (shell == null) { - shellToUse = new Shell(Display.getCurrent()); - } - String question; - if (resources.length == 1) { - question = Policy.bind("CVSAction.refreshQuestion", status.getMessage(), resources[0].getFullPath().toString()); //$NON-NLS-1$ - } else { - question = Policy.bind("CVSAction.refreshMultipleQuestion", status.getMessage()); //$NON-NLS-1$ - } - result[0] = MessageDialog.openQuestion(shellToUse, Policy.bind("CVSAction.refreshTitle"), question); //$NON-NLS-1$ - } - }; - Display.getDefault().syncExec(runnable); - return result[0]; - } - - /** - * Most CVS workspace actions modify the workspace and thus should - * save dirty editors. - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#needsToSaveDirtyEditors() - */ - protected boolean needsToSaveDirtyEditors() { - return true; - } - - /** - * The action is enabled for the appropriate resources. This method checks - * that: - *
                - *
              1. there is no overlap between a selected file and folder (overlapping - * folders is allowed because of logical vs. physical mapping problem in - * views) - *
              2. the state of the resources match the conditions provided by: - *
                  - *
                • isEnabledForIgnoredResources() - *
                • isEnabledForManagedResources() - *
                • isEnabledForUnManagedResources() (i.e. not ignored and not managed) - *
                - *
              - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - - // invoke the inherited method so that overlaps are maintained - IResource[] resources = super.getSelectedResources(); - - // disable if no resources are selected - if(resources.length==0) return false; - - // disable properly for single resource enablement - if (!isEnabledForMultipleResources() && resources.length != 1) return false; - - // validate enabled for each resource in the selection - List folderPaths = new ArrayList(); - List filePaths = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - - // only enable for accessible resources - if(resource.getType() == IResource.PROJECT) { - if (! resource.isAccessible()) return false; - } - - // no CVS actions are enabled if the selection contains a linked resource - if (CVSWorkspaceRoot.isLinkedResource(resource)) return false; - - // only enable for resources in a project shared with CVS - if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) { - return false; - } - - // collect files and folders separately to check for overlap later - IPath resourceFullPath = resource.getFullPath(); - if(resource.getType() == IResource.FILE) { - filePaths.add(resourceFullPath); - } else { - folderPaths.add(resourceFullPath); - } - - // ensure that resource management state matches what the action requires - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (!isEnabledForCVSResource(cvsResource)) { - return false; - } - } - // Ensure that there is no overlap between files and folders - // NOTE: folder overlap must be allowed because of logical vs. physical - if(!folderPaths.isEmpty()) { - for (Iterator fileIter = filePaths.iterator(); fileIter.hasNext();) { - IPath resourcePath = (IPath) fileIter.next(); - for (Iterator it = folderPaths.iterator(); it.hasNext();) { - IPath folderPath = (IPath) it.next(); - if (folderPath.isPrefixOf(resourcePath)) { - return false; - } - } - } - } - return true; - } - - /** - * Method isEnabledForCVSResource. - * @param cvsResource - * @return boolean - */ - protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { - boolean managed = false; - boolean ignored = false; - boolean added = false; - if (cvsResource.isIgnored()) { - ignored = true; - } else if (cvsResource.isFolder()) { - managed = ((ICVSFolder)cvsResource).isCVSFolder(); - } else { - ResourceSyncInfo info = cvsResource.getSyncInfo(); - managed = info != null; - if (managed) added = info.isAdded(); - } - if (managed && ! isEnabledForManagedResources()) return false; - if ( ! managed && ! isEnabledForUnmanagedResources()) return false; - if ( ignored && ! isEnabledForIgnoredResources()) return false; - if (added && ! isEnabledForAddedResources()) return false; - if ( ! cvsResource.exists() && ! isEnabledForNonExistantResources()) return false; - return true; - } - - /** - * Method isEnabledForIgnoredResources. - * @return boolean - */ - protected boolean isEnabledForIgnoredResources() { - return false; - } - - /** - * Method isEnabledForUnmanagedResources. - * @return boolean - */ - protected boolean isEnabledForUnmanagedResources() { - return false; - } - - /** - * Method isEnabledForManagedResources. - * @return boolean - */ - protected boolean isEnabledForManagedResources() { - return true; - } - - /** - * Method isEnabledForAddedResources. - * @return boolean - */ - protected boolean isEnabledForAddedResources() { - return true; - } - - /** - * Method isEnabledForAddedResources. - * @return boolean - */ - protected boolean isEnabledForMultipleResources() { - return true; - } - - /** - * Method isEnabledForNonExistantResources. - * @return boolean - */ - protected boolean isEnabledForNonExistantResources() { - return false; - } - - /** - * Method getNonOverlapping ensures that a resource is not covered more than once. - * @param resources - * @return IResource[] - */ - public static IResource[] getNonOverlapping(IResource[] resources) { - // Sort the resources so the shortest paths are first - List sorted = new ArrayList(); - sorted.addAll(Arrays.asList(resources)); - Collections.sort(sorted, new Comparator() { - public int compare(Object arg0, Object arg1) { - IResource resource0 = (IResource) arg0; - IResource resource1 = (IResource) arg1; - return resource0.getFullPath().segmentCount() - resource1.getFullPath().segmentCount(); - } - public boolean equals(Object arg0) { - return false; - } - }); - // Collect all non-overlapping resources - List coveredPaths = new ArrayList(); - for (Iterator iter = sorted.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - IPath resourceFullPath = resource.getFullPath(); - boolean covered = false; - for (Iterator it = coveredPaths.iterator(); it.hasNext();) { - IPath path = (IPath) it.next(); - if(path.isPrefixOf(resourceFullPath)) { - covered = true; - } - } - if (covered) { - // if the resource is covered by a parent, remove it - iter.remove(); - } else { - // if the resource is a non-covered folder, add it to the covered paths - if (resource.getType() == IResource.FOLDER) { - coveredPaths.add(resource.getFullPath()); - } - } - } - return (IResource[]) sorted.toArray(new IResource[sorted.size()]); - } - - /** - * Override to ensure that the selected resources so not overlap. - * This method assumes that all actions are deep. - * - * @see org.eclipse.team.internal.ui.actions.TeamAction#getSelectedResources() - */ - protected IResource[] getSelectedResources() { - return getNonOverlapping(super.getSelectedResources()); - } - - protected void executeProviderAction(IProviderAction action, IResource[] resources, IProgressMonitor monitor) throws InvocationTargetException { - Hashtable table = getProviderMapping(resources); - Set keySet = table.keySet(); - monitor.beginTask(null, keySet.size() * 1000); - Iterator iterator = keySet.iterator(); - - while (iterator.hasNext()) { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); - CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); - List list = (List)table.get(provider); - IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); - try { - addStatus(action.execute(provider, providerResources, subMonitor)); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - - } - } - - protected void executeProviderAction(IProviderAction action, IProgressMonitor monitor) throws InvocationTargetException { - executeProviderAction(action, getSelectedResources(), monitor); - } - - /** - * Given the current selection this method returns a text label that can - * be shown to the user that reflects the tags in the current selection. - * These can be used in the Compare With and Replace With actions. - */ - protected String calculateActionTagValue() { - try { - IResource[] resources = getSelectedResources(); - CVSTag commonTag = null; - boolean sameTagType = true; - boolean multipleSameNames = true; - - for (int i = 0; i < resources.length; i++) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - CVSTag tag = null; - if(cvsResource.isFolder()) { - FolderSyncInfo info = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - if(info != null) { - tag = info.getTag(); - } - if (tag != null && tag.getType() == CVSTag.BRANCH) { - tag = Util.getAccurateFolderTag(resources[i], tag); - } - } else { - tag = Util.getAccurateFileTag(cvsResource); - } - if(tag == null) { - tag = new CVSTag(); - } - if(commonTag == null) { - commonTag = tag; - } else if(!commonTag.equals(tag)) { - if(commonTag.getType() != tag.getType()) { - sameTagType = false; - } - if(!commonTag.getName().equals(tag.getName())) { - multipleSameNames = false; - } - } - } - - // set text to default - String actionText = Policy.bind("ReplaceWithLatestAction.multipleTags"); //$NON-NLS-1$ - if(commonTag != null) { - int tagType = commonTag.getType(); - String tagName = commonTag.getName(); - // multiple tag names but of the same type - if(sameTagType && !multipleSameNames) { - if(tagType == CVSTag.BRANCH) { - actionText = Policy.bind("ReplaceWithLatestAction.multipleBranches"); //$NON-NLS-1$ - } else { - actionText = Policy.bind("ReplaceWithLatestAction.multipleVersions"); //$NON-NLS-1$ - } - // same tag names and types - } else if(sameTagType && multipleSameNames) { - if(tagType == CVSTag.BRANCH) { - actionText = Policy.bind("ReplaceWithLatestAction.singleBranch", tagName); //$NON-NLS-1$ - } else if(tagType == CVSTag.VERSION){ - actionText = Policy.bind("ReplaceWithLatestAction.singleVersion", tagName); //$NON-NLS-1$ - } else if(tagType == CVSTag.HEAD) { - actionText = Policy.bind("ReplaceWithLatestAction.singleHEAD", tagName); //$NON-NLS-1$ - } - } - } - - return actionText; - } catch (CVSException e) { - // silently ignore - return Policy.bind("ReplaceWithLatestAction.multipleTags"); //$NON-NLS-1$ - } - } - - protected IResource[] checkOverwriteOfDirtyResources(IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException { - List dirtyResources = new ArrayList(); - IResource[] selectedResources = getSelectedResources(); - - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, selectedResources.length * 100); - monitor.setTaskName(Policy.bind("ReplaceWithAction.calculatingDirtyResources")); //$NON-NLS-1$ - for (int i = 0; i < selectedResources.length; i++) { - IResource resource = selectedResources[i]; - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if(cvsResource.isModified(Policy.subMonitorFor(monitor, 100))) { - dirtyResources.add(resource); - } - } - } finally { - monitor.done(); - } - - PromptingDialog dialog = new PromptingDialog(getShell(), selectedResources, - getPromptCondition((IResource[]) dirtyResources.toArray(new IResource[dirtyResources.size()])), Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$ - return dialog.promptForMultiple(); - } - - /** - * This is a helper for the CVS UI automated tests. It allows the tests to ignore prompting dialogs. - * @param resources - */ - protected IPromptCondition getPromptCondition(IResource[] resources) { - return getOverwriteLocalChangesPrompt(resources); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsoleFactory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsoleFactory.java deleted file mode 100644 index 48b16cbf5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsoleFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.console; - -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -//commented out because of Bug 75387 -//import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole.MyLifecycle; -import org.eclipse.ui.console.*; - -/** - * Console factory is used to show the console from the Console view "Open Console" - * drop-down action. This factory is registered via the org.eclipse.ui.console.consoleFactory - * extension point. - * - * @since 3.1 - */ -public class CVSConsoleFactory implements IConsoleFactory { - - public CVSConsoleFactory() { - } - - public void openConsole() { - showConsole(); - } - - public static void showConsole() { - CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); - if (console != null) { - IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); - IConsole[] existing = manager.getConsoles(); - boolean exists = false; - for (int i = 0; i < existing.length; i++) { - if(console == existing[i]) - exists = true; - } - if(! exists) - manager.addConsoles(new IConsole[] {console}); - manager.showConsoleView(console); - } - } - - public static void closeConsole() { - IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); - CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); - if (console != null) { - manager.removeConsoles(new IConsole[] {console}); - ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(console.new MyLifecycle()); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java deleted file mode 100644 index b6a52eabd..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.console; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.console.*; -import org.eclipse.ui.console.IConsole; -import org.eclipse.ui.console.IConsolePageParticipant; -import org.eclipse.ui.part.IPageBookViewPage; - -/** - * Console helper that allows contributing actions to the console view when - * the CVS console is visible. Added to the console via an extension point - * from org.eclipse.ui.console. - * - * @since 3.1 - */ -public class CVSConsolePageParticipant implements IConsolePageParticipant { - - private CVSOutputConsole console; - private IPageBookViewPage page; - private ConsoleRemoveAction consoleRemoveAction; - - public void init(IPageBookViewPage page, IConsole console) { - this.console = (CVSOutputConsole)console; - this.page = page; - this.consoleRemoveAction = new ConsoleRemoveAction(); - IActionBars bars = page.getSite().getActionBars(); - bars.getToolBarManager().appendToGroup(IConsoleConstants.LAUNCH_GROUP, consoleRemoveAction); - } - - public void dispose() { - this.consoleRemoveAction = null; - this.page = null; - this.console = null; - } - - public void activated() { - } - - public void deactivated() { - } - - public Object getAdapter(Class adapter) { - return null; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java deleted file mode 100644 index 1b152a347..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java +++ /dev/null @@ -1,424 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.console; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.console.*; - -/** - * Console that shows the output of CVS commands. It is shown as a page in the generic - * console view. It supports coloring for message, command, and error lines in addition - * the font can be configured. - * - * @since 3.0 - */ -public class CVSOutputConsole extends MessageConsole implements IConsoleListener, IPropertyChangeListener { - - // created colors for each line type - must be disposed at shutdown - private Color commandColor; - private Color messageColor; - private Color errorColor; - - // used to time the commands - private long commandStarted = 0; - - // streams for each command type - each stream has its own color - private MessageConsoleStream commandStream; - private MessageConsoleStream messageStream; - private MessageConsoleStream errorStream; - - // preferences for showing the cvs console when cvs output is provided - private boolean showOnMessage; - - private ConsoleDocument document; - private IConsoleManager consoleManager; - - // format for timings printed to console - private static final DateFormat TIME_FORMAT = new SimpleDateFormat(Policy.bind("Console.resultTimeFormat")); //$NON-NLS-1$ - - // Indicates whether the console is visible in the Console view - private boolean visible = false; - // Indicates whether the console's streams have been initialized - private boolean initialized = false; - - /* - * Constant used for indenting error status printing - */ - private static final String NESTING = " "; //$NON-NLS-1$ - - /** - * Used to notify this console of lifecycle methods init() - * and dispose(). - */ - public class MyLifecycle implements org.eclipse.ui.console.IConsoleListener { - public void consolesAdded(IConsole[] consoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; - if (console == CVSOutputConsole.this) { - init(); - } - } - - } - public void consolesRemoved(IConsole[] consoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; - if (console == CVSOutputConsole.this) { - ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this); - dispose(); - } - } - } - } - - /** - * Constructor initializes preferences and colors but doesn't create the console - * page yet. - */ - public CVSOutputConsole() { - super("CVS", CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_CVS_CONSOLE)); //$NON-NLS-1$ - showOnMessage = CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE); - document = new ConsoleDocument(); - consoleManager = ConsolePlugin.getDefault().getConsoleManager(); - CVSProviderPlugin.getPlugin().setConsoleListener(CVSOutputConsole.this); - CVSUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(CVSOutputConsole.this); - setAutoScroll(true); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.AbstractConsole#init() - */ - protected void init() { - // Called when console is added to the console view - super.init(); - - initLimitOutput(); - initWrapSetting(); - - // Ensure that initialization occurs in the ui thread - CVSUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - JFaceResources.getFontRegistry().addListener(CVSOutputConsole.this); - initializeStreams(); - dump(); - } - }); - } - - private void initWrapSetting() { - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - if(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_WRAP)) { - setConsoleWidth(store.getInt(ICVSUIConstants.PREF_CONSOLE_WIDTH)); - } else { - setConsoleWidth(-1); - } - } - - private void initLimitOutput() { - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - if(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT)) { - setWaterMarks(1000, store.getInt(ICVSUIConstants.PREF_CONSOLE_HIGH_WATER_MARK)); - } else { - setWaterMarks(-1, 0); - } - } - - /* - * Initialize thre streams of the console. Must be - * called from the UI thread. - */ - private void initializeStreams() { - synchronized(document) { - if (!initialized) { - commandStream = newMessageStream(); - errorStream = newMessageStream(); - messageStream = newMessageStream(); - // install colors - commandColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR); - commandStream.setColor(commandColor); - messageColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR); - messageStream.setColor(messageColor); - errorColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR); - errorStream.setColor(errorColor); - // install font - Font f = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry().get(ICVSUIConstants.PREF_CONSOLE_FONT); - setFont(f); - initialized = true; - } - } - } - - private void dump() { - synchronized(document) { - visible = true; - ConsoleDocument.ConsoleLine[] lines = document.getLines(); - for (int i = 0; i < lines.length; i++) { - ConsoleDocument.ConsoleLine line = lines[i]; - appendLine(line.type, line.line); - } - document.clear(); - } - } - - private void appendLine(int type, String line) { - showConsole(); - synchronized(document) { - if(visible) { - switch(type) { - case ConsoleDocument.COMMAND: - commandStream.println(line); - break; - case ConsoleDocument.MESSAGE: - messageStream.println(" " + line); //$NON-NLS-1$ - break; - case ConsoleDocument.ERROR: - errorStream.println(" " + line); //$NON-NLS-1$ - break; - } - } else { - document.appendConsoleLine(type, line); - } - } - } - - private void showConsole() { - show(false); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.MessageConsole#dispose() - */ - protected void dispose() { - // Here we can't call super.dispose() because we actually want the partitioner to remain - // connected, but we won't show lines until the console is added to the console manager - // again. - - // Called when console is removed from the console view - synchronized (document) { - visible = false; - JFaceResources.getFontRegistry().removeListener(this); - } - } - - /** - * Clean-up created fonts. - */ - public void shutdown() { - // Call super dispose because we want the partitioner to be - // disconnected. - super.dispose(); - if (commandColor != null) - commandColor.dispose(); - if (messageColor != null) - messageColor.dispose(); - if (errorColor != null) - errorColor.dispose(); - CVSUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandInvoked(java.lang.String) - */ - public void commandInvoked(Session session, String line) { - if (!session.isOutputToConsole()) return; - commandStarted = System.currentTimeMillis(); - appendLine(ConsoleDocument.COMMAND, Policy.bind("Console.preExecutionDelimiter")); //$NON-NLS-1$ - appendLine(ConsoleDocument.COMMAND, line); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#messageLineReceived(java.lang.String) - */ - public void messageLineReceived(Session session, String line, IStatus status) { - if (session.isOutputToConsole()) { - appendLine(ConsoleDocument.MESSAGE, " " + line); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#errorLineReceived(java.lang.String) - */ - public void errorLineReceived(Session session, String line, IStatus status) { - if (session.isOutputToConsole()) { - appendLine(ConsoleDocument.ERROR, " " + line); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandCompleted(org.eclipse.core.runtime.IStatus, java.lang.Exception) - */ - public void commandCompleted(Session session, IStatus status, Exception exception) { - if (!session.isOutputToConsole()) return; - long commandRuntime = System.currentTimeMillis() - commandStarted; - String time; - try { - time = TIME_FORMAT.format(new Date(commandRuntime)); - } catch (RuntimeException e) { - CVSUIPlugin.log(IStatus.ERROR, Policy.bind("Console.couldNotFormatTime"), e); //$NON-NLS-1$ - time = ""; //$NON-NLS-1$ - } - String statusText; - if (status != null) { - boolean includeRoot = true; - if (status.getCode() == CVSStatus.SERVER_ERROR) { - statusText = Policy.bind("Console.resultServerError", status.getMessage(), time); //$NON-NLS-1$ - includeRoot = false; - } else { - statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$ - } - appendLine(ConsoleDocument.COMMAND, statusText); - outputStatus(status, includeRoot, includeRoot ? 0 : 1); - } else if (exception != null) { - if (exception instanceof OperationCanceledException) { - statusText = Policy.bind("Console.resultAborted", time); //$NON-NLS-1$ - } else { - statusText = Policy.bind("Console.resultException", time); //$NON-NLS-1$ - } - appendLine(ConsoleDocument.COMMAND, statusText); - if (exception instanceof CoreException) { - outputStatus(((CoreException)exception).getStatus(), true, 1); - } - } else { - statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$ - } - appendLine(ConsoleDocument.COMMAND, Policy.bind("Console.postExecutionDelimiter")); //$NON-NLS-1$ - appendLine(ConsoleDocument.COMMAND, ""); //$NON-NLS-1$ - } - - private void outputStatus(IStatus status, boolean includeParent, int nestingLevel) { - if (includeParent && !status.isOK()) { - outputStatusMessage(status, nestingLevel); - nestingLevel++; - } - - // Include a CoreException in the status - Throwable t = status.getException(); - if (t instanceof CoreException) { - outputStatus(((CoreException)t).getStatus(), true, nestingLevel); - } - - // Include child status - IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { - outputStatus(children[i], true, nestingLevel); - } - } - - private void outputStatusMessage(IStatus status, int nesting) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < nesting; i++) { - buffer.append(NESTING); - } - buffer.append(messageLineForStatus(status)); - appendLine(ConsoleDocument.COMMAND, buffer.toString()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - // colors - if (visible) { - if (property.equals(ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR)) { - Color newColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR); - commandStream.setColor(newColor); - commandColor.dispose(); - commandColor = newColor; - } else if (property.equals(ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR)) { - Color newColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR); - messageStream.setColor(newColor); - messageColor.dispose(); - messageColor = newColor; - } else if (property.equals(ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR)) { - Color newColor = createColor(CVSUIPlugin.getStandardDisplay(), ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR); - errorStream.setColor(newColor); - errorColor.dispose(); - errorColor = newColor; - // font - } else if (property.equals(ICVSUIConstants.PREF_CONSOLE_FONT)) { - setFont(((FontRegistry) event.getSource()).get(ICVSUIConstants.PREF_CONSOLE_FONT)); - } - } - if (property.equals(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE)) { - Object value = event.getNewValue(); - if (value instanceof String) { - showOnMessage = Boolean.valueOf((String) value).booleanValue(); - } else { - showOnMessage = ((Boolean) value).booleanValue(); - } - } else if(property.equals(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT)) { - initLimitOutput(); - } else if(property.equals(ICVSUIConstants.PREF_CONSOLE_WRAP)) { - initWrapSetting(); - } - } - - /** - * Returns the NLSd message based on the status returned from the CVS - * command. - * - * @param status an NLSd message based on the status returned from the CVS - * command. - */ - private String messageLineForStatus(IStatus status) { - if (status.getSeverity() == IStatus.ERROR) { - return Policy.bind("Console.error", status.getMessage()); //$NON-NLS-1$ - } else if (status.getSeverity() == IStatus.WARNING) { - return Policy.bind("Console.warning", status.getMessage()); //$NON-NLS-1$ - } else if (status.getSeverity() == IStatus.INFO) { - return Policy.bind("Console.info", status.getMessage()); //$NON-NLS-1$ - } - return status.getMessage(); - } - - /** - * Returns a color instance based on data from a preference field. - */ - private Color createColor(Display display, String preference) { - RGB rgb = PreferenceConverter.getColor(CVSUIPlugin.getPlugin().getPreferenceStore(), preference); - return new Color(display, rgb); - } - - /** - * Show the console. - * @param showNoMatterWhat ignore preferences if true - */ - public void show(boolean showNoMatterWhat) { - if(showNoMatterWhat || showOnMessage) { - if(!visible) - CVSConsoleFactory.showConsole(); - else - consoleManager.showConsoleView(this); - } - - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleDocument.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleDocument.java deleted file mode 100644 index ba8f41ef5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleDocument.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.team.internal.ccvs.ui.console; - -/** - * Simple circular buffer that stores a fix number of lines. - */ -public class ConsoleDocument { - public static final int COMMAND = 0; // command text - public static final int MESSAGE = 1; // message received - public static final int ERROR = 2; // error received - public static final int STATUS = 3; // status text - public static final int DELIMITER = 4; // delimiter text between runs - - private int[] lineTypes; - private String[] lines; - - private int writeIndex = 0; - private int readIndex = 0; - - private static final int BUFFER_SIZE = 200; - - protected static class ConsoleLine { - public String line; - public int type; - ConsoleLine(String line, int type) { - this.line = line; - this.type = type; - } - } - - /** - * Creates an empty console document. - */ - public ConsoleDocument() { - } - - /** - * Clears the console document. - */ - public void clear() { - lineTypes = null; - lines = null; - writeIndex = 0; - readIndex = 0; - } - - /** - * Appends a line of the specified type to the end of the console. - */ - public void appendConsoleLine(int type, String line) { - if(lines == null) { - lines = new String[BUFFER_SIZE]; - lineTypes = new int[BUFFER_SIZE]; - } - lines[writeIndex] = line; //$NON-NLS-1$ - lineTypes[writeIndex] = type; - - if(++writeIndex >= BUFFER_SIZE) { - writeIndex = 0; - } - if(writeIndex == readIndex) { - if(++readIndex >= BUFFER_SIZE) { - readIndex = 0; - } - } - } - - public ConsoleLine[] getLines() { - if(isEmpty()) return new ConsoleLine[0]; - ConsoleLine[] docLines = new ConsoleLine[readIndex > writeIndex ? BUFFER_SIZE : writeIndex]; - int index = readIndex; - for (int i = 0; i < docLines.length; i++) { - docLines[i] = new ConsoleLine(lines[index], lineTypes[index]); - if (++index >= BUFFER_SIZE) { - index = 0; - } - } - return docLines; - } - - public boolean isEmpty() { - return writeIndex == readIndex; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java deleted file mode 100644 index c162cf8fd..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.console; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -public class ConsolePreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public ConsolePreferencesPage() { - super(GRID); - setPreferenceStore(CVSUIPlugin.getPlugin().getPreferenceStore()); - } - private ColorFieldEditor commandColorEditor; - private ColorFieldEditor messageColorEditor; - private ColorFieldEditor errorColorEditor; - private BooleanFieldEditor showOnMessage; - private BooleanFieldEditor restrictOutput; - private BooleanFieldEditor wrap; - private IntegerFieldEditor highWaterMark; - private IntegerFieldEditor width; - - protected void createFieldEditors() { - final Composite composite = getFieldEditorParent(); - createLabel(composite, Policy.bind("ConsolePreferencesPage.9")); //$NON-NLS-1$ - IPreferenceStore store = getPreferenceStore(); - - // ** WRAP - wrap = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_WRAP, Policy.bind("ConsolePreferencesPage.6"), composite); //$NON-NLS-1$ - addField(wrap); - - width = new IntegerFieldEditor(ICVSUIConstants.PREF_CONSOLE_WIDTH, Policy.bind("ConsolePreferencesPage.7"), composite); //$NON-NLS-1$) - width.setValidRange(80, Integer.MAX_VALUE - 1); - addField(width); - width.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_WRAP), composite); - - // ** RESTRICT OUTPUT - restrictOutput = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT, Policy.bind("ConsolePreferencesPage.5"), composite); //$NON-NLS-1$ - addField(restrictOutput); - - highWaterMark = new IntegerFieldEditor(ICVSUIConstants.PREF_CONSOLE_HIGH_WATER_MARK, Policy.bind("ConsolePreferencesPage.8"), composite); //$NON-NLS-1$) - highWaterMark.setValidRange(1000, Integer.MAX_VALUE - 1); - addField(highWaterMark); - highWaterMark.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSOLE_LIMIT_OUTPUT), composite); - - // ** SHOW AUTOMATICALLY - showOnMessage = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSOLE_SHOW_ON_MESSAGE, Policy.bind("ConsolePreferencesPage.4"), composite); //$NON-NLS-1$ - addField(showOnMessage); - - createLabel(composite, Policy.bind("ConsolePreferencePage.consoleColorSettings")); //$NON-NLS-1$ - - // ** COLORS AND FONTS - commandColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, - Policy.bind("ConsolePreferencePage.commandColor"), composite); //$NON-NLS-1$ - addField(commandColorEditor); - - messageColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, - Policy.bind("ConsolePreferencePage.messageColor"), composite); //$NON-NLS-1$ - addField(messageColorEditor); - - errorColorEditor = createColorFieldEditor(ICVSUIConstants.PREF_CONSOLE_ERROR_COLOR, - Policy.bind("ConsolePreferencePage.errorColor"), composite); //$NON-NLS-1$ - addField(errorColorEditor); - - Dialog.applyDialogFont(composite); - WorkbenchHelp.setHelp(composite, IHelpContextIds.CONSOLE_PREFERENCE_PAGE); - } - - - public void propertyChange(PropertyChangeEvent event) { - super.propertyChange(event); - highWaterMark.setEnabled(restrictOutput.getBooleanValue(), getFieldEditorParent()); - width.setEnabled(wrap.getBooleanValue(), getFieldEditorParent()); - } - - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - private Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - /** - * Creates a new color field editor. - */ - private ColorFieldEditor createColorFieldEditor(String preferenceName, String label, Composite parent) { - ColorFieldEditor editor = new ColorFieldEditor(preferenceName, label, parent); - editor.setPreferencePage(this); - editor.setPreferenceStore(getPreferenceStore()); - return editor; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - CVSUIPlugin.getPlugin().savePluginPreferences(); - return super.performOk(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleRemoveAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleRemoveAction.java deleted file mode 100644 index f9564f461..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsoleRemoveAction.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.console; - -import org.eclipse.jface.action.Action; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; - -/** - * Action that removed the CVS console from the console view. The console - * can be re-added via the console view "Open Console" drop-down. - * - * @since 3.1 - */ -public class ConsoleRemoveAction extends Action { - - ConsoleRemoveAction() { - Utils.initAction(this, "ConsoleRemoveAction.", Policy.getBundle()); //$NON-NLS-1$ - } - - public void run() { - CVSConsoleFactory.closeConsole(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties deleted file mode 100644 index 15eeb5723..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties +++ /dev/null @@ -1,1327 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -PasswordManagementPreferencePage.2=When you create a CVS repository location you have the option of saving the password to disk. This page allows you to manage the stored passwords. The following CVS repository locations have saved passwords: -PasswordManagementPreferencePage.3=Location -PasswordManagementPreferencePage.4=Username -PasswordManagementPreferencePage.5=&Remove -PasswordManagementPreferencePage.6=Remove &All -UserValidationDialog.5=CVS Repository: -UserValidationDialog.6=&Save Password -UserValidationDialog.7=Saved passwords are stored on your computer in a file that's difficult, but not impossible, for an intruder to read. -details=Press the details button for more information. -simpleInternal=Internal error -internal=An internal error has occurred, consult the error log for details. -yes=Yes -no=No -information=Server Information -exception=Server Exception -confirmOverwriteTitle=Confirm Overwrite Project -confirmOverwrite=The project already exists in the workspace. Its contents will be overwritten. -question=Question -localChanges=You have local changes which you are about to overwrite. Do you wish to continue? -error=Error -cvs=CVS -notAvailable=Not Available -buildError=A build error occurred after the CVS operation completed. -ok=OK -separator=/ - -nameAndRevision={0} {1} -currentRevision=*{0} - -AddAction.addFailed=Error occurred during Add -AddAction.adding=Adding... -AddAction.addIgnoredTitle=Add Ignored Resource? -AddAction.addIgnoredQuestion=You have explicitly asked to version control one or more resources that otherwise would have been ignored. Continue? - -AddToVersionControlDialog.title=Add to CVS Version Control -AddToVersionControlDialog.thereIsAnUnaddedResource=There is {0} resource that is not under CVS version control. Do you want to add it? -AddToVersionControlDialog.thereAreUnaddedResources=There are {0} resources that are not under CVS version control. Do you want to add them? - -CheckoutAction.overlappingModuleExpansions=You have attempted to check out multiple remote modules that expand to the same local resource ''{0}''. - -AutoDefineTagsAction.defineTags = Auto-discover tags - -AvoidableMessageDialog.dontShowAgain=Don't show this again - -BranchWizard.title=Create a new CVS Branch -BranchWizard.errorBranching=Error Branching Resources -BranchWizardPage.pageDescription=Creates a new branch and a starting point version. -BranchWizardPage.pageDescriptionVersion=Creates a new branch based on the version in the workspace. -BranchWizardPage.specifyVersion=The version will provide a starting point for merging the branch back to the source branch. -BranchWizardPage.branchName=Branch Name: -BranchWizardPage.versionName=Version Name: -BranchWizardPage.startWorking=Start working in the branch -BranchWizardPage.versionPrefix=Root_ -BranchWizard.versionNameWarning=Version name: {0} -BranchWizard.branchNameWarning=Branch name: {0} -BranchWizard.branchAndVersionMustBeDifferent=The branch name and version name must be different. -BranchWizard.branchNameAlreadyExists=Branch name already exists. -BranchWizard.versionNameAlreadyExists=Version name already exists. -BranchWizardPage.existingVersionsAndBranches=Existing Versions and Branches - -ConsolePreferencePage.consoleColorSettings=Console text color settings: -ConsolePreferencePage.commandColor=Command &Line: -ConsolePreferencePage.messageColor=&Message: -ConsolePreferencePage.errorColor=E&rror: -ConsolePreferencePage.font=Console font setting: - -CVSAction.errorTitle=Errors occurred -CVSAction.warningTitle=Warnings occurred -CVSAction.multipleProblemsMessage=Multiple problems occurred: -CVSAction.mixingTagsTitle=Confirm Mixing Tags -CVSAction.mixingTags=You are mixing tags within a project. Beware that synchronization uses the tag information associated with each resource to determine the remote resource with which the local resource is compared. \n\nThis means that the part(s) of your project that you are replacing with another tag will be synchronized with the tag ''{0}'' while other resources in the project will be synchronized with another tag. \n\nDo you wish to continue? - -CVSAnnotateView.showFileAnnotation=CVS Annotate - {0} -CVSAnnotateView.viewInstructions=This view shows annotations for a file in CVS. Select a file and then choose \"Team->Show Annotation\" from the context menu. - -ShowAnnotationAction.noSyncInfo=Cannot display annotation for {0} because it doesn't have a remote revision. -ShowAnnotationOperation.taskName=Fetching annotations from repository -ShowAnnotationOperation.0=Error opening perspective -ShowAnnotationOperation.1=Confirm Perspective Switch -ShowAnnotationOperation.2=The CVS Annotate View is associated with the {0} perspective. Do you want to switch to that perspective now? -ShowAnnotationOperation.4=&Remember my decision - -CVSCatchupReleaseViewer.commit=&Commit... -CVSCatchupReleaseViewer.update=&Update from Repository -CVSCatchupReleaseViewer.forceCommit=Override and Co&mmit... -CVSCatchupReleaseViewer.forceUpdate=Override and U&pdate -CVSCatchupReleaseViewer.ignore=A&dd to .cvsignore -CVSCatchupReleaseViewer.mergeUpdate=&Merge Changes into Local Copy -CVSCatchupReleaseViewer.commonFile=Common file: {0} -CVSCatchupReleaseViewer.commonFileRevision=Common file: {0} {1} -CVSCatchupReleaseViewer.noCommonFile=No common file -CVSCatchupReleaseViewer.noRepositoryFile=No repository file -CVSCatchupReleaseViewer.repositoryFile=Repository file: {0} -CVSCatchupReleaseViewer.repositoryFileRevision=Repository file: {0} {1} [{2}] -CVSCatchupReleaseViewer.workspaceFile=Workspace file: {0} -CVSCatchupReleaseViewer.showInHistory=Show in &Resource History -CVSCatchupReleaseViewer.fileDecoration={0} ({1}) -CVSCatchupReleaseViewer.folderDecoration={0} {1} -CVSCatchupReleaseViewer.confirmMerge=Mark as Mer&ged -CVSCatchupReleaseViewer.addAction=&Add to Version Control -CVSCatchupReleaseViewer.labelWithSyncKind={0} {1} - -CVSCompareEditorInput.branchLabel= -CVSCompareEditorInput.headLabel= -CVSCompareEditorInput.comparing=Comparing... -CVSCompareEditorInput.different=Cannot compare resources of different kind. -CVSCompareEditorInput.inBranch={0} in {1} -CVSCompareEditorInput.inHead={0} in HEAD -CVSCompareEditorInput.0=File is new -CVSCompareEditorInput.1=File has been deleted -CVSCompareEditorInput.repository=Repository: {0} {1} -CVSCompareEditorInput.titleAncestor=Compare {0} {1}-{2} and {3} -CVSCompareEditorInput.titleNoAncestor=Compare {0} {1} and {2} -CVSCompareEditorInput.titleNoAncestorDifferent=Compare {0} {1} and {2} {3} -CVSCompareEditorInput.workspace=Workspace: {0} -CVSCompareEditorInput.workspaceLabel= -CVSCompareEditorInput.noWorkspaceFile=No workspace file -CVSCompareEditorInput.noRepositoryFile=No repository file - -CVSCompareRevisionsInput.addToWorkspace=Get -CVSCompareRevisionsInput.compareResourceAndVersions=Revisions of ''{0}'' -CVSCompareRevisionsInput.errorReplacingTitle=Unable to Replace -CVSCompareRevisionsInput.errorReplacingMessage=Resource(s) could not be loaded. A communication error may have occurred, or \ - the resource(s) may not exist on the server, or you may \ - not have permission to access them. -CVSCompareRevisionsInput.repository=Repository file: {0} -CVSCompareRevisionsInput.structureCompare=Structure Compare -CVSCompareRevisionsInput.workspace=Workspace file: {0} -CVSCompareRevisionsInput.truncate={0}[...] - -CVSDecorator.projectDecoration={0} [{1}] -CVSDecorator.projectDecorationWithTag={0} [{1} {2}] -CVSDecorator.fileDecorationWithTag={0} [{1}:{2}] -CVSDecorator.fileDecorationNoTag={0} [{1}] -CVSDecorator.folderDecoration={0} [{1}] - -CVSDecoratorPreferencesPage.description=CVS Decorator settings: -CVSDecoratorPreferencesPage.iconDescription=Choose which CVS resource states should be indicated using an icon decorator: -CVSDecoratorPreferencesPage.generalDescription=Set general properties of CVS decorators: -CVSDecoratorPreferencesPage.generalTabFolder=&General -CVSDecoratorPreferencesPage.newResources=Indicate is &new resource -CVSDecoratorPreferencesPage.synchronizeTabFolder=S&ynchronize View -CVSDecoratorPreferencesPage.synchronizeDescription=Set the properties of CVS decorators for the Synchronize view: -CVSDecoratorPreferencesPage.showSyncInfoInLabel=Show all synchronization information in a resource's text label - -CVSFilePropertiesPage.ignored=The file is ignored by CVS. -CVSFilePropertiesPage.notManaged=The file is not managed by CVS. -CVSFilePropertiesPage.isAdded=This file has been added to CVS control but has not been committed -CVSFilePropertiesPage.baseRevision=Base revision: -CVSFilePropertiesPage.baseTimestamp=Base timestamp: -CVSFilePropertiesPage.dirty=Dirty: -CVSFilePropertiesPage.modified=Modified: -CVSFilePropertiesPage.keywordMode=Keyword mode: -CVSFilePropertiesPage.tag=Tag: -CVSFilePropertiesPage.none=HEAD -CVSFilePropertiesPage.version={0} (Version) -CVSFilePropertiesPage.branch={0} (Branch) -CVSFilePropertiesPage.date={0} (Date) -CVSFilePropertiesPage.error=An error occurred while creating this page. -CVSFilePropertiesPage.permissions=Permissions: -CVSFilePropertiesPage.notAvailable=Not Available - -CVSFolderPropertiesPage.ignored=The folder is ignored by CVS. -CVSFolderPropertiesPage.notManaged=The folder is not managed by CVS. -CVSFolderPropertiesPage.notCVSFolder=This folder has lost its CVS sharing information. -CVSFolderPropertiesPage.root=Repository root: -CVSFolderPropertiesPage.repository=Repository path: -CVSFolderPropertiesPage.static=Static: -CVSFolderPropertiesPage.disconnect=&Disconnect... -CVSFolderPropertiesPage.disconnectTitle=Disconnect folder? -CVSFolderPropertiesPage.disconnectQuestion=Disconnecting the folder from CVS control will delete the CVS synchronization information for the folder. Are you sure you want to disconnect? - -CVSLocalCompareEditorInput.title=CVS Compare [{0}] - -CVSOperationCancelledException.operationCancelled=Operation Cancelled - -CVSPropertiesPage.connectionType=&Connection type: -CVSPropertiesPage.user=&User: -CVSPropertiesPage.password=&Password: -CVSPropertiesPage.host=&Host: -CVSPropertiesPage.port=Port: -CVSPropertiesPage.path=Repository p&ath: -CVSPropertiesPage.module=Module: -CVSPropertiesPage.defaultPort=Default -CVSPropertiesPage.tag=Tag: -CVSPropertiesPage.update=Change &Tag... -CVSPropertiesPage.virtualModule= - -CVSPreferencePage.description=General CVS settings: -CVSPreferencePage.debugProtocol=&Display detailed protocol output to stdout (for debugging purposes) -CVSPreferencePage.pruneEmptyDirectories=&Prune empty directories -CVSPreferencePage.timeoutValue=&Communication timeout (in seconds): -CVSPreferencePage.quietness=&Quietness level: -CVSPreferencePage.notquiet=Verbose -CVSPreferencePage.somewhatquiet=Somewhat quiet -CVSPreferencePage.reallyquiet=Very quiet -CVSPreferencePage.silentWarningTitle="Very Quiet" mode is dangerous -CVSPreferencePage.silentWarningMessage= In "Very Quiet" mode, some cvs servers may not communicate important information about errors that have occurred. You may want to consider using "Somewhat quiet" mode instead. -CVSPreferencePage.considerContentsInCompare=Con&sider file contents in comparisons -CVSPreferencePage.showAddRemoveMarkers=Show deleted file &markers -CVSPreferencePage.replaceUnmanaged=&Delete unmanaged resources on replace -CVSPreferencePage.defaultTextKSubst=Default &keyword substitution: -CVSPreferencePage.compressionLevel=Compression &level: -CVSPreferencePage.level0=0 (disabled) -CVSPreferencePage.level1=1 (lowest compression) -CVSPreferencePage.level2=2 -CVSPreferencePage.level3=3 -CVSPreferencePage.level4=4 -CVSPreferencePage.level5=5 -CVSPreferencePage.level6=6 -CVSPreferencePage.level7=7 -CVSPreferencePage.level8=8 -CVSPreferencePage.level9=9 (highest compression) -CVSPreferencePage.lineend=Con&vert text files to use platform line ending -CVSPreferencePage.Save_dirty_editors_before_CVS_operations_1=Save dirty editors before CVS operations -CVSPreferencePage.&Never_2=&Never -CVSPreferencePage.&Prompt_3=P&rompt -CVSPreferencePage.Auto-&save_4=&Auto-save -CVSPreferencePage.repositoriesAreBinary=&Treat all new files as binary -CVSPreferencePage.determineVersionEnabled=&Validate server version compatibility on first connection -CVSPreferencePage.confirmMoveTag=Confirm &move tag on tag operation -CVSPreferencePage.showCompareMergeInSync=Show revision &comparisons in a dialog - -CVSRemoteFilePropertySource.name=Name -CVSRemoteFilePropertySource.revision=Revision -CVSRemoteFilePropertySource.date=Date -CVSRemoteFilePropertySource.author=Author -CVSRemoteFilePropertySource.comment=Comment -CVSRemoteFilePropertySource.tag=Tag - -CVSRemoteFolderPropertySource.name=Name -CVSRemoteFolderPropertySource.tag=Tag -CVSRemoteFolderPropertySource.none=(none) - -CVSRepositoryLocationPropertySource.default=Default -CVSRepositoryLocationPropertySource.host=Host -CVSRepositoryLocationPropertySource.user=User -CVSRepositoryLocationPropertySource.port=Port -CVSRepositoryLocationPropertySource.root=Root -CVSRepositoryLocationPropertySource.method=Connection Method - -CVSSyncCompareInput.confirmMergeMessageTitle=Information -CVSSyncCompareInput.confirmMergeMessage=Your changes have been saved. When you are finished, \ - select 'Mark as Merged' to make this file an outgoing change. -CVSSyncCompareInput.projectDeleted=Project ''{0}'' has been deleted locally and cannot be synchronized. -CVSSyncCompareInput.filteringOutgoingChanges=Accumulating resources with outgoing changes - -CVSSyncSet.conflicts={0} conflicts, -CVSSyncSet.incomings={0} incoming change(s), -CVSSyncSet.noConflicts=No conflicts, -CVSSyncSet.noIncomings=no incoming changes, -CVSSyncSet.noOutgoings=no outgoing changes, -CVSSyncSet.outgoings={0} outgoing change(s), -CVSSyncSet.noNew=no new resources. -CVSParticipant.0=Remote File ({0} - {1}) -CVSParticipant.1=Common Ancestor ({0} - {1}) -CVSParticipant.2=C&VS -CVSSyncSet.new={0} new resource(s). - -CVSUIPlugin.refreshTitle=Refresh Resource? -CVSUIPlugin.refreshQuestion={0} Would you like to refresh resource ''{1}''? -CVSUIPlugin.refreshMultipleQuestion={0} Would you like to refresh the selected resources? - -CVSAction.disabledTitle=Information -CVSAction.disabledMessage=The chosen operation is not enabled. -CVSAction.refreshTitle=Refresh Project? -CVSAction.refreshQuestion={0} Would you like to refresh project ''{1}''? -CVSAction.refreshMultipleQuestion={0} Would you like to refresh the projects of the selected resources? - -CommitAction.commitFailed=Problems encountered performing commit - -CommitSyncAction.questionRelease=You have changes that conflict with the server. Release those changes? -CommitSyncAction.titleRelease=Confirm Overwrite -CommitSyncAction.releaseAll=Release all changes, overriding any conflicting changes on the server. -CommitSyncAction.releasePart=Only release the changes that don't conflict with changes on the server. -CommitSyncAction.cancelRelease=Cancel the release operation. -CommitSyncAction.errorCommitting=An error occurred while committing changes. - -CompareWithRemoteAction.compare=Error Comparing with Latest -CompareWithRemoteAction.noRemote=No Remote Resource -CompareWithRemoteAction.noRemoteLong=The selected resource has no remote resource to compare with. -CompareWithRemoteAction.fetching=Comparing with latest from repository... - -CompareWithRevisionAction.compare=Error Comparing with Revision -CompareWithRevisionAction.noRevisions=No Revisions -CompareWithRevisionAction.noRevisionsLong=The selected resource has no revisions to compare with. -CompareWithRevisionAction.fetching=Fetching revisions from repository... - -CompareWithTagAction.message=Compare With Branch or Version -CompareWithTagAction.replace=Error Comparing With Branch or Version -CompareWithTagAction.noRemote=No Remote Resource -CompareWithTagAction.noRemoteLong=The selected tag has no remote resource to compare with. -CompareWithTagAction.fetching=Fetching resources with tag {0}... - -CompareEditorInput.fileProgress=Comparing CVS file: {0} - -ConfigurationWizardAutoconnectPage.description=Your project already has CVS/ directories. It was probably previously shared, or checked out using another tool. It will be automatically shared using the following information. -ConfigurationWizardAutoconnectPage.user=User: -ConfigurationWizardAutoconnectPage.host=Host: -ConfigurationWizardAutoconnectPage.port=Port: -ConfigurationWizardAutoconnectPage.default=Default -ConfigurationWizardAutoconnectPage.connectionType=Connection type: -ConfigurationWizardAutoconnectPage.repositoryPath=Repository path: -ConfigurationWizardAutoconnectPage.module=Module: -ConfigurationWizardAutoconnectPage.validate=&Validate Connection on Finish -ConfigurationWizardAutoconnectPage.noSyncInfo=Could not get folder information -ConfigurationWizardAutoconnectPage.noCVSDirectory=Could not find CVS/ directory - -RepositorySelectionPage.description=This wizard will help you to share your files with the CVS repository for the first time. Your project will automatically be imported into the CVS repository, and the Synchronize view will open to allow you to commit your resources. -RepositorySelectionPage.useExisting=&Use existing repository location: -RepositorySelectionPage.useNew=&Create a new repository location - -ConfigurationWizardMainPage.connection=&Connection type: -ConfigurationWizardMainPage.userName=&User: -ConfigurationWizardMainPage.password=&Password: -ConfigurationWizardMainPage.host=&Host: -ConfigurationWizardMainPage.0=Location already exists. -ConfigurationWizardMainPage.5=The host name must not start or end with a space -ConfigurationWizardMainPage.1=User Name Required -ConfigurationWizardMainPage.2=Host Required -ConfigurationWizardMainPage.3=Port Required -ConfigurationWizardMainPage.4=Repository Path Required -ConfigurationWizardMainPage.useDefaultPort=Use Default P&ort -ConfigurationWizardMainPage.usePort=Use Por&t: -ConfigurationWizardMainPage.repositoryPath=&Repository path: -ConfigurationWizardMainPage.invalidUserName=Invalid User Name -ConfigurationWizardMainPage.invalidHostName=Invalid Host Name -ConfigurationWizardMainPage.invalidPort=Invalid Port -ConfigurationWizardMainPage.invalidPathWithSpaces=The repository path cannot have segments with leading or trailing spaces -ConfigurationWizardMainPage.invalidPathWithSlashes=The repository path cannot contain a double slash (//) -ConfigurationWizardMainPage.useNTFormat=Use NT path names for specifying CVSNT repository paths (e.g. C:\\cvs\\root) - -Console.copy=Copy -Console.selectAll=Select All -Console.clearOutput=Clear Output -Console.resultServerError={0} {1} -Console.resultWarnings={0} {1} -Console.resultException=failed due to an internal error {0} -Console.resultAborted=operation canceled {0} -Console.resultOk=ok {0} -Console.resultTimeFormat='(took 'm:ss.SSS')' -Console.couldNotFormatTime=An error occurred formatting the output time for the CVS console. -Console.preExecutionDelimiter=*** -Console.postExecutionDelimiter=*** -Console.info=Info: {0} -Console.warning=Warning: {0} -Console.error=Error: {0} - -AddToBranchAction.enterTag=Enter Branch Tag -AddToBranchAction.enterTagLong=Enter the name of the branch: - -DiffAction.diff=Diff - -FixTypeAction.fix=Fix Types - -GenerateCVSDiff.title=Create Patch -GenerateCVSDiff.pageTitle=Run and save CVS diff results in a file -GenerateCVSDiff.pageDescription=The results of the CVS diff command can be used as an input file for the Apply Patch wizard. -GenerateCVSDiff.overwriteTitle=Confirm Overwrite -GenerateCVSDiff.overwriteMsg=A file with that name already exists. Overwrite? -GenerateCVSDiff.error=Error running the CVS diff command -GenerateCVSDiff.working=Running CVS diff... -GenerateCVSDiff.noDiffsFoundMsg=No differences found. -GenerateCVSDiff.noDiffsFoundTitle=CVS diff -GenerateCVSDiff.1=Read-only file -GenerateCVSDiff.2=The specified file is read-only and cannot be overwritten. -GenerateCVSDiff.3=Can't write directory -GenerateCVSDiff.4=You don't have permission to create a file in this directory. - -GetSyncAction.questionCatchup=You have local changes which you are about to overwrite. Should the conflicting changes be added? -GetSyncAction.titleCatchup=Catch up Over Conflicts? -GetSyncAction.catchupAll=Catch up to all incoming changes, overriding any conflicting local changes. -GetSyncAction.catchupPart=Only catch up to the changes that don't conflict with local changes. -GetSyncAction.cancelCatchup=Cancel the catch up operation. -UpdateSyncAction.errorUpdating=An error occurred while updating changes. - -HistoryFilterDialog.title = Filter Resource History -HistoryFilterDialog.showMatching = Show entries matching: -HistoryFilterDialog.matchingAny = a&ny of the provided criteria -HistoryFilterDialog.matchingAll = a&ll of the provided criteria -HistoryFilterDialog.author = &Author: -HistoryFilterDialog.comment = &Comment containing: -HistoryFilterDialog.fromDate = &From date (M/D/Y) : -HistoryFilterDialog.toDate = &To date (M/D/Y) : - -HistoryView.getAnnotateAction=Show &Annotation -HistoryView.getContentsAction=&Get Contents -HistoryView.getRevisionAction=Get Sticky &Revision -HistoryView.tagWithExistingAction=&Tag with Existing... -HistoryView.copy=&Copy -HistoryView.revision=Revision -HistoryView.tags=Tags -HistoryView.date=Date -HistoryView.author=Author -HistoryView.comment=Comment -HistoryView.refreshLabel=&Refresh View -HistoryView.refresh=Refresh View -HistoryView.linkWithLabel=Link with Editor -HistoryView.selectAll=Select &All -HistoryView.showComment=Show Comment Viewer -HistoryView.showTags=Show Tag Viewer -HistoryView.title=CVS Resource History -HistoryView.titleWithArgument=CVS Resource History ({0}) -HistoryView.overwriteTitle=Overwrite local changes? -HistoryView.overwriteMsg=You have local changes. Do you want to overwrite them? -HistoryView.fetchHistoryJob=Fetching CVS revision history -HistoryView.fetchHistoryJobFile=Fetching CVS revision history for: {0} -HistoryView.errorFetchingEntries=Error fetching entries for {0} - -IgnoreAction.ignore=Error Ignoring Resource - -MergeAction.saveChangesTitle=Save Changes -MergeAction.saveChanges=You have unsaved changes that will be saved before the action is performed. - -MergeEditorInput.title=Merge {0} with {1} - -MergeWizard.title=Merge -MergeWizard.0=Select the merge points -MergeWizard.1=Specify the branch or version to be merged and the common base version. -MergeWizardPage.0=Preview the merge in the &synchronize view -MergeWizardPage.1=Perform the merge into the local &workspace -MergeWizardPage.2=&Branch or version to be merged (end tag): -MergeWizardPage.3=Br&owse... -MergeWizardPage.4=Choose End Tag -MergeWizardPage.5=&Select end tag -MergeWizardPage.6=Common base &version (start tag): -MergeWizardPage.7=Bro&wse... -MergeWizardPage.8=Choose Start Tag -MergeWizardPage.9=&Select start tag -MergeWizardPage.10=The specified end tag is not known to exist. Either enter a different tag or refresh the known tags. -MergeWizardPage.11=The specified start tag is not known to exist. Either enter a different tag or refresh the known tags. -MergeWizardPage.12=The start and end tags cannot be the same. -MergeWizardPage.13=A start tag is required for previewing a merge in the synchronize view. -MergeWizard.preparing=Preparing merge wizard -MergeWizard.preparingStart=Fetching tags for start page -MergeWizard.preparingEnd=Fetching tags for end page -MergeWizardEndPage.branches=Branches - -ModuleSelectionPage.moduleIsProject=Use &project name as module name -ModuleSelectionPage.specifyModule=Use &specified module name: - -MoveTagAction.errorMessage=Error Tagging -MoveTagAction.title=Tag with Existing Tag -MoveTagAction.message=&Select the tag to be moved - -NewLocationWizard.title=Add CVS Repository -NewLocationWizard.heading=Add a new CVS Repository -NewLocationWizard.description=Add a new CVS Repository to the CVS Repositories view -NewLocationWizard.validationFailedText=Error validating location: "{0}"\n\nKeep location anyway? -NewLocationWizard.validationFailedTitle=Unable to Validate -NewLocationWizard.exception=Unable to create repository location - -OpenLogEntryAction.deletedTitle=Resource is Deleted -OpenLogEntryAction.deleted=The selected revision represents a deletion. It cannot be opened. - -ReleaseCommentDialog.title=Commit -ReleaseCommentDialog.choosePrevious=Choose a &previously entered comment: -ReleaseCommentDialog.enterComment=Edit the commit &comment: -ReleaseCommentDialog.unaddedResources=Checked resources will be &added to CVS version control. -ReleaseCommentDialog.selectAll=&Select All -ReleaseCommentDialog.deselectAll=D&eselect All -ReleaseCommentDialog.clearTextArea=&Reset Comment - -RemoteFolderElement.nameAndTag={0} {1} -RemoteFolderElement.fetchingRemoteChildren=Fetching remote CVS children for ''{0}''... - -RemoveRootAction.removeRoot=Error Discarding Location - -ReplaceWithTagAction.message=Replace with Branch or Version -ReplaceWithTagAction.replace=Error Replacing With Tag -ReplaceWithTagAction.replacing=Replacing with tag {0} -ReplaceWithTagAction.mixingTags=You are mixing tags within a project. This may cause confusion \ - when synchronizing with the repository. Synchronize uses the tag information associated with \ - each resource to determine the remote resource with which the local resource is compared. \ - For example, with version tags, the state of the tagged resources never change so you will \ - not see changes made to the resources in HEAD (or other branches). Do you wish to continue? - -ReplaceWithRemoteAction.replacing=Replacing -ReplaceWithRemoteAction.problemMessage=Error Replacing With Latest From Repository - -ReplaceWithAction.confirmOverwrite=Confirm Overwrite -ReplaceWithAction.localChanges={0} has local changes which you are about to overwrite. Do you wish to overwrite? -ReplaceWithAction.calculatingDirtyResources=Finding outgoing changes... - -ReplaceWithLatestAction.multipleTags=&Latest from Repository -ReplaceWithLatestAction.multipleVersions=&Versions from Repository -ReplaceWithLatestAction.multipleBranches=&Latest from Branches -ReplaceWithLatestAction.singleVersion=&Version {0} -ReplaceWithLatestAction.singleBranch=&Latest from Branch {0} -ReplaceWithLatestAction.singleHEAD=&Latest from {0} - -RepositoryDialog.getRepository=Select a repository -RepositoryDialog.description=Select a repository to connect your project to - -RepositoryManager.getting=Getting -RepositoryManager.committing=Committing -RepositoryManager.updating=Updating -RepositoryManager.deleting=Deleting -RepositoryManager.adding=Adding -RepositoryManager.rename=An IO Exception occurred while renaming the state file -RepositoryManager.save=An IO Exception occurred while saving the state file -RepositoryManager.ioException=An IO Exception occurred while reading the state file -RepositoryManager.parsingProblem=An error occurred parsing file ''{0}''. -RepositoryManager.fetchingRemoteFolders=Fetching remote CVS folders for ''{0}''... - -RepositoriesView.refresh=&Refresh View -RepositoriesView.refreshTooltip=Refresh View -RepositoriesView.new=&Repository Location... -RepositoriesView.newSubmenu=&New -RepositoriesView.newAnonCVS=&Anonymous Repository Location to dev.eclipse.org... -RepositoriesView.newWorkingSet=Select Working Set... -RepositoriesView.deselectWorkingSet=Deselect Working Set -RepositoriesView.editWorkingSet=Edit Active Working Set... -RepositoriesView.workingSetMenuItem={0} {1} -RepositoriesView.collapseAll=Collapse All -RepositoriesView.collapseAllTooltip=Collapse All -RepositoriesView.NItemsSelected={0} items selected -RepositoriesView.OneItemSelected=1 item selected -RepositoriesView.ResourceInRepository={0} in {1} -RepositoriesView.CannotGetRevision=Cannot get revision -RemoteViewPart.workingSetToolTip=Working Set: {0} - -ResourcePropertiesPage.status=Status -ResourcePropertiesPage.notManaged=Not managed by CVS -ResourcePropertiesPage.versioned=versioned -ResourcePropertiesPage.notVersioned=not versioned -ResourcePropertiesPage.state=State -ResourcePropertiesPage.checkedOut=Checked Out -ResourcePropertiesPage.checkedIn=Checked In -#ResourcePropertiesPage.baseRevision=Base Revision -#ResourcePropertiesPage.none=none -ResourcePropertiesPage.error=Error - -KSubstWizard.title=Set Keyword Substitution -KSubstWizard.working=Setting keyword substitution mode... -KSubstWizard.problemsMessage=Problems encountered setting keyword substitution -KSubstWizard.errorTitle=Errors Occurred -KSubstWizard.warningTitle=Warnings occurred - -KSubstWizardSharedFilesPage.pageTitle=Include versioned files -KSubstWizardSharedFilesPage.pageDescription=\ - Choose to include or exclude files that are already in the repository -KSubstWizardSharedFilesPage.contents=\ - Since the keyword substitution mode attribute is not version controlled, the \ - change will be reflected immediately on all branches and in all revisions of \ - any affected files that are already shared in the repository. You should inform \ - all developers that they must delete and check out fresh copies of project containing the affected \ - files before committing new changes to the repository. You may also experience \ - side-effects working with earlier revisions of these files. -KSubstWizardSharedFilesPage.includeSharedFiles=&Include files that are already shared in the repository. -KSubstWizardSharedFilesPage.sharedFilesViewer.title=&The following files were selected and are already shared in the repository: - -KSubstWizardDirtyFilesPage.pageTitle=Include files with outgoing changes -KSubstWizardDirtyFilesPage.pageDescription=\ - Choose to include or exclude files with outgoing changes -KSubstWizardDirtyFilesPage.contents=\ - This operation may commit changes to files without first providing a chance to resolve \ - conflicts. -KSubstWizardDirtyFilesPage.includeDirtyFiles=&Include files that have outgoing changes. -KSubstWizardDirtyFilesPage.dirtyFilesViewer.title=&The following files were selected and have outgoing changes. - -KSubstWizardSelectionPage.pageTitle=Select Keyword Substitution Mode -KSubstWizardSelectionPage.pageDescription=\ - Choose the desired keyword substitution mode for the selected files. -KSubstWizardSelectionPage.automaticButton=&Automatic -KSubstWizardSelectionPage.automaticLabel=\ - Automatically chooses ''{0}'' or ''{1}'' \ - for each file according to the Team file extension preferences. -KSubstWizardSelectionPage.binaryButton=&Binary (-kb) -KSubstWizardSelectionPage.binaryLabel=\ - Binary files are stored in the repository without alteration.\n\ - CVS does not directly support conflict resolution for binary files. -KSubstWizardSelectionPage.textButton=A&SCII without keyword substitution (-ko) -KSubstWizardSelectionPage.textLabel=\ - End of lines are replaced with the appropriate convention for the client system.\n\ - CVS supports conflict resolution and differencing of ASCII files with single line granularity. -KSubstWizardSelectionPage.textWithSubstitutionsButton=ASCII with &keyword substitution -KSubstWizardSelectionPage.textWithSubstitutionsLabel=\ - End of lines are replaced with the appropriate convention for the client system.\n\ - ASCII files may contain keywords that are expanded by the CVS server during file transfers.\n\ - Please consult the CVS documentation for a description of the various supported keywords and modes. - -KSubstWizardCommitCommentPage.pageTitle=Enter Commit Comment -KSubstWizardCommitCommentPage.pageDescription=\ - Enter the commit comment to be used for the selected files when they are committed. - -KSubstWizardSummaryPage.pageTitle=Summary -KSubstWizardSummaryPage.pageDescription=\ - Summary of keyword substitution changes to be performed. -KSubstWizardSummaryPage.contents=\ - Click on \'Finish\' to change the keyword substitution mode of the checked files indicated below.\n\ - You can change the mode on a per file basis by clicking in the corresponding cell.\n\ - Note: Files that are not checked, or that already have the indicated mode will not be affected in any way. -KSubstWizardSummaryPage.showUnaffectedFiles=&Show files that already have the requested keyword substitution mode. -KSubstWizardSummaryPage.summaryViewer.title=&The following checked files will have their keyword substitution mode changed to the indicated value. -KSubstWizardSummaryPage.summaryViewer.fileHeader=File Location -KSubstWizardSummaryPage.summaryViewer.ksubstHeader=Keyword Substitution Mode - -SharingWizard.autoConnectTitle=Connect Project to Repository -SharingWizard.autoConnectOneOTitle=Connect Project from Eclipse 1.0 to Repository -SharingWizard.autoConnectTitleDescription=Project is already configured with CVS repository information. -SharingWizard.couldNotImport=Remote Project Exists -SharingWizard.couldNotImportLong=Module ''{0}'' already exists remotely. Would you like to synchronize your local project with the existing remote module? -SharingWizard.selectTagTitle=Select Tag -SharingWizard.selectTag=&Select the tag to synchronize with: -SharingWizard.description=Configure a Project to Use CVS -SharingWizard.importTitle=Share Project with CVS Repository -SharingWizard.importTitleDescription=Select an existing repository location or create a new location. -SharingWizard.title=Share Project -SharingWizard.heading=Configure a Project to Use CVS -SharingWizard.enterInformation=Enter Repository Location Information -SharingWizard.enterInformationDescription=Define the location and protocol required to connect with an existing CVS repository. -SharingWizard.enterModuleName=Enter Module Name -SharingWizard.enterModuleNameDescription=Select the name of the module in the CVS repository. -SharingWizard.validationFailedText={0}. Set project sharing anyway? -SharingWizard.validationFailedTitle=Unable to Validate - -SharingWizardFinishPage.message=The wizard has all the information necessary to share your project with the CVS repository. When you click \"Finish\", the wizard will import your project into the repository and open the Synchronize view to allow you to commit your resources. - -ShowHistoryAction.showHistory=Error occurred performing Show History -ShowHistoryAction.noHistory=No History Available -ShowHistoryAction.noHistoryLong=No resource history available for selected resources. - -SyncAction.sync=Synchronize -SyncAction.workingSetName=Latest CVS Synchronize -SyncAction.noChangesTitle=No Changes -SyncAction.noChangesMessage=There are no changes between the workspace resource and the remote. - -TagAction.tagErrorTitle=Tagging Error -TagAction.tagWarningTitle=Tagging Warning -TagAction.tagProblemsMessage=Problems reported tagging the resource. -TagAction.tagProblemsMessageMultiple=Problems tagging the resources. {0} project(s) successfully tagged and {1} project(s) with errors. -TagAction.tagResources=Tag Resources -TagRefreshButtonArea.0=No Tags Found -TagRefreshButtonArea.1=Perform Deep Search -TagRefreshButtonArea.2=Configure Manually -TagRefreshButtonArea.3=Cancel -TagRefreshButtonArea.4=Tags were not found for {0} using the auto-refresh files and a shallow cvs log operation. You can choose to search using a deep cvs log operation, to manually configure the tags or to cancel. -TagRefreshButtonArea.5=Refreshing tags -TagAction.enterTag=&Please enter a version tag: -TagAction.moveTag=&Move tag if it already exists -TagRootElement.0=Dates -TagAction.moveTagConfirmTitle=Confirm Move Existing Tag -TagAction.moveTagConfirmMessage=If the tag {0} is already used in this project, it will be moved to the selected revisions. Are you sure you want to perform the tag operation? -TagAction.uncommittedChangesTitle=Confirm Uncommitted Changes -TagAction.uncommittedChanges=You are tagging ''{0}'' that has uncommitted changes. These changes are not in the repository and will not be included in the version you are creating. Do you still want to tag this resource? -TagAction.tagAlreadyExists=Version tag already exists. -TagAction.existingVersions=Existing Versions - -TagInRepositoryAction.tagProblemsMessage=Problems reported tagging the resource. -TagInRepositoryAction.tagProblemsMessageMultiple=Problems tagging the resources. {0} resource(s) successfully tagged and {1} resource(s) with errors. - -UpdateAction.update=Problems encountered performing update -UpdateAction.updating=Updating... -UpdateAction.promptForUpdateSeveral=Are you sure you want to update {0} resources? -UpdateAction.promptForUpdateOne=Are you sure you want to update {0} resource? -UpdateAction.promptForUpdateTitle=Confirm Update - -UpdateWizard.title=Update -UpdateWizard.0=Select Tag -UpdateWizard.1=Select the tag for the update -UpdateWizard.updatePage=Update Options -UpdateWizardPage.description=Select other options for the update - -UserValidationDialog.required=Password Required -UserValidationDialog.labelUser={0} -UserValidationDialog.labelPassword={1} -UserValidationDialog.password=&Password: -UserValidationDialog.user=&User name: - -KeyboradInteractiveDialog.message=Keyboard Interactive authentication for {0} -KeyboardInteractiveDialog.labelRepository=Enter values for the following repository: {0} - -VersionsElement.versions=Versions - -WorkbenchUserAuthenticator.cancelled=Operation cancelled because login cancelled -WorkbenchUserAuthenticator.errorFlushing=Error occurred while flushing password for {0} -WorkbenchUserAuthenticator.errorSaving=Error occurred while saving password for {0} - -Unmanage.unmanaging=Disconnecting from CVS... -Unmanage.unmanage=Disconnect from CVS -Unmanage.title=Confirm Disconnect from CVS -Unmanage.titleN=Confirm Multiple Project Disconnect from CVS -Unmanage.message=Are you sure you want to disconnect CVS from ''{0}''? -Unmanage.messageN=Are you sure you want to disconnect CVS from these {0} projects? -Unmanage.option1=Do not delete the CVS meta information (e.g. CVS sub-directories). -Unmanage.option2=Also delete the CVS meta information from the file system. -Unmanage.unmanagingError=Errors occurred while disconnecting - -Unmanage.message=Are you sure you want to disconnect CVS from ''{0}''? -Unmanage.messageN=Are you sure you want to disconnect CVS from these {0} projects? - -Save_To_Clipboard_2=&Save to clipboard -Save_In_File_System_3=Sa&ve in file system -Browse..._4=Br&owse... -Save_Patch_As_5=Save Patch As -patch.txt_6=patch.txt -Save_In_Workspace_7=Save in &workspace -Select_a_folder_then_type_in_the_file_name__8=Select a fol&der then type in the file name: -Fi&le_name__9=Fi&le name: -Do_not_recurse_into_sub-folders_10=&Recurse into sub-folders -Do_not_include_new_files_in_patch_11=&Include new files in patch -Diff_output_format_12=Diff output format -Unified_(format_required_by_Compare_With_Patch_feature)_13=&Unified (format required by the Apply Patch wizard) -Context_14=&Context -Standard_15=&Standard -Advanced_options_19=Advanced options -Configure_the_options_used_for_the_CVS_diff_command_20=Configure the options used for the CVS diff command - -After_configuring_the_project__1=After configuring the project: -Open_the_Synchronize_view_on_the_project_2=Open the Synchronize view on the project -Automatically_import_the_local_resources_into_the_repository_3=Automatically import the local resources into the repository -Run_update_4=Run update -Do_nothing_5=Do nothing -Validate_Connection_on_Finish_7=Validate Location on Finish - -TagSelectionDialog.Select_a_Tag_1=&Select a branch or version -TagSelectionDialog.recurseOption=Recurse into sub-&folders -TagSelectionDialog.0=&Add Date... -TagSelectionDialog.1=&Remove -TagSelectionArea.0=&Matching tags: -TagSelectionArea.1={0}: -TagSelectionArea.2={0} (? = any character, * = any String): -TagSelectionArea.3=Select a &tag -TagSelectionWizardPage.0=&Use the tag currently associated with the workspace resources -TagSelectionWizardPage.1=&Select the tag from the following list - -UpdateSyncAction.Conflicting_changes_found_1=Conflicting changes found -UpdateSyncAction.You_have_local_changes_you_are_about_to_overwrite_2=You have local changes you are about to overwrite -UpdateSyncAction.Only_update_resources_that_can_be_automatically_merged_3=Only update resources that can be automatically merged -UpdateSyncAction.Update_all_resources,_overwriting_local_changes_with_remote_contents_4=Update all resources, overwriting local changes with remote contents -UpdateSyncAction.Overwrite_local_changes__5=Overwrite local changes? -UpdateSyncAction.You_have_local_changes_you_are_about_to_overwrite._Do_you_wish_to_continue__6=You have local changes you are about to overwrite. Do you wish to continue? - -CVSDecoratorPreferencePage.1=T&ext -Example__1=&Preview -Text_Labels_12=&Formats -Select_the_format_for_file,_folders,_and_project_text_labels__13=Select the format for file, folders, and project text labels: -&File_Format__14=File For&mat: -Add_&Variables_15=Add &Variables... -F&older_Format__16=F&older Format: -Add_Varia&bles_17=Add Varia&bles... -&Project_Format__18=&Project Format: -Add_Variable&s_19=Add Variable&s... -&Label_decoration_for_outgoing__20=Di&rty flag: -Label_decorat&ion_for_added__22=Added f&lag: -Icon_Overlays_24=&Icons -Sho&w_outgoing_25=Indicate is o&utgoing -Show_has_&remote_26=Indicate &has remote -S&how_is_added_27=Indi&cate is added -&Compute_deep_outgoing_state_for_folders_(disabling_this_will_improve_decorator_performance)_28=&Compute deep outgoing state for folders (disabling this will improve decorator performance) -Select_the_&variables_to_add_to_the_decoration_format__30=Select the &variables to add to the decoration format: -Add_Variables_31=Add Variables -name_of_the_resource_being_decorated_34=name of the resource being decorated -the_tag_applied_to_the_resource_(version,_branch,_or_date)_35=the tag applied to the resource (version, branch, or date) -the_repository_location__s_hostname_36=the repository location\'s hostname -the_connection_method_(e.g._pserver,_ssh)_37=the connection method (e.g. pserver, ssh) -user_name_for_the_connection_38=user name for the connection -repository_home_directory_on_server_39=repository home directory on server -root_relative_directory_40=root relative directory -flag_indicating_that_the_folder_has_a_child_resource_with_outgoing_changes_41=flag indicating that the folder has a child resource with outgoing changes -name_of_the_resource_being_decorated_42=name of the resource being decorated -the_tag_applied_to_the_resource_43=the tag applied to the resource -keyword_substitution_rule_for_the_resource_44=keyword subsitution rule for the resource -last_revision_loaded_into_workspace_45=last revision loaded into workspace -flag_indicating_that_the_file_has_outgoing_changes_46=flag indicating that the file has outgoing changes -flag_indicating_that_the_file_has_been_added_to_the_server_47=flag indicating that the file has been added to the server - -ExtMethodPreferencePage_message=These variables define the external connection program to use with the \'ext\' connection method. These values should be the same as the \'ext\' CVS command-line environment variable settings. -ExtMethodPreferencePage_CVS_RSH=CVS_&RSH: -ExtMethodPreferencePage_Browse=&Browse... -ExtMethodPreferencePage.0=Use an &external program to connect -ExtMethodPreferencePage.2=Choosing to use another connection method allows the meta information in CVS projects to be compatible with external CVS tools while using a custom connection method. -ExtMethodPreferencePage.1=Use another &connection method type to connect -ExtMethodPreferencePage_Details=Select a program or script -ExtMethodPreferencePage_CVS_RSH_Parameters=&Parameters: -ExtMethodPreferencePage_Add_Variable=&Add Variable... -ExtMethodPreferencePage_CVS_SERVER__7=CVS_&SERVER: -UpdateMergeActionProblems_merging_remote_resources_into_workspace_1=Problems merging remote resources into workspace -UpdateMergeActionProblems_merging_remote_resources_into_workspace_2=Problems merging remote resources into workspace - -TagConfigurationDialog.1=Configure Branches and Versions for {0} -TagConfigurationDialog.4=Configure tags you will see in the workbench. -TagConfigurationDialog.5=&Browse files for tags: -TagConfigurationDialog.6=&New tags found in the selected files: -TagConfigurationDialog.7=Remembered &tags for these projects: -TagConfigurationDialog.8=&Add Checked Tags -TagConfigurationDialog.9=&Remove -TagConfigurationDialog.0=Add &Date... -TagConfigurationDialog.10=Re&move All -TagConfigurationDialog.11=&List of files to be automatically examined when refreshing tags: -TagConfigurationDialog.12=A&dd Selected Files -TagConfigurationDialog.13=Rem&ove -TagConfigurationDialog.14=Error fetching tags from remote CVS files -TagConfigurationDialog.20=&Refresh from Repository -TagConfigurationDialog.21=&Configure Tags... -TagConfigurationDialog.22=Updating Tags - -ChangeListener.Deleting_CVS_folders_1=Deleting CVS folders -ChangeListener.Folders_cannot_be_deleted_from_a_CVS_server_from_the_client._To_delete_the_folder_2=Folders cannot be deleted from a CVS server from the client. To delete the folder -ChangeListener.Do_not_ask_me_about_this_again_3=Do not ask me about this again -ConfigureTagsFromRepoViewConfigure_Tag_Error_1=Configure Tag Error -RemoteRootAction.label=Discard location -RemoteLogOperation.0=Fetching log information from {0} -RemoteLogOperation.1=Fetching log information -RemoveDateTagAction.0=&Remove -RemoteRootAction.Unable_to_Discard_Location_1=Unable to Discard Location -RemoteRootAction.Projects_in_the_local_workspace_are_shared_with__2=Projects in the local workspace are shared with {0}. This location cannot be discarded until all local projects are disconnected from it. -RemoveRootAction.removeRoot_3=RemoveRootAction.removeRoot -RemoteRootAction.The_projects_that_are_shared_with_the_above_repository_are__4=The projects that are shared with the above repository are: - -BranchCategory.Branches_1=Branches -GroupedByVersionCategory.Versions_1=Versions -VersionCategory.Versions_1=Versions -ModulesCategory.label=Modules -HistoryView.[...]_4=[...] - -CVSProjectPropertiesPage.connectionType=Connection type: -CVSProjectPropertiesPage.user=User: -CVSProjectPropertiesPage.Select_a_Repository_1=Select a Repository -CVSProjectPropertiesPage.Select_a_CVS_repository_location_to_share_the_project_with__2=Select a compatible CVS repository location to share the project with: -CVSProjectPropertiesPage.Change_Sharing_5=&Change Sharing... -CVSProjectPropertiesPage.fetchAbsentDirectoriesOnUpdate=&Fetch absent or new directories when updating -CVSProjectPropertiesPage.configureForWatchEdit=Enable watch/edit for this project -CVSProjectPropertiesPage.progressTaskName=Updating project's CVS properties -CVSProjectPropertiesPage.setReadOnly=Setting all files read-only -CVSProjectPropertiesPage.clearReadOnly=Setting all files writable -CVSRepositoryPropertiesPage.Confirm_Project_Sharing_Changes_1=Confirm Project Sharing Changes -CVSRepositoryPropertiesPage.There_are_projects_in_the_workspace_shared_with_this_repository_2=There are projects in the workspace shared with this repository. The projects will be updated with the new information that you have entered -CVSRepositoryPropertiesPage.sharedProject=The projects that are shared with {0} are: -CVSRepositoryPropertiesPage.useDefaultProgramName=Expect the &default program name "cvs" in text message prefixes from this server -CVSRepositoryPropertiesPage.useProgramName=Expect a custom &program name: -CVSRepositoryPropertiesPage.useLocationAsLabel=Use the &repository identification string as the label -CVSRepositoryPropertiesPage.useCustomLabel=Use a custom &label: - -CVSProjectSetSerializer.Confirm_Overwrite_Project_8=Confirm Overwrite Project -CVSProjectSetSerializer.The_project_{0}_already_exists._Do_you_wish_to_overwrite_it__9=The project {0} already exists. Do you wish to overwrite it? - -IgnoreResourcesDialog.titleSingle=Add {0} to .cvsignore -IgnoreResourcesDialog.titleMany=Add {0} resources to .cvsignore -IgnoreResourcesDialog.prompt=Select what to add to the .cvsignore file(s): -IgnoreResourcesDialog.addNameEntryButton=Resource(s) by name -IgnoreResourcesDialog.addNameEntryExample=Examples: file1.so, file2.so, .rcfile, bin -IgnoreResourcesDialog.addExtensionEntryButton=Wildcard extension -IgnoreResourcesDialog.addExtensionEntryExample=Examples: *.so, *.rcfile, bin -IgnoreResourcesDialog.addCustomEntryButton=Custom pattern -IgnoreResourcesDialog.addCustomEntryExample=The wildcard characters ''*'' and ''?'' are permitted. -IgnoreResourcesDialog.patternMustNotBeEmpty=Pattern must not be empty. -IgnoreResourcesDialog.patternDoesNotMatchFile=Pattern does not match all selected resources: e.g. {0} - -ContentAction.Confirm_Long_Operation_1=Confirm Long Operation -ContentAction.Changing_this_setting_will_involve_contacting_the_server_and_may_be_long-running_2=Changing this setting will involve contacting the server and may be long-running - -CVSProjectPropertiesPage.You_can_change_the_sharing_of_this_project_to_another_repository_location._However,_this_is_only_possible_if_the_new_location_is___compatible___(on_the_same_host_with_the_same_repository_path)._1=You can change the sharing of this project to another repository location. However, this is only possible if the new location is \"compatible\" (on the same host with the same repository path). - -ConfigurationWizardMainPage.Location_1=Location -ConfigurationWizardMainPage.Authentication_2=Authentication -ConfigurationWizardMainPage.Connection_3=Connection -AlternateUserValidationDialog.Enter_Password_2=Enter Password -AlternateUserValidationDialog.OK_6=OK -AlternateUserValidationDialog.Cancel_7=Cancel -AlternateUserValidationDialog.message=Enter the password for {0}: -WorkbenchUserAuthenticator.The_operation_was_canceled_by_the_user_1=The operation was canceled by the user -CVSCatchupReleaseViewer.No_workspace_file_1=No workspace file -CVSPreferencesPage.Timeout_must_not_be_negative_1=Timeout must not be negative -CVSPreferencesPage.Timeout_must_be_a_number_2=Timeout must be a number -CVSCatchupReleaseViewer.Select_&Outgoing_Additions_1=Select New Reso&urces -ForceCommitSyncAction.Outgoing_Changes_Not_Added_1=Outgoing Changes Not Added -ForceCommitSyncAction.You_have_chosen_to_commit_new_resources_which_have_not_been_added_to_version_control._Do_you_wish_to_add_them_to_version_control_now__2=You have chosen to commit new resources which have not been added to version control. Do you wish to add them to version control now? - -WorkingSetSelectionArea.workingSetOther=&Other... -ListSelectionArea.selectAll=&Select All -ListSelectionArea.deselectAll=&Deselect All - -RestoreFromRepositoryWizard.fileSelectionPageTitle=Restore from Repository -RestoreFromRepositoryWizard.fileSelectionPageDescription=Select the revision of each file that should be restored. -RestoreFromRepositoryFileSelectionPage.fileSelectionPaneTitle={0} - Select file to be restored: -RestoreFromRepositoryFileSelectionPage.revisionSelectionPaneTitle={0} - Check revision to be restored: -RestoreFromRepositoryFileSelectionPage.fileToRestore={0} ({1} to be restored) -RestoreFromRepositoryFileSelectionPage.fileContentPaneTitle={0} {1} in ''{2}'' -RestoreFromRepositoryFileSelectionPage.emptyRevisionPane=Remote revisions of selected file: -RestoreFromRepositoryFileSelectionPage.fileExists=File ''{0}'' already exists locally. -RestoreFromRepositoryFileSelectionPage.revisionIsDeletion=Revision {0} of {1} is the deletion and can not be restored. Select another revision of this file. -RestoreFromRepositoryAction.noFilesTitle=No Deleted Files Found -RestoreFromRepositoryAction.noFilesMessage=There were no deleted files found on the repository in folder ''{0}''. - -RepositoryRoot.folderInfoMissing=Local folder ''{0}'' is not properly mapped to a remote folder. - -RepositoriesViewContentHandler.unmatchedTag=No matching end tag found for tag ''{0}'' while reading repositories View configuration file. -RepositoriesViewContentHandler.missingAttribute=Required attribute ''{1}'' missing from tag ''{0}'' while reading repositories View configuration file. -RepositoriesViewContentHandler.errorCreatingRoot=An error occurred trying to create repository ''{0}''. - -CVSWorkingSetFolderSelectionPage.projectSelectionPageTitle=CVS Working Set -CVSWorkingSetFolderSelectionPage.projectSelectionPageDescription=Enter a working set name and select the working set folders. -CVSWorkingSetFolderSelectionPage.name=&Working set name: -CVSWorkingSetFolderSelectionPage.treeLabel=Working &set contents: -CVSWorkingSetFolderSelectionPage.refresh=&Refresh Contents -CVSWorkingSetFolderSelectionPage.invalidWorkingSetName=The name must contain only letters and digits. -CVSWorkingSetFolderSelectionPage.duplicateWorkingSetName=A working set of the specific name already exists. -CVSWorkingSetFolderSelectionPage.mustSelectFolder=At least one folder must be checked. - -WorkingSetSelectionDialog.title= Select CVS Working Set -WorkingSetSelectionDialog.title.multiSelect= Select CVS Working Sets -WorkingSetSelectionDialog.message= &Select a CVS working set: -WorkingSetSelectionDialog.message.multiSelect= &Select CVS working sets: -WorkingSetSelectionDialog.detailsButton.label= &Edit... -WorkingSetSelectionDialog.newButton.label= &New... -WorkingSetSelectionDialog.removeButton.label= &Remove - -RefreshTagsAction.title=Refresh Branch and Version Tags? -RefreshTagsAction.message=Repository ''{0}'' has {1} projects to refresh. Continue? - -WatchEditPreferencePage.description=Settings for CVS Watch/Edit. -WatchEditPreferencePage.checkoutReadOnly=&Configure projects to use Watch/Edit on checkout -WatchEditPreferencePage.validateEditSaveAction=When read-only files are modified in an editor -WatchEditPreferencePage.edit=Send a CVS &edit notification to the server -WatchEditPreferencePage.highjack=Edit the file &without informing the server -WatchEditPreferencePage.editPrompt=Before a CVS edit notification is sent to the server -WatchEditPreferencePage.neverPrompt=&Never prompt -WatchEditPreferencePage.alwaysPrompt=Always &prompt -WatchEditPreferencePage.onlyPrompt=&Only prompt if there are other editors - -Uneditaction.confirmMessage=Overwrite local changes to edited files? -Uneditaction.confirmTitle=Confirm Unedit - -FileModificationValidator.promptTitle=CVS Edit Files? -FileModificationValidator.promptMessage=There are read-only files being modified. Should a 'cvs edit' be performed? -FileModificationValidator.vetoMessage=User vetoed file modification - -RefreshRemoteProjectWizard.title=Refresh Branches -RefreshRemoteProjectWizard.0=Tags not found for some modules -RefreshRemoteProjectWizard.1=Search Deeply -RefreshRemoteProjectWizard.2=Skip -RefreshRemoteProjectWizard.3=Tags were not found on module {0} using the auto-refresh files and a shallow cvs log operation. You can choose to search this module using a deep cvs log operation or skip it. -RefreshRemoteProjectWizard.4=Tags were not found on {0} modules using the auto-refresh files and a shallow cvs log operation. You can choose to search these module using a deep cvs log operation or skip them. -RefreshRemoteProjectSelectionPage.pageTitle=Select Projects -RefreshRemoteProjectSelectionPage.pageDescription=Select the remote projects whose tags should be refreshed. -RefreshRemoteProjectSelectionPage.selectRemoteProjects=This wizard helps discover the tags associated with one or more remote projects. &Check the projects whose tags you wish to refresh. -RefreshRemoteProjectSelectionPage.noWorkingSet=Do not &use a working set -RefreshRemoteProjectSelectionPage.workingSet=Select a &working set (matching projects will be checked): - -EditorsView.file=File name -EditorsView.user=User name -EditorsView.date=Date -EditorsView.computer=Computer name - -EditorsDialog.title=Editors -EditorsDialog.question=The resource already has editors. Do you still want to edit the resource and send a CVS edit notification to server? -EditorsAction.classNotInitialized={0} not initialized - -TargetLocationSelectionDialog.projectNameLabel=&Project Name: -TargetLocationSelectionDialog.useDefaultLabel=Use default &workspace location -TargetLocationSelectionDialog.locationLabel=&Location: -TargetLocationSelectionDialog.parentDirectoryLabel=&Directory: -TargetLocationSelectionDialog.browseLabel=&Browse... -TargetLocationSelectionDialog.messageForSingle=Select the parent directory for project {0}. -TargetLocationSelectionDialog.messageForMulti=Select the parent directory for the {0} projects. -TagetLocationSelectionDialog.locationEmpty=Project contents directory must be specified. -TagetLocationSelectionDialog.invalidLocation=Invalid location path. -TagetLocationSelectionDialog.alreadyExists=Project {0} already exists. - -SynchronizeProjectsDialog.title=Synchronize CVS Projects -SynchronizeProjectsDialog.selectProjects=Projects to be synchronized -SynchronizeProjectsDialog.syncOutgoingChanges=Only synchronize projects with outgoing &changes -SynchronizeProjectsDialog.allSharedProjects=Include &all projects shared with CVS -SynchronizeProjectsDialog.sharedWorkingSetProjects=Include &working set resources shared with CVS: - -RemoteFileEditorInput.fullPathAndRevision={0} {1} - -CheckoutOperation.thisResourceExists=The resource ''{0}'' already exists in the workspace and will be deleted. Proceed with the check out of ''{1}''? -CheckoutOperation.thisExternalFileExists=The folder ''{0}'' exists in the local file system and will be deleted. Proceed with the check out of ''{1}''? -CheckoutOperation.confirmOverwrite=Confirm Overwrite -CheckoutOperation.scrubbingProject=Scrubbing project ''{0}''. -CheckoutOperation.refreshingProject=Configuring project ''{0}''. - -CheckoutSingleProjectOperation.taskname=Checking out ''{0}'' from CVS -CheckoutMultipleProjectsOperation.taskName=Checking out {0} folders from CVS - -CheckoutIntoOperation.taskname=Checking out {0} folders from CVS into ''{1}'' -CheckoutIntoOperation.targetIsFile=Folder ''{0}'' cannot be checked out because file ''{1}'' is in the way. -CheckoutIntoOperation.targetIsFolder=Folder ''{0}'' cannot be checked out because folder ''{1}'' is in the way. -CheckoutIntoOperation.targetIsPrunedFolder=Folder ''{0}'' cannot be checked out because it conflicts with the pruned folder ''{1}''. -CheckoutIntoOperation.mappingAlreadyExists=Cannot checkout remote folder ''{0}'' into ''{1}'' because local folder ''{2}'' is already mapped to remote folder ''{0}''. -CheckoutIntoOperation.cancelled=Checkout of ''{1}'' cancelled by user. -CheckoutIntoOperation.overwriteMessage=Folder ''{0}'' already exists and will be deleted. Continue? - -AddToWorkspace.taskName1=Checking out ''{0}'' from CVS -AddToWorkspace.taskNameN=Checking out {0} folders from CVS - -CheckoutAsAction.checkoutFailed=Problems encountered performing checkout - -CheckoutAsAction.enterProjectTitle=Check Out {0} As... -CheckoutAsAction.enterLocationTitle=Check Out {0} Projects As... -CheckoutAsAction.taskname=Checking out "{0}" from CVS as "{1}" -CheckoutAsAction.multiCheckout=Checking out {0} projects from CVS - -CheckoutAsWizard.title=Check Out As -CheckoutAsWizard.error=Problems encountered performing checkout -CheckoutAsMainPage.title=Check Out As -CheckoutAsMainPage.description=Select the method of check out -CheckoutAsMainPage.singleFolder=Choose how to check out folder ''{0}'' -CheckoutAsMainPage.asConfiguredProject=Check out as a project &configured using the New Project Wizard -CheckoutAsMainPage.asSimpleProject=Check out as a &project in the workspace -CheckoutAsMainPage.projectNameLabel=&Project Name: -CheckoutAsMainPage.multipleFolders=Choose how to check out the {0} folders -CheckoutAsMainPage.asProjects=Check out into the &workspace as projects -CheckoutAsMainPage.intoProject=Check out &into an existing project - -CheckoutAsLocationSelectionPage.title=Check Out As -CheckoutAsLocationSelectionPage.description=Select the project location -CheckoutAsLocationSelectionPage.useDefaultLabel=Use default &workspace location -CheckoutAsLocationSelectionPage.locationLabel=&Location: -CheckoutAsLocationSelectionPage.parentDirectoryLabel=&Directory: -CheckoutAsLocationSelectionPage.browseLabel=&Browse... -CheckoutAsLocationSelectionPage.locationEmpty=Project contents directory must be specified. -CheckoutAsLocationSelectionPage.invalidLocation=Invalid location path. -CheckoutAsLocationSelectionPage.messageForSingle=Select the parent directory for project {0}. -CheckoutAsLocationSelectionPage.messageForMulti=Select the parent directory for the {0} projects. - -CheckoutAsProjectSelectionPage.title=Check Out Into -CheckoutAsProjectSelectionPage.description=Select the local folder that is the target of the checkout operation. -CheckoutAsProjectSelectionPage.name=Target folder &name: -CheckoutAsProjectSelectionPage.treeLabel=&Parent of target folder: -CheckoutAsProjectSelectionPage.showLabel=&Filter project list: -CheckoutAsProjectSelectionPage.recurse=&Checkout subfolders -CheckoutAsProjectSelectionPage.showAll=Show all valid target projects -CheckoutAsProjectSelectionPage.showUnshared=Show unshared projects -CheckoutAsProjectSelectionPage.showSameRepo=Show projects shared with the same repository -CheckoutAsProjectSelectionPage.invalidFolderName=''{0}'' is not a valid folder name - -TargetLocationSelectionDialog.projectNameLabel=&Project Name: -TargetLocationSelectionDialog.useDefaultLabel=Use default &workspace location -TargetLocationSelectionDialog.locationLabel=&Location: -TargetLocationSelectionDialog.parentDirectoryLabel=&Directory: -TargetLocationSelectionDialog.browseLabel=&Browse... -TargetLocationSelectionDialog.messageForSingle=Select the parent directory for project {0}. -TargetLocationSelectionDialog.messageForMulti=Select the parent directory for the {0} projects. -TagetLocationSelectionDialog.locationEmpty=Project contents directory must be specified. -TagetLocationSelectionDialog.invalidLocation=Invalid location path. -TagetLocationSelectionDialog.alreadyExists=Project {0} already exists. -CheckoutIntoWizard.title=Checkout Into -CheckoutIntoWizard.projectSelectionPageTitle=Select local folder -CheckoutIntoWizard.projectSelectionPageDescription=Select the local folder that is the target of the checkout operation. -CheckoutIntoWizard.error=Checkout Error - -WorkspaceChangeSetCapability.1=New Set -OpenCommitSetAction.20=Open Change in Compare Editor -OpenCommitSetAction.21=Could not determine the repository location of the selected resources -WorkspaceChangeSetCapability.2=New Change Set -WorkspaceChangeSetCapability.3=Enter the name and comment for the new change set -CVSChangeSetCollector.4=Retrieving revision histories -CVSChangeSetCollector.0=Unassigned Remote Changes -WorkspaceChangeSetCapability.7=Edit Change Set Comment -WorkspaceChangeSetCapability.8=Edit the name and comment for the change set - -CheckoutIntoWizard.thisResourceExists=The resource ''{0}'' already exists in the workspace. Overwrite? -CheckoutIntoWizard.confirmOverwrite=Confirm Overwrite -CheckoutIntoWizard.mappingAlreadyExists=Cannot add remote folder ''{0}'' to project ''{1}'' as ''{2}'' because local folder ''{3}'' is already mapped to that folder. -CheckoutIntoProjectSelectionPage.description=Choose the name and parent folder where ''{0}'' should be checked out to. -CheckoutIntoProjectSelectionPage.name=Target folder &name: -CheckoutIntoProjectSelectionPage.treeLabel=&Parent of target folder: -CheckoutIntoProjectSelectionPage.showLabel=&Filter project list: -CheckoutIntoProjectSelectionPage.showAll=Show all valid target projects -CheckoutIntoProjectSelectionPage.showUnshared=Show unshared projects -CheckoutIntoProjectSelectionPage.showSameRepo=Show projects shared with the same repository -CheckoutIntoProjectSelectionPage.recurse=&Checkout subfolders -CheckoutIntoProjectSelectionPage.invalidFolderName=''{0}'' is not a valid folder name - -HasProjectMetaFile.taskName=Looking for a remote meta file -TagFromWorkspace.taskName=Tagging from workspace -TagFromRepository.taskName=Tagging from repository -UpdateOnlyMergeable.taskName=Updating mergeable changes -UpdateDialog.overwriteTitle=Overwrite Local Changes? -UpdateDialog.overwriteMessage=Do you want to overwrite local changes? -ReplaceOperation.taskName=CVS Replace -UpdateOperation.taskName=CVS Update - -SafeUpdateAction.warnFilesWithConflictsTitle=Non-mergeable files -SafeUpdateAction.warnFilesWithConflictsDescription=Some conflicting files cannot be merged automatically with the update action. They contain conflicting changes that will have to be merged manually. Use the Synchronize View to find the conflicts then merge the changes in a compare editor. - -SafeUpdateAction.warnFilesWithConflictsTitle=Non-mergeable files -SafeUpdateAction.warnFilesWithConflictsDescription=Some conflicting files cannot be merged automatically with the update action. They contain conflicting changes that will have to be merged manually. Use the Synchronize View to find the conflicts then merge the changes in a compare editor. - -Error.unableToShowSyncView=Error opening Synchronize View. Please ensure that the Team plugin is installed correctly. -ShowAnnotationAction.1=Unexpected response from CVS Server: {0} -ShowAnnotationAction.2=Annotate Binary File? -ShowAnnotationAction.3=File {0} is marked as a binary file. The CVS annotation operation only works properly for files that contain text. Do you wish to continue? - -UpdateAction.jobName=CVS Update -MergeUpdateAction.jobName=CVS Merge -MergeUpdateAction.invalidSubscriber=Invalid subscriber: {0} -CommitAction.jobName=CVS Commit -OverrideAndUpdateAction.jobName=Performing CVS Override and Update on {0} resources -WorkInProgressPreferencePage.0=CVS Work In Progress -WorkInProgressPreferencePage.1=Preferences for enabling features that are not complete: -WorkInProgressPreferencePage.7=Switch to the associated perspective after a show annotations operation is complete: -WorkInProgressPreferencePage.8=Al&ways -WorkInProgressPreferencePage.2=N&ever -WorkInProgressPreferencePage.3=&Prompt -WorkInProgressPreferencePage.4=Associated perspective for the show annotations operation: -WorkInProgressPreferencePage.5=Pe&rspective: -WorkInProgressPreferencePage.6=None - - - -CheckoutProjectOperation.8=Checking out ''{0}'' into project ''{1}'' -CheckoutProjectOperation.9=Checking out ''{0}'' into {1} projects -CheckoutProjectOperation.0=Checkout of remote folder {0} cancelled by user -CVSOperation.0=Errors occured in {0} of {1} operations. -CVSOperation.1=Show CVS Console -CVSOperation.2=Show CVS Console -CVSModelElement.0=Error -CVSModelElement.1=Error fetching resource list from repository. -CVSDecorator.exceptionMessage=Errors occured while applying CVS decorations to resources. -FetchMembersOperation.0=Fetching members of {0} - -RemoteRevisionQuickDiffProvider.readingFile=Error reading remote file -RemoteRevisionQuickDiffProvider.closingFile=Error closing remote file -RemoteRevisionQuickDiffProvider.fetchingFile=CVS QuickDiff: fetching remote contents -RemoteCompareOperation.0=Comparing tags {0} and {1} of {2} - -WorkspaceToolbarCommitAction.label=Commit -WorkspaceToolbarCommitAction.tooltip=Commit All Outgoing Changes... -WorkspaceToolbarCommitAction.description=Commit All Outgoing Changes... -WorkspaceToolbarCommitAction.image=checkin_action.gif - -WorkspaceToolbarUpdateAction.label=Update -WorkspaceToolbarUpdateAction.tooltip=Update All Incoming Changes... -WorkspaceToolbarUpdateAction.description=Update All Incoming Changes... -WorkspaceToolbarUpdateAction.image=checkout_action.gif - -SharingWizardIgnore.label=Ignore -SharingWizardIgnore.tooltip=Ignore Selected Resources... -SharingWizardIgnore.description=Ignore Selected Resources... -SharingWizardIgnore.image=ignorefiles.gif - -ConsoleRemoveAction.label=Close CVS Console -ConsoleRemoveAction.tooltip=Close CVS console -ConsoleRemoveAction.image=participant_rem.gif - -WorkspaceUpdateAction.label=&Update -WorkspaceUpdateAction.tooltip=Perform an update on the selected resources -WorkspaceUpdateAction.helpContextId=org.eclipse.team.cvs.ui.workspace_update_action - -OverrideAndUpdateAction.label=O&verride and Update -OverrideAndUpdateAction.tooltip=Perform an override and update on the selected resources. This will make the local contents equal to the remote ignoring any local changes. -OverrideAndUpdateAction.helpContextId=org.eclipse.team.cvs.ui.workspace_overupdate_action - -RefreshDirtyStateAction.label=C&lean Timestamps -RefreshDirtyStateOperation.0=Problems encountered cleaning timestamps -RefreshDirtyStateOperation.1=CVS Clean Timestamps -RefreshDirtyStateAction.tooltip=Reset the dirty state of out-of-sync files whose contents match the server contents -RefreshDirtyStateAction.helpContextId=org.eclipse.team.cvs.ui.workspace_refresh_dirty_state_action_context - -WorkspaceCommitAction.label=&Commit... -WorkspaceCommitAction.tooltip=Perform a commit on the selected resources -WorkspaceCommitAction.helpContextId="org.eclipse.team.cvs.ui.workspace_commit_action - -OverrideAndCommitAction.label=Override and Comm&it... -OverrideAndCommitAction.tooltip=Perform an override and commit on the selected resources. This will make the remote contents equal to the local ignoring any remote changes. -OverrideAndCommitAction.helpContextId=org.eclipse.team.cvs.ui.workspace_overcommit_action - -ConfirmMergedAction.label=&Mark as Merged -ConfirmMergedAction.tooltip=Mark the conflict as merged by upgrading the base to match the remote -ConfirmMergedAction.helpContextId=org.eclipse.team.cvs.ui.workspace_confirm_merged_action - -BranchAction.label=&Branch... -BranchAction.tooltip=Branch - -IgnoreAction.label=A&dd to .cvsignore... -IgnoreAction.0=Ignoring selected resources for project {0} -IgnoreAction.1=Ignoring Resources -IgnoreAction.tooltip=Ignore the Selected Resources when Synchronizing - -ShowResourceInHistoryAction.label=Show in Resource &History -ShowResourceInHistoryAction.tooltip=Show in Resource History - -ShowAnnotationAction.label=Show &Annotation -ShowAnnotationAction.tooltip=Show Annotation - -GenerateDiffFileAction.label=Create &Patch... -GenerateDiffFileOperation.0=The file could not be written. Possible reasons are the directory is write-protected or not enough disk space is available. -GenerateDiffFileOperation.1=The file could not be written due to an I/O error. -GenerateDiffFileOperation.2=An I/O error occured. -GenerateDiffFileWizard.0=Please enter a valid location. -GenerateDiffFileWizard.2=Please enter a file name. -GenerateDiffFileWizard.3=The specified directory does not exist. -GenerateDiffFileWizard.4=Please select a location in the workspace. -GenerateDiffFileWizard.5=Please enter a valid filename. -GenerateDiffFileAction.tooltip=Compare your workspace contents with the server and generate a diff file that can be used as a patch file. - -MergeUpdateAction.label=&Update -MergeUpdateAction.tooltip=Perform an update merge on the selected resources -MergeUpdateAction.helpContextId=org.eclipse.team.cvs.ui.merge_update_action - -CompareRevertAction.label=&Override and Update -CompareRevertAction.tooltip=Revert the local file contents to match that of their corresponding remotes -CompareRevertAction.helpContextId=org.eclipse.team.cvs.ui.compare_revert_action - -SharingCommitAction.label=Commit -SharingCommitAction.tooltip=Commit All Changes... -SharingCommitAction.description=Commit All Changes... -SharingCommitAction.image=checkin_action.gif - -MergeSynchronizeParticipant.8=Missing id initializing cvs merge participant -MergeSynchronizeParticipant.9=Unable to initialize cvs merge subscriber -MergeSynchronizeParticipant.10=Missing root nodes in cvs merge subscriber memento: {0} -MergeSynchronizeParticipant.11=Root resource in cvs merge subscriber is no longer in workspace, ignoring: {0} -MergeSynchronizeParticipant.12=Missing root resources for cvs merge subscriber: {0} -DisconnectOperation.0=Disconnecting -DisconnectOperation.1=Disconnecting {0} -SubscriberConfirmMergedAction.0=Synchronization information is missing for resource {0} -SubscriberConfirmMergedAction.jobName=Performing a CVS Mark as Merged operation on {0} resources. -CVSSubscriberAction.0=Invalid attemp to make unsupervised resource {0} in-sync. -ReleaseCommentDialog.6=Review resources that will be committed: -ReconcileProjectOperation.0=Reconciling project {0} with remote folder {1} -CheckoutToRemoteFolderOperation.0=Downloading folder {0} -CVSRepositoryPropertiesPage.21=Use this location's connection information for all connections -CVSRepositoryPropertiesPage.22=Use the following locations for read and write access -CVSRepositoryPropertiesPage.23=Read: -CVSRepositoryPropertiesPage.24=Write: -CVSRepositoryPropertiesPage.0=Confirm Host or Path Change -CVSRepositoryPropertiesPage.1=You have chosen to change the host name or repository root path for this location. You should ensure that this new information still identifies the same repository. -CompareRevertAction.0=Reverting {0} resources -CompareParticipant.0={0} ({1}) -ComparePreferencePage.0=Options for CVS comparisons: -ComparePreferencePage.1=Show the &file author in compare editors -ComparePreferencePage.2=Automatically enable co&mmit set grouping in CVS synchronizations -FileModificationValidator.3=Perform Edit? -FileModificationValidator.4=A CVS edit notification is required to be sent to the server in order to allow editing of one or more selected files. Continue? -CVSSynchronizeViewPage.0=Show incoming grouped by comment -CVSSynchronizeWizard.0=Unknown -Participant.comparing=Comparing -Participant.merging=Merging -Participant.synchronizing=Synchronizing - -Participant.comparingDetail=Comparing {0} with {1} -Participant.mergingDetail=Merging {0} -Participant.synchronizingDetail=Synchronizing {0} - -CompareWithRevisionAction.4=Compare With Revision -ReplaceWithRevisionAction.0=&Replace -ReplaceWithRevisionAction.1=Replace With Revision - -ConsolePreferencesPage.4=&Show CVS console automatically when command is run -ConsolePreferencesPage.5=&Limit console output -ConsolePreferencesPage.6=&Fixed width console -ConsolePreferencesPage.7=Character &width: -ConsolePreferencesPage.8=&Console &buffer size (characters): -ConsolePreferencesPage.9=CVS Console Settings: - -SharingWizard.23=Share Project Resources -SharingWizard.24=Review and commit resources to the repository. Use the context menu to perform additional operations on the resources. -SharingWizard.25=Module ''{0}'' exists on the server. Select the tag to synchronize with. -SharingWizardSyncPage.0=Sharing -ReconcileProjectOperation.1=Local resource {0} is a file while the corresponding remote {1} is a folder -ReconcileProjectOperation.2=Local resource {0} is a folder while the corresponding remote {1} is a file -ShareProjectOperation.0=Sharing project {0} as {1} -SharingWizard.26=Keep Sharing? -SharingWizard.27=Project {0} has been mapped to a remote module. Should this mapping be kept? -SharingWizardSyncPage.3=The resources of project {0} are in-sync with the repository. -SharingWizardSyncPage.4=An error has occurred populating this view. -SharingWizardSyncPage.5=Show Errors -SharingWizardSyncPage.8=Errors Occurred -SharingWizardSyncPage.9=The following errors occurred. -SharingWizardSyncPage.10=Commit Changes? -SharingWizardSyncPage.11=There are still uncommitted changes that have not been shared. Should these changes be committed? -ShareProjectOperation.1=Calculating synchronization states -CVSProjectPropertiesPage.31=Show only compatible repository locations -CVSProjectPropertiesPage.32=Confirm -CVSProjectPropertiesPage.33=The selected repository location may not be compatible with the current location. Are you sure you want to change sharing to the new location? -RepositoryEncodingPropertyPage.2=Identify the file system encoding used by the server where the repository is located. Setting this will allow file names and commit comments to be properly translated between the client and server in cases where the server encoding differs from the client. -RepositoryEncodingPropertyPage.3=Server Encoding -RepositoryEncodingPropertyPage.0=Cannot Change Encoding -RepositoryEncodingPropertyPage.1=Location {0} no longer exists. -RepositoryEncodingPropertyPage.4=Note: this setting does not apply to file content encodings. File content encodings can be set on the Workbench/Editors preference page and on the Info property page of a project. -CheckoutWizard.7=Checkout Project from CVS Repsitory -CheckoutWizard.8=This wizard allows you to checkout projects from a CVS Repository. -CheckoutWizard.0=Checkout from CVS -CheckoutWizard.10=Select Module -CheckoutWizard.11=Select the module to be checked out from CVS -ModuleSelectionPage.2=Use an existing &module (this will allow you to browse the modules in the repository) -CheckoutAsWizard.3=Select Tag -CheckoutAsWizard.4=Choose the tag to check out from -CheckoutAsMainPage.10=(Only available when the .project file does not exist in the repository) -CVSTeamProvider.updatingFile=Updating {0} -CVSTeamProvider.makeBranch=Creating branch -CVSTeamProvider.folderInfo=Updating folder synchronization information for project {0} -CVSTeamProvider.updatingFolder=Updating {0} -AddOperation.0=Adding {0} -BranchOperation.0=Branching -BranchOperation.1=Branching {0} -CommitOperation.0=Committing {0} -CommitSetDialog.0=&Name: -CommitSetDialog.2=Use the &title as the commit comment -CommitSetDialog.3=Enter a commit &comment -UpdateOperation.0=Updating {0} -ReplaceOperation.0=Replacing {0} -TagOperation.0=Tagging {0} -RemoteAnnotationStorage.1=As error occurred computing the content type of remote resource {0} -DateTagCategory.0=Dates -DateTagDialog.0=Date (M/D/Y): -DateTagDialog.1=Include time component in tag -DateTagDialog.2=Time (HH:MM:SS): -DateTagDialog.3=Time is local -DateTagDialog.4=Time is in universal time coordinates (UTC) -DateTagDialog.5=Create Date Tag -WorkbenchPreference.defaultEncoding = Defaul&t ({0}) -WorkbenchPreference.otherEncoding = &Other: -WorkbenchPreference.unsupportedEncoding = The selected encoding is not supported. - -LogEntryCacheUpdateHandler.0=Errors have occured while maintaining the log entry cache. -LogEntryCacheUpdateHandler.1=Updating revision histories -LogEntryCacheUpdateHandler.2=Could not fetch revision histories due to an internal timeout. -MultiFolderTagSource.0={0} folders -LocalProjectTagSource.0={0} Projects -AnnotateView.0=Could not find an appropriate editor diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/AllRootsElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/AllRootsElement.java deleted file mode 100644 index 20226e3de..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/AllRootsElement.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * AllRootsElement is the model element for the repositories view. - * Its children are the array of all known repository roots. - */ -public class AllRootsElement extends CVSModelElement implements IAdaptable { - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryRoots(); - } - public String getLabel(Object o) { - return null; - } - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - public Object getParent(Object o) { - return null; - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchCategory.java deleted file mode 100644 index df0bff51d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchCategory.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -/** - * BranchCategory is the model element for the branches category - * for a particular repository in the repositories view. Its children - * are the array of all known branch tags, other than HEAD, for the - * given repository. - */ -public class BranchCategory extends TagCategory { - - public BranchCategory(ICVSRepositoryLocation repository) { - super(repository); - } - - protected CVSTag[] getTags(IProgressMonitor monitor) throws CVSException { - return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(repository, getWorkingSet(), CVSTag.BRANCH, monitor); - } - - /** - * Returns an image descriptor to be used for displaying an object in the workbench. - * Returns null if there is no appropriate image. - * - * @param object The object to get an image descriptor for. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY); - } - - /** - * Returns the name of this element. This will typically - * be used to assign a label to this object when displayed - * in the UI. Returns an empty string if there is no appropriate - * name for this object. - * - * @param object The object to get a label for. - */ - public String getLabel(Object o) { - return Policy.bind("BranchCategory.Branches_1"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java deleted file mode 100644 index 03745ed11..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.views.properties.IPropertySource; - -public class CVSAdapterFactory implements IAdapterFactory { - private Object fileAdapter = new RemoteFileElement(); - private Object folderAdapter = new RemoteFolderElement(); - private Object rootAdapter = new CVSRepositoryRootElement(); - - // Property cache - private Object cachedPropertyObject = null; - private Object cachedPropertyValue = null; - - /** (Non-javadoc) - * Method declared on IAdapterFactory. - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (IWorkbenchAdapter.class == adapterType) { - return getWorkbenchAdapter(adaptableObject); - } - - if(IDeferredWorkbenchAdapter.class == adapterType) { - Object o = getWorkbenchAdapter(adaptableObject); - if(o != null && o instanceof IDeferredWorkbenchAdapter) { - return o; - } - return null; - } - - if (IPropertySource.class == adapterType) { - return getPropertySource(adaptableObject); - } - return null; - } - - protected Object getWorkbenchAdapter(Object o) { - if (o instanceof ICVSRemoteFile) { - return fileAdapter; - } else if (o instanceof ICVSRepositoryLocation) { - return rootAdapter; - } else if (o instanceof RepositoryRoot) { - return rootAdapter; - } else if (o instanceof ICVSRemoteFolder) { - return folderAdapter; - } - return null; - } - - /** (Non-javadoc) - * Method declared on IAdapterFactory. - */ - public Class[] getAdapterList() { - return new Class[] {IWorkbenchAdapter.class, IPropertySource.class, IDeferredWorkbenchAdapter.class}; - } - /** - * Returns the property source for the given object. Caches - * the result because the property sheet is extremely inefficient, - * it asks for the source seven times in a row. - */ - public Object getPropertySource(Object adaptableObject) { - if (adaptableObject == cachedPropertyObject) { - return cachedPropertyValue; - } - cachedPropertyObject = adaptableObject; - if (adaptableObject instanceof ICVSRemoteFile) { - cachedPropertyValue = new CVSRemoteFilePropertySource((ICVSRemoteFile)adaptableObject); - } else if (adaptableObject instanceof ICVSRemoteFolder) { - cachedPropertyValue = new CVSRemoteFolderPropertySource((ICVSRemoteFolder)adaptableObject); - } else if (adaptableObject instanceof ICVSRepositoryLocation) { - cachedPropertyValue = new CVSRepositoryLocationPropertySource((ICVSRepositoryLocation)adaptableObject); - } else if (adaptableObject instanceof RepositoryRoot) { - cachedPropertyValue = new CVSRepositoryLocationPropertySource(((RepositoryRoot)adaptableObject).getRoot()); - } else { - cachedPropertyValue = null; - } - return cachedPropertyValue; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java deleted file mode 100644 index 6a8475dd2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.progress.IElementCollector; - -public abstract class CVSModelElement implements IWorkbenchAdapter, IAdaptable { - - private IRunnableContext runnableContext; - private IWorkingSet workingSet; - - public IWorkingSet getWorkingSet() { - return workingSet; - } - - public void setWorkingSet(IWorkingSet workingSet) { - this.workingSet = workingSet; - } - - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) - return this; - if ((adapter == IDeferredWorkbenchAdapter.class) && this instanceof IDeferredWorkbenchAdapter) - return this; - return null; - } - - /** - * Returns the runnableContext. - * @return ITeamRunnableContext - */ - public IRunnableContext getRunnableContext() { - if (runnableContext == null) { - return PlatformUI.getWorkbench().getProgressService(); - } - return runnableContext; - } - - /** - * Sets the runnableContext. - * @param runnableContext The runnableContext to set - */ - public void setRunnableContext(IRunnableContext runnableContext) { - this.runnableContext = runnableContext; - } - - public Object[] getChildren(Object o) { - return getChildren(o, true); - } - - /** - * Gets the children of the receiver by invoking the internalGetChildren. - * A appropriate progress indicator will be used if requested. - */ - protected Object[] getChildren(final Object o, boolean needsProgress) { - try { - if (needsProgress) { - final Object[][] result = new Object[1][]; - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - result[0] = CVSModelElement.this.fetchChildren(o, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }; - getRunnableContext().run(true /*fork*/, true /*cancelable*/, runnable); - return result[0]; - } else { - return fetchChildren(o, null); - } - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - handle(e); - } catch (TeamException e) { - handle(e); - } - return new Object[0]; - } - - abstract protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException; - - /** - * Handle an exception that occurred in CVS model elements by displaying an error dialog. - * @param title the title of the error dialog - * @param description the description to be displayed - * @param e the exception that occurred - */ - protected void handle(final String title, final String description, final Throwable e) { - CVSUIPlugin.openError(null, title, description, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS | CVSUIPlugin.PERFORM_SYNC_EXEC); - } - - /** - * Helper methed error handler that displayes a generic dialog title and message when displaying an error to the user. - * @param t the exception that occurred. - */ - protected void handle(Throwable t) { - handle(Policy.bind("CVSModelElement.0"), Policy.bind("CVSModelElement.1"), t); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Handle an exception that occurred while fetching the children for a deferred workbench adapter. - * @param collector the collector for the adapter - * @param e the exception that occurred - */ - protected void handle(IElementCollector collector, Throwable t) { - // TODO: For now, just display a dialog (see bug 65008 and 65741) - handle(t); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java deleted file mode 100644 index 4067cea15..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class CVSRemoteFilePropertySource implements IPropertySource { - ICVSRemoteFile file; - ILogEntry entry; - boolean initialized; - - // Property Descriptors - static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[5]; - { - PropertyDescriptor descriptor; - String category = Policy.bind("cvs"); //$NON-NLS-1$ - - // resource name - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_NAME, Policy.bind("CVSRemoteFilePropertySource.name")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[0] = descriptor; - // revision - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_REVISION, Policy.bind("CVSRemoteFilePropertySource.revision")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[1] = descriptor; - // date - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_DATE, Policy.bind("CVSRemoteFilePropertySource.date")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[2] = descriptor; - // author - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_AUTHOR, Policy.bind("CVSRemoteFilePropertySource.author")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[3] = descriptor; - // comment - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_COMMENT, Policy.bind("CVSRemoteFilePropertySource.comment")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[4] = descriptor; - } - - /** - * Create a PropertySource and store its file - */ - public CVSRemoteFilePropertySource(ICVSRemoteFile file) { - this.file = file; - } - - /** - * Do nothing because properties are read only. - */ - public Object getEditableValue() { - return this; - } - - /** - * Return the Property Descriptors for the receiver. - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - return propertyDescriptors; - } - - /* - * @see IPropertySource#getPropertyValue(Object) - */ - public Object getPropertyValue(Object id) { - if (!initialized) { - initialize(); - initialized = true; - } - if (id.equals(ICVSUIConstants.PROP_NAME)) { - return file.getName(); - } - if (entry != null) { - if (id.equals(ICVSUIConstants.PROP_REVISION)) { - return entry.getRevision(); - } - if (id.equals(ICVSUIConstants.PROP_DATE)) { - return entry.getDate(); - } - if (id.equals(ICVSUIConstants.PROP_AUTHOR)) { - return entry.getAuthor(); - } - if (id.equals(ICVSUIConstants.PROP_COMMENT)) { - return entry.getComment(); - } - } - return ""; //$NON-NLS-1$ - } - - /** - * Answer true if the value of the specified property - * for this object has been changed from the default. - */ - public boolean isPropertySet(Object property) { - return false; - } - /** - * Reset the specified property's value to its default value. - * Do nothing because properties are read only. - * - * @param property The property to reset. - */ - public void resetPropertyValue(Object property) { - } - /** - * Do nothing because properties are read only. - */ - public void setPropertyValue(Object name, Object value) { - } - - private void initialize() { - try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ILogEntry[] entries = file.getLogEntries(monitor); - String revision = file.getRevision(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getRevision().equals(revision)) { - entry = entries[i]; - return; - } - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InterruptedException e) { // ignore cancellation - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(null, null, null, e); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFolderPropertySource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFolderPropertySource.java deleted file mode 100644 index 618d69ec3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFolderPropertySource.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class CVSRemoteFolderPropertySource implements IPropertySource { - ICVSRemoteFolder folder; - - // Property Descriptors - static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[2]; - { - PropertyDescriptor descriptor; - String category = Policy.bind("cvs"); //$NON-NLS-1$ - - // resource name - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_NAME, Policy.bind("CVSRemoteFolderPropertySource.name")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[0] = descriptor; - // tag - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_TAG, Policy.bind("CVSRemoteFolderPropertySource.tag")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[1] = descriptor; - } - - /** - * Create a PropertySource and store its file - */ - public CVSRemoteFolderPropertySource(ICVSRemoteFolder folder) { - this.folder = folder; - } - - /** - * Do nothing because properties are read only. - */ - public Object getEditableValue() { - return this; - } - - /** - * Return the Property Descriptors for the receiver. - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - return propertyDescriptors; - } - - /* - * @see IPropertySource#getPropertyValue(Object) - */ - public Object getPropertyValue(Object id) { - if (id.equals(ICVSUIConstants.PROP_NAME)) { - return folder.getName(); - } - if (id.equals(ICVSUIConstants.PROP_TAG)) { - CVSTag tag = folder.getTag(); - if (tag == null) { - return Policy.bind("CVSRemoteFolderPropertySource.none"); //$NON-NLS-1$ - } - return tag.getName(); - } - return ""; //$NON-NLS-1$ - } - - /** - * Answer true if the value of the specified property - * for this object has been changed from the default. - */ - public boolean isPropertySet(Object property) { - return false; - } - /** - * Reset the specified property's value to its default value. - * Do nothing because properties are read only. - * - * @param property The property to reset. - */ - public void resetPropertyValue(Object property) { - } - /** - * Do nothing because properties are read only. - */ - public void setPropertyValue(Object name, Object value) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryLocationPropertySource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryLocationPropertySource.java deleted file mode 100644 index e4c45de8a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryLocationPropertySource.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -public class CVSRepositoryLocationPropertySource implements IPropertySource { - ICVSRepositoryLocation location; - - // Property Descriptors - static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[5]; - { - PropertyDescriptor descriptor; - String category = Policy.bind("cvs"); //$NON-NLS-1$ - - // host - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_HOST, Policy.bind("CVSRepositoryLocationPropertySource.host")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[0] = descriptor; - // user - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_USER, Policy.bind("CVSRepositoryLocationPropertySource.user")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[1] = descriptor; - // port - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_PORT, Policy.bind("CVSRepositoryLocationPropertySource.port")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[2] = descriptor; - // root - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_ROOT, Policy.bind("CVSRepositoryLocationPropertySource.root")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[3] = descriptor; - // method - descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_METHOD, Policy.bind("CVSRepositoryLocationPropertySource.method")); //$NON-NLS-1$ - descriptor.setAlwaysIncompatible(true); - descriptor.setCategory(category); - propertyDescriptors[4] = descriptor; - } - - /** - * Create a PropertySource and store its file - */ - public CVSRepositoryLocationPropertySource(ICVSRepositoryLocation location) { - this.location = location; - } - - /** - * Do nothing because properties are read only. - */ - public Object getEditableValue() { - return this; - } - - /** - * Return the Property Descriptors for the receiver. - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - return propertyDescriptors; - } - - /* - * @see IPropertySource#getPropertyValue(Object) - */ - public Object getPropertyValue(Object id) { - if (id.equals(ICVSUIConstants.PROP_HOST)) { - return location.getHost(); - } - if (id.equals(ICVSUIConstants.PROP_USER)) { - return location.getUsername(); - } - if (id.equals(ICVSUIConstants.PROP_METHOD)) { - return location.getMethod().getName(); - } - if (id.equals(ICVSUIConstants.PROP_ROOT)) { - return location.getRootDirectory(); - } - if (id.equals(ICVSUIConstants.PROP_PORT)) { - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { - return Policy.bind("CVSRepositoryLocationPropertySource.default"); //$NON-NLS-1$ - } - return "" + port; //$NON-NLS-1$ - } - return ""; //$NON-NLS-1$ - } - - /** - * Answer true if the value of the specified property - * for this object has been changed from the default. - */ - public boolean isPropertySet(Object property) { - return false; - } - /** - * Reset the specified property's value to its default value. - * Do nothing because properties are read only. - * - * @param property The property to reset. - */ - public void resetPropertyValue(Object property) { - } - /** - * Do nothing because properties are read only. - */ - public void setPropertyValue(Object name, Object value) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryRootElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryRootElement.java deleted file mode 100644 index 6a36ee995..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRepositoryRootElement.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; - -/** - * RemoteRootElement is the model element for a repository that - * appears in the repositories view. Its children are: - * a) HEAD - * b) Branch tags category - * c) Version tags category - */ -public class CVSRepositoryRootElement extends CVSModelElement { - public ImageDescriptor getImageDescriptor(Object object) { - if (object instanceof ICVSRepositoryLocation || object instanceof RepositoryRoot) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_REPOSITORY); - } - return null; - } - public String getLabel(Object o) { - if (o instanceof ICVSRepositoryLocation) { - ICVSRepositoryLocation root = (ICVSRepositoryLocation)o; - o = CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(root); - if (o == null) { - return root.getLocation(); - } - } - if (o instanceof RepositoryRoot) { - RepositoryRoot root = (RepositoryRoot)o; - String name = root.getName(); - if (name == null) - return root.getRoot().getLocation(); - else - return name; - } - return null; - } - public Object getParent(Object o) { - return null; - } - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - ICVSRepositoryLocation location = null; - if (o instanceof ICVSRepositoryLocation) { - location = (ICVSRepositoryLocation)o; - } - if (o instanceof RepositoryRoot) { - RepositoryRoot root = (RepositoryRoot)o; - location = root.getRoot(); - } - if (location == null) return null; - return new Object[] { - new CVSTagElement(CVSTag.DEFAULT, location), - new BranchCategory(location), - new VersionCategory(location), - new DateTagCategory(location) - }; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSResourceElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSResourceElement.java deleted file mode 100644 index 6bf857197..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSResourceElement.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.ui.model.IWorkbenchAdapter; - -public abstract class CVSResourceElement extends CVSModelElement implements IAdaptable { - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - /** - * Initial implementation: return the resource's name - */ - public String getLabel(Object o) { - if (!(o instanceof ICVSResource)) return null; - return ((ICVSResource)o).getName(); - } - /** - * Return null. - */ - public Object getParent(Object o) { - if (!(o instanceof ICVSResource)) return null; - return null; - } - - abstract public ICVSResource getCVSResource(); -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java deleted file mode 100644 index dddebca71..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import java.lang.reflect.InvocationTargetException; -import java.text.SimpleDateFormat; -import java.util.*; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation; -import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation.RemoteFolderFilter; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.progress.IElementCollector; - -public class CVSTagElement extends CVSModelElement implements IDeferredWorkbenchAdapter { - CVSTag tag; - ICVSRepositoryLocation root; - - private static final String REPO_VIEW_LONG_FORAMT = "dd MMM yyyy HH:mm:ss"; //$NON-NLS-1$ - private static final String REPO_VIEW_SHORT_FORMAT = "dd MMM yyyy"; //$NON-NLS-1$ - private static final String TIME_ONLY_COLUMN_FORMAT = "HH:mm:ss"; //$NON-NLS-1$ - private static SimpleDateFormat localLongFormat = new SimpleDateFormat(REPO_VIEW_LONG_FORAMT,Locale.getDefault()); - private static SimpleDateFormat localShortFormat = new SimpleDateFormat(REPO_VIEW_SHORT_FORMAT,Locale.getDefault()); - private static SimpleDateFormat timeColumnFormat = new SimpleDateFormat(TIME_ONLY_COLUMN_FORMAT, Locale.getDefault()); - - static synchronized public String toDisplayString(Date date){ - String localTime = timeColumnFormat.format(date); - timeColumnFormat.setTimeZone(TimeZone.getDefault()); - if(localTime.equals("00:00:00")){ //$NON-NLS-1$ - return localShortFormat.format(date); - } - return localLongFormat.format(date); - } - - public CVSTagElement(CVSTag tag, ICVSRepositoryLocation root) { - this.tag = tag; - this.root = root; - } - - public ICVSRepositoryLocation getRoot() { - return root; - } - - public CVSTag getTag() { - return tag; - } - - public boolean equals(Object o) { - if (!(o instanceof CVSTagElement)) - return false; - CVSTagElement t = (CVSTagElement) o; - if (!tag.equals(t.tag)) - return false; - return root.equals(t.root); - } - - public int hashCode() { - return root.hashCode() ^ tag.hashCode(); - } - - public ImageDescriptor getImageDescriptor(Object object) { - if (!(object instanceof CVSTagElement)) - return null; - if (tag.getType() == CVSTag.BRANCH || tag.getType() == CVSTag.HEAD) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_TAG); - } else if (tag.getType() == CVSTag.VERSION) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_PROJECT_VERSION); - } else { - // This could be a Date tag - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_DATE); - } - } - public String getLabel(Object o) { - if (!(o instanceof CVSTagElement)) - return null; - CVSTag aTag = ((CVSTagElement) o).tag; - if(aTag.getType() == CVSTag.DATE){ - Date date = tag.asDate(); - if (date != null){ - return toDisplayString(date); - } - } - return aTag.getName(); - } - - public String toString() { - return tag.getName(); - } - - public Object getParent(Object o) { - if (!(o instanceof CVSTagElement)) - return null; - return ((CVSTagElement) o).root; - } - - protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - ICVSRemoteResource[] children = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, tag, monitor); - if (getWorkingSet() != null) - children = CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), children); - return children; - } - - public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { - if (tag.getType() == CVSTag.HEAD || tag.getType() == CVSTag.DATE) { - try { - monitor = Policy.monitorFor(monitor); - RemoteFolder folder = new RemoteFolder(null, root, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); - monitor.beginTask(Policy.bind("RemoteFolderElement.fetchingRemoteChildren", root.toString()), 100); //$NON-NLS-1$ - FetchMembersOperation operation = new FetchMembersOperation(null, folder, collector); - operation.setFilter(new RemoteFolderFilter() { - public ICVSRemoteResource[] filter(ICVSRemoteResource[] folders) { - return CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), folders); - } - }); - operation.run(Policy.subMonitorFor(monitor, 100)); - } catch (final InvocationTargetException e) { - handle(collector, e); - } catch (InterruptedException e) { - // Cancelled by the user; - } finally { - monitor.done(); - } - } else { - try { - collector.add(fetchChildren(o, monitor), monitor); - } catch (TeamException e) { - handle(collector, e); - } - } - } - - public ISchedulingRule getRule(Object element) { - return new RepositoryLocationSchedulingRule(root); //$NON-NLS-1$ - } - - public boolean isContainer() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.java deleted file mode 100644 index ec08b51f2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/DateTagCategory.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.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * The DateTagCategory is the parent of all the date tags in the repositories view. - */ -public class DateTagCategory extends TagCategory { - - public DateTagCategory(ICVSRepositoryLocation repository) { - super(repository); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.model.TagCategory#getTags(org.eclipse.core.runtime.IProgressMonitor) - */ - protected CVSTag[] getTags(IProgressMonitor monitor) throws CVSException { - return CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(repository).getDateTags(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return Policy.bind("DateTagCategory.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.model.TagCategory#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (adapter.equals(ICVSRepositoryLocation.class)) { - return getRepository(null); - } - return super.getAdapter(adapter); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/GroupedByVersionCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/GroupedByVersionCategory.java deleted file mode 100644 index b44805524..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/GroupedByVersionCategory.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.model.IWorkbenchAdapter; - -public class GroupedByVersionCategory extends CVSModelElement implements IAdaptable { - private ICVSRepositoryLocation repository; - - /** - * ProjectVersionsCategory constructor. - */ - public GroupedByVersionCategory(ICVSRepositoryLocation repo) { - super(); - this.repository = repo; - } - - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns null if - * no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - - /** - * Returns the children of this object. When this object - * is displayed in a tree, the returned objects will be this - * element's children. Returns an empty enumeration if this - * object has no children. - * - * XXX This method looks wrong to me somehow - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - //String -> CTags[] - Map mappings = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownProjectsAndVersions(repository); - Map remoteVersionModules = new HashMap(); - for (Iterator it = mappings.keySet().iterator(); it.hasNext();) { - String project = (String) it.next(); - CVSTag[] versions = (CVSTag[])((HashSet)mappings.get(project)).toArray(new CVSTag[0]); - for (int i = 0; i < versions.length; i++) { - CVSTag tag = versions[i]; - RemoteVersionModule module = (RemoteVersionModule)remoteVersionModules.get(tag); - if(module==null) { - module = new RemoteVersionModule(tag, this); - remoteVersionModules.put(tag, module); - } - module.addProject(new RemoteFolder(null, repository, project, tag)); - } - } - return (RemoteVersionModule[])remoteVersionModules.values().toArray(new RemoteVersionModule[0]); - } - - /** - * Returns an image descriptor to be used for displaying an object in the workbench. - * Returns null if there is no appropriate image. - * - * @param object The object to get an image descriptor for. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY); - } - - /** - * Returns the name of this element. This will typically - * be used to assign a label to this object when displayed - * in the UI. Returns an empty string if there is no appropriate - * name for this object. - * - * @param object The object to get a label for. - */ - public String getLabel(Object o) { - return Policy.bind("GroupedByVersionCategory.Versions_1"); //$NON-NLS-1$ - } - - /** - * Returns the logical parent of the given object in its tree. - * Returns null if there is no parent, or if this object doesn't - * belong to a tree. - * - * @param object The object to get the parent for. - */ - public Object getParent(Object o) { - return repository; - } - - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return repository; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/ModulesCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/ModulesCategory.java deleted file mode 100644 index b50274e0b..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/ModulesCategory.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * ModulesCategory is the model element for the mdoules category - * for a particular repository. Its children are the array of all - * modules defined in the CVSROOT/Modules file - */ -public class ModulesCategory extends CVSModelElement implements IAdaptable { - private ICVSRepositoryLocation repository; - - public ModulesCategory(ICVSRepositoryLocation repository) { - super(); - this.repository = repository; - } - - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns null if - * no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - return repository.members(CVSTag.DEFAULT, true /* module definitions */, monitor); - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION); - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return Policy.bind("ModulesCategory.label"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return repository; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#isRemoteElement() - */ - public boolean isRemoteElement() { - return true; - } - - /** - * Returns the repository. - * @return ICVSRepositoryLocation - */ - public ICVSRepositoryLocation getRepository() { - return repository; - } - - public String toString() { - return getRepository().toString() + " (modules)"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java deleted file mode 100644 index ed617d0b7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.progress.DeferredTreeContentManager; - -/** - * Extension to the generic workbench content provider mechanism - * to lazily determine whether an element has children. That is, - * children for an element aren't fetched until the user clicks - * on the tree expansion box. - */ -public class RemoteContentProvider extends WorkbenchContentProvider { - - IWorkingSet workingSet; - DeferredTreeContentManager manager; - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (viewer instanceof AbstractTreeViewer) { - manager = new DeferredTreeContentManager(this, (AbstractTreeViewer) viewer); - } - super.inputChanged(viewer, oldInput, newInput); - } - - public boolean hasChildren(Object element) { - // the + box will always appear, but then disappear - // if not needed after you first click on it. - if (element instanceof ICVSRemoteResource) { - if (element instanceof ICVSRemoteFolder) { - return ((ICVSRemoteFolder) element).isExpandable(); - } - return ((ICVSRemoteResource) element).isContainer(); - } else if (element instanceof CVSResourceElement) { - ICVSResource r = ((CVSResourceElement) element).getCVSResource(); - if (r instanceof RemoteResource) { - return r.isFolder(); - } - } else if (element instanceof VersionCategory) { - return true; - } else if (element instanceof BranchCategory) { - return true; - } else if (element instanceof ModulesCategory) { - return true; - } else if (element instanceof CVSTagElement) { - return true; - } else if (element instanceof RemoteModule) { - return true; - } - if (manager != null) { - if (manager.isDeferredAdapter(element)) - return manager.mayHaveChildren(element); - } - - return super.hasChildren(element); - } - - /** - * Sets the workingSet. - * @param workingSet The workingSet to set - */ - public void setWorkingSet(IWorkingSet workingSet) { - this.workingSet = workingSet; - } - - /** - * Returns the workingSet. - * @return IWorkingSet - */ - public IWorkingSet getWorkingSet() { - return workingSet; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.WorkbenchContentProvider#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object element) { - if (manager != null) { - Object[] children = manager.getChildren(element); - if (children != null) { - // This will be a placeholder to indicate - // that the real children are being fetched - return children; - } - } - Object[] children = super.getChildren(element); - for (int i = 0; i < children.length; i++) { - Object object = children[i]; - if (object instanceof CVSModelElement) - ((CVSModelElement)object).setWorkingSet(getWorkingSet()); - } - return children; - } - - public void cancelJobs(RepositoryRoot[] roots) { - if (manager != null) { - for (int i = 0; i < roots.length; i++) { - RepositoryRoot root = roots[i]; - cancelJobs(root.getRoot()); - } - } - } - - /** - * Cancel any jobs that are fetching content from the given location. - * @param location - */ - public void cancelJobs(ICVSRepositoryLocation location) { - if (manager != null) { - manager.cancel(location); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java deleted file mode 100644 index 5c20e22fb..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.PlatformUI; - -public class RemoteFileElement extends RemoteResourceElement { - /** - * Initial implementation: return null; - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - return new Object[0]; - } - /** - * Initial implementation: return null. - */ - public ImageDescriptor getImageDescriptor(Object object) { - if (!(object instanceof ICVSRemoteFile)) return null; - return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(((ICVSRemoteFile)object).getName()); - } - /** - * Initial implementation: return the file's name and version - */ - public String getLabel(Object o) { - if (!(o instanceof ICVSRemoteFile)) return null; - ICVSRemoteFile file = (ICVSRemoteFile)o; - try { - return Policy.bind("nameAndRevision", file.getName(), file.getRevision()); //$NON-NLS-1$ - } catch (TeamException e) { - handle(null, null, e); - return null; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java deleted file mode 100644 index d999ff0ae..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.team.internal.ccvs.ui.model; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.progress.IElementCollector; - -public class RemoteFolderElement extends RemoteResourceElement implements IDeferredWorkbenchAdapter { - - /** - * Overridden to append the version name to remote folders which - * have version tags and are top-level folders. - */ - public String getLabel(Object o) { - if (!(o instanceof ICVSRemoteFolder)) - return null; - ICVSRemoteFolder folder = (ICVSRemoteFolder) o; - CVSTag tag = folder.getTag(); - if (tag != null && tag.getType() != CVSTag.HEAD) { - if (folder.getRemoteParent() == null) { - return Policy.bind("RemoteFolderElement.nameAndTag", folder.getName(), tag.getName()); //$NON-NLS-1$ - } - } - return folder.getName(); - } - - public ImageDescriptor getImageDescriptor(Object object) { - if (!(object instanceof ICVSRemoteFolder)) - return null; - ICVSRemoteFolder folder = (ICVSRemoteFolder) object; - if (folder.isDefinedModule()) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_MODULE); - } - return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); - } - - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - if (!(o instanceof ICVSRemoteFolder)) - return new Object[0]; - return ((ICVSRemoteFolder) o).members(monitor); - } - - public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { - // If it's not a folder, return an empty array - if (!(o instanceof ICVSRemoteFolder)) { - collector.add(new Object[0], monitor); - } - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(Policy.bind("RemoteFolderElement.fetchingRemoteChildren", getLabel(o)), 100); //$NON-NLS-1$ - FetchMembersOperation operation = new FetchMembersOperation(null, (ICVSRemoteFolder)o, collector); - operation.run(Policy.subMonitorFor(monitor, 100)); - } catch (InvocationTargetException e) { - handle(collector, e); - } catch (InterruptedException e) { - // Cancelled by the user; - } finally { - monitor.done(); - } - } - - public ISchedulingRule getRule(Object element) { - ICVSRepositoryLocation location = getRepositoryLocation(element); - return new RepositoryLocationSchedulingRule(location); //$NON-NLS-1$ - } - - private ICVSRepositoryLocation getRepositoryLocation(Object o) { - if (!(o instanceof ICVSRemoteFolder)) - return null; - return ((ICVSRemoteFolder)o).getRepository(); - } - - public boolean isContainer() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java deleted file mode 100644 index ffa796cbc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.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.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.progress.IElementCollector; - -/** - * This class represents an IProject resource in a repository. The children of a - * RemoteModule are its versions. A RemoteModule is a child of the - * VersionsCategory. - */ -public class RemoteModule extends CVSModelElement implements IAdaptable, - IDeferredWorkbenchAdapter { - ICVSRemoteFolder folder; - - VersionCategory parent; - - /** - * RemoteProject constructor. - */ - public RemoteModule(ICVSRemoteFolder folder, VersionCategory parent) { - this.folder = folder; - this.parent = parent; - } - - /** - * Returns an object which is an instance of the given class associated with - * this object. Returns null if no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) - return this; - if (adapter == IDeferredWorkbenchAdapter.class) - return this; - return null; - } - - /** - * Returns an image to be used for displaying an object in the desktop. - * - * @param object The object to get an image for. - * @param owner The viewer that the image will be used in. The image will be - * disposed when this viewer is closed. If the owner is null, a - * new image is returned, and the caller is responsible for - * disposing it. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_PROJECT_VERSION); - } - - /** - * Returns the name of this element. This will typically be used to assign a - * label to this object when displayed in the UI. - */ - public String getLabel(Object o) { - return folder.getName(); - } - - /** - * Returns the logical parent of the given object in its tree. - */ - public Object getParent(Object o) { - return parent; - } - - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return folder.getRepository(); - } - - /** - * (Non-javadoc) For debugging purposes only. - */ - public String toString() { - return "RemoteModule(" + folder.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - public ICVSRemoteResource getCVSResource() { - return folder; - } - - /** - * Returns the children of this object. When this object is displayed in a - * tree, the returned objects will be this element's children. Returns an - * empty enumeration if this object has no children. The children of the - * RemoteModule are the versions for that module. - * - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#internalGetChildren(java.lang.Object, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) - throws TeamException { - RepositoryManager manager = CVSUIPlugin.getPlugin() - .getRepositoryManager(); - try { - manager.refreshDefinedTags(folder, false /* recurse */, false /* notify */, monitor); - } catch (TeamException e) { - // continue - } - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() - .getKnownTags(folder, CVSTag.VERSION); - Object[] versions = new Object[tags.length]; - for (int i = 0; i < versions.length; i++) { - versions[i] = folder.forTag(tags[i]); - } - return versions; - } - - public void fetchDeferredChildren(Object o, IElementCollector collector, - IProgressMonitor monitor) { - try { - collector.add(fetchChildren(o, monitor), monitor); - } catch (TeamException e) { - handle(collector, e); - } - } - - public boolean isContainer() { - return true; - } - - public ISchedulingRule getRule(Object element) { - return new RepositoryLocationSchedulingRule(folder.getRepository()); //$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java deleted file mode 100644 index 3f75d89c0..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; - -/** - * This model element provides the remote projects for a given repository and - * tag. - */ -public class RemoteProjectsElement extends CVSTagElement { - - /** - * Constructor for RemoteProjectsElement. - */ - public RemoteProjectsElement() { - super(CVSTag.DEFAULT, null); - } - - /** - * Constructor for RemoteProjectsElement. - */ - public RemoteProjectsElement(ICVSRepositoryLocation root) { - super(CVSTag.DEFAULT, root); - } - - /** - * Sets the root. - * @param root The root to set - */ - public void setRoot(ICVSRepositoryLocation root) { - this.root = root; - } - - /** - * Sets the tag. - * @param tag The tag to set - */ - public void setTag(CVSTag tag) { - this.tag = tag; - } - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof RemoteProjectsElement)) return false; - RemoteProjectsElement element = (RemoteProjectsElement)o; - if (root == null) { - return element.root == null && tag.equals(element.tag); - } - return super.equals(o); - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - if (root == null) return tag.hashCode(); - return super.hashCode(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#internalGetChildren(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - if (root == null) return new Object[0]; - return super.fetchChildren(o, monitor); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteResourceElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteResourceElement.java deleted file mode 100644 index c70214163..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteResourceElement.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; - -public abstract class RemoteResourceElement extends CVSModelElement { - /** - * Initial implementation: return the resource's name - */ - public String getLabel(Object o) { - if (!(o instanceof ICVSRemoteResource)) return null; - return ((ICVSRemoteResource)o).getName(); - } - /** - * Return null. - */ - public Object getParent(Object o) { - if (!(o instanceof ICVSRemoteResource)) return null; - ICVSRemoteResource rr = (ICVSRemoteResource)o; - return rr.getParent(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteVersionModule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteVersionModule.java deleted file mode 100644 index d81650861..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteVersionModule.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * This class represents an IProject resource in a repository. The - * children of a RemoteModule are its versions. A RemoteModule is - * a child of the VersionsCategory. - */ -public class RemoteVersionModule extends CVSModelElement implements IAdaptable { - CVSTag tag; - List projects = new ArrayList(); - GroupedByVersionCategory parent; - - /** - * RemoteProject constructor. - */ - public RemoteVersionModule(CVSTag tag, GroupedByVersionCategory parent) { - this.tag = tag; - this.parent = parent; - } - - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns null if - * no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - - public void addProject(ICVSRemoteFolder project) { - projects.add(project); - } - - /** - * Returns the children of this object. When this object - * is displayed in a tree, the returned objects will be this - * element's children. Returns an empty enumeration if this - * object has no children. The children of the RemoteModule - * are the versions for that module. - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - return (ICVSRemoteFolder[]) projects.toArray(new ICVSRemoteFolder[projects.size()]); - } - - /** - * Returns an image to be used for displaying an object in the desktop. - * @param object The object to get an image for. - * @param owner The viewer that the image will be used in. The image will - * be disposed when this viewer is closed. If the owner is null, a new - * image is returned, and the caller is responsible for disposing it. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION); - } - - /** - * Returns the name of this element. This will typically - * be used to assign a label to this object when displayed - * in the UI. - */ - public String getLabel(Object o) { - return tag.getName(); - } - - /** - * Returns the logical parent of the given object in its tree. - */ - public Object getParent(Object o) { - return parent; - } - - - /** (Non-javadoc) - * For debugging purposes only. - */ - public String toString() { - return "RemoteVersionModule(" + tag.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RepositoryLocationSchedulingRule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RepositoryLocationSchedulingRule.java deleted file mode 100644 index 94228114f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RepositoryLocationSchedulingRule.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; - -/** - * A simple job scheduling rule for serializing jobs for an ICVSRepositoryLocation - */ -public class RepositoryLocationSchedulingRule implements ISchedulingRule { - ICVSRepositoryLocation location; - public RepositoryLocationSchedulingRule(ICVSRepositoryLocation location) { - this.location = location; - } - public boolean isConflicting(ISchedulingRule rule) { - if(rule instanceof RepositoryLocationSchedulingRule) { - return ((RepositoryLocationSchedulingRule)rule).location.equals(location); - } - return false; - } - public boolean contains(ISchedulingRule rule) { - return isConflicting(rule); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/TagCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/TagCategory.java deleted file mode 100644 index 666dd0978..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/TagCategory.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.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * This class provides common behavior between the branch and date tag categories - */ -public abstract class TagCategory extends CVSModelElement { - protected ICVSRepositoryLocation repository; - - public TagCategory(ICVSRepositoryLocation repository) { - this.repository = repository; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#fetchChildren(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws CVSException { - CVSTag[] tags = getTags(monitor); - CVSTagElement[] elements = new CVSTagElement[tags.length]; - for (int i = 0; i < tags.length; i++) { - elements[i] = new CVSTagElement(tags[i], repository); - } - return elements; - } - - /** - * Return the tags that are to be displyed as children of this category - * @param monitor - * @return - */ - protected abstract CVSTag[] getTags(IProgressMonitor monitor) throws CVSException; - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return repository; - } - - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return repository; - } - - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns null if - * no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java deleted file mode 100644 index f629351da..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.model; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; -import org.eclipse.ui.progress.IElementCollector; - -public class VersionCategory extends CVSModelElement implements IAdaptable, - IDeferredWorkbenchAdapter { - private ICVSRepositoryLocation repository; - - /** - * ProjectVersionsCategory constructor. - */ - public VersionCategory(ICVSRepositoryLocation repo) { - super(); - this.repository = repo; - } - - /** - * Returns an object which is an instance of the given class associated with - * this object. Returns null if no such object can be found. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) - return this; - if (adapter == IDeferredWorkbenchAdapter.class) - return this; - return null; - } - - /** - * Returns the children of this object. When this object is displayed in a - * tree, the returned objects will be this element's children. Returns an - * empty enumeration if this object has no children. - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) - throws TeamException { - if (CVSUIPlugin.getPlugin().getRepositoryManager() - .isDisplayingProjectVersions(repository)) { - return getProjectVersionChildren(o, monitor); - } else { - return getVersionTagChildren(o, monitor); - } - } - - /* - * Return the children as a list of versions whose children are projects - */ - private Object[] getVersionTagChildren(Object o, IProgressMonitor monitor) - throws CVSException { - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() - .getKnownTags(repository, getWorkingSet(), CVSTag.VERSION, monitor); - CVSTagElement[] versionElements = new CVSTagElement[tags.length]; - for (int i = 0; i < tags.length; i++) { - versionElements[i] = new CVSTagElement(tags[i], repository); - } - return versionElements; - } - - /* - * Return the children as a list of projects whose children ar project - * versions - */ - private Object[] getProjectVersionChildren(Object o, - IProgressMonitor monitor) throws TeamException { - - ICVSRemoteResource[] resources = CVSUIPlugin.getPlugin() - .getRepositoryManager().getFoldersForTag(repository, - CVSTag.DEFAULT, monitor); - if (getWorkingSet() != null) - resources = CVSUIPlugin.getPlugin().getRepositoryManager() - .filterResources(getWorkingSet(), resources); - Object[] modules = new Object[resources.length]; - for (int i = 0; i < resources.length; i++) { - modules[i] = new RemoteModule((ICVSRemoteFolder) resources[i], - VersionCategory.this); - } - return modules; - } - - /** - * Returns an image descriptor to be used for displaying an object in the - * workbench. Returns null if there is no appropriate image. - * - * @param object The object to get an image descriptor for. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_VERSIONS_CATEGORY); - } - - /** - * Returns the name of this element. This will typically be used to assign a - * label to this object when displayed in the UI. Returns an empty string if - * there is no appropriate name for this object. - * - * @param object The object to get a label for. - */ - public String getLabel(Object o) { - return Policy.bind("VersionCategory.Versions_1"); //$NON-NLS-1$ - } - - /** - * Returns the logical parent of the given object in its tree. Returns null - * if there is no parent, or if this object doesn't belong to a tree. - * - * @param object The object to get the parent for. - */ - public Object getParent(Object o) { - return repository; - } - - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return repository; - } - - public void fetchDeferredChildren(Object o, IElementCollector collector, - IProgressMonitor monitor) { - try { - collector.add(fetchChildren(o, monitor), monitor); - } catch (TeamException e) { - handle(collector, e); - } - } - - public boolean isContainer() { - return true; - } - - public ISchedulingRule getRule(Object element) { - return new RepositoryLocationSchedulingRule(repository); //$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java deleted file mode 100644 index 6164e3cd5..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.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.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Performs a "cvs add" - */ -public class AddOperation extends RepositoryProviderOperation { - - public AddOperation(IWorkbenchPart part, IResource[] resources) { - super(part, resources); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException { - add(provider, resources, IResource.DEPTH_INFINITE, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("AddAction.adding"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("AddOperation.0", provider.getProject().getName()); //$NON-NLS-1$ - } - - /* - * Add the given resources to the project. - *

              - * The sematics follow that of CVS in the sense that any folders - * being added are created remotely as a result of this operation - * while files are created remotely on the next commit. - *

              - *

              - * This method uses the team file type registry to determine the type - * of added files. If the extension of the file is not in the registry, - * the file is assumed to be binary. - *

              - *

              - * NOTE: for now we do three operations: one each for folders, text files and binary files. - * We should optimize this when time permits to either use one operations or defer server - * contact until the next commit. - *

              - * - *

              - * There are special semantics for adding the project itself to the repo. In this case, the project - * must be included in the resources array. - *

              - */ - private void add(CVSTeamProvider provider, IResource[] resources, int depth, IProgressMonitor progress) throws CVSException { - - // Visit the children of the resources using the depth in order to - // determine which folders, text files and binary files need to be added - // A TreeSet is needed for the folders so they are in the right order (i.e. parents created before children) - final SortedSet folders = new TreeSet(); - // Sets are required for the files to ensure that files will not appear twice if there parent was added as well - // and the depth isn't zero - final Map /* from KSubstOption to Set */ files = new HashMap(); - final CVSException[] eHolder = new CVSException[1]; - for (int i=0; itrue if all resources in the array have a sticky tag - */ - private boolean areAllResourcesSticky(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - if(!hasStickyTag(resources[i])) return false; - } - return true; - } - - /** - * Answers true if the resource has a sticky tag - */ - private boolean hasStickyTag(IResource resource) { - try { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - CVSTag tag; - if(cvsResource.isFolder()) { - FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - tag = folderInfo.getTag(); - } else { - ResourceSyncInfo info = cvsResource.getSyncInfo(); - tag = info.getTag(); - } - if(tag!=null) { - int tagType = tag.getType(); - if(tagType==CVSTag.VERSION) { - return true; - } - } - } catch(CVSException e) { - CVSUIPlugin.log(e); - return false; - } - return false; - } - - private String calculateInitialVersionName(IResource[] resources, boolean allSticky) { - String versionName = ""; //$NON-NLS-1$ - try { - if(allSticky) { - IResource stickyResource = resources[0]; - if(stickyResource.getType()==IResource.FILE) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)stickyResource); - versionName = cvsFile.getSyncInfo().getTag().getName(); - } else { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)stickyResource); - versionName = cvsFolder.getFolderSyncInfo().getTag().getName(); - } - } - } catch(CVSException e) { - CVSUIPlugin.log(e); - versionName = ""; //$NON-NLS-1$ - } - return versionName; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java deleted file mode 100644 index 3d33624ef..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java +++ /dev/null @@ -1,366 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole; -import org.eclipse.team.ui.TeamOperation; -import org.eclipse.ui.IWorkbenchPart; - - -/** - * This class is the abstract superclass for CVS operations. It provides - * error handling, prompting and other UI. - */ -public abstract class CVSOperation extends TeamOperation { - - private int statusCount; - - private boolean involvesMultipleResources = false; - - private List errors = new ArrayList(); // of IStatus - - protected static final IStatus OK = Status.OK_STATUS; //$NON-NLS-1$ - - private Shell shell; - - // instance variable used to indicate behavior while prompting for overwrite - private boolean confirmOverwrite = true; - - protected CVSOperation(IWorkbenchPart part) { - super(part); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamOperation#getJobName() - */ - protected String getJobName() { - return getTaskName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#getOperationIcon() - */ - protected URL getOperationIcon() { - URL url = null; - try { - URL baseURL = CVSUIPlugin.getPlugin().getBundle().getEntry("/"); //$NON-NLS-1$ - return new URL(baseURL, ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE); - } catch (MalformedURLException e) { - return null; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - startOperation(); - try { - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - monitor.setTaskName(getTaskName()); - execute(Policy.subMonitorFor(monitor, 100)); - endOperation(); - } catch (CVSException e) { - // TODO: errors may not be empty (i.e. endOperation has not been executed) - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - - protected void startOperation() { - statusCount = 0; - resetErrors(); - confirmOverwrite = true; - } - - protected void endOperation() throws CVSException { - handleErrors((IStatus[]) errors.toArray(new IStatus[errors.size()])); - } - - /** - * Subclasses must override this method to perform the operation. - * Clients should never call this method directly. - * - * @param monitor - * @throws CVSException - * @throws InterruptedException - */ - protected abstract void execute(IProgressMonitor monitor) throws CVSException, InterruptedException; - - protected void addError(IStatus status) { - if (status.isOK()) return; - if (isLastError(status)) return; - errors.add(status); - } - - protected void collectStatus(IStatus status) { - if (isLastError(status)) return; - statusCount++; - if (!status.isOK()) addError(status); - } - - protected void resetErrors() { - errors.clear(); - statusCount = 0; - } - - /** - * Get the last error taht occured. This can be useful when a method - * has a return type but wants to signal an error. The method in question - * can add the error using addError(IStatus) and return null. - * The caller can then query the error using this method. Also, addError(IStatus) - * will not add the error if it is already on the end of the list (using identity comparison) - * which allows the caller to still perform a collectStatus(IStatus) - * to get a valid operation count. - * @return - */ - protected IStatus getLastError() { - Assert.isTrue(errors.size() > 0); - IStatus status = (IStatus)errors.get(errors.size() - 1); - return status; - } - - private boolean isLastError(IStatus status) { - return (errors.size() > 0 && getLastError() == status); - } - - /** - * Throw an exception that contains the given error status - * @param errors the errors that occurred during the operation - * @throws CVSException an exception that wraps the errors - */ - protected void asException(IStatus[] errors) throws CVSException { - if (errors.length == 0) return; - if (errors.length == 1 && statusCount == 1) { - throw new CVSException(errors[0]); - } - MultiStatus result = new MultiStatus(CVSUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null); - for (int i = 0; i < errors.length; i++) { - IStatus s = errors[i]; - if (s.isMultiStatus()) { - result.add(new CVSStatus(s.getSeverity(), s.getMessage(), s.getException())); - result.addAll(s); - } else { - result.add(s); - } - } - throw new CVSException(result); - } - - /** - * Handle the errors that occured during an operation. - * The default is to throw an exception containing an status - * that are reportable (determined using isReportableError). - * @param errors the errors that occurred during the operation. - * Subclasses may override. - * @throws CVSException an exception if appropriate - */ - protected void handleErrors(IStatus[] errors) throws CVSException { - // We are only concerned with reportable errors. - // Others will appear in the console - List serverErrors = new ArrayList(); - for (int i = 0; i < errors.length; i++) { - IStatus status = errors[i]; - if (isReportableError(status)) { - serverErrors.add(status); - } else if (status.isMultiStatus()) { - IStatus[] children = status.getChildren(); - for (int j = 0; j < children.length; j++) { - IStatus child = children[j]; - if (isReportableError(child)) { - serverErrors.add(status); - break; - } - } - } - } - if (!serverErrors.isEmpty()) - asException((IStatus[]) serverErrors.toArray(new IStatus[serverErrors.size()])); - } - - /** - * Return whether the given status is reportable. By default, - * only server errors are reportable. Subclasses may override. - * @param status an error status - * @return whether the status is reportable or should be ignored - */ - protected boolean isReportableError(IStatus status) { - return status.getCode() == CVSStatus.SERVER_ERROR; - } - - protected String getErrorMessage(IStatus[] failures, int totalOperations) { - return Policy.bind("CVSOperation.0", String.valueOf(failures.length), String.valueOf(totalOperations)); //$NON-NLS-1$ - } - - /** - * This method prompts the user to overwrite an existing resource. It uses the - * involvesMultipleResources to determine what buttons to show. - * @param project - * @return - */ - protected boolean promptToOverwrite(final String title, final String msg) { - if (!confirmOverwrite) { - return true; - } - final String buttons[]; - if (involvesMultipleResources()) { - buttons = new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.NO_LABEL, - IDialogConstants.CANCEL_LABEL}; - } else { - buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}; - } - final Shell displayShell = getShell(); - if (displayShell == null) { - // We couldn't get a shell (perhaps due to shutdown) - return false; - } - - // run in syncExec because callback is from an operation, - // which is probably not running in the UI thread. - final int[] code = new int[] {0}; - displayShell.getDisplay().syncExec( - new Runnable() { - public void run() { - MessageDialog dialog = - new MessageDialog(displayShell, title, null, msg, MessageDialog.QUESTION, buttons, 0); - dialog.open(); - code[0] = dialog.getReturnCode(); - } - }); - if (involvesMultipleResources()) { - switch (code[0]) { - case 0://Yes - return true; - case 1://Yes to all - confirmOverwrite = false; - return true; - case 2://No - return false; - case 3://Cancel - default: - throw new OperationCanceledException(); - } - } else { - return code[0] == 0; - } - } - - /** - * This method is used by promptToOverwrite to determine which - * buttons to show in the prompter. - * - * @return - */ - protected boolean involvesMultipleResources() { - return involvesMultipleResources; - } - - public void setInvolvesMultipleResources(boolean b) { - involvesMultipleResources = b; - } - - /** - * Return the string that is to be used as the task name for the operation - * - * @param remoteFolders - * @return - */ - protected abstract String getTaskName(); - - /** - * Return true if any of the accumulated status have a severity of ERROR - * @return - */ - protected boolean errorsOccurred() { - for (Iterator iter = errors.iterator(); iter.hasNext();) { - IStatus status = (IStatus) iter.next(); - if (status.getSeverity() == IStatus.ERROR) return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamOperation#getShell() - */ - protected Shell getShell() { - // Use the shell assigned to the operation if possible - if (shell != null && !shell.isDisposed()) { - return shell; - } - return super.getShell(); - } - - /** - * Set the shell to be used by the operation. This only needs - * to be done if the operation does not have a workbench part. - * For example, if the operation is being run in a wizard. - * @param shell The shell to set. - */ - public void setShell(Shell shell) { - this.shell = shell; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#canRunAsJob() - */ - protected boolean canRunAsJob() { - // Put CVS jobs in the background by default. - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#isSameFamilyAs(org.eclipse.team.ui.TeamOperation) - */ - protected boolean isSameFamilyAs(TeamOperation operation) { - // Trat all CVS operations as a single family - return operation instanceof CVSOperation; - } - - /* - * Action to show the console that can be used by subclasses - * that wish to link the progress service to the console - */ - protected IAction getShowConsoleAction() { - // Show the console as the goto action - return new Action(Policy.bind("CVSOperation.1")) { //$NON-NLS-1$ - public void run() { - CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); - if (console != null) - console.show(true); - } - public String getToolTipText() { - return Policy.bind("CVSOperation.2"); //$NON-NLS-1$ - } - }; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java deleted file mode 100644 index 6a3433720..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java +++ /dev/null @@ -1,442 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * This method checks out one or more remote folders from the same repository - * into an existing project or folder in the workspace. The target project - * must either be shared with the same repository or it must not be shared - * with any repository - */ -public class CheckoutIntoOperation extends CheckoutOperation { - - private boolean recursive; - private ICVSFolder localFolder; - private String localFolderName; - - /** - * Constructor which takes a set of remote folders and the local folder into which the folders should be - * loaded. - */ - public CheckoutIntoOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, IContainer localFolder, boolean recursive) { - super(part, remoteFolders); - this.recursive = recursive; - this.localFolder = CVSWorkspaceRoot.getCVSFolderFor(localFolder); - } - - /** - * Constructor which takes a single remote folder and the target local folder. - */ - public CheckoutIntoOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder, IContainer localFolder, boolean recursive) { - this(part, new ICVSRemoteFolder[] { remoteFolder }, localFolder.getParent(), recursive); - this.localFolderName = localFolder.getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#getTaskName() - */ - protected String getTaskName() { - ICVSRemoteFolder[] remoteFolders = getRemoteFolders(); - String localFolderName = ""; //$NON-NLS-1$ - try { - localFolderName = getLocalFolder().getIResource().getFullPath().toString(); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - return Policy.bind("CheckoutIntoOperation.taskname", new Integer(remoteFolders.length).toString(), localFolderName); //$NON-NLS-1$ - } - - /** - * @return - */ - public ICVSFolder getLocalFolder() { - return localFolder; - } - - /** - * @return - */ - public boolean isRecursive() { - return recursive; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus checkout(final ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { - final IStatus[] result = new IStatus[] { null }; - try { - // Wrap in a workspace runnable to avoid auto-build. - // This is necessary because CVS has a POST_BUILD - // listener that will clear the sync info from - // orphaned (i.e. unmanaged) subtrees and we will - // purposely create some which we subsequently manage - // from their parent (see manageFolders()) - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - result[0] = checkout(folder, getLocalFolder(), isRecursive(), monitor); - } - }, getSchedulingRule(), 0, monitor); - } catch (CoreException e) { - result[0] = CVSException.wrapException(e).getStatus(); - } - return result[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void checkout(final ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException { - // Batch sync info changes with the CVS synchronizer to optimize cache writing - EclipseSynchronizer.getInstance().run(getSchedulingRule(), new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); - try { - // Obtain a scheduling rule on the projects were about to overwrite - CheckoutIntoOperation.super.checkout(folders, Policy.subMonitorFor(monitor, 90)); - refreshRoot(getLocalRoot(getLocalFolder()), Policy.subMonitorFor(monitor, 10)); - } finally { - monitor.done(); - } - } - }, Policy.monitorFor(monitor)); - } - - /* - * Prepare the local folders to receive the remote folders. If localFolderName is not null, then - * if will be the only target folder of the checkout. Otherwise, the remote folder - * could expand to multiple local folders witinb the given parent folder. - */ - private ICVSFolder[] prepareLocalFolders(Session session, ICVSRemoteFolder remoteFolder, ICVSFolder parentFolder, String localFolderName, IProgressMonitor monitor) throws CVSException { - Set targetFolderSet = new HashSet(); - monitor.beginTask(null, 30); - if (localFolderName == null) { - - // Determine which local folders will be afected - IStatus status = Request.EXPAND_MODULES.execute(session, new String[] { remoteFolder.getRepositoryRelativePath()}, Policy.subMonitorFor(monitor, 10)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - addError(status); - return null; - } - - // Convert the module expansions to target folders - String[] expansions = session.getModuleExpansions(); - for (int j = 0; j < expansions.length; j++) { - String childPath = new Path(null, expansions[j]).segment(0); - ICVSResource resource = parentFolder.getChild(childPath); - if (resource != null && !resource.isFolder()) { - // The target folder conflicts with an existing file - addError(new CVSStatus(IStatus.ERROR, Policy.bind("CheckoutIntoOperation.targetIsFile", remoteFolder.getName(), resource.getIResource().getFullPath().toString()))); //$NON-NLS-1$ - return null; - } - targetFolderSet.add(parentFolder.getFolder(childPath)); - } - - } else { - targetFolderSet.add(parentFolder.getFolder(localFolderName)); - } - - final ICVSFolder[] targetFolders = (ICVSFolder[]) targetFolderSet.toArray(new ICVSFolder[targetFolderSet.size()]); - - // Ensure that the checkout will not conflict with existing resources - IStatus status = validateTargetFolders(remoteFolder, targetFolders, Policy.subMonitorFor(monitor, 10)); - if (!status.isOK()) { - addError(status); - return null; - } - - // Prepare the target projects to receive resources - status = scrubFolders(remoteFolder, targetFolders, Policy.subMonitorFor(monitor, 10)); - // return the target projects if the scrub succeeded - if (status.isOK()) { - return targetFolders; - } else { - addError(status); - return null; - } - } - - /* - * Ensure that the new folders will not conflict with existing folders (even those that are pruned). - */ - private IStatus validateTargetFolders(ICVSRemoteFolder remoteFolder, ICVSFolder[] targetFolders, IProgressMonitor monitor) throws CVSException { - for (int i = 0; i < targetFolders.length; i++) { - ICVSFolder targetFolder = targetFolders[i]; - FolderSyncInfo localInfo = targetFolder.getFolderSyncInfo(); - FolderSyncInfo remoteInfo = remoteFolder.getFolderSyncInfo(); - - if (!remoteInfo.isSameMapping(localInfo)) { - if (localInfo != null ) { - if (isRemoteChildOfParent(targetFolder)) { - // if the local folder is child of it's parent remotely (i.e. path of child is parent/child) - // then the remote cannot be loaded. - String message; - if (targetFolder.exists()) { - message = Policy.bind("CheckoutIntoOperation.targetIsFolder", remoteFolder.getName(), targetFolder.getIResource().getFullPath().toString()); //$NON-NLS-1$ - } else { - message = Policy.bind("CheckoutIntoOperation.targetIsPrunedFolder", remoteFolder.getName(), targetFolder.getFolderSyncInfo().getRepository()); //$NON-NLS-1$ - } - return new CVSStatus(IStatus.ERROR, message); - } - } - // Verify that no other folders in the local workspace are mapped to the remote folder - IStatus status = validateUniqueMapping(remoteFolder, targetFolder, Policy.subMonitorFor(monitor, 10)); - if (!status.isOK()) return status; - } - } - return OK; - } - - /* - * Return true if the given local folder is a direct descendant of it's local parent in - * the repository as well - */ - private boolean isRemoteChildOfParent(ICVSFolder targetFolder) throws CVSException { - FolderSyncInfo localInfo = targetFolder.getFolderSyncInfo(); - if (localInfo == null) return false; - FolderSyncInfo parentInfo = targetFolder.getParent().getFolderSyncInfo(); - if (parentInfo == null) return false; - IPath childPath = new Path(null, localInfo.getRepository()); - IPath parentPath = new Path(null, parentInfo.getRepository()); - return parentPath.isPrefixOf(childPath); - } - - /** - * @param targetFolder - * @return - */ - private IContainer getLocalRoot(ICVSFolder targetFolder) throws CVSException { - return targetFolder.getIResource().getProject(); - } - - /* - * Ensure that there is no equivalent mapping alreay in the local workspace - */ - private IStatus validateUniqueMapping(final ICVSRemoteFolder remoteFolder, final ICVSFolder targetFolder, IProgressMonitor iProgressMonitor) throws CVSException { - - final IContainer root = getLocalRoot(targetFolder); - final FolderSyncInfo remoteInfo = remoteFolder.getFolderSyncInfo(); - if (remoteInfo.equals(FolderSyncInfo.VIRTUAL_DIRECTORY)) { - // We can't really check the mapping ahead of time - // so we'll let the operation continue - return OK; - } - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(root); - try { - cvsFolder.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - // do nothing - } - public void visitFolder(ICVSFolder folder) throws CVSException { - if (!folder.isCVSFolder()) return; - IResource resource = folder.getIResource(); - if (resource == null) return; - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info.isSameMapping(remoteInfo)) { - throw new CVSException(Policy.bind("CheckoutIntoOperation.mappingAlreadyExists", //$NON-NLS-1$ - new Object[] { - remoteFolder.getName(), - targetFolder.getIResource().getFullPath().toString(), - resource.getFullPath().toString() - })); - } - folder.acceptChildren(this); - } - }); - } catch (CVSException e) { - return e.getStatus(); - } - return OK; - } - - /* - * Purge the local contents of the given folders - */ - private IStatus scrubFolders(ICVSRemoteFolder remoteFolder, ICVSFolder[] targetFolders, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100 * targetFolders.length); - - // Prompt first before any work is done - if (targetFolders.length > 1) { - setInvolvesMultipleResources(true); - } - for (int i=0;i 1) { - localName = path.lastSegment(); - } - } - ICVSFolder[] targetFolders = prepareLocalFolders(session, remoteFolder, parentFolder, localName, Policy.subMonitorFor(monitor, 5)); - if (targetFolders == null) { - // an error occured and has been added to the operation's error list - return getLastError(); - } - - // Add recurse option - List localOptions = new ArrayList(); - if (!recurse) - localOptions.add(Update.DO_NOT_RECURSE); - if (localName != null) { - localOptions.add(Checkout.makeDirectoryNameOption(localName)); - } - - // Prune empty directories if pruning enabled - if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) - localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES); - // Add the options related to the CVSTag - CVSTag tag = remoteFolder.getTag(); - if (tag == null) { - // A null tag in a remote resource indicates HEAD - tag = CVSTag.DEFAULT; - } - localOptions.add(Update.makeTagOption(tag)); - - // Perform the checkout - IStatus status = Command.CHECKOUT.execute(session, - Command.NO_GLOBAL_OPTIONS, - (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]), - new String[] { remoteFolder.getRepositoryRelativePath() }, - null, - Policy.subMonitorFor(monitor, 80)); - if (!status.isOK()) { - return status; - } - - manageFolders(targetFolders, repository.getLocation()); - - return OK; - - } finally { - session.close(); - } - } - - private void manageFolders(ICVSFolder[] targetFolders, String root) throws CVSException { - for (int i = 0; i < targetFolders.length; i++) { - manageFolder(targetFolders[i], root); - } - } - - private static void manageFolder(ICVSFolder folder, String root) throws CVSException { - // Ensure that the parent is a CVS folder - ICVSFolder parent = folder.getParent(); - if (!parent.isCVSFolder()) { - parent.setFolderSyncInfo(new FolderSyncInfo(FolderSyncInfo.VIRTUAL_DIRECTORY, root, CVSTag.DEFAULT, true)); - IResource resource = parent.getIResource(); - if (resource.getType() != IResource.PROJECT) { - manageFolder(parent, root); - } - } - // reset the folder sync info so it will be managed by it's parent - folder.setFolderSyncInfo(folder.getFolderSyncInfo()); - } - - /* - * Bring the provided projects into the workspace - */ - private static void refreshRoot(IContainer root, IProgressMonitor monitor) throws CVSException { - try { - IProject project = root.getProject(); - CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if (provider == null) { - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - if (folder.isCVSFolder()) { - // Register the project with Team - RepositoryProvider.map(project, CVSProviderPlugin.getTypeId()); - - // TODO: This should be somewhere else - provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - provider.setWatchEditEnabled(CVSProviderPlugin.getPlugin().isWatchEditEnabled()); - } - } - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - - public String getName() { - return getTaskName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getSchedulingRule() - */ - protected ISchedulingRule getSchedulingRule() { - try { - // Use the project of the target folder as the scheduling rule - return getLocalFolder().getIResource().getProject(); - } catch (CVSException e) { - CVSUIPlugin.log(e); - return null; - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java deleted file mode 100644 index 54abf5a03..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.ui.IWorkbenchPart; - -/** - * This operation checks out a multiple remote folders into the workspace. - * Each one will become a new project (overwritting any exsiting projects - * with the same name). - */ -public class CheckoutMultipleProjectsOperation extends CheckoutProjectOperation { - - boolean hasTargetLocation; - - public CheckoutMultipleProjectsOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) { - super(part, remoteFolders, targetLocation); - hasTargetLocation = targetLocation != null; - setInvolvesMultipleResources(remoteFolders.length > 1); - } - - /** - * Return the target location where the given project should be located or - * null if the default location should be used. - * - * @param project - */ - protected IPath getTargetLocationFor(IProject project) { - IPath targetLocation = super.getTargetLocationFor(project); - if (targetLocation == null) return null; - return targetLocation.append(project.getName()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { - return checkout(folder, null, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java deleted file mode 100644 index 761169a42..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -public abstract class CheckoutOperation extends RemoteOperation { - - public CheckoutOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders) { - super(part, remoteFolders); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - ICVSRemoteFolder[] folders = getRemoteFolders(); - checkout(folders, monitor); - } - - /** - * This method invokes checkout(ICVSRemoteFolder, IProgressMonitor) - * for each remote folder of the operation. - * @param folders the remote folders for the operation - * @param monitor the progress monitor - * @throws CVSException if an error occured that should prevent the remaining - * folders from being checked out - */ - protected void checkout(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, folders.length * 100); - for (int i = 0; i < folders.length; i++) { - ICVSRemoteFolder folder = folders[i]; - IStatus result = checkout(folder, Policy.subMonitorFor(monitor, 100)); - collectStatus(result); - Policy.checkCanceled(monitor); - } - monitor.done(); - } - - protected ICVSRemoteFolder[] getRemoteFolders() { - return (ICVSRemoteFolder[])getRemoteResources(); - } - - /** - * Checkout the selected remote folders in a form appropriate for the operation subclass. - * @param folders - * @param monitor - */ - protected abstract IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException; - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() - */ - public boolean canRunAsJob() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#isKeepOneProgressServiceEntry() - */ - public boolean isKeepOneProgressServiceEntry() { - // Keep the last repository provider operation in the progress service - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#getGotoAction() - */ - protected IAction getGotoAction() { - return getShowConsoleAction(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java deleted file mode 100644 index 3fc09d18d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; -/** - * This class acts as an abstract class for checkout operations. - * It provides a few common methods. - */ -public abstract class CheckoutProjectOperation extends CheckoutOperation { - - private String targetLocation; - - public CheckoutProjectOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) { - super(part, remoteFolders); - this.targetLocation = targetLocation; - } - - /** - * Create and open the project, using a custom location if there is one. - * - * @param project - * @param monitor - * @throws CVSException - */ - protected void createAndOpenProject(IProject project, IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 5); - IProjectDescription desc = getDescriptionFor(project); - if (project.exists()) { - if (desc != null) { - project.move(desc, true, Policy.subMonitorFor(monitor, 3)); - } - } else { - if (desc == null) { - // create in default location - project.create(Policy.subMonitorFor(monitor, 3)); - } else { - // create in some other location - project.create(desc, Policy.subMonitorFor(monitor, 3)); - } - } - if (!project.isOpen()) { - project.open(Policy.subMonitorFor(monitor, 2)); - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - protected IProjectDescription getDescriptionFor(IProject project) { - if (targetLocation == null) return null; - String projectName = project.getName(); - IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); - description.setLocation(getTargetLocationFor(project)); - return description; - } - - /** - * Return the target location where the given project should be located or - * null if the default location should be used. - * - * @param project - */ - protected IPath getTargetLocationFor(IProject project) { - if (targetLocation == null) return null; - return new Path(targetLocation); - } - - protected String getRemoteModuleName(ICVSRemoteFolder resource) { - String moduleName; - if (resource.isDefinedModule()) { - moduleName = resource.getName(); - } else { - moduleName = resource.getRepositoryRelativePath(); - } - return moduleName; - } - - protected IStatus checkout(final ICVSRemoteFolder resource, IProject project, IProgressMonitor pm) throws CVSException { - // Get the location and the workspace root - ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()); - ICVSRepositoryLocation repository = resource.getRepository(); - // Open a connection session to the repository - final Session session = new Session(repository, root); - pm.beginTask(null, 100); - Policy.checkCanceled(pm); - session.open(Policy.subMonitorFor(pm, 5), false /* read-only */); - try { - - // Check to see if the entire repo is being checked out. - if (project == null && resource.getName().equals(".")) { //$NON-NLS-1$ - // No project was specified but we need on for this to work - String name = new Path(null, resource.getRepository().getRootDirectory()).lastSegment(); - project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); - } - - // Determine the local target projects (either the project provider or the module expansions) - // Note: Module expansions can be run over the same connection as a checkout - final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5)); - if (targetProjects == null) { - // An error occurred and was recorded so return it - return getLastError(); - } else if (targetProjects.length == 0) { - return OK; - } - - final boolean sendModuleName = project != null; - final IStatus[] result = new IStatus[] { null }; - ISchedulingRule schedulingRule = getSchedulingRule(targetProjects); - if (schedulingRule instanceof IResource && ((IResource)schedulingRule).getType() == IResource.ROOT) { - // One of the projects is mapped to a provider that locks the workspace. - // Just return the workspace root rule - try { - Platform.getJobManager().beginRule(schedulingRule, pm); - result[0] = performCheckout(session, resource, targetProjects, sendModuleName, Policy.subMonitorFor(pm, 90)); - } finally { - Platform.getJobManager().endRule(schedulingRule); - } - } else { - EclipseSynchronizer.getInstance().run(schedulingRule, new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor); - } - }, Policy.subMonitorFor(pm, 90)); - } - return result[0]; - } catch (CVSException e) { - // An exception occurred either during the module-expansion or checkout - // Since we were able to make a connection, return the status so the - // checkout of any other modules can proceed - return e.getStatus(); - } finally { - session.close(); - pm.done(); - } - } - - private ISchedulingRule getSchedulingRule(IProject[] projects) { - if (projects.length == 1) { - return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[0]); - } else { - Set rules = new HashSet(); - for (int i = 0; i < projects.length; i++) { - ISchedulingRule modifyRule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[i]); - if (modifyRule instanceof IResource && ((IResource)modifyRule).getType() == IResource.ROOT) { - // One of the projects is mapped to a provider that locks the workspace. - // Just return the workspace root rule - return modifyRule; - } - rules.add(modifyRule); - } - return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()])); - } - } - - /* private */ IStatus performCheckout(Session session, ICVSRemoteFolder resource, IProject[] targetProjects, boolean sendModuleName, IProgressMonitor pm) throws CVSException { - // Set the task name of the progress monitor to let the user know - // which project we're on. Don't use subTask since that will be - // changed when the checkout command is run. - String taskName; - if (targetProjects.length == 1) { - taskName = Policy.bind("CheckoutProjectOperation.8", resource.getName(), targetProjects[0].getName()); //$NON-NLS-1$ - } else { - taskName = Policy.bind("CheckoutProjectOperation.9", resource.getName(), String.valueOf(targetProjects.length)); //$NON-NLS-1$ - } - pm.beginTask(taskName, 100); - pm.setTaskName(taskName); - Policy.checkCanceled(pm); - try { - // Scrub the local contents if requested - if (performScrubProjects()) { - IStatus result = scrubProjects(resource, targetProjects, Policy.subMonitorFor(pm, 9)); - if (!result.isOK()) { - return result; - } - } - - // Determine if t - // in which case we'll use -d to flatten the directory structure. - // Only flatten the directory structure if the folder is not a root folder - IProject project = null; - if (targetProjects.length == 1) { - if (sendModuleName) { - project = targetProjects[0]; - } else if (targetProjects[0].getName().equals(resource.getName())) { - // The target project has the same name as the remote folder. - // If the repository relative path has multiple segments - // we will want to flatten the directory structure - String path = resource.getRepositoryRelativePath(); - if (!path.equals(FolderSyncInfo.VIRTUAL_DIRECTORY) - && new Path(null, path).segmentCount() > 1) { - project = targetProjects[0]; - } - } - } - - try { - // Build the local options - List localOptions = new ArrayList(); - // Add the option to load into the target project if one was supplied - if (project != null) { - localOptions.add(Checkout.makeDirectoryNameOption(project.getName())); - } - // Prune empty directories if pruning enabled - if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) - localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES); - // Add the options related to the CVSTag - CVSTag tag = resource.getTag(); - if (tag == null) { - // A null tag in a remote resource indicates HEAD - tag = CVSTag.DEFAULT; - } - localOptions.add(Update.makeTagOption(tag)); - - // Perform the checkout - IStatus status = Command.CHECKOUT.execute(session, - Command.NO_GLOBAL_OPTIONS, - (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]), - new String[]{getRemoteModuleName(resource)}, - null, - Policy.subMonitorFor(pm, 90)); - return status; - } finally { - // Map the projects if they have CVS meta infomation even if a failure occurred - refreshProjects(targetProjects, Policy.subMonitorFor(pm, 1)); - } - } finally { - pm.done(); - } - } - - /* - * Determine the workspace project(s) that will be affected by the checkout. - * If project is not null, then it will be the only target project of the checkout. - * Otherwise, the remote folder could expand to multiple projects. - * - * If the remote resource is a folder which is not a root folder (i.e. a/b/c), - * then the target project will be the last segment (i.e. c). - */ - private IProject[] determineProjects(Session session, final ICVSRemoteFolder remoteFolder, IProject project, IProgressMonitor pm) throws CVSException { - - Set targetProjectSet = new HashSet(); - String moduleName = getRemoteModuleName(remoteFolder); - if (project == null) { - - // Fetch the module expansions - Policy.checkCanceled(pm); - IStatus status = Request.EXPAND_MODULES.execute(session, new String[] {moduleName}, pm); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - collectStatus(status); - return null; - } - - // Convert the module expansions to local projects - String[] expansions = session.getModuleExpansions(); - if (expansions.length == 1 && expansions[0].equals(moduleName)) { - // For a remote folder, use the last segment as the project to be created - String lastSegment = new Path(null, expansions[0]).lastSegment(); - targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment)); - } else { - for (int j = 0; j < expansions.length; j++) { - targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(null, expansions[j]).segment(0))); - } - } - - } else { - targetProjectSet.add(project); - } - - // Return the local projects affected by the checkout - IProject[] targetProjects = (IProject[]) targetProjectSet.toArray(new IProject[targetProjectSet.size()]); - return targetProjects; - } - - /** - * Return true if the target projects should be scrubbed before the checkout occurs. - * Default is to scrub the projects. Can be overridden by subclasses. - */ - protected boolean performScrubProjects() { - return true; - } - - /* - * This method is invoked to scrub the local projects that are the check out target of - * a single remote module. - */ - private IStatus scrubProjects(ICVSRemoteFolder remoteFolder, IProject[] projects, IProgressMonitor monitor) throws CVSException { - if (projects == null) { - monitor.done(); - return OK; - } - // Prompt first before any work is done - if (projects.length > 1) { - setInvolvesMultipleResources(true); - } - for (int i=0;itrue if execution should continue - */ - public boolean performPrompting(IProgressMonitor monitor) throws CVSException, InvocationTargetException, InterruptedException { - monitor.beginTask(null, 20); - IResource[] resourcesToBeAdded = promptForResourcesToBeAdded(Policy.subMonitorFor(monitor, 10)); - if (resourcesToBeAdded == null) return false; - String comment = promptForComment(getResources()); - if (comment == null) return false; - addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment)); - if (resourcesToBeAdded.length > 0) { - new AddOperation(getPart(), resourcesToBeAdded) - .run(Policy.subMonitorFor(monitor, 10)); - } - setResources(getSharedResources(getResources())); - monitor.done(); - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - // Ensure that a comment has been provided - if (!Command.MESSAGE_OPTION.isElementOf(getLocalOptions())) { - String comment = promptForComment(getResources()); - if (comment == null) return; - addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment)); - } - super.execute(monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException { - return Command.COMMIT.execute(session, - Command.NO_GLOBAL_OPTIONS, - getLocalOptions(), - resources, - null, - monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("RepositoryManager.committing"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("CommitOperation.0", provider.getProject().getName()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getErrorMessage(org.eclipse.core.runtime.IStatus[], int) - */ - protected String getErrorMessage(IStatus[] failures, int totalOperations) { - return Policy.bind("CommitAction.commitFailed"); //$NON-NLS-1$ - } - - private IResource[] getUnaddedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws CVSException { - final List unadded = new ArrayList(); - final CVSException[] exception = new CVSException[] { null }; - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - // visit each resource deeply - try { - resource.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - // skip ignored resources and their children - try { - if (cvsResource.isIgnored()) - return false; - // visit the children of shared resources - if (cvsResource.isManaged()) - return true; - if (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder()) - return true; - } catch (CVSException e) { - exception[0] = e; - } - // don't add folders to avoid comitting empty folders - if (resource.getType() == IResource.FOLDER) - return true; - // file is unshared so record it - unadded.add(resource); - // no need to go into children because add is deep - return false; - } - }); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - if (exception[0] != null) throw exception[0]; - } - return (IResource[]) unadded.toArray(new IResource[unadded.size()]); - } - - protected IResource[] promptForResourcesToBeAdded(IProgressMonitor monitor) throws CVSException { - IResource[] unadded = getUnaddedResources(getResources(), monitor); - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - return manager.promptForResourcesToBeAdded(getShell(), unadded); - } - - protected String promptForComment(IResource[] resourcesToCommit) { - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - return manager.promptForComment(getShell(), resourcesToCommit, null); - } - - /* - * Return all resources in the provided collection that are shared with a repo - * @param resources - * @return IResource[] - */ - private IResource[] getSharedResources(IResource[] resources) throws CVSException { - List shared = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (cvsResource.isManaged() - || (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder())) { - shared.add(resource); - } - } - return (IResource[]) shared.toArray(new IResource[shared.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#isServerModificationOperation() - */ - protected boolean isServerModificationOperation() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java deleted file mode 100644 index c32e8abaa..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Disconnect the given projects from CVS control - */ -public class DisconnectOperation extends RepositoryProviderOperation { - - private boolean unmanage; - - public DisconnectOperation(IWorkbenchPart part, IProject[] projects, boolean unmanage) { - super(part, projects); - this.unmanage = unmanage; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute( - CVSTeamProvider provider, - IResource[] resources, - IProgressMonitor monitor) - throws CVSException, InterruptedException { - - // This method will be invoked for each provider being disconnected - IProject project = provider.getProject(); - try { - RepositoryProvider.unmap(project); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - if (unmanage) { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(project); - cvsFolder.unmanage(monitor); - EclipseSynchronizer.getInstance().deconfigure(project, monitor); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("DisconnectOperation.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("DisconnectOperation.1", provider.getProject().getName()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() - */ - public boolean canRunAsJob() { - // Do not run in the background - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java deleted file mode 100644 index d7a4cd68a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.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.team.internal.ccvs.ui.operations; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderMemberFetcher; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.progress.IElementCollector; - -/** - * Fetch the members of a remote folder in the background, passing incremental - * results through an IElementCollector. - */ -public class FetchMembersOperation extends RemoteOperation { - - /* internal uzse only */ IElementCollector collector; - /* internal uzse only */ RemoteFolderFilter filter = new RemoteFolderFilter(); - - public static class RemoteFolderFilter { - public ICVSRemoteResource[] filter(ICVSRemoteResource[] resource) { - return resource; - } - } - - public class InternalRemoteFolderMemberFetcher extends RemoteFolderMemberFetcher { - long sendIncrement = 100; - List unsent = new ArrayList(); - long intervalStart; - protected InternalRemoteFolderMemberFetcher(RemoteFolder parentFolder, CVSTag tag) { - super(parentFolder, tag); - } - protected void parentDoesNotExist() { - super.parentDoesNotExist(); - // Indicate that there are no children - collector.add(new Object[0], getProgressMonitor()); - } - protected RemoteFolder recordFolder(String name) { - RemoteFolder folder = super.recordFolder(name); - unsent.add(folder); - if (isTimeToSend()) { - sendFolders(); - } - return folder; - } - private boolean isTimeToSend() { - long currentTime = System.currentTimeMillis(); - return ((currentTime - intervalStart) > sendIncrement) || unsent.size() > sendIncrement; - } - protected IStatus performUpdate(IProgressMonitor progress, CVSTag tag) throws CVSException { - intervalStart = System.currentTimeMillis(); - IStatus status = super.performUpdate(progress, tag); - sendFolders(); - return status; - } - protected void updateFileRevisions(ICVSFile[] files, IProgressMonitor monitor) throws CVSException { - super.updateFileRevisions(files, monitor); - sendFiles(); - } - private void sendFolders() { - updateParentFolderChildren(); - collector.add(filter.filter((ICVSRemoteFolder[]) unsent.toArray(new ICVSRemoteFolder[unsent.size()])), getProgressMonitor()); - unsent.clear(); - intervalStart = System.currentTimeMillis(); - } - private void sendFiles() { - collector.add(getFiles(), getProgressMonitor()); - unsent.clear(); - } - private IProgressMonitor getProgressMonitor() { - return null; - } - } - - public FetchMembersOperation(IWorkbenchPart part, ICVSRemoteFolder folder, IElementCollector collector) { - super(part, new ICVSRemoteResource[] { folder }); - this.collector = collector; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - ICVSRemoteFolder remote = getRemoteFolder(); - if (remote.getClass().equals(RemoteFolder.class)) { - monitor = Policy.monitorFor(monitor); - boolean isRoot = remote.getName().equals(ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME); - monitor.beginTask(null, 100 + (isRoot ? 30 : 0)); - RemoteFolderMemberFetcher fetcher = new InternalRemoteFolderMemberFetcher((RemoteFolder)remote, remote.getTag()); - fetcher.fetchMembers(Policy.subMonitorFor(monitor, 100)); - if (isRoot) { - ICVSRemoteResource[] modules = CVSUIPlugin.getPlugin() - .getRepositoryManager() - .getRepositoryRootFor(remote.getRepository()) - .getDefinedModules(remote.getTag(), Policy.subMonitorFor(monitor, 25)); - collector.add(filter.filter(modules), Policy.subMonitorFor(monitor, 5)); - } - } else { - monitor = Policy.monitorFor(monitor); - try { - monitor.beginTask(null, 100); - ICVSRemoteResource[] children = remote.members(Policy.subMonitorFor(monitor, 95)); - collector.add(children, Policy.subMonitorFor(monitor, 5)); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("FetchMembersOperation.0", getRemoteFolder().getName()); //$NON-NLS-1$ - } - - private ICVSRemoteFolder getRemoteFolder() { - return (ICVSRemoteFolder)getRemoteResources()[0]; - } - - public RemoteFolderFilter getFilter() { - return filter; - } - - public void setFilter(RemoteFolderFilter filter) { - this.filter = filter; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java deleted file mode 100644 index 00a0cf363..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Operation which checks for the existance of the .project file - * in a remote folder. The operation can be run using the hasMetaFile - * static method of by executing the operation and then checking metaFileExists - */ -public class HasProjectMetaFileOperation extends CVSOperation { - - private ICVSRemoteFolder remoteFolder; - private boolean metaFileExists; - - public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException, InterruptedException { - HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder); - op.run(); - return op.metaFileExists(); - } - - public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) { - super(part); - this.remoteFolder = remoteFolder; - } - - /* - * Return true if the provided remote folder contains a valid meta-file - * (i.e. .project file). - */ - private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { - - // make a copy of the folder so that we will not effect the original folder when we refetch the members - // TODO: this is a strange thing to need to do. We shold fix this. - folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag()); - - try { - folder.members(monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - // Check for the existance of the .project file - try { - folder.getFile(".project"); //$NON-NLS-1$ - return true; - } catch (TeamException e) { - // We couldn't retrieve the meta file so assume it doesn't exist - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - metaFileExists = hasMetaFile(remoteFolder, monitor); - } - - /** - * Return true if the meta file exists remotely. This method should only be invoked - * after the operation has been executed; - * @return - */ - public boolean metaFileExists() { - return metaFileExists; - } - - protected String getTaskName() { - return Policy.bind("HasProjectMetaFile.taskName"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() - */ - public boolean canRunAsJob() { - // This operation should never be run in the background. - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java deleted file mode 100644 index 493126987..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; - -public interface ITagOperation { - public abstract CVSTag getTag(); - public abstract void setTag(CVSTag tag); - public abstract void run() throws InvocationTargetException, InterruptedException; - public abstract ICVSResource[] getCVSResources(); - public abstract void moveTag(); - public abstract void recurse(); - public abstract TagSource getTagSource(); -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java deleted file mode 100644 index c5bb066f3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.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.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.ui.IWorkbenchPart; - -/** - * A specialized Replace operation that will update managed resources and - * unmanaged resources that are conflicting additions (so that the remote is fetched) - */ -public class OverrideAndUpdateOperation extends ReplaceOperation { - - private IResource[] conflictingAdditions; - - public OverrideAndUpdateOperation(IWorkbenchPart part, IResource[] allResources, IResource[] conflictingAdditions, CVSTag tag, boolean recurse) { - super(part, allResources, tag, recurse); - this.conflictingAdditions = conflictingAdditions; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation#getResourcesToUpdate(org.eclipse.team.internal.ccvs.core.ICVSResource[]) - */ - protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException { - // Add the conflicting additions to the list of resources to update - Set update = new HashSet(); - ICVSResource[] conflicts = getCVSArguments(conflictingAdditions); - update.addAll(Arrays.asList(conflicts)); - update.addAll(Arrays.asList(super.getResourcesToUpdate(resources))); - return (ICVSResource[]) update.toArray(new ICVSResource[update.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#updateWorkspaceSubscriber(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void updateWorkspaceSubscriber(CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) { - // No need to update the workspace subscriber since we know this operation will do it properly by itself - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java deleted file mode 100644 index 875b30376..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.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.team.internal.ccvs.ui.operations; - -import java.lang.reflect.InvocationTargetException; -import java.util.Date; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * Reconcile an existing unshared local project with an existing remote folder. - */ -public class ReconcileProjectOperation extends ShareProjectOperation { - - private ICVSRemoteFolder folder; - private ContentComparisonSyncInfoFilter contentCompare = new ContentComparisonSyncInfoFilter(false); - private CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); - - public ReconcileProjectOperation(Shell shell, IProject project, ICVSRemoteFolder folder) { - super(shell, folder.getRepository(), project, folder.getRepositoryRelativePath()); - this.folder = folder; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("ReconcileProjectOperation.0", getProject().getName(), folder.getRepositoryRelativePath()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#createRemoteFolder(org.eclipse.core.runtime.IProgressMonitor) - */ - protected ICVSRemoteFolder createRemoteFolder(IProgressMonitor monitor) throws CVSException { - // The folder already exists so just return the handle - return folder; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#mapProjectToRemoteFolder(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void mapProjectToRemoteFolder(ICVSRemoteFolder remote, IProgressMonitor monitor) throws TeamException { - // Map the project - monitor.beginTask(null, 100); - super.mapProjectToRemoteFolder(remote, Policy.subMonitorFor(monitor, 10)); - // Reconcile the sync info - reconcileSyncInfo(Policy.subMonitorFor(monitor, 90)); - monitor.done(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void reconcileSyncInfo(IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 100); - // Fetch the entire remote tree - ICVSRemoteFolder remote = CheckoutToRemoteFolderOperation.checkoutRemoteFolder(getPart(), folder, Policy.subMonitorFor(monitor, 80)); - // Traverse the tree and populate the workspace base or remote - // with the sync info depending on file contents - populateWorkspace(remote, Policy.subMonitorFor(monitor, 20)); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } finally { - monitor.done(); - } - - } - - private void populateWorkspace(final ICVSRemoteFolder remote, IProgressMonitor monitor) throws CVSException { - CVSWorkspaceRoot.getCVSFolderFor(getProject()).run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - populateWorkspace(getProject(), remote, monitor); - } - }, monitor); - - } - - /* private */ void populateWorkspace(IResource resource, ICVSRemoteResource remote, IProgressMonitor monitor) throws CVSException { - try { - if (resource.getType() == IResource.FILE) { - if (remote.isContainer()) { - CVSUIPlugin.log(IStatus.ERROR, Policy.bind("ReconcileProjectOperation.1", resource.getFullPath().toString(), remote.getRepositoryRelativePath()), null); //$NON-NLS-1$ - } else { - IFile file = (IFile)resource; - IResourceVariant variant = (IResourceVariant)remote; - if (file.exists() - && variant != null - && contentCompare.compareContents(file, variant, monitor)) { - // The contents are the same so populate the local workspace - // with the remote sync info and make the file in-sync - makeInSync(file, remote, monitor); - } else { - // Would like to put the bytes in the remote but this - // is complicated due to subscriber events. - // We'll refresh the subcriber at the end. - } - } - } else { - if (!remote.isContainer()) { - CVSUIPlugin.log(IStatus.ERROR, Policy.bind("ReconcileProjectOperation.2", resource.getFullPath().toString(), remote.getRepositoryRelativePath()), null); //$NON-NLS-1$ - } else { - // Map the local folder to the remote folder. - // (Note that this will make phantoms for non-exisiting local folders) - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(resource); - folder.setFolderSyncInfo(((ICVSFolder)remote).getFolderSyncInfo()); - // Traverse the children of the remote - // (The members were prefetched). - ICVSRemoteResource[] members = remote.members(monitor); - for (int i = 0; i < members.length; i++) { - ICVSRemoteResource member = members[i]; - populateWorkspace(getLocalChild((IContainer)resource, member), member, monitor); - } - } - } - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - - /* - * Get the local resource handle for corresponding to the remote resource - */ - private IResource getLocalChild(IContainer parent, ICVSRemoteResource member) { - IResource resource = parent.findMember(member.getName()); - if (resource == null) { - if (member.isContainer()) { - resource = parent.getFolder(new Path(null, member.getName())); - } else { - resource = parent.getFile(new Path(null, member.getName())); - } - } - return resource; - } - - /* - * Make the file in-sync with its corresponding remote. - */ - private void makeInSync(IFile file, ICVSRemoteResource remote, IProgressMonitor monitor) throws CVSException { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - ResourceSyncInfo info = remote.getSyncInfo(); - Date modTime = info.getTimeStamp(); - if (modTime != null) { - cvsFile.setTimeStamp(modTime); - } - modTime = cvsFile.getTimeStamp(); - MutableResourceSyncInfo newInfoWithTimestamp = info.cloneMutable(); - newInfoWithTimestamp.setTimeStamp(modTime); - cvsFile.setSyncInfo(newInfoWithTimestamp, ICVSFile.CLEAN); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java deleted file mode 100644 index 3c5fb84ff..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java +++ /dev/null @@ -1,381 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.compare.CompareUI; -import org.eclipse.core.runtime.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener; -import org.eclipse.team.internal.ccvs.core.resources.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Compare the two versions of given remote folders obtained from the two tags specified. - */ -public class RemoteCompareOperation extends RemoteOperation { - - private CompareTreeBuilder builder; - private CVSTag left, right; - - /** - * Helper class for builder and comparing the resource trees - */ - public static class CompareTreeBuilder implements RDiffSummaryListener.IFileDiffListener { - private ICVSRepositoryLocation location; - private RemoteFolderTree leftTree, rightTree; - private CVSTag left, right; - - public CompareTreeBuilder(ICVSRepositoryLocation location, CVSTag left, CVSTag right) { - this.left = left; - this.right = right; - this.location = location; - reset(); - } - - public RemoteFolderTree getLeftTree() { - return leftTree; - } - public RemoteFolderTree getRightTree() { - return rightTree; - } - - /** - * Reset the builder to prepare for a new build - */ - public void reset() { - leftTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, left); - leftTree.setChildren(new ICVSRemoteResource[0]); - rightTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, right); - rightTree.setChildren(new ICVSRemoteResource[0]); - } - - /** - * Cache the contents for the files that are about to be compares - * @throws CVSException - */ - public void cacheContents(IProgressMonitor monitor) throws CVSException { - String[] overlappingFilePaths = getOverlappingFilePaths(); - if (overlappingFilePaths.length > 0) { - monitor.beginTask(null, 100); - fetchFileContents(leftTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50)); - fetchFileContents(rightTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50)); - monitor.done(); - } - } - - /** - * Open the comparison in a compare editor - */ - public void openCompareEditor(final IWorkbenchPage page, final String title, final String toolTip) { - if (leftTree == null || rightTree == null) return; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - CompareUI.openCompareEditorOnPage( - new CVSCompareEditorInput(title, toolTip, new ResourceEditionNode(leftTree), new ResourceEditionNode(rightTree)), page); - } - }); - } - - /** - * Add the predecessor to the left tree and the remote to the right tree. - * @param predecessor - * @param remote - */ - public void addToTrees(ICVSRemoteFile predecessor, ICVSRemoteFile remote) { - if (remote != null) { - try { - Path filePath = new Path(null, remote.getRepositoryRelativePath()); - addFile(rightTree, right, filePath, remote.getRevision()); - getFolder(leftTree, left, filePath.removeLastSegments(1), Path.EMPTY); - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - if (predecessor != null) { - try { - Path filePath = new Path(null, predecessor.getRepositoryRelativePath()); - addFile(leftTree, left, filePath, predecessor.getRevision()); - getFolder(rightTree, right, filePath.removeLastSegments(1), Path.EMPTY); - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - } - - private void addFile(RemoteFolderTree tree, CVSTag tag, Path filePath, String revision) throws CVSException { - RemoteFolderTree parent = (RemoteFolderTree)getFolder(tree, tag, filePath.removeLastSegments(1), Path.EMPTY); - String name = filePath.lastSegment(); - ICVSRemoteFile file = new RemoteFile(parent, 0, name, revision, null, getTag(revision, tag)); - addChild(parent, file); - } - - private CVSTag getTag(String revision, CVSTag tag) { - if (tag == null) { - tag = new CVSTag(revision, CVSTag.VERSION); - } - return tag; - } - - /* - * Get the folder at the given path in the given tree, creating any missing folders as needed. - */ - private ICVSRemoteFolder getFolder(RemoteFolderTree tree, CVSTag tag, IPath remoteFolderPath, IPath parentPath) throws CVSException { - if (remoteFolderPath.segmentCount() == 0) return tree; - String name = remoteFolderPath.segment(0); - ICVSResource child; - IPath childPath = parentPath.append(name); - if (tree.childExists(name)) { - child = tree.getChild(name); - } else { - child = new RemoteFolderTree(tree, tree.getRepository(), childPath.toString(), tag); - ((RemoteFolderTree)child).setChildren(new ICVSRemoteResource[0]); - addChild(tree, (ICVSRemoteResource)child); - } - return getFolder((RemoteFolderTree)child, tag, remoteFolderPath.removeFirstSegments(1), childPath); - } - - private void addChild(RemoteFolderTree tree, ICVSRemoteResource resource) { - ICVSRemoteResource[] children = tree.getChildren(); - ICVSRemoteResource[] newChildren; - if (children == null) { - newChildren = new ICVSRemoteResource[] { resource }; - } else { - newChildren = new ICVSRemoteResource[children.length + 1]; - System.arraycopy(children, 0, newChildren, 0, children.length); - newChildren[children.length] = resource; - } - tree.setChildren(newChildren); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#fileDiff(java.lang.String, java.lang.String, java.lang.String) - */ - public void fileDiff(String remoteFilePath, String leftRevision, String rightRevision) { - try { - addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - try { - addFile(leftTree, left, new Path(null, remoteFilePath), leftRevision); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#newFile(java.lang.String, java.lang.String) - */ - public void newFile(String remoteFilePath, String rightRevision) { - try { - addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#deletedFile(java.lang.String) - */ - public void deletedFile(String remoteFilePath, String leftRevision) { - // The leftRevision may be null in which case the tag is used - try { - addFile(leftTree, left, new Path(null, remoteFilePath), leftRevision); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#directory(java.lang.String) - */ - public void directory(String remoteFolderPath) { - try { - getFolder(leftTree, left, new Path(null, remoteFolderPath), Path.EMPTY); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - try { - getFolder(rightTree, right, new Path(null, remoteFolderPath), Path.EMPTY); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - - private String[] getOverlappingFilePaths() { - String[] leftFiles = getFilePaths(leftTree); - String[] rightFiles = getFilePaths(rightTree); - Set set = new HashSet(); - for (int i = 0; i < rightFiles.length; i++) { - String rightFile = rightFiles[i]; - for (int j = 0; j < leftFiles.length; j++) { - String leftFile = leftFiles[j]; - if (leftFile.equals(rightFile)) { - set.add(leftFile); - } - } - } - return (String[]) set.toArray(new String[set.size()]); - } - - private void fetchFileContents(RemoteFolderTree tree, String[] overlappingFilePaths, IProgressMonitor monitor) throws CVSException { - FileContentCachingService.fetchFileContents(tree, overlappingFilePaths, monitor); - } - - private String[] getFilePaths(RemoteFolderTree tree) { - ICVSRemoteResource[] children = tree.getChildren(); - List result = new ArrayList(); - for (int i = 0; i < children.length; i++) { - ICVSRemoteResource resource = children[i]; - if (resource.isContainer()) { - result.addAll(Arrays.asList(getFilePaths((RemoteFolderTree)resource))); - } else { - result.add(resource.getRepositoryRelativePath()); - } - } - return (String[]) result.toArray(new String[result.size()]); - } - } - - public static CVSTag getTag(ICVSRemoteResource resource) throws CVSException { - CVSTag tag = null; - try { - if (resource.isContainer()) { - tag = ((ICVSRemoteFolder)resource).getTag(); - } else { - ICVSRemoteFile file = (ICVSRemoteFile)resource; - String revision = file.getRevision(); - if (revision.equals(ResourceSyncInfo.ADDED_REVISION)) { - ResourceSyncInfo info =file.getSyncInfo(); - if (info != null) tag = info.getTag(); - } else { - tag = new CVSTag(revision, CVSTag.VERSION); - } - } - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - if (tag == null) tag = CVSTag.DEFAULT; - return tag; - } - - /** - * Compare two versions of the given remote resource. - * @param shell - * @param remoteResource the resource whose tags are being compared - * @param left the earlier tag (not null) - * @param right the later tag (not null) - */ - public RemoteCompareOperation(IWorkbenchPart part, ICVSRemoteResource remoteResource, CVSTag tag) { - super(part, new ICVSRemoteResource[] {remoteResource}); - Assert.isNotNull(tag); - this.right = tag; - try { - this.left = getTag(remoteResource); - } catch (CVSException e) { - // This shouldn't happen but log it just in case - CVSProviderPlugin.log(e); - } - if (this.left == null) { - this.left = CVSTag.DEFAULT; - } - builder = new CompareTreeBuilder(remoteResource.getRepository(), left, right); - } - - /* - * This command only supports the use of a single resource - */ - private ICVSRemoteResource getRemoteResource() { - return getRemoteResources()[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(IProgressMonitor monitor) throws CVSException { - boolean fetchContents = CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS); - monitor.beginTask(getTaskName(), 50 + (fetchContents ? 100 : 0)); - try { - ICVSRemoteResource resource = getRemoteResource(); - IStatus status = buildTrees(resource, Policy.subMonitorFor(monitor, 50)); - if (status.isOK() && fetchContents) { - builder.cacheContents(Policy.subMonitorFor(monitor, 100)); - } - collectStatus(status); - openCompareEditor(builder); - } finally { - monitor.done(); - } - } - - /** - * This method is here to allow subclasses to override - */ - protected void openCompareEditor(CompareTreeBuilder builder) { - builder.openCompareEditor(getTargetPage(), null, null); - } - - /* - * Build the two trees uses the reponses from "cvs rdiff -s ...". - */ - private IStatus buildTrees(ICVSRemoteResource resource, IProgressMonitor monitor) throws CVSException { - // Initialize the resulting trees - builder.reset(); - Command.QuietOption oldOption= CVSProviderPlugin.getPlugin().getQuietness(); - Session session = new Session(resource.getRepository(), builder.getLeftTree(), false); - try { - monitor.beginTask(getTaskName(), 100); - CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); - session.open(Policy.subMonitorFor(monitor, 10)); - IStatus status = Command.RDIFF.execute(session, - Command.NO_GLOBAL_OPTIONS, - getLocalOptions(), - new ICVSResource[] { resource }, - new RDiffSummaryListener(builder), - Policy.subMonitorFor(monitor, 90)); - return status; - } finally { - try { - session.close(); - } finally { - CVSProviderPlugin.getPlugin().setQuietness(oldOption); - } - monitor.done(); - } - } - - private LocalOption[] getLocalOptions() { - return new LocalOption[] {RDiff.SUMMARY, RDiff.makeTagOption(left), RDiff.makeTagOption(right)}; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("RemoteCompareOperation.0", new Object[] {left.getName(), right.getName(), getRemoteResource().getRepositoryRelativePath()}); //$NON-NLS-1$ - } - - protected IWorkbenchPage getTargetPage() { - return TeamUIPlugin.getActivePage(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java deleted file mode 100644 index b2ad792ce..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.listeners.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Performs an rlog on the resources and caches the results. - */ -public class RemoteLogOperation extends RepositoryLocationOperation { - - private RLog rlog = new RLog(); - private CVSTag tag1; - private CVSTag tag2; - private LogEntryCache entryCache; - - /** - * A log entry cache that can be shared by multiple instances of the - * remote log operation. - */ - public static class LogEntryCache implements ILogEntryListener { - - /* - * Cache of all log entries - */ - private Map entries = new HashMap(); /* Map String:remoteFilePath->Map (String:revision -> ILogEntry) */ - - private Map internalGetLogEntries(String path) { - return (Map)entries.get(path); - } - - /** - * Return all the log entries at the given path - * @param path the file path - * @return the log entries for the file - */ - public ILogEntry[] getLogEntries(String path) { - Map map = internalGetLogEntries(path); - return (ILogEntry[]) map.values().toArray(new ILogEntry[map.values().size()]); - } - - private ILogEntry internalGetLogEntry(String path, String revision) { - Map fileEntries = internalGetLogEntries(path); - if (fileEntries != null) { - return (ILogEntry)fileEntries.get(revision); - } - return null; - } - - public String[] getCachedFilePaths() { - return (String[]) entries.keySet().toArray(new String[entries.size()]); - } - - /** - * Return the log entry that for the given resource - * or null if no entry was fetched or the - * resource is not a file. - * @param getFullPath(resource) the resource - * @return the log entry or null - */ - public synchronized ILogEntry getLogEntry(ICVSRemoteResource resource) { - if (resource instanceof ICVSRemoteFile) { - try { - String path = getFullPath(resource); - String revision = ((ICVSRemoteFile)resource).getRevision(); - return internalGetLogEntry(path, revision); - } catch (TeamException e) { - // Log and return null - CVSUIPlugin.log(e); - } - } - return null; - } - - /** - * Return the log entries that were fetched for the given resource - * or an empty list if no entry was fetched. - * @param getFullPath(resource) the resource - * @return the fetched log entries or an empty list is none were found - */ - public synchronized ILogEntry[] getLogEntries(ICVSRemoteResource resource) { - Map fileEntries = internalGetLogEntries(getFullPath(resource)); - if (fileEntries != null) { - return (ILogEntry[]) fileEntries.values().toArray(new ILogEntry[fileEntries.size()]); - } - return new ILogEntry[0]; - } - - /* - * Return the full path that uniquely identifies the resource - * accross repositories. This path include the repository and - * resource path but does not include the revision so that - * all log entries for a file can be retrieved. - */ - private String getFullPath(ICVSRemoteResource resource) { - return Util.appendPath(resource.getRepository().getLocation(), resource.getRepositoryRelativePath()); - } - - public synchronized void clearEntries() { - entries.clear(); - } - - public synchronized ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - ILogEntry[] allLogs = getLogEntries(file); - String revision = file.getRevision(); - // First decrement the last digit and see if that revision exists - String predecessorRevision = getPredecessorRevision(revision); - ICVSRemoteFile predecessor = findRevison(allLogs, predecessorRevision); - // If nothing was found, try to fond the base of a branch - if (predecessor == null && isBrancheRevision(revision)) { - predecessorRevision = getBaseRevision(revision); - predecessor = findRevison(allLogs, predecessorRevision); - } - // If that fails, it is still possible that there is a revision. - // This can happen if the revision has been manually set. - if (predecessor == null) { - // We don't search in this case since this is costly and would be done - // for any file that is new as well. - } - return predecessor; - } - - /* - * Find the given revision in the list of log entries. - * Return null if the revision wasn't found. - */ - private ICVSRemoteFile findRevison(ILogEntry[] allLogs, String predecessorRevision) throws TeamException { - for (int i = 0; i < allLogs.length; i++) { - ILogEntry entry = allLogs[i]; - ICVSRemoteFile file = entry.getRemoteFile(); - if (file.getRevision().equals(predecessorRevision)) { - return file; - } - } - return null; - } - /* - * Decrement the trailing digit by one. - */ - private String getPredecessorRevision(String revision) { - int digits[] = Util.convertToDigits(revision); - digits[digits.length -1]--; - StringBuffer buffer = new StringBuffer(revision.length()); - for (int i = 0; i < digits.length; i++) { - buffer.append(Integer.toString(digits[i])); - if (i < digits.length - 1) { - buffer.append('.'); - } - } - return buffer.toString(); - } - - /* - * Return true if there are more than 2 digits in the revision number - * (i.e. the revision is on a branch) - */ - private boolean isBrancheRevision(String revision) { - return Util.convertToDigits(revision).length > 2; - } - - /* - * Remove the trailing revision digits such that the - * returned revision is shorter than the given revision - * and is an even number of digits long - */ - private String getBaseRevision(String revision) { - int digits[] = Util.convertToDigits(revision); - int length = digits.length - 1; - if (length % 2 == 1) { - length--; - } - StringBuffer buffer = new StringBuffer(revision.length()); - for (int i = 0; i < length; i++) { - buffer.append(Integer.toString(digits[i])); - if (i < length - 1) { - buffer.append('.'); - } - } - return buffer.toString(); - } - /** - * Remove any entries for the remote resources - * @param resource the remote resource - */ - public synchronized void clearEntries(ICVSRemoteResource resource) { - String remotePath = getFullPath(resource); - entries.remove(remotePath); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ILogEntryListener#addEntry(org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry) - */ - public void handleLogEntryReceived(ILogEntry entry) { - ICVSRemoteFile file = entry.getRemoteFile(); - String fullPath = getFullPath(file); - String revision = entry.getRevision(); - Map fileEntries = internalGetLogEntries(fullPath); - if (fileEntries == null) { - fileEntries = new HashMap(); - entries.put(fullPath, fileEntries); - } - fileEntries.put(revision, entry); - } - } - - public RemoteLogOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources, CVSTag tag1, CVSTag tag2, LogEntryCache cache) { - super(part, remoteResources); - this.tag1 = tag1; - this.tag2 = tag2; - this.entryCache = cache; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryLocationOperation#execute(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSRemoteResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void execute(ICVSRepositoryLocation location, ICVSRemoteResource[] remoteResources, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(Policy.bind("RemoteLogOperation.0", location.getHost()), 100); //$NON-NLS-1$ - Session s = new Session(location, CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()), false /* do not output to console */); - // Create a log listener that will update the cache as entries are received - LogListener listener = new LogListener(entryCache); - - ICVSRemoteResource[] remotes = remoteResources; - Command.LocalOption[] localOptions = getLocalOptions(tag1, tag2); - if(tag1 == null || tag2 == null) { - // Optimize the cases were we are only fetching the history for a single revision. If it is - // already cached, don't fetch it again. - ArrayList unCachedRemotes = new ArrayList(); - for (int i = 0; i < remoteResources.length; i++) { - ICVSRemoteResource r = remoteResources[i]; - if(entryCache.getLogEntry(r) == null) { - unCachedRemotes.add(r); - } - } - remotes = (ICVSRemoteResource[]) unCachedRemotes.toArray(new ICVSRemoteResource[unCachedRemotes.size()]); - } - if (remotes.length > 0) { - try { - s.open(Policy.subMonitorFor(monitor, 10)); - IStatus status = rlog.execute(s, Command.NO_GLOBAL_OPTIONS, localOptions, remotes, listener, Policy.subMonitorFor(monitor, 90)); - collectStatus(status); - } finally { - s.close(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("RemoteLogOperation.1"); //$NON-NLS-1$ - } - - protected Command.LocalOption[] getLocalOptions(CVSTag tag1, CVSTag tag2) { - if(tag1 != null && tag2 != null) { - return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES, RLog.makeTagOption(tag1, tag2)}; - } else { - return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES}; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java deleted file mode 100644 index 8e778e947..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.ui.IWorkbenchPart; - -public abstract class RemoteOperation extends CVSOperation { - - private ICVSRemoteResource[] remoteResources; - - protected RemoteOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources) { - super(part); - this.remoteResources =remoteResources; - } - - protected ICVSRemoteResource[] getRemoteResources() { - return remoteResources; - } - - public void setRemoteResources(ICVSRemoteResource[] remoteResources) { - this.remoteResources = remoteResources; - } - - public ICVSResource[] getCVSResources() { - ICVSResource[] cvsResources = new ICVSResource[remoteResources.length]; - for (int i = 0; i < remoteResources.length; i++) { - cvsResources[i] = remoteResources[i]; - } - return cvsResources; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java deleted file mode 100644 index c12f535b3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Thsi operation replaces the local resources with their remote contents - */ -public class ReplaceOperation extends UpdateOperation { - - boolean recurse = true; - - public ReplaceOperation(IWorkbenchPart part, IResource[] resources, CVSTag tag, boolean recurse) { - super(part, resources, getReplaceOptions(recurse), tag); - this.recurse = recurse; - } - - /* - * Create the local options required to do a replace - */ - private static LocalOption[] getReplaceOptions(boolean recurse) { - List options = new ArrayList(); - options.add(Update.IGNORE_LOCAL_CHANGES); - if(!recurse) { - options.add(Command.DO_NOT_RECURSE); - } - return (LocalOption[]) options.toArray(new LocalOption[options.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("ReplaceOperation.taskName"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus executeCommand( - Session session, - CVSTeamProvider provider, - ICVSResource[] resources, - IProgressMonitor monitor) - throws CVSException, InterruptedException { - - monitor.beginTask(null, 100); - ICVSResource[] managedResources = getResourcesToUpdate(resources); - try { - // Purge any unmanaged or added files - new PrepareForReplaceVisitor().visitResources( - provider.getProject(), - resources, - "CVSTeamProvider.scrubbingResource", // TODO: This is a key in CVS core! //$NON-NLS-1$ - recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, - Policy.subMonitorFor(monitor, 30)); //$NON-NLS-1$ - - // Only perform the remote command if some of the resources being replaced were managed - IStatus status = OK; - if (managedResources.length > 0) { - // Perform an update, ignoring any local file modifications - status = super.executeCommand(session, provider, managedResources, Policy.subMonitorFor(monitor, 70)); - } - - // Prune any empty folders left after the resources were purged. - // This is done to prune any empty folders that contained only unmanaged resources - if (status.isOK() && CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { - new PruneFolderVisitor().visit(session, resources); - } - - return status; - } finally { - monitor.done(); - } - } - - /** - * Return the resources that need to be updated from the server. - * By default, this is all resources that are managed. - * @param resources all resources being replaced - * @return resources that ae to be updated from the server - * @throws CVSException - */ - protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException { - // Accumulate the managed resources from the list of provided resources - List managedResources = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - if ((resource.isFolder() && ((ICVSFolder)resource).isCVSFolder())) { - managedResources.add(resource); - } else if (!resource.isFolder()){ - byte[] syncBytes = ((ICVSFile)resource).getSyncBytes(); - if (syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) { - managedResources.add(resource); - } - } - } - return (ICVSResource[]) managedResources.toArray(new ICVSResource[managedResources.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getUpdateCommand() - */ - protected Update getUpdateCommand() { - return Command.REPLACE; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("ReplaceOperation.0", provider.getProject().getName()); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java deleted file mode 100644 index 0da7eaaec..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.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.team.internal.ccvs.ui.operations; - -import java.util.*; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Operation that divides the resources by location - */ -public abstract class RepositoryLocationOperation extends RemoteOperation { - - protected RepositoryLocationOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources) { - super(part, remoteResources); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - Map table = getLocationMapping(getRemoteResources()); - Set keySet = table.keySet(); - monitor.beginTask(null, keySet.size() * 100); - Iterator iterator = keySet.iterator(); - while (iterator.hasNext()) { - ICVSRepositoryLocation location = (ICVSRepositoryLocation)iterator.next(); - List list = (List)table.get(location); - ICVSRemoteResource[] remoteResources = (ICVSRemoteResource[])list.toArray(new ICVSRemoteResource[list.size()]); - execute(location, remoteResources, Policy.subMonitorFor(monitor, 100)); - } - } - - /** - * Perform the operation for the given resources found on the - * given repository. - * @param location the repository location - * @param resources the resources of this operation found in the repository - * @param monitor a progres monitor - */ - protected abstract void execute(ICVSRepositoryLocation location, ICVSRemoteResource[] resources, IProgressMonitor monitor) throws CVSException; - - /* - * Return a map that maps a location to all the resources - * from the given list that are located in that repository. - */ - private Map getLocationMapping(ICVSRemoteResource[] remoteResources) { - Map locationsMap = new HashMap(); - for (int i = 0; i < remoteResources.length; i++) { - ICVSRemoteResource resource = remoteResources[i]; - ICVSRepositoryLocation location = resource.getRepository(); - List resources = (List)locationsMap.get(location); - if (resources == null) { - resources = new ArrayList(); - locationsMap.put(location, resources); - } - resources.add(resource); - } - return locationsMap; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java deleted file mode 100644 index cc2e0bf5a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.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.team.internal.ccvs.ui.operations; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Performs a cvs operation on multiple repository providers - */ -public abstract class RepositoryProviderOperation extends CVSOperation { - - private IResource[] resources; - - public RepositoryProviderOperation(IWorkbenchPart part, IResource[] resources) { - super(part); - this.resources = resources; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - Map table = getProviderMapping(getResources()); - Set keySet = table.keySet(); - monitor.beginTask(null, keySet.size() * 1000); - Iterator iterator = keySet.iterator(); - while (iterator.hasNext()) { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); - CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); - List list = (List)table.get(provider); - IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); - ISchedulingRule rule = getSchedulingRule(provider); - try { - Platform.getJobManager().beginRule(rule, monitor); - monitor.setTaskName(getTaskName(provider)); - execute(provider, providerResources, subMonitor); - } finally { - Platform.getJobManager().endRule(rule); - } - } - } - - /** - * Return the taskname to be shown in the progress monitor while operating - * on the given provider. - * @param provider the provider being processed - * @return the taskname to be shown in the progress monitor - */ - protected abstract String getTaskName(CVSTeamProvider provider); - - /** - * Retgurn the scheduling rule to be obtained before work - * begins on the given provider. By default, it is the provider's project. - * This can be changed by subclasses. - * @param provider - * @return - */ - protected ISchedulingRule getSchedulingRule(CVSTeamProvider provider) { - return provider.getProject(); - } - - /* - * Helper method. Return a Map mapping provider to a list of resources - * shared with that provider. - */ - private Map getProviderMapping(IResource[] resources) { - Map result = new HashMap(); - for (int i = 0; i < resources.length; i++) { - RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject(), CVSProviderPlugin.getTypeId()); - List list = (List)result.get(provider); - if (list == null) { - list = new ArrayList(); - result.put(provider, list); - } - list.add(resources[i]); - } - return result; - } - - /** - * Return the resources that the operation is being performed on - * @return - */ - protected IResource[] getResources() { - return resources; - } - - /** - * Set the resources that the operation is to be performed on - * @param resources - */ - protected void setResources(IResource[] resources) { - this.resources = resources; - } - - /** - * Execute the operation on the resources for the given provider. - * @param provider - * @param providerResources - * @param subMonitor - * @throws CVSException - * @throws InterruptedException - */ - protected abstract void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException; - - protected ICVSResource[] getCVSArguments(IResource[] resources) { - ICVSResource[] cvsResources = new ICVSResource[resources.length]; - for (int i = 0; i < cvsResources.length; i++) { - cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - } - return cvsResources; - } - - /* - * Get the arguments to be passed to a commit or update - */ - protected String[] getStringArguments(IResource[] resources) throws CVSException { - List arguments = new ArrayList(resources.length); - for (int i=0;inull - * then the tag will be omitted from the local options and the tags on the local resources - * will be used. - * @param shell - * @param resources - * @param options - * @param tag - */ - public UpdateOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options, CVSTag tag) { - super(part, resources, options); - this.tag = tag; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus executeCommand( - Session session, - CVSTeamProvider provider, - ICVSResource[] resources, - IProgressMonitor monitor) - throws CVSException, InterruptedException { - - // Build the local options - List localOptions = new ArrayList(); - - // Use the appropriate tag options - if (tag != null) { - localOptions.add(Update.makeTagOption(tag)); - } - - // Build the arguments list - localOptions.addAll(Arrays.asList(getLocalOptions())); - LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]); - - monitor.beginTask(null, 100); - IStatus execute = getUpdateCommand().execute( - session, - Command.NO_GLOBAL_OPTIONS, - commandOptions, - resources, - getCommandOutputListener(), - Policy.subMonitorFor(monitor, 95)); - - updateWorkspaceSubscriber(provider, resources, Policy.subMonitorFor(monitor, 5)); - monitor.done(); - return execute; - } - - protected Update getUpdateCommand() { - return Command.UPDATE; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() - */ - protected String getTaskName() { - return Policy.bind("UpdateOperation.taskName"); //$NON-NLS-1$; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) - */ - protected String getTaskName(CVSTeamProvider provider) { - return Policy.bind("UpdateOperation.0", provider.getProject().getName()); //$NON-NLS-1$ - } - - /** - * Return the listener that is used to process E and M messages. - * The default is null. - * @return - */ - protected ICommandOutputListener getCommandOutputListener() { - return null; - } - - protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT - || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH - || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getErrorMessage(org.eclipse.core.runtime.IStatus[], int) - */ - protected String getErrorMessage(IStatus[] failures, int totalOperations) { - return Policy.bind("UpdateAction.update"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java deleted file mode 100644 index be3b44f37..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; - -/** - * Action to add a root remote folder to a branch - */ -public class AddToBranchAction extends CVSAction { - - IInputValidator validator = new IInputValidator() { - public String isValid(String newText) { - IStatus status = CVSTag.validateTagName(newText); - if (status.isOK()) return null; - return status.getMessage(); - } - }; - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - final ICVSRemoteFolder folder = getSelectedRootFolder(); - if (folder == null) return; - Shell shell = getShell(); - final CVSException[] exception = new CVSException[] { null }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - InputDialog dialog = new InputDialog(getShell(), Policy.bind("AddToBranchAction.enterTag"), Policy.bind("AddToBranchAction.enterTagLong"), null, validator); //$NON-NLS-1$ //$NON-NLS-2$ - if (dialog.open() == InputDialog.OK) { - CVSTag tag = new CVSTag(dialog.getValue(), CVSTag.BRANCH); - try { - CVSUIPlugin.getPlugin().getRepositoryManager().addTags(folder, new CVSTag[] {tag}); - } catch (CVSException e) { - exception[0] = e; - } - } - } - }); - if (exception[0] != null) - throw new InvocationTargetException(exception[0]); - } - }, false, PROGRESS_BUSYCURSOR); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() throws TeamException { - return getSelectedRootFolder() != null; - } - - protected ICVSRemoteFolder getSelectedRootFolder() { - ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); - ICVSRemoteFolder selectedFolder = null; - for (int i = 0; i < folders.length; i++) { - ICVSRemoteFolder folder = folders[i]; - if (folder.isDefinedModule() || new Path(null, folder.getRepositoryRelativePath()).segmentCount()==1) { - // only return a folder if one valid one is selected. - if (selectedFolder != null) return null; - selectedFolder = folder; - } - } - return selectedFolder; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepoViewAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepoViewAction.java deleted file mode 100644 index df4f9ccdf..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepoViewAction.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.model.BranchCategory; - -/** - * Abstract superclass for actions in the repositories view - */ -public abstract class CVSRepoViewAction extends CVSAction { - - /** - * Returns the selected CVS Repository locations - */ - protected ICVSRepositoryLocation[] getSelectedRepositoryLocations() { - ArrayList tags = new ArrayList(); - if (!selection.isEmpty()) { - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object element = elements.next(); - Object adapter = getAdapter(element, ICVSRepositoryLocation.class); - if (adapter != null) { - tags.add(adapter); - } else { - adapter = getAdapter(element, BranchCategory.class); - if(adapter != null) { - tags.add(((BranchCategory)adapter).getRepository(adapter)); - } - } - } - } - return (ICVSRepositoryLocation[])tags.toArray(new ICVSRepositoryLocation[tags.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java deleted file mode 100644 index f79f1e72d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java +++ /dev/null @@ -1,595 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage; -import org.eclipse.team.internal.ui.dialogs.DetailsDialogWithProjects; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.ui.help.WorkbenchHelp; - -public class CVSRepositoryPropertiesPage extends PropertyPage { - private static final String FAKE_PASSWORD = "*********"; //$NON-NLS-1$ - ICVSRepositoryLocation location; - - // Widgets - Text userText; - Text passwordText; - Combo methodType; - Text hostText; - Text pathText; - // Port - private Text portText; - private Button useDefaultPort; - private Button useCustomPort; - - // Caching password - private Button allowCachingButton; - private boolean allowCaching = false; - - boolean passwordChanged; - boolean connectionInfoChanged; - - IUserInfo info; - - // Label - private Button useLocationAsLabel; - private Button useCustomLabel; - private Text labelText; - - /* - * @see PreferencesPage#createContents - */ - protected Control createContents(Composite parent) { - initialize(); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - composite.setLayout(layout); - - // Repository Label - // create a composite to ensure the radio buttons come in the correct order - Composite labelGroup = new Composite(composite, SWT.NONE); - GridData data = new GridData(); - data.horizontalSpan = 3; - labelGroup.setLayoutData(data); - layout = new GridLayout(); - layout.numColumns = 3; - layout.marginHeight = 0; - layout.marginWidth = 0; - labelGroup.setLayout(layout); - Listener labelListener = new Listener() { - public void handleEvent(Event event) { - updateWidgetEnablements(); - } - }; - useLocationAsLabel = createRadioButton(labelGroup, Policy.bind("CVSRepositoryPropertiesPage.useLocationAsLabel"), 3); //$NON-NLS-1$ - useCustomLabel = createRadioButton(labelGroup, Policy.bind("CVSRepositoryPropertiesPage.useCustomLabel"), 1); //$NON-NLS-1$ - useCustomLabel.addListener(SWT.Selection, labelListener); - labelText = createTextField(labelGroup); - labelText.addListener(SWT.Modify, labelListener); - - // Add some extra space - createLabel(composite, "", 3); //$NON-NLS-1$ - - createLabel(composite, Policy.bind("CVSPropertiesPage.connectionType"), 1); //$NON-NLS-1$ - methodType = createCombo(composite); - - createLabel(composite, Policy.bind("CVSPropertiesPage.user"), 1); //$NON-NLS-1$ - userText = createTextField(composite); - - createLabel(composite, Policy.bind("CVSPropertiesPage.password"), 1); //$NON-NLS-1$ - passwordText = createPasswordField(composite); - - createLabel(composite, Policy.bind("CVSPropertiesPage.host"), 1); //$NON-NLS-1$ - hostText = createTextField(composite); - - createLabel(composite, Policy.bind("CVSPropertiesPage.path"), 1); //$NON-NLS-1$ - pathText = createTextField(composite); - - // Port number - // create a composite to ensure the radio buttons come in the correct order - Composite portGroup = new Composite(composite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 3; - portGroup.setLayoutData(data); - layout = new GridLayout(); - layout.numColumns = 3; - layout.marginHeight = 0; - layout.marginWidth = 0; - portGroup.setLayout(layout); - useDefaultPort = createRadioButton(portGroup, Policy.bind("ConfigurationWizardMainPage.useDefaultPort"), 3); //$NON-NLS-1$ - useCustomPort = createRadioButton(portGroup, Policy.bind("ConfigurationWizardMainPage.usePort"), 1); //$NON-NLS-1$ - portText = createTextField(portGroup); - - // Add some extra space - createLabel(composite, "", 3); //$NON-NLS-1$ - - allowCachingButton = new Button(composite, SWT.CHECK); - allowCachingButton.setText(Policy.bind("UserValidationDialog.6")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - allowCachingButton.setLayoutData(data); - allowCachingButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - allowCaching = allowCachingButton.getSelection(); - } - }); - - Composite warningComposite = new Composite(composite, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginHeight = 0; - warningComposite.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - warningComposite.setLayoutData(data); - Label warningLabel = new Label(warningComposite, SWT.NONE); - warningLabel.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); - warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); - Label warningText = new Label(warningComposite, SWT.WRAP); - warningText.setText(Policy.bind("UserValidationDialog.7")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 300; - warningText.setLayoutData(data); - - // Add some extra space - createLabel(composite, "", 3); //$NON-NLS-1$ - - initializeValues(); - updateWidgetEnablements(); - Listener connectionInfoChangedListener = new Listener() { - public void handleEvent(Event event) { - connectionInfoChanged = true; - updateWidgetEnablements(); - } - }; - passwordText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - passwordChanged = !passwordText.getText().equals(FAKE_PASSWORD); - } - }); - userText.addListener(SWT.Modify, connectionInfoChangedListener); - methodType.addListener(SWT.Modify, connectionInfoChangedListener); - hostText.addListener(SWT.Modify, connectionInfoChangedListener); - portText.addListener(SWT.Modify, connectionInfoChangedListener); - useCustomPort.addListener(SWT.Selection, connectionInfoChangedListener); - pathText.addListener(SWT.Modify, connectionInfoChangedListener); - - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.REPOSITORY_LOCATION_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Utility method that creates a combo box - * - * @param parent the parent for the new label - * @return the new widget - */ - protected Combo createCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - data.horizontalSpan = 2; - combo.setLayoutData(data); - return combo; - } - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = span; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - /** - * Create a text field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - protected Text createTextField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); - return layoutTextField(text); - } - /** - * Create a password field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - protected Text createPasswordField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD); - return layoutTextField(text); - } - /** - * Layout a text or password field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - protected Text layoutTextField(Text text) { - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.verticalAlignment = GridData.CENTER; - data.grabExcessVerticalSpace = false; - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - data.horizontalSpan = 2; - text.setLayoutData(data); - return text; - } - - /** - * Utility method to create a radio button - * - * @param parent the parent of the radio button - * @param label the label of the radio button - * @param span the number of columns to span - * @return the created radio button - */ - protected Button createRadioButton(Composite parent, String label, int span) { - Button button = new Button(parent, SWT.RADIO); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = span; - button.setLayoutData(data); - return button; - } - /** - * Initializes the page - */ - private void initialize() { - location = null; - IAdaptable element = getElement(); - if (element instanceof ICVSRepositoryLocation) { - location = (ICVSRepositoryLocation)element; - } else { - Object adapter = element.getAdapter(ICVSRepositoryLocation.class); - if (adapter instanceof ICVSRepositoryLocation) { - location = (ICVSRepositoryLocation)adapter; - } - } - } - /** - * Set the initial values of the widgets - */ - private void initializeValues() { - passwordChanged = false; - connectionInfoChanged = false; - - IConnectionMethod[] methods = CVSRepositoryLocation.getPluggedInConnectionMethods(); - for (int i = 0; i < methods.length; i++) { - methodType.add(methods[i].getName()); - } - String method = location.getMethod().getName(); - methodType.select(methodType.indexOf(method)); - info = location.getUserInfo(true); - userText.setText(info.getUsername()); - passwordText.setText(FAKE_PASSWORD); - hostText.setText(location.getHost()); - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { - useDefaultPort.setSelection(true); - useCustomPort.setSelection(false); - portText.setEnabled(false); - } else { - useDefaultPort.setSelection(false); - useCustomPort.setSelection(true); - portText.setText("" + port); //$NON-NLS-1$ - } - pathText.setText(location.getRootDirectory()); - allowCachingButton.setSelection(location.getUserInfoCached()); - - // get the repository label - String label = null; - RepositoryRoot root = CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(location); - label = root.getName(); - useLocationAsLabel.setSelection(label == null); - useCustomLabel.setSelection(!useLocationAsLabel.getSelection()); - if (label == null) { - label = location.getLocation(); - } - labelText.setText(label); - } - - private boolean performConnectionInfoChanges() { - // Set the caching mode of the location - if (!connectionInfoChanged) { - location.setAllowCaching(allowCaching); - if (!passwordChanged) { - ((CVSRepositoryLocation)location).updateCache(); - } - } - // Don't do anything else if there wasn't a password or connection change - if (!passwordChanged && !connectionInfoChanged) return true; - - try { - // Check if the password was the only thing to change. - if (passwordChanged && !connectionInfoChanged) { - CVSRepositoryLocation oldLocation = (CVSRepositoryLocation)location; - oldLocation.setPassword(getNewPassword()); - if (allowCaching) { - oldLocation.updateCache(); - } - passwordChanged = false; - return true; - } - - // Otherwise change the connection info and the password - // This operation is done inside a workspace operation in case the sharing - // info for existing projects is changed - if (!(location.getHost().equals(hostText.getText()) && location.getRootDirectory().equals(pathText.getText()))) { - // The host or path has changed - if (!MessageDialog.openConfirm(getShell(), - Policy.bind("CVSRepositoryPropertiesPage.0"), //$NON-NLS-1$ - Policy.bind("CVSRepositoryPropertiesPage.1"))) { //$NON-NLS-1$ - return false; - } - } - final boolean[] result = new boolean[] { false }; - final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); - progressMonitorDialog.run(false, false, new WorkspaceModifyOperation(null) { - public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - // Create a new repository location with the new information - CVSRepositoryLocation newLocation = CVSRepositoryLocation.fromProperties(createProperties()); - location.setAllowCaching(allowCaching); - try { - // For each project shared with the old location, set connection info to the new one - List projects = new ArrayList(); - IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < allProjects.length; i++) { - RepositoryProvider teamProvider = RepositoryProvider.getProvider(allProjects[i], CVSProviderPlugin.getTypeId()); - if (teamProvider != null) { - CVSTeamProvider cvsProvider = (CVSTeamProvider)teamProvider; - if (cvsProvider.getCVSWorkspaceRoot().getRemoteLocation().equals(location)) { - projects.add(allProjects[i]); - } - } - } - if (projects.size() > 0) { - // To do: warn the user - DetailsDialogWithProjects dialog = new DetailsDialogWithProjects( - progressMonitorDialog.getShell(), - Policy.bind("CVSRepositoryPropertiesPage.Confirm_Project_Sharing_Changes_1"), //$NON-NLS-1$ - Policy.bind("CVSRepositoryPropertiesPage.There_are_projects_in_the_workspace_shared_with_this_repository_2"), //$NON-NLS-1$ - Policy.bind("CVSRepositoryPropertiesPage.sharedProject", location.toString()), //$NON-NLS-1$ - (IProject[]) projects.toArray(new IProject[projects.size()]), - true, - DetailsDialogWithProjects.DLG_IMG_WARNING); - int r = dialog.open(); - if (r != DetailsDialogWithProjects.OK) { - result[0] = false; - return; - } - monitor.beginTask(null, 1000 * projects.size()); - try { - Iterator it = projects.iterator(); - while (it.hasNext()) { - IProject project = (IProject)it.next(); - RepositoryProvider teamProvider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - CVSTeamProvider cvsProvider = (CVSTeamProvider)teamProvider; - cvsProvider.setRemoteRoot(newLocation, Policy.subMonitorFor(monitor, 1000)); - } - } finally { - monitor.done(); - } - } - - // Dispose the old repository location - CVSUIPlugin.getPlugin().getRepositoryManager().replaceRepositoryLocation(location, newLocation); - - } finally { - // Even if we failed, ensure that the new location appears in the repo view. - newLocation = (CVSRepositoryLocation)KnownRepositories.getInstance().addRepository(newLocation, !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation())); - } - - // Set the location of the page to the new location in case Apply was chosen - location = newLocation; - connectionInfoChanged = false; - passwordChanged = false; - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - result[0] = true; - } - }); - return result[0]; - } catch (InvocationTargetException e) { - handle(e); - } catch (InterruptedException e) { - } - return false; /* we only get here if an exception occurred */ - } - - private void performNonConnectionInfoChanges() { - recordNewLabel((CVSRepositoryLocation)location); - } - /* - * @see PreferencesPage#performOk - */ - public boolean performOk() { - if (performConnectionInfoChanges()) { - performNonConnectionInfoChanges(); - return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#performDefaults() - */ - protected void performDefaults() { - super.performDefaults(); - initializeValues(); - } - - /** - * Shows the given errors to the user. - */ - protected void handle(Throwable e) { - CVSUIPlugin.openError(getShell(), null, null, e); - } - - /** - * Updates widget enablements and sets error message if appropriate. - */ - protected void updateWidgetEnablements() { - if (useLocationAsLabel.getSelection()) { - labelText.setEnabled(false); - } else { - labelText.setEnabled(true); - } - if (useDefaultPort.getSelection()) { - portText.setEnabled(false); - } else { - portText.setEnabled(true); - } - validateFields(); - } - - private void validateFields() { - if (labelText.isEnabled()) { - if (labelText.getText().length() == 0) { - setValid(false); - return; - } - } - String user = userText.getText(); - IStatus status = ConfigurationWizardMainPage.validateUserName(user); - if (!isStatusOK(status)) { - return; - } - - String host = hostText.getText(); - status = ConfigurationWizardMainPage.validateHost(host); - if (!isStatusOK(status)) { - return; - } - - if (portText.isEnabled()) { - String port = portText.getText(); - status = ConfigurationWizardMainPage.validatePort(port); - if (!isStatusOK(status)) { - return; - } - } - - String pathString = pathText.getText(); - status = ConfigurationWizardMainPage.validatePath(pathString); - if (!isStatusOK(status)) { - return; - } - - try { - CVSRepositoryLocation l = CVSRepositoryLocation.fromProperties(createProperties()); - if (!l.equals(location) && KnownRepositories.getInstance().isKnownRepository(l.getLocation())) { - setErrorMessage(Policy.bind("ConfigurationWizardMainPage.0")); //$NON-NLS-1$ - setValid(false); - return; - } - } catch (CVSException e) { - CVSUIPlugin.log(e); - // Let it pass. Creation should fail - } - - setErrorMessage(null); - setValid(true); - } - - private boolean isStatusOK(IStatus status) { - if (!status.isOK()) { - setErrorMessage(status.getMessage()); - setValid(false); - return false; - } - return true; - } - - private void recordNewLabel(CVSRepositoryLocation location) { - String newLabel = getNewLabel(location); - if (newLabel == null) { - String oldLabel = getOldLabel(location); - if (oldLabel == null || oldLabel.equals(location.getLocation())) { - return; - } - } else if (newLabel.equals(getOldLabel(location))) { - return; - } - CVSUIPlugin.getPlugin().getRepositoryManager().setLabel(location, newLabel); - } - private String getOldLabel(CVSRepositoryLocation location) { - return CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(location).getName(); - } - private String getNewLabel(CVSRepositoryLocation location) { - String label = null; - if (useCustomLabel.getSelection()) { - label = labelText.getText(); - if (label.equals(location.getLocation())) { - label = null; - } - } - return label; - } - /* internal use only */ String getNewPassword() { - return passwordText.getText(); - } - - private Properties createProperties() { - Properties result = new Properties(); - result.setProperty("connection", methodType.getText()); //$NON-NLS-1$ - result.setProperty("user", userText.getText()); //$NON-NLS-1$ - if (passwordChanged) { - result.setProperty("password", passwordText.getText()); //$NON-NLS-1$ - } - result.setProperty("host", hostText.getText()); //$NON-NLS-1$ - if (useCustomPort.getSelection()) { - result.setProperty("port", portText.getText()); //$NON-NLS-1$ - } - result.setProperty("root", pathText.getText()); //$NON-NLS-1$ - return result; - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java deleted file mode 100644 index f3f3d58f2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.Vector; - -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.Attributes; - -class CommentHistoryContentHandler extends DefaultHandler { - - private StringBuffer buffer; - private Vector comments; - public CommentHistoryContentHandler() { - } - - /** - * @see ContentHandler#characters(char[], int, int) - */ - public void characters(char[] chars, int startIndex, int length) throws SAXException { - if (buffer == null) return; - buffer.append(chars, startIndex, length); - } - - /** - * @see ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - public void startElement( - String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - String elementName = getElementName(namespaceURI, localName, qName); - if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { - buffer = new StringBuffer(); - return; - } - if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_HISTORY)) { - comments = new Vector(RepositoryManager.MAX_COMMENTS); - return; - } - } - - /** - * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) - */ - public void endElement(String namespaceURI, String localName, String qName) { - String elementName = getElementName(namespaceURI, localName, qName); - if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { - comments.add(buffer.toString()); - buffer = null; - return; - } - if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_HISTORY)) { - RepositoryManager.previousComments = new String[comments.size()]; - comments.copyInto(RepositoryManager.previousComments); - return; - } - } - - /* - * Couldn't figure out from the SAX API exactly when localName vs. qName is used. - * However, the XML for project sets doesn't use namespaces so either of the two names - * is fine. Therefore, use whichever one is provided. - */ - private String getElementName(String namespaceURI, String localName, String qName) { - if (localName != null && localName.length() > 0) { - return localName; - } else { - return qName; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CopyRepositoryNameAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CopyRepositoryNameAction.java deleted file mode 100644 index 50b1cbb54..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CopyRepositoryNameAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.dnd.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; - -public class CopyRepositoryNameAction extends CVSAction { - protected boolean isEnabled() throws TeamException { - return true; - } - public void execute(IAction action) { - ICVSRepositoryLocation[] locations = getSelectedRepositories(); - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < locations.length; i++) { - buffer.append(locations[i].getLocation()); - if (i < locations.length - 1) buffer.append("\n"); //$NON-NLS-1$ - } - copyToClipbard(Display.getDefault(), buffer.toString()); - } - protected ICVSRepositoryLocation[] getSelectedRepositories() { - ArrayList repositories = null; - if (!selection.isEmpty()) { - repositories = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = getAdapter(elements.next(), ICVSRepositoryLocation.class); - if (next instanceof ICVSRepositoryLocation) { - repositories.add(next); - continue; - } - } - } - if (repositories != null && !repositories.isEmpty()) { - ICVSRepositoryLocation[] result = new ICVSRepositoryLocation[repositories.size()]; - repositories.toArray(result); - return result; - } - return new ICVSRepositoryLocation[0]; - } - private void copyToClipbard(Display display, String str) { - Clipboard clipboard = new Clipboard(display); - clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance()}); - clipboard.dispose(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewCVSRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewCVSRepositoryAction.java deleted file mode 100644 index 172607e6a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewCVSRepositoryAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.wizards.NewLocationWizard; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * Called from Welcome page only. - */ -public class NewCVSRepositoryAction extends Action { - public void run() { - Shell shell; - IWorkbenchWindow window = CVSUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - shell = window.getShell(); - } else { - Display display = Display.getCurrent(); - shell = new Shell(display); - } - NewLocationWizard wizard = new NewLocationWizard(); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewDateTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewDateTagAction.java deleted file mode 100644 index b536fb34a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/NewDateTagAction.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.team.internal.ccvs.ui.repo; - -import java.lang.reflect.InvocationTargetException; -import java.util.Date; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.DateTagDialog; - -/** - * Action for creating a CVS Date tag. - */ -public class NewDateTagAction extends CVSRepoViewAction { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - if (locations.length != 1) return; - CVSTag tag = getDateTag(getShell(), locations[0]); - CVSUIPlugin.getPlugin().getRepositoryManager().addDateTag(locations[0], tag); - } - - public static CVSTag getDateTag(Shell shell, ICVSRepositoryLocation location) { - DateTagDialog dialog = new DateTagDialog(shell); - if (dialog.open() == Window.OK) { - Date date = dialog.getDate(); - CVSTag tag = new CVSTag(date); - return tag; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() { - ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - if (locations.length != 1) return false; - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java deleted file mode 100644 index 8dfb75598..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.Arrays; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.ListSelectionArea; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.WorkingSetSelectionArea; -import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider; -import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * Page that allows the user to select the remote projects whose tags should be - * refreshed. - */ -public class RefreshRemoteProjectSelectionPage extends CVSWizardPage { - - private ICVSRemoteResource[] rootFolders; - private ListSelectionArea listArea; - private WorkingSetSelectionArea workingSetArea; - private IWorkingSet workingSet; - private IDialogSettings settings; - - /** - * Custom input provider which returns the list of root folders - */ - private class InputElement implements IWorkbenchAdapter, IAdaptable { - public Object[] getChildren(Object o) { - return rootFolders; - } - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - public String getLabel(Object o) { - return null; - } - public Object getParent(Object o) { - return null; - } - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - } - - /** - * Constructor for RemoteProjectSelectionPage. - * @param pageName - * @param title - * @param titleImage - * @param description - */ - public RefreshRemoteProjectSelectionPage( - String pageName, - String title, - ImageDescriptor titleImage, - String description, - IDialogSettings settings, - ICVSRepositoryLocation root, - ICVSRemoteResource[] rootFolders) { - super(pageName, title, titleImage, description); - this.settings = settings; - this.rootFolders = rootFolders; - } - - /** - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - - final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - - setControl(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.REFRESH_REMOTE_PROJECT_SELECTION_PAGE); - - listArea = new ListSelectionArea( - new InputElement(), - new RemoteContentProvider(), - new WorkbenchLabelProvider(), - Policy.bind("RefreshRemoteProjectSelectionPage.selectRemoteProjects")); //$NON-NLS-1$ - listArea.createArea(composite); - - listArea.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - updateEnablement(); - } - }); - listArea.getViewer().setSorter(new RepositorySorter()); - - workingSetArea = new WorkingSetSelectionArea(getShell(), Policy.bind("RefreshRemoteProjectSelectionPage.noWorkingSet"), Policy.bind("RefreshRemoteProjectSelectionPage.workingSet"), settings); //$NON-NLS-1$ //$NON-NLS-2$ - setWorkingSet(workingSet); - workingSetArea.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - workingSet = (IWorkingSet)event.getNewValue(); - handleWorkingSetChange(); - } - }); - workingSetArea.createArea(composite); - Dialog.applyDialogFont(parent); - } - - /** - * Sets the working set that should be selected in the most recently - * used working set list. - * - * @param workingSet the working set that should be selected. - * has to exist in the list returned by - * org.eclipse.ui.IWorkingSetManager#getRecentWorkingSets(). - * Must not be null. - */ - public void setWorkingSet(IWorkingSet workingSet) { - this.workingSet = workingSet; - - if (workingSetArea != null) { - workingSetArea.setWorkingSet(workingSet); - } - } - - private void handleWorkingSetChange() { - if (workingSet != null) { - // check any projects in the working set - listArea.getViewer().setAllChecked(false); - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - ICVSRemoteResource[] resources = manager.filterResources(workingSet, rootFolders); - for (int i = 0; i < resources.length; i++) { - ICVSRemoteResource resource = resources[i]; - listArea.getViewer().setChecked(resource, true); - } - } - } - - private void updateEnablement() { - boolean atLeastOne = listArea.getViewer().getCheckedElements().length > 0; - setPageComplete(atLeastOne); - } - - /** - * Method getSelectedRemoteProject. - * @return ICVSRemoteResource[] - */ - public ICVSRemoteResource[] getSelectedRemoteProject() { - Object[] checked = listArea.getViewer().getCheckedElements(); - return (ICVSRemoteResource[]) Arrays.asList(checked).toArray(new ICVSRemoteResource[checked.length]); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java deleted file mode 100644 index 6f9e95087..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * Wizard for refreshing the tags for a CVS repository location - */ -public class RefreshRemoteProjectWizard extends Wizard { - - // The initial size of this wizard. - private final static int INITIAL_WIDTH = 300; - private final static int INITIAL_HEIGHT = 350; - - private ICVSRepositoryLocation root; - private ICVSRemoteResource[] rootFolders; - private RefreshRemoteProjectSelectionPage projectSelectionPage; - private IDialogSettings settings; - - public static boolean execute(Shell shell, final ICVSRepositoryLocation root) { - final ICVSRemoteResource[][] rootFolders = new ICVSRemoteResource[1][0]; - rootFolders[0] = null; - try { - new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - rootFolders[0] = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, CVSTag.DEFAULT, monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(shell, null, null, e); - return false; - } catch (InterruptedException e) { - return false; - } - RefreshRemoteProjectWizard wizard = new RefreshRemoteProjectWizard(root, rootFolders[0]); - WizardDialog dialog = new WizardDialog(shell, wizard); - /** - * This is the only place where a size hint > 0 is required. The wizard - * page should in general have hints of 0 (and grab excessive space). - */ - dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); - return (dialog.open() == Window.OK); - } - - public RefreshRemoteProjectWizard(ICVSRepositoryLocation root, ICVSRemoteResource[] rootFolders) { - this.root = root; - this.rootFolders = rootFolders; - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - this.settings = workbenchSettings.getSection("RefreshRemoteProjectWizard");//$NON-NLS-1$ - if (settings == null) { - this.settings = workbenchSettings.addNewSection("RefreshRemoteProjectWizard");//$NON-NLS-1$ - } - setWindowTitle(Policy.bind("RefreshRemoteProjectWizard.title")); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jface.wizard.IWizard#addPages() - */ - public void addPages() { - setNeedsProgressMonitor(true); - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION); - projectSelectionPage = new RefreshRemoteProjectSelectionPage( - "ProjectSelectionPage", //$NON-NLS-1$ - Policy.bind("RefreshRemoteProjectSelectionPage.pageTitle"), //$NON-NLS-1$ - substImage, - Policy.bind("RefreshRemoteProjectSelectionPage.pageDescription"), //$NON-NLS-1$ - settings, root, rootFolders); - addPage(projectSelectionPage); - } - - /** - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - public boolean performFinish() { - final ICVSRemoteResource[] selectedFolders = projectSelectionPage.getSelectedRemoteProject(); - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - // Run in the manager to avoid multiple repo view updates - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException { - monitor.beginTask(null, 100); - ICVSRemoteResource[] failedFolders = internalRefresh(manager, selectedFolders, false /* recurse */, Policy.subMonitorFor(monitor, 80)); - if (failedFolders.length > 0) { - // Go deep any any failed folders. - if (promptForDeepRefresh(failedFolders)) - internalRefresh(manager, failedFolders, true /* recurse */, Policy.subMonitorFor(monitor, 20)); - } - monitor.done(); - } - }, monitor); - } - }); - return true; - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null ,e); - } catch (InterruptedException e) { - } - return false; - } - - /* - * Refresh the tags of the given resources and return those for which no tags were found. - */ - private ICVSRemoteResource[] internalRefresh(final RepositoryManager manager, final ICVSRemoteResource[] selectedFolders, final boolean recurse, IProgressMonitor monitor) throws InvocationTargetException { - List failedFolders = new ArrayList(); - monitor.beginTask(null, 100 * selectedFolders.length); - try { - for (int i = 0; i < selectedFolders.length; i++) { - ICVSRemoteResource resource = selectedFolders[i]; - if (resource instanceof ICVSFolder) { - CVSTag[] tags = manager.refreshDefinedTags((ICVSFolder)resource, recurse, true /* notify */, Policy.subMonitorFor(monitor, 100)); - if (tags.length == 0) { - failedFolders.add(resource); - } - } - } - return (ICVSRemoteResource[]) failedFolders.toArray(new ICVSRemoteResource[failedFolders.size()]); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - - private boolean promptForDeepRefresh(final ICVSRemoteResource[] folders) { - final boolean[] prompt = new boolean[] { false }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(getShell(), Policy.bind("RefreshRemoteProjectWizard.0"), null, //$NON-NLS-1$ - getNoTagsMessage(folders), - MessageDialog.INFORMATION, - new String[] { - Policy.bind("RefreshRemoteProjectWizard.1"), //$NON-NLS-1$ - Policy.bind("RefreshRemoteProjectWizard.2") //$NON-NLS-1$ - }, 1); - int code = dialog.open(); - if (code == 0) { - prompt[0] = true; - } - - } - }); - return prompt[0]; - } - - private String getNoTagsMessage(ICVSRemoteResource[] folders) { - if (folders.length == 1) { - return Policy.bind("RefreshRemoteProjectWizard.3", folders[0].getRepositoryRelativePath()); //$NON-NLS-1$ - } - return Policy.bind("RefreshRemoteProjectWizard.4", Integer.toString(folders.length)); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java deleted file mode 100644 index a845aa27c..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.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.team.internal.ccvs.ui.repo; - -import org.eclipse.jface.action.IAction; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; - -/** - * Action that refreshs the tags in the CVS repositories view. - */ -public class RefreshTagsAction extends CVSRepoViewAction { - - /** - * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) - */ - protected void execute(IAction action) { - ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - RefreshRemoteProjectWizard.execute(getShell(), locations[0]); - } - - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() { - ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - if (locations.length != 1) return false; - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java deleted file mode 100644 index 84b0a63dc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement; -import org.eclipse.team.internal.ccvs.ui.model.RemoteProjectsElement; -import org.eclipse.team.internal.ui.actions.TeamAction; -import org.eclipse.ui.IWorkbenchPart; - -/** - * This view shows a list of projects stored in a repository that share the same - * tag - */ -public class RemoteProjectsView extends RemoteViewPart { - - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.RemoteProjectsView"; //$NON-NLS-1$ - - private RemoteProjectsElement root; - - /** - * Constructor for RemoteProjectsView. - * @param partName - */ - public RemoteProjectsView() { - super(VIEW_ID); - } - - protected void initializeListeners() { - // listen for selection changes in the repo view - getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RepositoriesView.VIEW_ID, this); - getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RemoteTagsView.VIEW_ID, this); - } - - /** - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RepositoriesView.VIEW_ID, this); - getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RemoteTagsView.VIEW_ID, this); - super.dispose(); - } - - /** - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - Object[] selected = TeamAction.getSelectedAdaptables(selection, ICVSRepositoryLocation.class); - if (selected.length != 0) { - root.setRoot((ICVSRepositoryLocation)selected[0]); - } else { - selected = TeamAction.getSelectedAdaptables(selection, CVSTagElement.class); - if (selected.length != 0) { - CVSTagElement element = (CVSTagElement)selected[0]; - root.setRoot(element.getRoot()); - root.setTag(element.getTag()); - } - }; - refreshViewer(); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getTreeInput() - */ - protected Object getTreeInput() { - root = new RemoteProjectsElement(); - return root; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java deleted file mode 100644 index 9826ee5ce..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ui.actions.TeamAction; -import org.eclipse.ui.IWorkbenchPart; - - -/** - * This view shows the tags for the repository selected in the Repositories view - */ -public class RemoteTagsView extends RemoteViewPart { - - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.RemoteTagsView"; //$NON-NLS-1$ - - /** - * Constructor for RemoteTagsView. - * @param partName - */ - public RemoteTagsView() { - super(VIEW_ID); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getTreeInput() - */ - protected Object getTreeInput() { - return null; - } - - protected void initializeListeners() { - // listen for selection changes in the repo view - getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RepositoriesView.VIEW_ID, this); - } - - /** - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RepositoriesView.VIEW_ID, this); - super.dispose(); - } - - /** - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - Object[] selected = TeamAction.getSelectedAdaptables(selection, ICVSRepositoryLocation.class); - if (selected.length == 0) { - getViewer().setInput(null); - } else { - getViewer().setInput(selected[0]); - }; - refreshViewer(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java deleted file mode 100644 index 13319967e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java +++ /dev/null @@ -1,429 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.OpenRemoteFileAction; -import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.dialogs.IWorkingSetEditWizard; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.part.DrillDownAdapter; -import org.eclipse.ui.part.ViewPart; - -/** - * This class acts as a superclass to all remote CVS tree views. - */ -public abstract class RemoteViewPart extends ViewPart implements ISelectionListener { - - // The tree viewer - protected TreeViewer viewer; - - // Drill down adapter - private DrillDownAdapter drillPart; - - private Action refreshAction; - private Action collapseAllAction; - - private Action selectWorkingSetAction; - private Action deselectWorkingSetAction; - private Action editWorkingSetAction; - private OpenRemoteFileAction openAction; - - private RemoteContentProvider contentProvider; - private IDialogSettings settings; - private static final String SELECTED_WORKING_SET = "SelectedWorkingSet"; //$NON-NLS-1$ - - private class ChangeWorkingSetAction extends Action { - String name; - public ChangeWorkingSetAction(String name, int index) { - super(Policy.bind("RepositoriesView.workingSetMenuItem", new Integer(index).toString(), name)); //$NON-NLS-1$ - this.name = name; - } - public void run() { - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - setWorkingSet(manager.getWorkingSet(name), true); - } - } - - protected RemoteViewPart(String partName) { - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - settings = workbenchSettings.getSection(partName); - if (settings == null) { - settings = workbenchSettings.addNewSection(partName); - } - String name = settings.get(SELECTED_WORKING_SET); - IWorkingSet set = null; - if (name != null) - set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name); - setWorkingSet(set, false); - } - - /** - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setContentProvider(getContentProvider()); - viewer.setLabelProvider(new WorkbenchLabelProvider()); - getSite().setSelectionProvider(viewer); - viewer.setInput(getTreeInput()); - viewer.setSorter(new RepositorySorter()); - viewer.getControl().addKeyListener(getKeyListener()); - drillPart = new DrillDownAdapter(viewer); - - contributeActions(); - initializeListeners(); - - // F1 Help - String helpID = getHelpContextId(); - if (helpID != null) - WorkbenchHelp.setHelp(viewer.getControl(), helpID); - } - - /** - * @see WorkbenchPart#setFocus - */ - public void setFocus() { - viewer.getControl().setFocus(); - } - - /** - * Method getHelpContextId should be overridden by subclasses to provide the - * appropriate help id. - * - * @return String - */ - protected String getHelpContextId() { - return null; - } - - /** - * Method getTreeInput. - * @return Object - */ - protected abstract Object getTreeInput(); - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getContentProvider() - */ - protected RemoteContentProvider getContentProvider() { - if (contentProvider == null) { - contentProvider = new RemoteContentProvider(); - } - return contentProvider; - }; - - protected KeyAdapter getKeyListener() { - return new KeyAdapter() { - public void keyPressed(KeyEvent event) { - if (event.keyCode == SWT.F5) { - refreshAction.run(); - } - } - }; - } - - protected void initializeListeners() { - // listen for selection changes in the repo view - getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this); - } - - protected IWorkingSet getWorkingSet() { - return getContentProvider().getWorkingSet(); - } - - protected void setWorkingSet(IWorkingSet workingSet, boolean refreshViewer) { - if (settings != null) { - String name = null; - if (workingSet != null) - name = workingSet.getName(); - settings.put(SELECTED_WORKING_SET, name); - } - getContentProvider().setWorkingSet(workingSet); - String toolTip; - if (workingSet == null) { - toolTip = null; - } else { - toolTip = Policy.bind("RemoteViewPart.workingSetToolTip", workingSet.getName()); //$NON-NLS-1$ - } - setTitleToolTip(toolTip); - if (refreshViewer) refreshViewer(); - } - - /** - * Contribute actions to the view - */ - protected void contributeActions() { - - final Shell shell = getShell(); - - // Refresh (toolbar) - CVSUIPlugin plugin = CVSUIPlugin.getPlugin(); - refreshAction = new Action(Policy.bind("RepositoriesView.refresh"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_REFRESH_ENABLED)) { //$NON-NLS-1$ - public void run() { - refreshAll(); - } - }; - refreshAction.setToolTipText(Policy.bind("RepositoriesView.refreshTooltip")); //$NON-NLS-1$ - refreshAction.setDisabledImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH_DISABLED)); - refreshAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH)); - getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); - - collapseAllAction = new Action(Policy.bind("RepositoriesView.collapseAll"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL_ENABLED)) { //$NON-NLS-1$ - public void run() { - collapseAll(); - } - }; - collapseAllAction.setToolTipText(Policy.bind("RepositoriesView.collapseAllTooltip")); //$NON-NLS-1$ - collapseAllAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL)); - - // Select Working Set (popup) - selectWorkingSetAction = new Action(Policy.bind("RepositoriesView.newWorkingSet")) { //$NON-NLS-1$ - public void run() { - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(shell, false); - IWorkingSet workingSet = null; - if (workingSet != null) - dialog.setSelection(new IWorkingSet[]{workingSet}); - - if (dialog.open() == Window.OK) { - IWorkingSet[] result = dialog.getSelection(); - if (result != null && result.length > 0) { - setWorkingSet(result[0], true); - manager.addRecentWorkingSet(result[0]); - } else { - setWorkingSet(null, true); - } - } - } - }; - WorkbenchHelp.setHelp(selectWorkingSetAction, IHelpContextIds.SELECT_WORKING_SET_ACTION); - - // Deselect Working Set (popup) - deselectWorkingSetAction = new Action(Policy.bind("RepositoriesView.deselectWorkingSet")) { //$NON-NLS-1$ - public void run() { - setWorkingSet(null, true); - } - }; - WorkbenchHelp.setHelp(deselectWorkingSetAction, IHelpContextIds.DESELECT_WORKING_SET_ACTION); - - // Edit Working Set (popup) - editWorkingSetAction = new Action(Policy.bind("RepositoriesView.editWorkingSet")) { //$NON-NLS-1$ - public void run() { - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSet workingSet = getWorkingSet(); - if (workingSet == null) { - setEnabled(false); - return; - } - IWorkingSetEditWizard wizard = manager.createWorkingSetEditWizard(workingSet); - if (wizard == null) { - // todo - String title = Policy.bind("EditWorkingSetAction.error.nowizard.title"); //$NON-NLS-1$ - String message = Policy.bind("EditWorkingSetAction.error.nowizard.message"); //$NON-NLS-1$ - CVSUIPlugin.openError(shell, title, message, null); - return; - } - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.create(); - if (dialog.open() == WizardDialog.OK) - setWorkingSet(wizard.getSelection(), true); - } - }; - WorkbenchHelp.setHelp(editWorkingSetAction, IHelpContextIds.EDIT_WORKING_SET_ACTION); - - // Create the popup menu - MenuManager menuMgr = new MenuManager(); - Tree tree = viewer.getTree(); - Menu menu = menuMgr.createContextMenu(tree); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - addWorkbenchActions(manager); - } - - }); - menuMgr.setRemoveAllWhenShown(true); - tree.setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - - // Create the local tool bar - IActionBars bars = getViewSite().getActionBars(); - IToolBarManager tbm = bars.getToolBarManager(); - drillPart.addNavigationActions(tbm); - tbm.add(refreshAction); - tbm.add(new Separator()); - tbm.add(collapseAllAction); - tbm.update(false); - - // Create the open action for double clicks - openAction = new OpenRemoteFileAction(); - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent e) { - handleDoubleClick(e); - } - }); - - updateWorkingSetMenu(); - bars.updateActionBars(); - } - - /** - * Add the menu actions that were contributed in plugin.xml - * - * @param manager - */ - protected void addWorkbenchActions(IMenuManager manager) { - // File actions go first (view file) - manager.add(new Separator(IWorkbenchActionConstants.GROUP_FILE)); - // Misc additions - manager.add(new Separator("checkoutGroup")); //$NON-NLS-1$ - manager.add(new Separator("tagGroup")); //$NON-NLS-1$ - manager.add(new Separator("miscGroup")); //$NON-NLS-1$ - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - - manager.add(refreshAction); - } - - /** - * Method getShell. - * @return Shell - */ - protected Shell getShell() { - return viewer.getTree().getShell(); - } - - public void updateWorkingSetMenu() { - IActionBars bars = getViewSite().getActionBars(); - IMenuManager mgr = bars.getMenuManager(); - - mgr.removeAll(); - - mgr.add(selectWorkingSetAction); - mgr.add(deselectWorkingSetAction); - deselectWorkingSetAction.setEnabled(getWorkingSet() != null); - mgr.add(editWorkingSetAction); - editWorkingSetAction.setEnabled(getWorkingSet() != null); - - mgr.add(new Separator()); - - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSet[] workingSets = manager.getWorkingSets(); - for (int i = 0; i < workingSets.length; i++) { - String name = workingSets[i].getName(); - ChangeWorkingSetAction action = new ChangeWorkingSetAction(name, i + 1); - mgr.add(action); - action.setChecked(getWorkingSet() != null && getWorkingSet().getName().equals(name)); - } - - bars.updateActionBars(); - } - - protected void refreshAll() { - //CVSUIPlugin.getPlugin().getRepositoryManager().clearCaches(); - refreshViewer(); - } - - protected void refreshViewer() { - if (viewer == null) return; - ((RemoteContentProvider)viewer.getContentProvider()).cancelJobs(CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryRoots()); - CVSUIPlugin.getPlugin().getRepositoryManager().purgeCache(); - updateWorkingSetMenu(); - viewer.refresh(); - } - - public void collapseAll() { - if (viewer == null) return; - viewer.getControl().setRedraw(false); - viewer.collapseToLevel(viewer.getInput(), TreeViewer.ALL_LEVELS); - viewer.getControl().setRedraw(true); - } - /** - * The mouse has been double-clicked in the tree, perform appropriate - * behaviour. - */ - private void handleDoubleClick(DoubleClickEvent e) { - // Only act on single selection - ISelection selection = e.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection structured = (IStructuredSelection)selection; - if (structured.size() == 1) { - Object first = structured.getFirstElement(); - if (first instanceof ICVSRemoteFile) { - // It's a file, open it. - openAction.selectionChanged(null, selection); - openAction.run(null); - } else { - // Try to expand/contract - viewer.setExpandedState(first, !viewer.getExpandedState(first)); - } - } - } - } - - /** - * Returns the viewer. - * @return TreeViewer - */ - protected TreeViewer getViewer() { - return viewer; - } - - /** - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - } - - /** - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(this); - super.dispose(); - viewer = null; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java deleted file mode 100644 index 342491766..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement; -import org.eclipse.ui.actions.SelectionListenerAction; - - -public class RemoveDateTagAction extends SelectionListenerAction { - private IStructuredSelection selection; - - public RemoveDateTagAction() { - super(Policy.bind("RemoveDateTagAction.0")); //$NON-NLS-1$ - } - - public void run() { - CVSTagElement[] elements = getSelectedCVSTagElements(); - if (elements.length == 0) return; - for(int i = 0; i < elements.length; i++){ - RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); - CVSTag tag = elements[i].getTag(); - if(tag.getType() == CVSTag.DATE){ - mgr.removeDateTag(elements[i].getRoot(),tag); - } - } - } - - protected boolean updateSelection(IStructuredSelection selection) { - this.selection = selection; - boolean b = containsDataTag(); - setEnabled(b); - return b; - } - - private boolean containsDataTag(){ - CVSTagElement[] elements = getSelectedCVSTagElements(); - if (elements.length > 0){ - for(int i = 0; i < elements.length; i++){ - CVSTag tag = elements[i].getTag(); - if(tag.getType() == CVSTag.DATE){ - return true; - } - } - } - return false; - } - - /** - * Returns the selected CVS date tag elements - */ - private CVSTagElement[] getSelectedCVSTagElements() { - ArrayList cvsTagElements = null; - if (selection!=null && !selection.isEmpty()) { - cvsTagElements = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = CVSAction.getAdapter(elements.next(), CVSTagElement.class); - if (next instanceof CVSTagElement) { - cvsTagElements.add(next); - } - } - } - if (cvsTagElements != null && !cvsTagElements.isEmpty()) { - CVSTagElement[] result = new CVSTagElement[cvsTagElements.size()]; - cvsTagElements.toArray(result); - return result; - } - return new CVSTagElement[0]; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java deleted file mode 100644 index d5b72d705..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.model.RepositoryLocationSchedulingRule; -import org.eclipse.team.internal.ui.dialogs.DetailsDialogWithProjects; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; -import org.eclipse.ui.progress.IProgressService; - - -/** - * RemoveRootAction removes a repository - */ -public class RemoveRootAction extends SelectionListenerAction { - private IStructuredSelection selection; - /* internal use only */ Shell shell; - private RepositoriesView view; - - public RemoveRootAction(Shell shell, RepositoriesView view) { - super(Policy.bind("RemoteRootAction.label")); //$NON-NLS-1$ - this.view = view; - this.shell = shell; - } - - /** - * Returns the selected remote files - */ - protected ICVSRepositoryLocation[] getSelectedRemoteRoots() { - ArrayList resources = null; - if (selection!=null && !selection.isEmpty()) { - resources = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = CVSAction.getAdapter(elements.next(), RepositoryRoot.class); - if (next instanceof RepositoryRoot) { - resources.add(((RepositoryRoot)next).getRoot()); - } - } - } - if (resources != null && !resources.isEmpty()) { - ICVSRepositoryLocation[] result = new ICVSRepositoryLocation[resources.size()]; - resources.toArray(result); - return result; - } - return new ICVSRepositoryLocation[0]; - } - - protected String getErrorTitle() { - return Policy.bind("RemoveRootAction.removeRoot_3"); //$NON-NLS-1$ - } - - public void run() { - ICVSRepositoryLocation[] roots = getSelectedRemoteRoots(); - if (roots.length == 0) return; - for (int i = 0; i < roots.length; i++) { - final ICVSRepositoryLocation root = roots[i]; - try { - // Check if any projects are shared with the repository - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - final ArrayList shared = new ArrayList(); - for (int j = 0; j < projects.length; j++) { - RepositoryProvider teamProvider = RepositoryProvider.getProvider(projects[j], CVSProviderPlugin.getTypeId()); - if (teamProvider!=null) { - CVSTeamProvider cvsProvider = (CVSTeamProvider)teamProvider; - if (cvsProvider.getCVSWorkspaceRoot().getRemoteLocation().equals(roots[i])) { - shared.add(projects[j]); - } - } - } - - // This will notify the RepositoryManager of the removal - if (!shared.isEmpty()) { - final String location = roots[i].getLocation(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - DetailsDialogWithProjects dialog = new DetailsDialogWithProjects( - shell, - Policy.bind("RemoteRootAction.Unable_to_Discard_Location_1"), //$NON-NLS-1$ - Policy.bind("RemoteRootAction.Projects_in_the_local_workspace_are_shared_with__2", location), //$NON-NLS-1$ - Policy.bind("RemoteRootAction.The_projects_that_are_shared_with_the_above_repository_are__4"), //$NON-NLS-1$ - (IProject[]) shared.toArray(new IProject[shared.size()]), - false, - DetailsDialogWithProjects.DLG_IMG_ERROR); - dialog.open(); - } - }); - } else { - IProgressService manager = PlatformUI.getWorkbench().getProgressService(); - try { - manager.busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - ISchedulingRule rule = new RepositoryLocationSchedulingRule(root); - try { - Platform.getJobManager().beginRule(rule, monitor); - view.getContentProvider().cancelJobs(root); - KnownRepositories.getInstance().disposeRepository(root); - } finally { - Platform.getJobManager().endRule(rule); - } - - } - }); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Canceled - return; - } - } - } catch (CVSException e) { - CVSUIPlugin.openError(view.getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC | CVSUIPlugin.LOG_TEAM_EXCEPTIONS | CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); - } - } - } - - protected boolean updateSelection(IStructuredSelection selection) { - this.selection = selection; - ICVSRepositoryLocation[] roots = getSelectedRemoteRoots(); - boolean b = roots.length > 0; - setEnabled(b); - return b; - } - -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java deleted file mode 100644 index 8735040af..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - - -import java.util.Properties; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -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.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.IRepositoryListener; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.WorkbenchUserAuthenticator; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement; -import org.eclipse.team.internal.ccvs.ui.wizards.NewLocationWizard; -import org.eclipse.team.internal.core.TeamPlugin; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.dialogs.PropertyDialogAction; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * RepositoriesView is a view on a set of known CVS repositories - * which allows navigation of the structure of the repository and - * the performing of CVS-specific operations on the repository contents. - */ -public class RepositoriesView extends RemoteViewPart { - public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.RepositoriesView"; //$NON-NLS-1$ - - // The root - private AllRootsElement root; - - // Actions - private IAction removeAction; - private Action newAction; - private Action newAnonAction; - private PropertyDialogAction propertiesAction; - private RemoveRootAction removeRootAction; - private RemoveDateTagAction removeDateTagAction; - - IRepositoryListener listener = new IRepositoryListener() { - public void repositoryAdded(final ICVSRepositoryLocation root) { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - refreshViewer(); - getViewer().setSelection(new StructuredSelection(root)); - } - }); - } - public void repositoryRemoved(ICVSRepositoryLocation root) { - refresh(); - } - public void repositoriesChanged(ICVSRepositoryLocation[] roots) { - refresh(); - } - private void refresh() { - Display display = getViewer().getControl().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - RepositoriesView.this.refreshViewer(); - } - }); - } - }; - - /** - * Constructor for RepositoriesView. - * @param partName - */ - public RepositoriesView() { - super(VIEW_ID); - } - - /** - * Contribute actions to the view - */ - protected void contributeActions() { - - final Shell shell = getShell(); - - // Create actions - - // New Repository (popup) - newAction = new Action(Policy.bind("RepositoriesView.new"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_NEWLOCATION)) { //$NON-NLS-1$ - public void run() { - NewLocationWizard wizard = new NewLocationWizard(); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - }; - WorkbenchHelp.setHelp(newAction, IHelpContextIds.NEW_REPOSITORY_LOCATION_ACTION); - - if (includeAnonConnection()) { - newAnonAction = new Action(Policy.bind("RepositoriesView.newAnonCVS"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_NEWLOCATION)) { //$NON-NLS-1$ - public void run() { - Properties p = new Properties(); - p.setProperty("connection", "pserver"); //$NON-NLS-1$ //$NON-NLS-2$ - p.setProperty("user", "anonymous"); //$NON-NLS-1$ //$NON-NLS-2$ - p.setProperty("host", "dev.eclipse.org"); //$NON-NLS-1$ //$NON-NLS-2$ - p.setProperty("root", "/home/eclipse"); //$NON-NLS-1$ //$NON-NLS-2$ - NewLocationWizard wizard = new NewLocationWizard(p); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } - }; - WorkbenchHelp.setHelp(newAnonAction, IHelpContextIds.NEW_DEV_ECLIPSE_REPOSITORY_LOCATION_ACTION); - } - - // Properties - propertiesAction = new PropertyDialogAction(shell, getViewer()); - getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction); - IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); - if (selection.size() == 1 && selection.getFirstElement() instanceof RepositoryRoot) { - propertiesAction.setEnabled(true); - } else { - propertiesAction.setEnabled(false); - } - getViewer().addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection ss = (IStructuredSelection)event.getSelection(); - boolean enabled = ss.size() == 1 && ss.getFirstElement() instanceof RepositoryRoot; - propertiesAction.setEnabled(enabled); - } - }); - removeRootAction = new RemoveRootAction(viewer.getControl().getShell(), this); - removeRootAction.selectionChanged((IStructuredSelection)null); - removeDateTagAction = new RemoveDateTagAction(); - removeDateTagAction.selectionChanged( (IStructuredSelection)null); - removeAction = new Action(){ - public void run(){ - if(removeRootAction.isEnabled()){ - removeRootAction.run(); - } - if(removeDateTagAction.isEnabled()){ - removeDateTagAction.run(); - } - } - }; - WorkbenchHelp.setHelp(removeRootAction, IHelpContextIds.REMOVE_REPOSITORY_LOCATION_ACTION); - IActionBars bars = getViewSite().getActionBars(); - bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeAction); - - super.contributeActions(); - } - - /** - * Method includeEclipseConnection. - * @return boolean - */ - private boolean includeAnonConnection() { - return System.getProperty("eclipse.cvs.anon") != null; //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#addWorkbenchActions(org.eclipse.jface.action.IMenuManager) - */ - protected void addWorkbenchActions(IMenuManager manager) { - // New actions go next - MenuManager sub = new MenuManager(Policy.bind("RepositoriesView.newSubmenu"), IWorkbenchActionConstants.GROUP_ADD); //$NON-NLS-1$ - manager.add(sub); - super.addWorkbenchActions(manager); - IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); - - removeRootAction.selectionChanged(selection); - removeDateTagAction.selectionChanged(selection); - if(removeRootAction.isEnabled()) { - manager.add(removeRootAction); - } - if(removeDateTagAction.isEnabled()){ - manager.add(removeDateTagAction); - } - if (selection.size() == 1 && selection.getFirstElement() instanceof RepositoryRoot) { - manager.add(new Separator()); - manager.add(propertiesAction); - } - sub.add(newAction); - if (newAnonAction != null) - sub.add(newAnonAction); - sub.add(new Separator("group1")); //$NON-NLS-1$ - } - - /* - * @see WorkbenchPart#createPartControl - */ - public void createPartControl(Composite parent) { - super.createPartControl(parent); - CVSUIPlugin.getPlugin().getRepositoryManager().addRepositoryListener(listener); - } - - /* - * @see WorkbenchPart#dispose - */ - public void dispose() { - CVSUIPlugin.getPlugin().getRepositoryManager().removeRepositoryListener(listener); - super.dispose(); - } - - /** - * Initialize the repositories and actions - */ - private void initialize() { - root = new AllRootsElement(); - } - - protected void initializeListeners() { - super.initializeListeners(); - viewer.addSelectionChangedListener(removeRootAction); - viewer.addSelectionChangedListener(removeDateTagAction); - viewer.addSelectionChangedListener(new ISelectionChangedListener(){ - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - handleChange(selection); - } - }); - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getTreeInput() - */ - protected Object getTreeInput() { - initialize(); - return root; - } - - /** - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - String msg = getStatusLineMessage(selection); - getViewSite().getActionBars().getStatusLineManager().setMessage(msg); - } - - private String getStatusLineMessage(ISelection selection) { - if (selection==null || selection.isEmpty()) return ""; //$NON-NLS-1$ - if (!(selection instanceof IStructuredSelection)) return ""; //$NON-NLS-1$ - IStructuredSelection s = (IStructuredSelection)selection; - - if (s.size() > 1) return Policy.bind("RepositoriesView.NItemsSelected", String.valueOf(s.size())); //$NON-NLS-1$ - Object element = CVSAction.getAdapter(s.getFirstElement(), ICVSResource.class); - if (element instanceof ICVSRemoteResource) { - ICVSRemoteResource res = (ICVSRemoteResource)element; - String name; - if (res.isContainer()) { - name = res.getRepositoryRelativePath(); - } else { - try { - name = res.getRepositoryRelativePath() + " " + ((ICVSRemoteFile)res).getRevision(); //$NON-NLS-1$ - } catch (TeamException e) { - TeamPlugin.log(IStatus.ERROR, Policy.bind("RepositoriesView.CannotGetRevision"), e); //$NON-NLS-1$ - name = res.getRepositoryRelativePath(); - } - } - return Policy.bind("RepositoriesView.ResourceInRepository", name, res.getRepository().getLocation()); //$NON-NLS-1$ - } - return Policy.bind("RepositoriesView.OneItemSelected"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getHelpContextId() - */ - protected String getHelpContextId() { - return IHelpContextIds.REPOSITORIES_VIEW; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getKeyListener() - */ - protected KeyAdapter getKeyListener() { - return new KeyAdapter() { - public void keyPressed(KeyEvent event) { - if (event.keyCode == SWT.F5) { - if (WorkbenchUserAuthenticator.USE_ALTERNATE_PROMPTER) { - ICVSRepositoryLocation[] locations = KnownRepositories.getInstance().getRepositories(); - for (int i = 0; i < locations.length; i++) { - locations[i].flushUserInfo(); - } - } else { - refreshAll(); - } - } else if (event.keyCode == SWT.F9 && WorkbenchUserAuthenticator.USE_ALTERNATE_PROMPTER) { - refreshAll(); - } - } - }; - } - - private void handleChange(IStructuredSelection selection){ - removeRootAction.updateSelection(selection); - removeDateTagAction.updateSelection(selection); - removeAction.setEnabled(removeRootAction.isEnabled() || removeDateTagAction.isEnabled()); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java deleted file mode 100644 index 2b78cedc9..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import java.util.*; - -import org.eclipse.core.runtime.Path; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.xml.sax.*; -import org.xml.sax.helpers.DefaultHandler; - -public class RepositoriesViewContentHandler extends DefaultHandler { - - public static final String REPOSITORIES_VIEW_TAG = "repositories-view"; //$NON-NLS-1$ - - public static final String REPOSITORY_TAG = "repository"; //$NON-NLS-1$ - public static final String WORKING_SET_TAG = "working-set"; //$NON-NLS-1$ - public static final String CURRENT_WORKING_SET_TAG = "current-working-set"; //$NON-NLS-1$ - public static final String MODULE_TAG = "module"; //$NON-NLS-1$ - public static final String TAG_TAG = "tag"; //$NON-NLS-1$ - public static final String AUTO_REFRESH_FILE_TAG = "auto-refresh-file"; //$NON-NLS-1$ - public static final String DATE_TAGS_TAG = "date-tags"; //$NON-NLS-1$ - public static final String DATE_TAG_TAG = "date-tag"; //$NON-NLS-1$ - - public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ - public static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ - public static final String PATH_ATTRIBUTE = "path"; //$NON-NLS-1$ - public static final String FULL_PATH_ATTRIBUTE = "full-path"; //$NON-NLS-1$ - public static final String TYPE_ATTRIBUTE = "type"; //$NON-NLS-1$ - public static final String READ_ID_ATTRIBUTE = "read-id"; //$NON-NLS-1$ - public static final String WRITE_ID_ATTRIBUTE = "write-id"; //$NON-NLS-1$ - public static final String LAST_ACCESS_TIME_ATTRIBUTE = "lastAcessTime"; //$NON-NLS-1$ - - public static final String[] TAG_TYPES = {"head", "branch", "version", "date"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - public static final String DEFAULT_TAG_TYPE = "version"; //$NON-NLS-1$ - public static final String DEFINED_MODULE_TYPE = "defined"; //$NON-NLS-1$ - - private RepositoryManager manager; - private StringBuffer buffer = new StringBuffer(); - private Stack tagStack = new Stack(); - private RepositoryRoot currentRepositoryRoot; - private String currentRemotePath; - private List tags; - private List dateTags; - private List autoRefreshFiles; - private boolean ignoreElements; - - private long lastAccessTime; - - public RepositoriesViewContentHandler(RepositoryManager manager) { - this.manager = manager; - } - - /** - * @see ContentHandler#characters(char[], int, int) - */ - public void characters(char[] chars, int startIndex, int length) throws SAXException { - buffer.append(chars, startIndex, length); - } - - /** - * @see ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) - */ - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - - String elementName = getElementName(namespaceURI, localName, qName); - if (!elementName.equals(tagStack.peek())) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.unmatchedTag", elementName)); //$NON-NLS-1$ - } - - if (elementName.equals(REPOSITORIES_VIEW_TAG)) { - // all done - } else if (elementName.equals(REPOSITORY_TAG)) { - if (!ignoreElements) { - manager.add(currentRepositoryRoot); - } - currentRepositoryRoot = null; - } else if (elementName.equals(WORKING_SET_TAG)) { - // This tag is no longer used - ignoreElements = false; - } else if (elementName.equals(CURRENT_WORKING_SET_TAG)) { - // This tag is no longer used - ignoreElements = false; - } else if (elementName.equals(MODULE_TAG)) { - if (! ignoreElements && currentRepositoryRoot != null) { - currentRepositoryRoot.addTags(currentRemotePath, - (CVSTag[]) tags.toArray(new CVSTag[tags.size()])); - if (lastAccessTime > 0) - currentRepositoryRoot.setLastAccessedTime(currentRemotePath, lastAccessTime); - currentRepositoryRoot.setAutoRefreshFiles(currentRemotePath, - (String[]) autoRefreshFiles.toArray(new String[autoRefreshFiles.size()])); - } - }else if(elementName.equals(DATE_TAG_TAG)){ - if (! ignoreElements && currentRepositoryRoot != null) { - Iterator iter = dateTags.iterator(); - while(iter.hasNext()){ - CVSTag tag = (CVSTag)iter.next(); - currentRepositoryRoot.addDateTag(tag); - } - } - } - tagStack.pop(); - } - - /** - * @see ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - public void startElement( - String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - String elementName = getElementName(namespaceURI, localName, qName); - if (elementName.equals(REPOSITORIES_VIEW_TAG)) { - // just started - } else if (elementName.equals(REPOSITORY_TAG)) { - String id = atts.getValue(ID_ATTRIBUTE); - if (id == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", REPOSITORY_TAG, ID_ATTRIBUTE)); //$NON-NLS-1$ - } - ICVSRepositoryLocation root; - try { - root = KnownRepositories.getInstance().getRepository(id); - if (!KnownRepositories.getInstance().isKnownRepository(id)) { - KnownRepositories.getInstance().addRepository(root, false); - } - } catch (CVSException e) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.errorCreatingRoot", id), e); //$NON-NLS-1$ - } - currentRepositoryRoot = new RepositoryRoot(root); - String name = atts.getValue(NAME_ATTRIBUTE); - if (name != null) { - currentRepositoryRoot.setName(name); - } - } else if(elementName.equals(DATE_TAGS_TAG)){ - //prepare to collect date tag - dateTags = new ArrayList(); - } else if (elementName.equals(DATE_TAG_TAG)){ - String name = atts.getValue(NAME_ATTRIBUTE); - if (name == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", DATE_TAGS_TAG, NAME_ATTRIBUTE)); //$NON-NLS-1$ - } - dateTags.add(new CVSTag(name, CVSTag.DATE)); - }else if (elementName.equals(WORKING_SET_TAG)) { - String name = atts.getValue(NAME_ATTRIBUTE); - if (name == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", WORKING_SET_TAG, NAME_ATTRIBUTE)); //$NON-NLS-1$ - } - // Ignore any elements until the corresponding end tag is reached - ignoreElements = true; - } else if (elementName.equals(MODULE_TAG)) { - String path = atts.getValue(PATH_ATTRIBUTE); - if (path == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", MODULE_TAG, PATH_ATTRIBUTE)); //$NON-NLS-1$ - } - String type = atts.getValue(TYPE_ATTRIBUTE); - if (type != null && type.equals(DEFINED_MODULE_TYPE)) { - path = RepositoryRoot.asDefinedModulePath(path); - } - long cachedTime = 0; - String cachedTimeString = atts.getValue(LAST_ACCESS_TIME_ATTRIBUTE); - if (cachedTimeString != null) { - try { - Long time = Long.valueOf(cachedTimeString); - cachedTime = time.longValue(); - } catch (NumberFormatException e) { - // Ignore - } - } - startModule(path, cachedTime); - } else if (elementName.equals(TAG_TAG)) { - String type = atts.getValue(TYPE_ATTRIBUTE); - if (type == null) { - type = DEFAULT_TAG_TYPE; - } - String name = atts.getValue(NAME_ATTRIBUTE); - if (name == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", TAG_TAG, NAME_ATTRIBUTE)); //$NON-NLS-1$ - } - tags.add(new CVSTag(name, getCVSTagType(type))); - } else if (elementName.equals(AUTO_REFRESH_FILE_TAG)) { - String path = atts.getValue(FULL_PATH_ATTRIBUTE); - if (path == null) { - // get the old path attribute format which was relative to the module - path = atts.getValue(PATH_ATTRIBUTE); - if (path == null) { - throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", AUTO_REFRESH_FILE_TAG, FULL_PATH_ATTRIBUTE)); //$NON-NLS-1$ - } - if (RepositoryRoot.isDefinedModuleName(currentRemotePath)) { - path = null; - } else { - path = new Path(null, currentRemotePath).append(path).toString(); - } - } - if (path != null) autoRefreshFiles.add(path); - } else if (elementName.equals(CURRENT_WORKING_SET_TAG)) { - // Ignore any elements until the corresponding end tag is reached - ignoreElements = true; - } - // empty buffer - buffer = new StringBuffer(); - tagStack.push(elementName); - } - - private void startModule(String path, long cachedTime) { - currentRemotePath = path; - tags = new ArrayList(); - this.lastAccessTime = cachedTime; - autoRefreshFiles = new ArrayList(); - } - - /** - * Method getCVSTagType. - * @param type - */ - public int getCVSTagType(String type) { - for (int i = 0; i < TAG_TYPES.length; i++) { - if (TAG_TYPES[i].equals(type)) - return i; - } - return CVSTag.VERSION; - } - - /* - * Couldn't figure out from the SAX API exactly when localName vs. qName is used. - * However, the XML for project sets doesn't use namespaces so either of the two names - * is fine. Therefore, use whichever one is provided. - */ - private String getElementName(String namespaceURI, String localName, String qName) { - if (localName != null && localName.length() > 0) { - return localName; - } else { - return qName; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java deleted file mode 100644 index cc893bb7f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java +++ /dev/null @@ -1,419 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -/** - * Repository preference page for setting the encoding of the server - */ -public class RepositoryEncodingPropertyPage extends PropertyPage implements IPropertyChangeListener { - - private static final int LABEL_WIDTH_HINT = 400; - - private EncodingFieldEditor encoding; - private ICVSRepositoryLocation location; - - public class OSGIPreferenceStore implements IPreferenceStore { - private Preferences preferences, defaults; - private boolean dirty; - - /** - * Create a wrapper for the given OSGI preferences node - * @param preferences an OSGI preferences node - */ - public OSGIPreferenceStore(Preferences preferences, Preferences defaults) { - this.preferences = preferences; - this.defaults = defaults; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object) - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) - */ - public boolean contains(String name) { - try { - String[] keys = preferences.keys(); - for (int i = 0; i < keys.length; i++) { - String string = keys[i]; - if (string.equals(name)) { - return true; - } - } - return false; - } catch (BackingStoreException e) { - CVSUIPlugin.log(new CVSStatus(IStatus.ERROR, Policy.bind("internal"), e)); //$NON-NLS-1$ - return false; - } - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) - */ - public boolean getBoolean(String name) { - return preferences.getBoolean(name, getDefaultBoolean(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String) - */ - public boolean getDefaultBoolean(String name) { - if (defaults != null) { - return defaults.getBoolean(name, false); - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String) - */ - public double getDefaultDouble(String name) { - if (defaults != null) { - return defaults.getDouble(name, 0); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String) - */ - public float getDefaultFloat(String name) { - if (defaults != null) { - return defaults.getFloat(name, 0); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String) - */ - public int getDefaultInt(String name) { - if (defaults != null) { - return defaults.getInt(name, 0); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String) - */ - public long getDefaultLong(String name) { - if (defaults != null) { - return defaults.getLong(name, 0); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String) - */ - public String getDefaultString(String name) { - if (defaults != null) { - return defaults.get(name, null); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) - */ - public double getDouble(String name) { - return preferences.getDouble(name, getDefaultDouble(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) - */ - public float getFloat(String name) { - return preferences.getFloat(name, getDefaultFloat(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) - */ - public int getInt(String name) { - return preferences.getInt(name, getDefaultInt(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) - */ - public long getLong(String name) { - return preferences.getLong(name, getDefaultLong(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) - */ - public String getString(String name) { - return preferences.get(name, getDefaultString(name)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) - */ - public boolean isDefault(String name) { - return !contains(name); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() - */ - public boolean needsSaving() { - return dirty; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String) - */ - public void putValue(String name, String value) { - preferences.put(name, value); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double) - */ - public void setDefault(String name, double value) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, float) - */ - public void setDefault(String name, float value) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, int) - */ - public void setDefault(String name, int value) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, long) - */ - public void setDefault(String name, long value) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, java.lang.String) - */ - public void setDefault(String name, String defaultObject) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, boolean) - */ - public void setDefault(String name, boolean value) { - // Defaults cannot be set this way - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String) - */ - public void setToDefault(String name) { - preferences.remove(name); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, double) - */ - public void setValue(String name, double value) { - preferences.putDouble(name, value); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, float) - */ - public void setValue(String name, float value) { - preferences.putFloat(name, value); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, int) - */ - public void setValue(String name, int value) { - preferences.putInt(name, value); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, long) - */ - public void setValue(String name, long value) { - preferences.putLong(name, value); - dirty = true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, java.lang.String) - */ - public void setValue(String name, String value) { - putValue(name, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, boolean) - */ - public void setValue(String name, boolean value) { - preferences.putBoolean(name, value); - dirty = true; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - initialize(); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - - createWrappingLabel(composite, Policy.bind("RepositoryEncodingPropertyPage.2"), 1); //$NON-NLS-1$ - - encoding = new EncodingFieldEditor(CVSRepositoryLocation.PREF_SERVER_ENCODING, Policy.bind("RepositoryEncodingPropertyPage.3"), composite); //$NON-NLS-1$ - encoding.setPreferencePage(this); - encoding.setPreferenceStore(getLocationPreferenceStore()); - encoding.load(); - encoding.setPropertyChangeListener(this); - - createWrappingLabel(composite, Policy.bind("RepositoryEncodingPropertyPage.4"), 1); //$NON-NLS-1$ - - WorkbenchHelp.setHelp(getControl(), IHelpContextIds.REPOSITORY_ENCODING_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); - return composite; - } - - private IPreferenceStore getLocationPreferenceStore() { - return new OSGIPreferenceStore( - ((CVSRepositoryLocation)location).getPreferences(), - CVSRepositoryLocation.getDefaultPreferences()); - } - - private void initialize() { - location = null; - IAdaptable element = getElement(); - if (element instanceof ICVSRepositoryLocation) { - location = (ICVSRepositoryLocation)element; - } else { - Object adapter = element.getAdapter(ICVSRepositoryLocation.class); - if (adapter instanceof ICVSRepositoryLocation) { - location = (ICVSRepositoryLocation)adapter; - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty() == FieldEditor.IS_VALID) { - setValid(((Boolean)event.getNewValue()).booleanValue()); - return; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - if (!KnownRepositories.getInstance().isKnownRepository(location.getLocation())) { - // The location may have been replaced by the main properties page - MessageDialog.openInformation(getShell(), Policy.bind("RepositoryEncodingPropertyPage.0"), Policy.bind("RepositoryEncodingPropertyPage.1", location.getLocation())); //$NON-NLS-1$ //$NON-NLS-2$ - return true; - } - encoding.store(); - try { - ((CVSRepositoryLocation)location).getPreferences().flush(); - } catch (BackingStoreException e) { - // Log and ignore - CVSUIPlugin.log(new CVSStatus(IStatus.ERROR, Policy.bind("internal"), e)); //$NON-NLS-1$ - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#performDefaults() - */ - protected void performDefaults() { - super.performDefaults(); - encoding.loadDefault(); - } - - private Label createWrappingLabel(Composite parent, String text, int horizontalSpan) { - Label label = new Label(parent, SWT.LEFT | SWT.WRAP); - label.setText(text); - label.setFont(parent.getFont()); - GridData data = new GridData(); - data.horizontalSpan = horizontalSpan; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = LABEL_WIDTH_HINT; - label.setLayoutData(data); - return label; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java deleted file mode 100644 index 1e863e649..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java +++ /dev/null @@ -1,813 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import javax.xml.parsers.*; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.IWorkingSet; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * This class is repsible for maintaining the UI's list of known repositories, - * and a list of known tags within each of those repositories. - * - * It also provides a number of useful methods for assisting in repository operations. - */ -public class RepositoryManager { - // old state file - private static final String STATE_FILE = ".repositoryManagerState"; //$NON-NLS-1$ - private static final int STATE_FILE_VERSION_1 = -1; - // new state file - private static final String REPOSITORIES_VIEW_FILE = "repositoriesView.xml"; //$NON-NLS-1$ - private static final String COMMENT_HIST_FILE = "commitCommentHistory.xml"; //$NON-NLS-1$ - static final String ELEMENT_COMMIT_COMMENT = "CommitComment"; //$NON-NLS-1$ - static final String ELEMENT_COMMIT_HISTORY = "CommitComments"; //$NON-NLS-1$ - - private Map repositoryRoots = new HashMap(); - - List listeners = new ArrayList(); - - // The previously remembered comment - static String[] previousComments = new String[0]; - - public static boolean notifyRepoView = true; - - // Cache of changed repository roots - private int notificationLevel = 0; - private Map changedRepositories = new HashMap(); - - static final int MAX_COMMENTS = 10; - - /** - * Answer an array of all known remote roots. - */ - public ICVSRepositoryLocation[] getKnownRepositoryLocations() { - return KnownRepositories.getInstance().getRepositories(); - } - - /** - * Method getRepositoryRoots. - * @param iCVSRepositoryLocations - * @return RepositoryRoot[] - */ - private RepositoryRoot[] getRepositoryRoots(ICVSRepositoryLocation[] locations) { - List roots = new ArrayList(); - for (int i = 0; i < locations.length; i++) { - ICVSRepositoryLocation location = locations[i]; - RepositoryRoot root = getRepositoryRootFor(location); - if (root != null) - roots.add(root); - } - return (RepositoryRoot[]) roots.toArray(new RepositoryRoot[roots.size()]); - } - - public RepositoryRoot[] getKnownRepositoryRoots() { - return getRepositoryRoots(getKnownRepositoryLocations()); - } - - /** - * Get the list of known branch tags for a given remote root. - */ - public CVSTag[] getKnownTags(ICVSFolder project, int tagType) { - try { - CVSTag[] tags = getKnownTags(project); - Set result = new HashSet(); - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (tag.getType() == tagType) - result.add(tag); - } - - return (CVSTag[])result.toArray(new CVSTag[result.size()]); - } catch(CVSException e) { - CVSUIPlugin.log(e); - return new CVSTag[0]; - } - } - - /** - * Get the list of known version tags for a given project. - */ - public CVSTag[] getKnownTags(ICVSRepositoryLocation location, int tagType) { - Set result = new HashSet(); - RepositoryRoot root = (RepositoryRoot)repositoryRoots.get(location.getLocation()); - if (root != null) { - String[] paths = root.getKnownRemotePaths(); - for (int i = 0; i < paths.length; i++) { - String path = paths[i]; - CVSTag[] tags = root.getAllKnownTags(path); - for (int j = 0; j < tags.length; j++) { - CVSTag tag = tags[j]; - if (tag.getType() == tagType) - result.add(tag); - } - } - } - return (CVSTag[])result.toArray(new CVSTag[0]); - } - - /** - * Method getKnownTags. - * @param repository - * @param set - * @param i - * @param monitor - * @return CVSTag[] - */ - public CVSTag[] getKnownTags(ICVSRepositoryLocation repository, IWorkingSet set, int tagType, IProgressMonitor monitor) throws CVSException { - if (set == null) { - return getKnownTags(repository, tagType); - } - ICVSRemoteResource[] folders = getFoldersForTag(repository, CVSTag.DEFAULT, monitor); - folders = filterResources(set, folders); - Set tags = new HashSet(); - for (int i = 0; i < folders.length; i++) { - ICVSRemoteFolder folder = (ICVSRemoteFolder)folders[i]; - tags.addAll(Arrays.asList(getKnownTags(folder, tagType))); - } - return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); - } - - public CVSTag[] getKnownTags(ICVSFolder project) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(project); - String remotePath = RepositoryRoot.getRemotePathFor(project); - return root.getAllKnownTags(remotePath); - } - - /* - * XXX I hope this methos is not needed in this form - */ - public Map getKnownProjectsAndVersions(ICVSRepositoryLocation location) { - Map knownTags = new HashMap(); - RepositoryRoot root = getRepositoryRootFor(location); - String[] paths = root.getKnownRemotePaths(); - for (int i = 0; i < paths.length; i++) { - String path = paths[i]; - Set result = new HashSet(); - result.addAll(Arrays.asList(root.getAllKnownTags(path))); - knownTags.put(path, result); - } - return knownTags; - } - - public ICVSRemoteResource[] getFoldersForTag(ICVSRepositoryLocation location, CVSTag tag, IProgressMonitor monitor) throws CVSException { - monitor = Policy.monitorFor(monitor); - try { - monitor.beginTask(Policy.bind("RepositoryManager.fetchingRemoteFolders", tag.getName()), 100); //$NON-NLS-1$ - if (tag.getType() == CVSTag.HEAD) { - ICVSRemoteResource[] resources = location.members(tag, false, Policy.subMonitorFor(monitor, 60)); - RepositoryRoot root = getRepositoryRootFor(location); - ICVSRemoteResource[] modules = root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40)); - ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length]; - System.arraycopy(resources, 0, result, 0, resources.length); - System.arraycopy(modules, 0, result, resources.length, modules.length); - return result; - } - if (tag.getType() == CVSTag.DATE) { - ICVSRemoteResource[] resources = location.members(tag, false, Policy.subMonitorFor(monitor, 60)); - RepositoryRoot root = getRepositoryRootFor(location); - ICVSRemoteResource[] modules = root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40)); - ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length]; - System.arraycopy(resources, 0, result, 0, resources.length); - System.arraycopy(modules, 0, result, resources.length, modules.length); - return result; - } - Set result = new HashSet(); - // Get the tags for the location - RepositoryRoot root = getRepositoryRootFor(location); - String[] paths = root.getKnownRemotePaths(); - for (int i = 0; i < paths.length; i++) { - String path = paths[i]; - List tags = Arrays.asList(root.getAllKnownTags(path)); - if (tags.contains(tag)) { - ICVSRemoteFolder remote = root.getRemoteFolder(path, tag, Policy.subMonitorFor(monitor, 100)); - result.add(remote); - } - } - return (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[result.size()]); - } finally { - monitor.done(); - } - } - - /* - * Fetches tags from auto-refresh files if they exist. Then fetches tags from the user defined auto-refresh file - * list. The fetched tags are cached in the CVS ui plugin's tag cache. - */ - public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, boolean notify, IProgressMonitor monitor) throws TeamException { - RepositoryRoot root = getRepositoryRootFor(folder); - CVSTag[] tags = root.refreshDefinedTags(folder, recurse, monitor); - if (tags.length > 0 && notify) - broadcastRepositoryChange(root); - return tags; - } - - /** - * A repository root has been added. Notify any listeners. - */ - public void rootAdded(ICVSRepositoryLocation root) { - Iterator it = listeners.iterator(); - while (it.hasNext()) { - IRepositoryListener listener = (IRepositoryListener)it.next(); - listener.repositoryAdded(root); - } - } - - /** - * A repository root has been removed. - * Remove the tags defined for this root and notify any listeners - */ - public void rootRemoved(ICVSRepositoryLocation root) { - RepositoryRoot repoRoot = (RepositoryRoot)repositoryRoots.remove(root.getLocation()); - if (repoRoot != null) - broadcastRepositoryChange(repoRoot); - } - - /** - * Accept tags for any CVS resource. However, for the time being, - * the given version tags are added to the list of known tags for the - * remote ancestor of the resource that is a direct child of the remote root - */ - public void addTags(ICVSResource resource, CVSTag[] tags) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(resource); - // XXX could be a file or folder - String remotePath = RepositoryRoot.getRemotePathFor(resource); - root.addTags(remotePath, tags); - broadcastRepositoryChange(root); - } - public void addDateTag(ICVSRepositoryLocation location, CVSTag tag) { - if(tag == null) return; - RepositoryRoot root = getRepositoryRootFor(location); - root.addDateTag(tag); - broadcastRepositoryChange(root); - } - public CVSTag[] getDateTags(ICVSRepositoryLocation location) { - RepositoryRoot root = getRepositoryRootFor(location); - return root.getDateTags(); - } - public void removeDateTag(ICVSRepositoryLocation location, CVSTag tag){ - RepositoryRoot root = getRepositoryRootFor(location); - root.removeDateTag(tag); - broadcastRepositoryChange(root); - } - public void setAutoRefreshFiles(ICVSFolder project, String[] filePaths) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(project); - String remotePath = RepositoryRoot.getRemotePathFor(project); - root.setAutoRefreshFiles(remotePath, filePaths); - } - - public void removeAutoRefreshFiles(ICVSFolder project, String[] relativeFilePaths) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(project); - String remotePath = RepositoryRoot.getRemotePathFor(project); - Set set = new HashSet(); - set.addAll(Arrays.asList(root.getAutoRefreshFiles(remotePath))); - set.removeAll(Arrays.asList(relativeFilePaths)); - root.setAutoRefreshFiles(remotePath, (String[]) set.toArray(new String[set.size()])); - } - - public String[] getAutoRefreshFiles(ICVSFolder project) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(project); - String remotePath = RepositoryRoot.getRemotePathFor(project); - return root.getAutoRefreshFiles(remotePath); - } - - /** - * Remove the given tags from the list of known tags for the - * given remote root. - */ - public void removeTags(ICVSFolder project, CVSTag[] tags) throws CVSException { - RepositoryRoot root = getRepositoryRootFor(project); - String remotePath = RepositoryRoot.getRemotePathFor(project); - root.removeTags(remotePath, tags); - broadcastRepositoryChange(root); - } - - public void startup() { - loadState(); - loadCommentHistory(); - CVSProviderPlugin.getPlugin().addRepositoryListener(new ICVSListener() { - public void repositoryAdded(ICVSRepositoryLocation root) { - rootAdded(root); - } - public void repositoryRemoved(ICVSRepositoryLocation root) { - rootRemoved(root); - } - }); - } - - public void shutdown() throws TeamException { - saveState(); - saveCommentHistory(); - } - - private void loadState() { - IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(REPOSITORIES_VIEW_FILE); - File file = pluginStateLocation.toFile(); - if (file.exists()) { - try { - BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); - try { - readState(is); - } finally { - is.close(); - } - } catch (IOException e) { - CVSUIPlugin.log(Status.ERROR, Policy.bind("RepositoryManager.ioException"), e); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } else { - IPath oldPluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(STATE_FILE); - file = oldPluginStateLocation.toFile(); - if (file.exists()) { - try { - DataInputStream dis = new DataInputStream(new FileInputStream(file)); - try { - readOldState(dis); - } finally { - dis.close(); - } - saveState(); - file.delete(); - } catch (IOException e) { - CVSUIPlugin.log(Status.ERROR, Policy.bind("RepositoryManager.ioException"), e); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - } - } - private void loadCommentHistory() { - IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(COMMENT_HIST_FILE); - File file = pluginStateLocation.toFile(); - if (!file.exists()) return; - try { - BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); - try { - readCommentHistory(is); - } finally { - is.close(); - } - } catch (IOException e) { - CVSUIPlugin.log(Status.ERROR, Policy.bind("RepositoryManager.ioException"), e); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - - protected void saveState() throws TeamException { - IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation(); - File tempFile = pluginStateLocation.append(REPOSITORIES_VIEW_FILE + ".tmp").toFile(); //$NON-NLS-1$ - File stateFile = pluginStateLocation.append(REPOSITORIES_VIEW_FILE).toFile(); - try { - XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile))); - try { - writeState(writer); - } finally { - writer.close(); - } - if (stateFile.exists()) { - stateFile.delete(); - } - boolean renamed = tempFile.renameTo(stateFile); - if (!renamed) { - throw new TeamException(new Status(Status.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$ - } - } catch (IOException e) { - throw new TeamException(new Status(Status.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.save",stateFile.getAbsolutePath()), e)); //$NON-NLS-1$ - } - } - private void writeState(XMLWriter writer) { - writer.startTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG, null, true); - // Write the repositories - Collection repos = Arrays.asList(getKnownRepositoryLocations()); - Iterator it = repos.iterator(); - while (it.hasNext()) { - CVSRepositoryLocation location = (CVSRepositoryLocation)it.next(); - RepositoryRoot root = getRepositoryRootFor(location); - root.writeState(writer); - } - writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG); - } - - private void readState(InputStream stream) throws IOException, TeamException { - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); - parser.parse(new InputSource(stream), new RepositoriesViewContentHandler(this)); - } catch (SAXException ex) { - throw new CVSException(Policy.bind("RepositoryManager.parsingProblem", REPOSITORIES_VIEW_FILE), ex); //$NON-NLS-1$ - } catch (ParserConfigurationException ex) { - throw new CVSException(Policy.bind("RepositoryManager.parsingProblem", REPOSITORIES_VIEW_FILE), ex); //$NON-NLS-1$ - } - } - private void readCommentHistory(InputStream stream) throws IOException, TeamException { - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); - parser.parse(new InputSource(stream), new CommentHistoryContentHandler()); - } catch (SAXException ex) { - throw new CVSException(Policy.bind("RepositoryManager.parsingProblem", COMMENT_HIST_FILE), ex); //$NON-NLS-1$ - } catch (ParserConfigurationException ex) { - throw new CVSException(Policy.bind("RepositoryManager.parsingProblem", COMMENT_HIST_FILE), ex); //$NON-NLS-1$ - } - } - - private void readOldState(DataInputStream dis) throws IOException, TeamException { - int repoSize = dis.readInt(); - boolean version1 = false; - if (repoSize == STATE_FILE_VERSION_1) { - version1 = true; - repoSize = dis.readInt(); - } - for (int i = 0; i < repoSize; i++) { - ICVSRepositoryLocation root = KnownRepositories.getInstance().getRepository(dis.readUTF()); - RepositoryRoot repoRoot = getRepositoryRootFor(root); - - // read branch tags associated with this root - int tagsSize = dis.readInt(); - CVSTag[] branchTags = new CVSTag[tagsSize]; - for (int j = 0; j < tagsSize; j++) { - String tagName = dis.readUTF(); - int tagType = dis.readInt(); - branchTags[j] = new CVSTag(tagName, tagType); - } - // Ignore the branch tags since they are handled differently now - // addBranchTags(root, branchTags); - - // read the number of projects for this root that have version tags - int projSize = dis.readInt(); - if (projSize > 0) { - for (int j = 0; j < projSize; j++) { - String name = dis.readUTF(); - Set tagSet = new HashSet(); - int numTags = dis.readInt(); - for (int k = 0; k < numTags; k++) { - tagSet.add(new CVSTag(dis.readUTF(), CVSTag.VERSION)); - } - CVSTag[] tags = (CVSTag[]) tagSet.toArray(new CVSTag[tagSet.size()]); - repoRoot.addTags(name, tags); - } - } - // read the auto refresh filenames for this project - if (version1) { - try { - projSize = dis.readInt(); - if (projSize > 0) { - for (int j = 0; j < projSize; j++) { - String name = dis.readUTF(); - Set filenames = new HashSet(); - int numFilenames = dis.readInt(); - for (int k = 0; k < numFilenames; k++) { - filenames.add(name + "/" + dis.readUTF()); //$NON-NLS-1$ - } - repoRoot.setAutoRefreshFiles(name, (String[]) filenames.toArray(new String[filenames.size()])); - } - } - } catch (EOFException e) { - // auto refresh files are not persisted, continue and save them next time. - } - } - broadcastRepositoryChange(repoRoot); - } - } - - protected void saveCommentHistory() throws TeamException { - IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation(); - File tempFile = pluginStateLocation.append(COMMENT_HIST_FILE + ".tmp").toFile(); //$NON-NLS-1$ - File histFile = pluginStateLocation.append(COMMENT_HIST_FILE).toFile(); - try { - XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile))); - try { - writeCommentHistory(writer); - } finally { - writer.close(); - } - if (histFile.exists()) { - histFile.delete(); - } - boolean renamed = tempFile.renameTo(histFile); - if (!renamed) { - throw new TeamException(new Status(Status.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$ - } - } catch (IOException e) { - throw new TeamException(new Status(Status.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.save",histFile.getAbsolutePath()), e)); //$NON-NLS-1$ - } - } - private void writeCommentHistory(XMLWriter writer) { - writer.startTag(ELEMENT_COMMIT_HISTORY, null, false); - for (int i=0; i TagCacheEntry - Map versionAndBranchTags = new HashMap(); - // Map of String (remote folder path) -> Set (file paths that are project relative) - Map autoRefreshFiles = new HashMap(); - // Map of String (module name) -> ICVSRemoteFolder (that is a defined module) - Map modulesCache; - Object modulesCacheLock = new Object(); - // Lis of date tags - List dateTags = new ArrayList(); - - public static class TagCacheEntry { - Set tags = new HashSet(); - long lastAccessTime; - private static final int CACHE_LIFESPAN_IN_DAYS = 7; - public TagCacheEntry() { - accessed(); - } - public boolean isExpired() { - long currentTime = System.currentTimeMillis(); - long ms = currentTime - lastAccessTime; - int seconds = (int)ms / 1000; - int hours = seconds / 60 / 60; - int days = hours / 24; - return days > CACHE_LIFESPAN_IN_DAYS; - } - public void accessed() { - lastAccessTime = System.currentTimeMillis(); - } - } - - public RepositoryRoot(ICVSRepositoryLocation root) { - this.root = root; - } - - /** - * Returns the name. - * @return String - */ - public String getName() { - return name; - } - - /** - * Method getRemoteFolder. - * @param path - * @param tag - * @return ICVSRemoteFolder - */ - public ICVSRemoteFolder getRemoteFolder(String path, CVSTag tag, IProgressMonitor monitor) { - if (isDefinedModuleName(path)) { - return getDefinedModule(getDefinedModuleName(path), tag, monitor); - } else { - return root.getRemoteFolder(path, tag); - } - } - - static boolean isDefinedModuleName(String path) { - return path.startsWith(DEFINED_MODULE_PREFIX); - } - - static String getDefinedModuleName(String path) { - return path.substring(DEFINED_MODULE_PREFIX.length()); - } - - static String asDefinedModulePath(String path) { - return DEFINED_MODULE_PREFIX + path; - } - - /** - * Method getDefinedModule. - * @param path - * @param tag - * @param monitor - * @return ICVSRemoteFolder - */ - private ICVSRemoteFolder getDefinedModule(String path, CVSTag tag, IProgressMonitor monitor) { - Map cache = getDefinedModulesCache(tag, monitor); - ICVSRemoteFolder folder = (ICVSRemoteFolder)cache.get(path); - if (folder != null) { - folder = (ICVSRemoteFolder)folder.forTag(tag); - } - return folder; - } - - private Map getDefinedModulesCache(CVSTag tag, IProgressMonitor monitor) { - if (modulesCache == null) { - try { - // Fetch the modules before locking the cache (to avoid deadlock) - ICVSRemoteResource[] folders = root.members(CVSTag.DEFAULT, true, monitor); - synchronized(modulesCacheLock) { - modulesCache = new HashMap(); - for (int i = 0; i < folders.length; i++) { - ICVSRemoteResource resource = folders[i]; - modulesCache.put(resource.getName(), resource); - } - } - } catch (CVSException e) { - // we could't fetch the modules. Log the problem and continue - CVSUIPlugin.log(e); - // Return an empty map but don't save it so the fetching of - // the modules will occur again - return new HashMap(); - } - } - return modulesCache; - } - - public ICVSRemoteResource[] getDefinedModules(CVSTag tag, IProgressMonitor monitor) { - Map cache = getDefinedModulesCache(tag, monitor); - return (ICVSRemoteResource[]) cache.values().toArray(new ICVSRemoteResource[cache.size()]); - } - - public static String getRemotePathFor(ICVSResource resource) throws CVSException { - if (resource.isFolder()) { - if (resource instanceof ICVSRemoteFolder) { - ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) resource; - if (remoteFolder.isDefinedModule()) { - return asDefinedModulePath(remoteFolder.getName()); - } - } - FolderSyncInfo info = ((ICVSFolder)resource).getFolderSyncInfo(); - if (info == null) - throw new CVSException(Policy.bind("RepositoryRoot.folderInfoMissing", resource.getName())); //$NON-NLS-1$ - return info.getRepository(); - } else { - FolderSyncInfo info = resource.getParent().getFolderSyncInfo(); - if (info == null) - throw new CVSException(Policy.bind("RepositoryRoot.folderInfoMissing", resource.getParent().getName())); //$NON-NLS-1$ - String path = new Path(null, info.getRepository()).append(resource.getName()).toString(); - return path; - } - } - - /** - * Returns the root. - * @return ICVSRepositoryLocation - */ - public ICVSRepositoryLocation getRoot() { - return root; - } - - /** - * Sets the name. - * @param name The name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * Accept the tags for any remote path that represents a folder. However, for the time being, - * the given version tags are added to the list of known tags for the - * remote ancestor of the resource that is a direct child of the remote root. - * - * It is the reponsibility of the caller to ensure that the given remote path is valid. - */ - public void addTags(String remotePath, CVSTag[] tags) { - addDateTags(tags); - addVersionAndBranchTags(remotePath, tags); - } - - private void addDateTags(CVSTag[] tags){ - for(int i = 0; i < tags.length; i++){ - if(tags[i].getType() == CVSTag.DATE){ - dateTags.add(tags[i]); - } - } - } - private void addVersionAndBranchTags(String remotePath, CVSTag[] tags) { - // Get the name to cache the version tags with - String name = getCachePathFor(remotePath); - - // Make sure there is a table for the ancestor that holds the tags - TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); - if (entry == null) { - entry = new TagCacheEntry(); - versionAndBranchTags.put(name, entry); - } else { - entry.accessed(); - } - - // Store the tag with the appropriate ancestor - for (int i = 0; i < tags.length; i++) { - if(tags[i].getType() != CVSTag.DATE){ - entry.tags.add(tags[i]); - } - } - } - - /** - * Add the given date tag to the list of date tags associated with the repository. - * @param tag a date tag - */ - public void addDateTag(CVSTag tag) { - if (!dateTags.contains(tag)) { - dateTags.add(tag); - } - } - public void removeDateTag(CVSTag tag) { - if (dateTags.contains(tag)) { - dateTags.remove(tag); - } - } - /** - * Return the list of date tags assocaiated with the repository. - * @return the list of date tags - */ - public CVSTag[] getDateTags() { - return (CVSTag[]) dateTags.toArray(new CVSTag[dateTags.size()]); - } - - /** - * Remove the given tags from the receiver - * @param remotePath - * @param tags - */ - public void removeTags(String remotePath, CVSTag[] tags) { - removeDateTags(tags); - removeVersionAndBranchTags(remotePath, tags); - } - - private void removeDateTags(CVSTag[] tags) { - if(dateTags.isEmpty())return; - // Store the tag with the appropriate ancestor - for (int i = 0; i < tags.length; i++) { - dateTags.remove(tags[i]); - } - } - - private void removeVersionAndBranchTags(String remotePath, CVSTag[] tags) { - // Get the name to cache the version tags with - String name = getCachePathFor(remotePath); - - // Make sure there is a table for the ancestor that holds the tags - TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); - if (entry == null) { - return; - } - - // Store the tag with the appropriate ancestor - for (int i = 0; i < tags.length; i++) { - entry.tags.remove(tags[i]); - } - entry.accessed(); - } - - /** - * Returns the absolute paths of the auto refresh files relative to the - * repository. - * - * @return String[] - */ - public String[] getAutoRefreshFiles(String remotePath) { - String name = getCachePathFor(remotePath); - Set files = (Set)autoRefreshFiles.get(name); - if (files == null || files.isEmpty()) { - // convert the default relative file paths to full paths - if (isDefinedModuleName(remotePath)) { - return new String[0]; - } - List result = new ArrayList(); - for (int i = 0; i < DEFAULT_AUTO_REFRESH_FILES.length; i++) { - String relativePath = DEFAULT_AUTO_REFRESH_FILES[i]; - result.add(new Path(null, remotePath).append(relativePath).toString()); - } - return (String[]) result.toArray(new String[result.size()]); - } else { - return (String[]) files.toArray(new String[files.size()]); - } - } - - /** - * Sets the auto refresh files for the given remote path to the given - * string values which are absolute file paths (relative to the receiver). - * - * @param autoRefreshFiles The autoRefreshFiles to set - */ - public void setAutoRefreshFiles(String remotePath, String[] autoRefreshFiles) { - Set newFiles = new HashSet(Arrays.asList(autoRefreshFiles)); - // Check to see if the auto-refresh files are the default files - if (autoRefreshFiles.length == DEFAULT_AUTO_REFRESH_FILES.length) { - boolean isDefault = true; - for (int i = 0; i < DEFAULT_AUTO_REFRESH_FILES.length; i++) { - String filePath = DEFAULT_AUTO_REFRESH_FILES[i]; - if (!newFiles.contains(new Path(null, remotePath).append(filePath).toString())) { - isDefault = false; - break; - } - } - if (isDefault) { - this.autoRefreshFiles.remove(getCachePathFor(remotePath)); - return; - } - } - this.autoRefreshFiles.put(getCachePathFor(remotePath), newFiles); - } - - /** - * Fetches tags from auto-refresh files. - */ - public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - CVSTag[] tags = null; - if (!recurse) { - // Only try the auto-refresh file(s) if we are not recursing into sub-folders - tags = fetchTagsUsingAutoRefreshFiles(folder, Policy.subMonitorFor(monitor, 50)); - } - if (tags == null || tags.length == 0) { - // There we're no tags found on the auto-refresh files or we we're aksed to go deep - // Try using the log command - tags = fetchTagsUsingLog(folder, recurse, Policy.subMonitorFor(monitor, 50)); - } - if (tags != null && tags.length > 0) { - String remotePath = getRemotePathFor(folder); - addTags(remotePath, tags); - } - monitor.done(); - return tags; - } - - private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, final boolean recurse, IProgressMonitor monitor) throws CVSException { - LogEntryCache logEntries = new LogEntryCache(); - RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { - protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) { - Command.LocalOption[] options = super.getLocalOptions(tag1, tag2); - if (recurse) - return options; - Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; - System.arraycopy(options, 0, newOptions, 0, options.length); - newOptions[options.length] = Command.DO_NOT_RECURSE; - return newOptions; - } - }; - try { - operation.run(monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Ignore; - } - String[] keys = logEntries.getCachedFilePaths(); - Set tags = new HashSet(); - for (int i = 0; i < keys.length; i++) { - String key = keys[i]; - ILogEntry[] entries = logEntries.getLogEntries(key); - for (int j = 0; j < entries.length; j++) { - ILogEntry entry = entries[j]; - tags.addAll(Arrays.asList(entry.getTags())); - } - } - return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); - } - - private ICVSRemoteResource asRemoteResource(ICVSFolder folder) throws CVSException { - if (folder instanceof ICVSRemoteResource) { - return (ICVSRemoteResource)folder; - } - return CVSWorkspaceRoot.getRemoteResourceFor(folder); - } - - /** - * Fetches tags from auto-refresh files. - */ - private CVSTag[] fetchTagsUsingAutoRefreshFiles(ICVSFolder folder, IProgressMonitor monitor) throws TeamException { - String remotePath = getRemotePathFor(folder); - String[] filesToRefresh = getAutoRefreshFiles(remotePath); - try { - monitor.beginTask(null, filesToRefresh.length * 10); //$NON-NLS-1$ - List tags = new ArrayList(); - for (int i = 0; i < filesToRefresh.length; i++) { - ICVSRemoteFile file = root.getRemoteFile(filesToRefresh[i], CVSTag.DEFAULT); - try { - tags.addAll(Arrays.asList(fetchTags(file, Policy.subMonitorFor(monitor, 5)))); - } catch (TeamException e) { - IStatus status = e.getStatus(); - boolean doesNotExist = false; - if (status.getCode() == CVSStatus.SERVER_ERROR && status.isMultiStatus()) { - IStatus[] children = status.getChildren(); - if (children.length == 1 && children[0].getCode() == CVSStatus.DOES_NOT_EXIST) { - // Don't throw an exception if the file does no exist - doesNotExist = true; - } - } - if (!doesNotExist) { - throw e; - } - } - } - return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); - } finally { - monitor.done(); - } - } - - /** - * Returns Branch and Version tags for the given files - */ - private CVSTag[] fetchTags(ICVSRemoteFile file, IProgressMonitor monitor) throws TeamException { - Set tagSet = new HashSet(); - ILogEntry[] entries = file.getLogEntries(monitor); - for (int j = 0; j < entries.length; j++) { - CVSTag[] tags = entries[j].getTags(); - for (int k = 0; k < tags.length; k++) { - tagSet.add(tags[k]); - } - } - return (CVSTag[])tagSet.toArray(new CVSTag[0]); - } - - /* - * Return the cache key (path) for the given folder path. - * This has been changed to cache the tags directly - * with the folder to better support non-root projects. - * However, resources in the local workspace use the folder - * the project is mapped to as the tag source (see TagSource) - */ - private String getCachePathFor(String remotePath) { - return remotePath; - } - - /** - * Write out the state of the receiver as XML on the given XMLWriter. - * - * @param writer - * @throws IOException - */ - public void writeState(XMLWriter writer) { - - HashMap attributes = new HashMap(); - - attributes.clear(); - attributes.put(RepositoriesViewContentHandler.ID_ATTRIBUTE, root.getLocation()); - if (name != null) { - attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, name); - } - - writer.startTag(RepositoriesViewContentHandler.REPOSITORY_TAG, attributes, true); - - //put date tag under repository - if(!dateTags.isEmpty()){ - writer.startTag(RepositoriesViewContentHandler.DATE_TAGS_TAG, attributes, true); - Iterator iter = dateTags.iterator(); - while(iter.hasNext()){ - CVSTag tag = (CVSTag)iter.next(); - writeATag(writer, attributes, tag, RepositoriesViewContentHandler.DATE_TAG_TAG); - } - writer.endTag(RepositoriesViewContentHandler.DATE_TAGS_TAG); - } - - // Gather all the modules that have tags and/or auto-refresh files - // for each module, write the moduel, tags and auto-refresh files. - String[] paths = getKnownRemotePaths(); - for (int i = 0; i < paths.length; i++) { - String path = paths[i]; - attributes.clear(); - String name = path; - if (isDefinedModuleName(path)) { - name = getDefinedModuleName(path); - - attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.DEFINED_MODULE_TYPE); - } - attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, name); - TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(path); - boolean writeOutTags = entry != null && !entry.isExpired(); - if (writeOutTags) - attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); - writer.startTag(RepositoriesViewContentHandler.MODULE_TAG, attributes, true); - if (writeOutTags) { - Iterator tagIt = entry.tags.iterator(); - while (tagIt.hasNext()) { - CVSTag tag = (CVSTag)tagIt.next(); - writeATag(writer, attributes, tag, RepositoriesViewContentHandler.TAG_TAG); - } - } - Set refreshSet = (Set)autoRefreshFiles.get(path); - if (refreshSet != null) { - Iterator filenameIt = refreshSet.iterator(); - while (filenameIt.hasNext()) { - String filename = (String)filenameIt.next(); - attributes.clear(); - attributes.put(RepositoriesViewContentHandler.FULL_PATH_ATTRIBUTE, filename); - writer.startAndEndTag(RepositoriesViewContentHandler.AUTO_REFRESH_FILE_TAG, attributes, true); - } - } - writer.endTag(RepositoriesViewContentHandler.MODULE_TAG); - } - writer.endTag(RepositoriesViewContentHandler.REPOSITORY_TAG); - } - - private void writeATag(XMLWriter writer, HashMap attributes, CVSTag tag, String s) { - attributes.clear(); - attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, tag.getName()); - attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.TAG_TYPES[tag.getType()]); - writer.startAndEndTag(s, attributes, true); - } - - /** - * Method getKnownTags. - * @param remotePath - * @return CVSTag[] - */ - public CVSTag[] getAllKnownTags(String remotePath) { - TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); - if(entry != null){ - entry.accessed(); - CVSTag [] tags1 = (CVSTag[]) entry.tags.toArray(new CVSTag[entry.tags.size()]); - CVSTag[] tags2 = getDateTags(); - int len = tags1.length + tags2.length; - CVSTag[] tags = new CVSTag[len]; - for(int i = 0; i < len; i++){ - if(i < tags1.length){ - tags[i] = tags1[i]; - }else{ - tags[i] = tags2[i-tags1.length]; - } - } - return tags; - } - return getDateTags(); - } - - public String[] getKnownRemotePaths() { - Set paths = new HashSet(); - paths.addAll(versionAndBranchTags.keySet()); - paths.addAll(autoRefreshFiles.keySet()); - return (String[]) paths.toArray(new String[paths.size()]); - } - /** - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (ICVSRepositoryLocation.class.equals(adapter)) return getRoot(); - return super.getAdapter(adapter); - } - - public ICVSRemoteResource[] filterResources(ICVSRemoteResource[] resource) { - List result = new ArrayList(); - for (int i = 0; i < resource.length; i++) { - ICVSRemoteResource remoteResource = resource[i]; - if (remoteResource instanceof ICVSRemoteFolder) { - ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource; - if (tagIsKnown(remoteResource)) { - result.add(folder); - } - } - } - return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]); - } - - /** - * Method tagIsKnown. - * @param remoteResource - * @return boolean - */ - public boolean tagIsKnown(ICVSRemoteResource remoteResource) { - if (remoteResource instanceof ICVSRemoteFolder) { - ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource; - String path = getCachePathFor(folder.getRepositoryRelativePath()); - CVSTag[] tags = getAllKnownTags(path); - CVSTag tag = folder.getTag(); - for (int i = 0; i < tags.length; i++) { - CVSTag knownTag = tags[i]; - if (knownTag.equals(tag)) return true; - } - } - return false; - } - - /** - * This method is invoked whenever the refresh button in the - * RepositoriesView is pressed. - */ - void clearCache() { - synchronized(modulesCacheLock) { - if (modulesCache != null) - modulesCache = null; - } - } - - /** - * Sets the root. - * @param root The root to set - */ - void setRepositoryLocation(ICVSRepositoryLocation root) { - this.root = root; - } - - /* - * Set the last access time of the cache entry for the given path - * as it was read from the persitent store. - */ - /* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { - TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); - if(entry != null){ - entry.lastAccessTime = lastAccessTime; - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java deleted file mode 100644 index b5eb52453..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.repo; - - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.model.BranchCategory; -import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement; -import org.eclipse.team.internal.ccvs.ui.model.DateTagCategory; -import org.eclipse.team.internal.ccvs.ui.model.RemoteModule; -import org.eclipse.team.internal.ccvs.ui.model.VersionCategory; - -public class RepositorySorter extends ViewerSorter { - public int category(Object element) { - if (element instanceof ICVSRemoteFolder) { - if (((ICVSRemoteFolder)element).isDefinedModule()) { - return 7; - } - return 1; - } - if (element instanceof RemoteModule) { - ICVSRemoteResource resource = ((RemoteModule)element).getCVSResource(); - if (resource instanceof ICVSRemoteFolder) { - ICVSRemoteFolder folder = (ICVSRemoteFolder) resource; - if (folder.isDefinedModule()) { - return 7; - } - } - return 1; - } - if (element instanceof ICVSRemoteFile) { - return 2; - } - if (element instanceof CVSTagElement) { - CVSTagElement tagElement = (CVSTagElement)element; - if (tagElement.getTag().getType() == CVSTag.HEAD) { - return 0; - } else if (tagElement.getTag().getType() == CVSTag.BRANCH) { - return 4; - } else if (tagElement.getTag().getType() == CVSTag.VERSION) { - return 5; - } else if (tagElement.getTag().getType() == CVSTag.DATE){ - return 6; - }else{ - return 7; - } - } - if (element instanceof BranchCategory) { - return 4; - } - if (element instanceof VersionCategory) { - return 5; - } - if (element instanceof DateTagCategory){ - return 6; - } - return 0; - } - - public int compare(Viewer viewer, Object o1, Object o2) { - int cat1 = category(o1); - int cat2 = category(o2); - if (cat1 != cat2) return cat1 - cat2; - - if (o1 instanceof CVSTagElement && o2 instanceof CVSTagElement) { - CVSTag tag1 = ((CVSTagElement)o1).getTag(); - CVSTag tag2 = ((CVSTagElement)o2).getTag(); - if (tag1.getType() == CVSTag.BRANCH) { - return tag1.compareTo(tag2); - } else { - return -1 * tag1.compareTo(tag2); - } - } - - // Sort versions in reverse alphabetical order - if (o1 instanceof ICVSRemoteFolder && o2 instanceof ICVSRemoteFolder) { - ICVSRemoteFolder f1 = (ICVSRemoteFolder)o1; - ICVSRemoteFolder f2 = (ICVSRemoteFolder)o2; - if (f1.getName().equals(f2.getName())) { - return compare(f1, f2); - } - } - - if (o1 instanceof ICVSRepositoryLocation && o2 instanceof ICVSRepositoryLocation) { - return ((ICVSRepositoryLocation)o1).getLocation().compareTo(((ICVSRepositoryLocation)o2).getLocation()); - } - - return super.compare(viewer, o1, o2); - } - - /* - * Compare to remote folders whose names are the same. - */ - private int compare(ICVSRemoteFolder f1, ICVSRemoteFolder f2) { - CVSTag tag1 = f1.getTag(); - CVSTag tag2 = f2.getTag(); - if (tag1 == null) return 1; - if (tag2 == null) return -1; - return tag2.compareTo(tag1); - } -} - diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSActionDelegateWrapper.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSActionDelegateWrapper.java deleted file mode 100644 index 1cff07326..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSActionDelegateWrapper.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.ui.IActionDelegate; - -/** - * Superclass of CVS participant action delegates that uses the classname as the key - * to access the text from the resource bundle - */ -public class CVSActionDelegateWrapper extends ActionDelegateWrapper { - - public CVSActionDelegateWrapper(IActionDelegate delegate, ISynchronizePageConfiguration configuration) { - super(delegate, configuration); - Utils.initAction(this, getBundleKeyPrefix(), Policy.getBundle()); - } - - /** - * Return the key to the action text in the resource bundle. - * The default is the class name followed by a dot (.). - * @return the bundle key prefix - */ - protected String getBundleKeyPrefix() { - String name = getDelegate().getClass().getName(); - int lastDot = name.lastIndexOf("."); //$NON-NLS-1$ - if (lastDot == -1) { - return name; - } - return name.substring(lastDot + 1) + "."; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java deleted file mode 100644 index 81bf2c347..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; - -/** - * Action group that is used by CVS Change Set Capabilities - */ -public class CVSChangeSetActionGroup extends SynchronizePageActionGroup { - - private OpenChangeSetAction openCommitSet; - - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - openCommitSet = new OpenChangeSetAction(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) - */ - public void fillContextMenu(IMenuManager menu) { - if (getConfiguration().getParticipant().getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) { - appendToGroup( - menu, - ISynchronizePageConfiguration.FILE_GROUP, - openCommitSet); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java deleted file mode 100644 index b0e57b3eb..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.ui.synchronize.*; - - -public class CVSChangeSetCapability extends ChangeSetCapability { - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#supportsCheckedInChangeSets() - */ - public boolean supportsCheckedInChangeSets() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#supportsActiveChangeSets() - */ - public boolean supportsActiveChangeSets() { - return getActiveChangeSetManager() != null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#createCheckedInChangeSetCollector(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public SyncInfoSetChangeSetCollector createCheckedInChangeSetCollector(ISynchronizePageConfiguration configuration) { - return new CVSChangeSetCollector(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#getActionGroup() - */ - public SynchronizePageActionGroup getActionGroup() { - return new CVSChangeSetActionGroup(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#enableChangeSetsByDefault() - */ - public boolean enableChangeSetsByDefault() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java deleted file mode 100644 index 3083818a8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java +++ /dev/null @@ -1,441 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.text.DateFormat; -import java.util.Date; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; -import org.eclipse.team.ui.synchronize.*; - -/** - * Collector that fetches the log for incoming CVS change sets - */ -public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector implements LogEntryCacheUpdateHandler.ILogsFetchedListener { - - /* - * Constant used to add the collector to the configuration of a page so - * it can be accessed by the CVS custom actions - */ - public static final String CVS_CHECKED_IN_COLLECTOR = CVSUIPlugin.ID + ".CVSCheckedInCollector"; //$NON-NLS-1$ - - /* - * Constant used to store the log entry handler in the configuration so it can - * be kept around over layout changes - */ - private static final String LOG_ENTRY_HANDLER = CVSUIPlugin.ID + ".LogEntryHandler"; //$NON-NLS-1$ - - private static final String DEFAULT_INCOMING_SET_NAME = Policy.bind("CVSChangeSetCollector.0"); //$NON-NLS-1$ - - boolean disposed = false; - - private LogEntryCache logEntryCache; - - /* ***************************************************************************** - * Special sync info that has its kind already calculated. - */ - public class CVSUpdatableSyncInfo extends CVSSyncInfo { - public int kind; - public CVSUpdatableSyncInfo(int kind, IResource local, IResourceVariant base, IResourceVariant remote, Subscriber s) { - super(local, base, remote, s); - this.kind = kind; - } - - protected int calculateKind() throws TeamException { - return kind; - } - } - - private class DefaultCheckedInChangeSet extends CheckedInChangeSet { - - private Date date = new Date(); - - public DefaultCheckedInChangeSet(String name) { - setName(name); - } - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getAuthor() - */ - public String getAuthor() { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getDate() - */ - public Date getDate() { - return date; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ChangeSet#getComment() - */ - public String getComment() { - return ""; //$NON-NLS-1$ - } - - } - - private class CVSCheckedInChangeSet extends CheckedInChangeSet { - - private final ILogEntry entry; - - public CVSCheckedInChangeSet(ILogEntry entry) { - this.entry = entry; - String date = DateFormat.getDateTimeInstance().format(entry.getDate()); - String comment = HistoryView.flattenText(entry.getComment()); - setName("["+entry.getAuthor()+ "] (" + date +") " + comment); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getAuthor() - */ - public String getAuthor() { - return entry.getAuthor(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getDate() - */ - public Date getDate() { - return entry.getDate(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ChangeSet#getComment() - */ - public String getComment() { - return entry.getComment(); - } - } - - public CVSChangeSetCollector(ISynchronizePageConfiguration configuration) { - super(configuration); - configuration.setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, this); - } - - public synchronized LogEntryCacheUpdateHandler getLogEntryHandler() { - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); - if (handler == null) { - handler = initializeLogEntryHandler(getConfiguration()); - } - handler.setListener(this); - return handler; - } - - /* - * Initialize the log entry handler and place it in the configuration - */ - private LogEntryCacheUpdateHandler initializeLogEntryHandler(ISynchronizePageConfiguration configuration) { - final LogEntryCacheUpdateHandler logEntryHandler = new LogEntryCacheUpdateHandler(configuration); - configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); - // Use an action group to get notified when the configuration is disposed - configuration.addActionContribution(new SynchronizePageActionGroup() { - public void dispose() { - super.dispose(); - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); - if (handler != null) { - handler.shutdown(); - getConfiguration().setProperty(LOG_ENTRY_HANDLER, null); - } - } - }); - return logEntryHandler; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.SyncInfoSetChangeSetCollector#add(org.eclipse.team.core.synchronize.SyncInfo[]) - */ - protected void add(SyncInfo[] infos) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) - try { - handler.fetch(infos); - } catch (CVSException e) { - getConfiguration().getSyncInfoSet().addError(new TeamStatus(IStatus.ERROR, CVSUIPlugin.ID, 0, e.getMessage(), e, null)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#reset(org.eclipse.team.core.synchronize.SyncInfoSet) - */ - public void reset(SyncInfoSet seedSet) { - // Notify thet handler to stop any fetches in progress - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { - handler.stopFetching(); - } - super.reset(seedSet); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.views.HierarchicalModelProvider#dispose() - */ - public void dispose() { - // No longer listen for log entry changes - // (The handler is disposed with the page) - disposed = true; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) handler.setListener(null); - getConfiguration().setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, null); - logEntryCache = null; - super.dispose(); - } - - /** - * Fetch the log histories for the remote changes and use this information - * to add each resource to an appropriate commit set. - */ - private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { - performUpdate(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) { - addLogEntries(infos, logEntries, monitor); - } - }, true /* preserver expansion */, monitor); - } - - /* - * Add the following sync info elements to the viewer. It is assumed that these elements have associated - * log entries cached in the log operation. - */ - private void addLogEntries(SyncInfo[] commentInfos, LogEntryCache logs, IProgressMonitor monitor) { - try { - monitor.beginTask(null, commentInfos.length * 10); - if (logs != null) { - for (int i = 0; i < commentInfos.length; i++) { - addSyncInfoToCommentNode(commentInfos[i], logs); - monitor.worked(10); - } - } - } finally { - monitor.done(); - } - } - - /* - * Create a node for the given sync info object. The logs should contain the log for this info. - * - * @param info the info for which to create a node in the model - * @param log the cvs log for this node - */ - private void addSyncInfoToCommentNode(SyncInfo info, LogEntryCache logs) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { - ICVSRemoteResource remoteResource = handler.getRemoteResource(info); - if(handler.getSubscriber() instanceof CVSCompareSubscriber && remoteResource != null) { - addMultipleRevisions(info, logs, remoteResource); - } else { - addSingleRevision(info, logs, remoteResource); - } - } - } - - /* - * Add a single log entry to the model. - * - * @param info - * @param logs - * @param remoteResource - */ - private void addSingleRevision(SyncInfo info, LogEntryCache logs, ICVSRemoteResource remoteResource) { - ILogEntry logEntry = logs.getLogEntry(remoteResource); - if (remoteResource != null && !remoteResource.isFolder()) { - // For incoming deletions grab the comment for the latest on the same branch - // which is now in the attic. - try { - String remoteRevision = ((ICVSRemoteFile) remoteResource).getRevision(); - if (isDeletedRemotely(info)) { - ILogEntry[] logEntries = logs.getLogEntries(remoteResource); - for (int i = 0; i < logEntries.length; i++) { - ILogEntry entry = logEntries[i]; - String revision = entry.getRevision(); - if (entry.isDeletion() && ResourceSyncInfo.isLaterRevision(revision, remoteRevision)) { - logEntry = entry; - } - } - } - } catch (TeamException e) { - // continue and skip deletion checks - } - } - addRemoteChange(info, remoteResource, logEntry); - } - - /* - * Add multiple log entries to the model. - * - * @param info - * @param logs - * @param remoteResource - */ - private void addMultipleRevisions(SyncInfo info, LogEntryCache logs, ICVSRemoteResource remoteResource) { - ILogEntry[] logEntries = logs.getLogEntries(remoteResource); - if(logEntries == null || logEntries.length == 0) { - // If for some reason we don't have a log entry, try the latest - // remote. - addRemoteChange(info, null, null); - } else { - for (int i = 0; i < logEntries.length; i++) { - ILogEntry entry = logEntries[i]; - addRemoteChange(info, remoteResource, entry); - } - } - } - - private boolean isDeletedRemotely(SyncInfo info) { - int kind = info.getKind(); - if(kind == (SyncInfo.INCOMING | SyncInfo.DELETION)) return true; - if(SyncInfo.getDirection(kind) == SyncInfo.CONFLICTING && info.getRemote() == null) return true; - return false; - } - - /* - * Add the remote change to an incoming commit set - */ - private void addRemoteChange(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { - if (disposed) return; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if(handler != null && remoteResource != null && logEntry != null && handler.isRemoteChange(info)) { - if(requiresCustomSyncInfo(info, remoteResource, logEntry)) { - info = new CVSUpdatableSyncInfo(info.getKind(), info.getLocal(), info.getBase(), (RemoteResource)logEntry.getRemoteFile(), ((CVSSyncInfo)info).getSubscriber()); - try { - info.init(); - } catch (TeamException e) { - // this shouldn't happen, we've provided our own calculate kind - } - } - // Only add the info if the base and remote differ - IResourceVariant base = info.getBase(); - IResourceVariant remote = info.getRemote(); - if ((base == null && remote != null) || (remote == null && base != null) || !base.equals(remote)) { - synchronized(this) { - ChangeSet set = getChangeSetFor(logEntry); - if (set == null) { - set = createChangeSetFor(logEntry); - add(set); - } - set.add(info); - } - } - } else { - // The info was not retrieved for the remote change for some reason. - // Add the node to the root - addToDefaultSet(DEFAULT_INCOMING_SET_NAME, info); - } - } - - private void addToDefaultSet(String name, SyncInfo info) { - ChangeSet set; - synchronized(this) { - set = getChangeSetFor(name); - if (set == null) { - set = createDefaultChangeSet(name); - add(set); - } - set.add(info); - } - } - - private ChangeSet createDefaultChangeSet(String name) { - return new DefaultCheckedInChangeSet(name); - } - - private ChangeSet createChangeSetFor(ILogEntry logEntry) { - return new CVSCheckedInChangeSet(logEntry); - } - - private ChangeSet getChangeSetFor(ILogEntry logEntry) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set instanceof CheckedInChangeSet && - set.getComment().equals(logEntry.getComment()) && - ((CheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) { - return set; - } - } - return null; - } - - private ChangeSet getChangeSetFor(String name) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.getName().equals(name)) { - return set; - } - } - return null; - } - - private boolean requiresCustomSyncInfo(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { - // Only interested in non-deletions - if (logEntry.isDeletion() || !(info instanceof CVSSyncInfo)) return false; - // Only require a custom sync info if the remote of the sync info - // differs from the remote in the log entry - IResourceVariant remote = info.getRemote(); - if (remote == null) return true; - return !remote.equals(remoteResource); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#waitUntilDone(org.eclipse.core.runtime.IProgressMonitor) - */ - public void waitUntilDone(IProgressMonitor monitor) { - super.waitUntilDone(monitor); - monitor.worked(1); - // wait for the event handler to process changes. - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { - while(handler.getEventHandlerJob().getState() != Job.NONE) { - monitor.worked(1); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } - Policy.checkCanceled(monitor); - } - } - monitor.worked(1); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.LogEntryCacheUpdateHandler.ILogsFetchedListener#logEntriesFetched(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor) { - if (disposed) return; - // Hold on to the cache so we can use it while commit sets are visible - this.logEntryCache = logEntryCache; - handleRemoteChanges(set.getSyncInfos(), logEntryCache, monitor); - } - - public ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - if (logEntryCache != null) - return logEntryCache.getImmediatePredecessor(file); - return null; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java deleted file mode 100644 index b5c1c2456..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.*; - -/** - * Superclass for all CVS particpants (workspace, merge and compare) - */ -public class CVSParticipant extends SubscriberParticipant { - - private CVSChangeSetCapability capability; - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - // The decorator adds itself to the configuration - ILabelDecorator labelDecorator = new CVSParticipantLabelDecorator(configuration); - configuration.addLabelDecorator(labelDecorator); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#updateLabels(org.eclipse.team.ui.synchronize.ISynchronizeModelElement, org.eclipse.compare.CompareConfiguration, org.eclipse.core.runtime.IProgressMonitor) - */ - public void prepareCompareInput(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); - super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); - updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - - /** - * Helper method for updating compare editor labels - */ - protected static void updateLabelsForCVS(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) { - // Add the author to the remote or base - if (CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR)) { - SyncInfo info = getSyncInfo(element); - if (info != null) { - final IResourceVariant remote = info.getRemote(); - final IResourceVariant base = info.getBase(); - String remoteAuthor = null; - if (remote != null && !remote.isContainer()) { - try { - ILogEntry entry = ((ICVSRemoteFile)remote).getLogEntry(monitor); - remoteAuthor = entry.getAuthor(); - config.setRightLabel(Policy.bind("CVSParticipant.0", remote.getContentIdentifier(), remoteAuthor)); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - if (base != null && !base.isContainer()) { - try { - String baseAuthor; - if (remoteAuthor != null && remote.getContentIdentifier().equals(base.getContentIdentifier())) { - baseAuthor = remoteAuthor; - } else { - ILogEntry entry = ((ICVSRemoteFile)base).getLogEntry(monitor); - baseAuthor = entry.getAuthor(); - } - config.setAncestorLabel(Policy.bind("CVSParticipant.1", base.getContentIdentifier(), baseAuthor)); //$NON-NLS-1$ - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - } - } - } - - protected static SyncInfo getSyncInfo(ISynchronizeModelElement element) { - if (element instanceof IAdaptable) { - return (SyncInfo)((IAdaptable)element).getAdapter(SyncInfo.class); - } - return null; - } - - /** - * If the local is not modified and the base matches the local then - * cache the local contents as the contents of the base. - * @param element - * @throws CoreException - * @throws TeamException - */ - public static void deriveBaseContentsFromLocal(ISynchronizeModelElement element, IProgressMonitor monitor) throws TeamException { - SyncInfo info = getSyncInfo(element); - if (info == null) - return; - - // We need a base that is a file and a local that is a file - IResource local = info.getLocal(); - IResourceVariant base = info.getBase(); - if (base == null || base.isContainer() || local.getType() != IResource.FILE || !local.exists()) - return; - - // We can only use the local contents for incoming changes. - // Outgoing or conflicting changes imply that the local has changed - if ((info.getKind() & SyncInfo.DIRECTION_MASK) != SyncInfo.INCOMING) - return; - - try { - RemoteFile remoteFile = (RemoteFile)base; - if (!remoteFile.isContentsCached()) - (remoteFile).setContents((IFile)local, monitor); - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - // The file must have just been deleted - return; - } - throw CVSException.wrapException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getPreferencePages() - */ - public PreferencePage[] getPreferencePages() { - return addCVSPreferencePages(super.getPreferencePages()); - } - - public static PreferencePage[] addCVSPreferencePages(PreferencePage[] inheritedPages) { - PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1]; - for (int i = 0; i < inheritedPages.length; i++) { - pages[i] = inheritedPages[i]; - } - pages[pages.length - 1] = new ComparePreferencePage(); - pages[pages.length - 1].setTitle(Policy.bind("CVSParticipant.2")); //$NON-NLS-1$ - return pages; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getChangeSetCapability() - */ - public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = createChangeSetCapability(); - } - return capability; - } - - /** - * Create the change set capability for this particpant. - * @return the created capability - */ - protected CVSChangeSetCapability createChangeSetCapability() { - return new CVSChangeSetCapability(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#isViewerContributionsSupported() - */ - protected boolean isViewerContributionsSupported() { - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java deleted file mode 100644 index c3a034649..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelAction; - -/** - * Superclass of CVS participant actions that uses the classname as the key - * to access the text from the resource bundle - */ -public abstract class CVSParticipantAction extends SynchronizeModelAction { - - protected CVSParticipantAction(ISynchronizePageConfiguration configuration) { - super(null, configuration); - Utils.initAction(this, getBundleKeyPrefix(), Policy.getBundle()); - } - - protected CVSParticipantAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) { - super(null, configuration, provider); - Utils.initAction(this, bundleKey, Policy.getBundle()); - } - - /** - * Return the key to the action text in the resource bundle. - * The default is the class name followed by a dot (.). - * @return the bundle key prefix - */ - protected String getBundleKeyPrefix() { - String name = getClass().getName(); - int lastDot = name.lastIndexOf("."); //$NON-NLS-1$ - if (lastDot == -1) { - return name; - } - return name.substring(lastDot + 1) + "."; //$NON-NLS-1$ - } - - protected boolean needsToSaveDirtyEditors() { - int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); - return option != ICVSUIConstants.OPTION_NEVER; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#confirmSaveOfDirtyEditor() - */ - protected boolean confirmSaveOfDirtyEditor() { - int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); - return option == ICVSUIConstants.OPTION_PROMPT; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java deleted file mode 100644 index 2b749f7e4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.ui.CVSDecoration; -import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - - -class CVSParticipantLabelDecorator extends LabelProvider implements IPropertyChangeListener, ILabelDecorator { - private ISynchronizePageConfiguration configuration; - - public CVSParticipantLabelDecorator(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - // Listen for decorator changed to refresh the viewer's labels. - CVSUIPlugin.addPropertyChangeListener(this); - TeamUI.addPropertyChangeListener(this); - } - - public String decorateText(String input, Object element) { - try { - String text = input; - if (element instanceof ISynchronizeModelElement) { - IResource resource = ((ISynchronizeModelElement) element).getResource(); - if (resource != null && resource.getType() != IResource.ROOT) { - // Prepare the decoration but substitute revision and hide dirty indicator - CVSDecoration decoration = CVSLightweightDecorator.decorate(resource); - decoration.setRevision(getRevisionNumber((ISynchronizeModelElement) element)); - decoration.setDirty(false); - decoration.compute(); - // Update label - StringBuffer output = new StringBuffer(25); - if (decoration.getPrefix() != null) { - output.append(decoration.getPrefix()); - } - output.append(text); - if (decoration.getSuffix() != null) { - output.append(decoration.getSuffix()); - } - return output.toString(); - } - } - return text; - } catch (CVSException e) { - return input; - } - } - public Image decorateImage(Image base, Object element) { - return base; - } - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if(property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || property.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED)) { - Viewer viewer = configuration.getPage().getViewer(); - if(viewer instanceof StructuredViewer && !viewer.getControl().isDisposed()) { - ((StructuredViewer)viewer).refresh(true); - } - } - } - public void dispose() { - CVSUIPlugin.removePropertyChangeListener(this); - TeamUI.removePropertyChangeListener(this); - } - - protected String getRevisionNumber(ISynchronizeModelElement element) { - if(element instanceof SyncInfoModelElement) { - SyncInfo info = ((SyncInfoModelElement)element).getSyncInfo(); - if(info != null && info.getLocal().getType() == IResource.FILE && info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo)info; - ICVSRemoteResource remote = (ICVSRemoteResource) cvsInfo.getRemote(); - ICVSRemoteResource local; - try { - local = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(info.getLocal()); - } catch (CVSException e) { - local = null; - } - if(local == null) { - local = (ICVSRemoteResource)info.getBase(); - } - StringBuffer revisionString = new StringBuffer(); - String remoteRevision = getRevisionString(remote); - String localRevision = getRevisionString(local); - if(localRevision != null) { - revisionString.append(localRevision); - } - if(remoteRevision != null) { - revisionString.append( (localRevision != null ? " - " : "") + remoteRevision); //$NON-NLS-1$ //$NON-NLS-2$ - } - return revisionString.toString(); - } - } - return null; - } - - private String getRevisionString(ICVSRemoteResource remoteFile) { - if(remoteFile instanceof RemoteFile) { - return ((RemoteFile)remoteFile).getRevision(); - } - return null; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java deleted file mode 100644 index 3b801323c..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java +++ /dev/null @@ -1,334 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.client.PruneFolderVisitor; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -public abstract class CVSSubscriberOperation extends SynchronizeModelOperation { - - protected CVSSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(configuration, elements); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - // Divide the sync info by project - final Map projectSyncInfos = getProjectSyncInfoSetMap(); - monitor.beginTask(null, projectSyncInfos.size() * 100); - for (Iterator iter = projectSyncInfos.keySet().iterator(); iter.hasNext(); ) { - final IProject project = (IProject) iter.next(); - try { - // Pass the scheduling rule to the synchronizer so that sync change events - // and cache commits to disk are batched - EclipseSynchronizer.getInstance().run( - project, - new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - try { - CVSSubscriberOperation.this.run((SyncInfoSet)projectSyncInfos.get(project), monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - } - }, Policy.subMonitorFor(monitor, 100)); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - monitor.done(); - } - - /** - * Run the operation on the sync info in the given set. The sync info will be all - * from the same project. - * @param set the sync info set - * @param monitor a progress monitor - */ - protected abstract void run(SyncInfoSet set, IProgressMonitor monitor) throws TeamException; - - /* - * Indicate that the resource is out of sync if the sync state is not IN_SYNC - * or if the local doesn't exist but the remote does. - */ - protected boolean isOutOfSync(SyncInfo resource) { - if (resource == null) return false; - return (!(resource.getKind() == 0) || - (! resource.getLocal().exists() && resource.getRemote() != null)); - } - - protected void makeInSync(SyncInfo[] folders, IProgressMonitor monitor) throws TeamException { - // If a node has a parent that is an incoming folder creation, we have to - // create that folder locally and set its sync info before we can get the - // node itself. We must do this for all incoming folder creations (recursively) - // in the case where there are multiple levels of incoming folder creations. - monitor.beginTask(null, folders.length); - for (int i = 0; i < folders.length; i++) { - SyncInfo resource = folders[i]; - makeInSync(resource); - monitor.worked(1); - } - monitor.done(); - } - - protected boolean makeInSync(SyncInfo info) throws TeamException { - if (isOutOfSync(info)) { - SyncInfo parent = getParent(info); - if (parent == null) { - if (info.getLocal().getType() == IResource.ROOT) { - // ROOT should be null - return true; - } else { - // No other ancestors should be null. Log the problem. - CVSUIPlugin.log(IStatus.WARNING, Policy.bind("CVSSubscriberAction.0", info.getLocal().getFullPath().toString()), null); //$NON-NLS-1$ - return false; - } - } else { - if (!makeInSync(parent)) { - // The failed makeInSync will log any errors - return false; - } - } - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo= (CVSSyncInfo) info; - IStatus status = cvsInfo.makeInSync(); - if (status.getSeverity() == IStatus.ERROR) { - logError(status); - return false; - } - return true; - } - return false; - } else { - return true; - } - } - - protected void makeOutgoing(SyncInfo[] folders, IProgressMonitor monitor) throws TeamException { - // If a node has a parent that is an incoming folder creation, we have to - // create that folder locally and set its sync info before we can get the - // node itself. We must do this for all incoming folder creations (recursively) - // in the case where there are multiple levels of incoming folder creations. - monitor.beginTask(null, 100 * folders.length); - for (int i = 0; i < folders.length; i++) { - SyncInfo info = folders[i]; - makeOutgoing(info, Policy.subMonitorFor(monitor, 100)); - } - monitor.done(); - } - - private void makeOutgoing(SyncInfo info, IProgressMonitor monitor) throws TeamException { - if (info == null) return; - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo= (CVSSyncInfo) info; - IStatus status = cvsInfo.makeOutgoing(monitor); - if (status.getSeverity() == IStatus.ERROR) { - logError(status); - } - } - } - - /** - * Log an error associated with an operation. - * @param status - */ - protected void logError(IStatus status) { - CVSUIPlugin.log(status); - } - - /** - * Handle the exception by showing an error dialog to the user. - * Sync actions seem to need to be sync-execed to work - * @param t - */ - protected void handle(Exception t) { - CVSUIPlugin.openError(getShell(), getErrorTitle(), null, t, CVSUIPlugin.PERFORM_SYNC_EXEC | CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); - } - - /** - * Return the error title that will appear in any error dialogs shown to the user - * @return - */ - protected String getErrorTitle() { - return null; - } - - protected boolean canRunAsJob() { - return true; - } - - protected void pruneEmptyParents(SyncInfo[] nodes) throws CVSException { - // TODO: A more explicit tie in to the pruning mechanism would be prefereable. - // i.e. I don't like referencing the option and visitor directly - if (!CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) return; - ICVSResource[] cvsResources = new ICVSResource[nodes.length]; - for (int i = 0; i < cvsResources.length; i++) { - cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(nodes[i].getLocal()); - } - new PruneFolderVisitor().visit( - CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()), - cvsResources); - } - - public CVSSyncInfo getCVSSyncInfo(SyncInfo info) { - if (info instanceof CVSSyncInfo) { - return (CVSSyncInfo)info; - } - return null; - } - - protected SyncInfo getParent(SyncInfo info) throws TeamException { - return ((CVSSyncInfo)info).getSubscriber().getSyncInfo(info.getLocal().getParent()); - } - - protected IResource[] getIResourcesFrom(SyncInfo[] nodes) { - List resources = new ArrayList(nodes.length); - for (int i = 0; i < nodes.length; i++) { - resources.add(nodes[i].getLocal()); - } - return (IResource[]) resources.toArray(new IResource[resources.size()]); - } - - /** - * Prompt to overwrite those resources that could not be safely updated - * Note: This method is designed to be overridden by test cases. - * - * @return whether to perform the overwrite - */ - protected boolean promptForOverwrite(final SyncInfoSet syncSet) { - final int[] result = new int[] {Dialog.CANCEL}; - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - UpdateDialog dialog = new UpdateDialog(getShell(), syncSet); - result[0] = dialog.open(); - } - }); - return (result[0] == UpdateDialog.YES); - } - - /** - * Make the contents of the local resource match that of the remote - * without modifying the sync info of the local resource. - * If called on a new folder, the sync info will be copied. - */ - protected void makeRemoteLocal(SyncInfo info, IProgressMonitor monitor) throws TeamException { - IResourceVariant remote = info.getRemote(); - IResource local = info.getLocal(); - try { - if(remote==null) { - if (local.exists()) { - local.delete(IResource.KEEP_HISTORY, monitor); - } - } else { - if(remote.isContainer()) { - ensureContainerExists(info); - } else { - monitor.beginTask(null, 200); - try { - IFile localFile = (IFile)local; - if(local.exists()) { - localFile.setContents(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, true /*keep history*/, Policy.subMonitorFor(monitor, 100)); - } else { - ensureContainerExists(getParent(info)); - localFile.create(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, Policy.subMonitorFor(monitor, 100)); - } - } finally { - monitor.done(); - } - } - } - } catch(CoreException e) { - throw new CVSException(Policy.bind("UpdateMergeActionProblems_merging_remote_resources_into_workspace_1"), e); //$NON-NLS-1$ - } - } - - private boolean ensureContainerExists(SyncInfo info) throws TeamException { - IResource local = info.getLocal(); - // make sure that the parent exists - if (!local.exists()) { - if (!ensureContainerExists(getParent(info))) { - return false; - } - } - // make sure that the folder sync info is set; - if (isOutOfSync(info)) { - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo)info; - IStatus status = cvsInfo.makeInSync(); - if (status.getSeverity() == IStatus.ERROR) { - logError(status); - return false; - } - } - } - // create the folder if it doesn't exist - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local); - if (!cvsFolder.exists()) { - cvsFolder.mkdir(); - } - return true; - } - - /* - * Divide the sync info for the operation by project - */ - private Map getProjectSyncInfoSetMap() { - Map map = new HashMap(); - SyncInfoSet all = getSyncInfoSet(); - SyncInfo[] infos = all.getSyncInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IProject project = info.getLocal().getProject(); - SyncInfoSet set = (SyncInfoSet)map.get(project); - if (set == null) { - set = new SyncInfoSet(); - map.put(project, set); - } - set.add(info); - } - return map; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeWizard.java deleted file mode 100644 index 38ffdd435..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeWizard.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.team.internal.ccvs.ui.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutWizard; -import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantWizard; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; -import org.eclipse.team.ui.synchronize.ISynchronizeScope; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; - -/** - * This is the class registered with the org.eclipse.team.ui.synchronizeWizard - */ -public class CVSSynchronizeWizard extends SubscriberParticipantWizard { - - protected IResource[] getRootResources() { - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().roots(); - } - - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SubscriberParticipantWizard#getName() - */ - protected String getName() { - ISynchronizeParticipantDescriptor desc = TeamUI.getSynchronizeManager().getParticipantDescriptor(WorkspaceSynchronizeParticipant.ID); - if(desc != null) { - return desc.getName(); - } else { - return Policy.bind("CVSSynchronizeWizard.0"); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SubscriberParticipantWizard#createParticipant(org.eclipse.core.resources.IResource[]) - */ - protected SubscriberParticipant createParticipant(ISynchronizeScope scope) { - // First check if there is an existing matching participant - IResource[] roots = scope.getRoots(); - if (roots == null) { - roots = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().roots(); - } - WorkspaceSynchronizeParticipant participant = (WorkspaceSynchronizeParticipant)SubscriberParticipant.getMatchingParticipant(WorkspaceSynchronizeParticipant.ID, roots); - // If there isn't, create one and add to the manager - if (participant == null) { - return new WorkspaceSynchronizeParticipant(scope); - } else { - return participant; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SubscriberParticipantWizard#getImportWizard() - */ - protected IWizard getImportWizard() { - return new CheckoutWizard(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java deleted file mode 100644 index 089250d53..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.subscribers.ActiveChangeSet; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Dialog for creating and editing commit set - * title and comment - */ -public class CommitSetDialog extends Dialog { - - private final ActiveChangeSet set; - private CommitCommentArea commitCommentArea; - private Text nameText; - private Button useTitleButton; - private Button enterCommentButton; - private final String title; - private final String description; - private String comment; - - public CommitSetDialog(Shell parentShell, ActiveChangeSet set, IResource[] files, String title, String description) { - super(parentShell); - this.set = set; - this.title = title; - this.description = description; - if (files == null) { - files = set.getResources(); - } - - int shellStyle = getShellStyle(); - setShellStyle(shellStyle | SWT.RESIZE | SWT.MAX); - commitCommentArea = new CommitCommentArea(); - // Get a project from which the commit template can be obtained - if (files.length > 0) - commitCommentArea.setProject(files[0].getProject()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - getShell().setText(title); - Composite composite = (Composite)super.createDialogArea(parent); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createWrappingLabel(composite, description); - createNameArea(composite); - - if (hasCommitTemplate()) { - if (set.hasComment()) { - // Only set the comment if the set has a custom comment. - // Otherwise, the template should be used - comment = set.getComment(); - commitCommentArea.setProposedComment(comment); - } - } else { - comment = set.getComment(); - commitCommentArea.setProposedComment(comment); - createOptionsArea(composite); - } - - commitCommentArea.createArea(composite); - commitCommentArea.addPropertyChangeListener(new IPropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty() == CommitCommentArea.OK_REQUESTED) { - okPressed(); - } else if (event.getProperty() == CommitCommentArea.COMMENT_MODIFIED) { - comment = (String)event.getNewValue(); - updateEnablements(); - } - } - }); - - initializeValues(); - updateEnablements(); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.COMMIT_SET_DIALOG); - Dialog.applyDialogFont(parent); - return composite; - } - - private void createNameArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = 0; - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - layout.numColumns = 2; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - composite.setFont(parent.getFont()); - - Label label = new Label(composite, SWT.NONE); - label.setText(Policy.bind("CommitSetDialog.0")); //$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.BEGINNING)); - - nameText = new Text(composite, SWT.BORDER); - nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - nameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateEnablements(); - } - }); - } - - private void initializeValues() { - String initialText = set.getTitle(); - if (initialText == null) initialText = ""; //$NON-NLS-1$ - nameText.setText(initialText); - - if (useTitleButton != null) { - useTitleButton.setSelection(!set.hasComment()); - enterCommentButton.setSelection(set.hasComment()); - } - } - - private void createOptionsArea(Composite composite) { - useTitleButton = createRadioButton(composite, Policy.bind("CommitSetDialog.2")); //$NON-NLS-1$ - enterCommentButton = createRadioButton(composite, Policy.bind("CommitSetDialog.3")); //$NON-NLS-1$ - SelectionAdapter listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateEnablements(); - } - }; - useTitleButton.addSelectionListener(listener); - enterCommentButton.addSelectionListener(listener); - - } - - private Button createRadioButton(Composite parent, String label) { - Button button = new Button(parent, SWT.RADIO); - button.setText(label); - button.setLayoutData(new GridData()); - return button; - } - - private void updateEnablements() { - commitCommentArea.setEnabled(isUseCustomComment()); - String name = nameText.getText(); - if (name == null && name.length() == 0) { - setPageComplete(false); - return; - } - if (isUseCustomComment()) { - if (comment == null || comment.length() == 0) { - setPageComplete(false); - return; - } - } - setPageComplete(true); - } - - final protected void setPageComplete(boolean complete) { - Button okButton = getButton(IDialogConstants.OK_ID); - if(okButton != null ) { - okButton.setEnabled(complete); - } - } - - private boolean hasCommitTemplate() { - return commitCommentArea.hasCommitTemplate(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - set.setTitle(nameText.getText()); - if (isUseCustomComment()) { - // Call getComment so the comment gets saved - set.setComment(commitCommentArea.getComment()); - } else { - set.setComment(null); - } - super.okPressed(); - } - - private boolean isUseCustomComment() { - return enterCommentButton == null || enterCommentButton.getSelection(); - } - - protected Label createWrappingLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT | SWT.WRAP); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - data.horizontalIndent = 0; - data.grabExcessHorizontalSpace = true; - data.widthHint = 200; - label.setLayoutData(data); - return label; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - updateEnablements(); - return control; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java deleted file mode 100644 index fa088f061..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.util.Arrays; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.subscribers.SubscriberChangeSetCollector; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction; -import org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; - -public class CompareParticipant extends CVSParticipant implements IPropertyChangeListener { - - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_1"; //$NON-NLS-1$ - public static final String NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_2"; //$NON-NLS-1$ - - /** - * Actions for the compare particpant's toolbar - */ - public class CompareParticipantActionContribution extends SynchronizePageActionGroup { - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP, - new CompareRevertAction(configuration)); - - if (!configuration.getSite().isModal()) { - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP, - new CVSActionDelegateWrapper(new ShowAnnotationAction(), configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP, - new CVSActionDelegateWrapper(new ShowResourceInHistoryAction(), configuration)); - } - } - } - - private SyncInfoFilter contentComparison = new SyncInfoFilter() { - private SyncInfoFilter contentCompare = new SyncInfoFilter.ContentComparisonSyncInfoFilter(); - public boolean select(SyncInfo info, IProgressMonitor monitor) { - // Want to select infos whose contents do not match - return !contentCompare.select(info, monitor); - } - }; - - public CompareParticipant(CVSCompareSubscriber subscriber) { - setSubscriber(subscriber); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber) - */ - protected void setSubscriber(Subscriber subscriber) { - super.setSubscriber(subscriber); - if (CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) { - setSyncInfoFilter(contentComparison); - } - try { - ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSCompareSubscriber.ID); - setInitializationData(descriptor); - CVSCompareSubscriber s = getCVSCompareSubscriber(); - setSecondaryId(s.getId().getLocalName()); - } catch (CoreException e) { - CVSUIPlugin.log(e); - } - CVSUIPlugin.getPlugin().getPluginPreferences().addPropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getName() - */ - public String getName() { - return Policy.bind("CompareParticipant.0", getSubscriber().getName(), Utils.convertSelection(getSubscriber().roots())); //$NON-NLS-1$ - } - - /* - * Returns a merge participant that exist and is configured with the given set of resources, start, and end tags. - */ - public static CompareParticipant getMatchingParticipant(IResource[] resources, CVSTag tag) { - ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - if (reference.getId().equals(CVSCompareSubscriber.ID)) { - try { - CompareParticipant p = (CompareParticipant) reference.getParticipant(); - if (p.matches(resources, tag)) { - return p; - } - } catch (TeamException e) { - continue; - } - } - } - return null; - } - - /** - * Return whether this compare subscriber matches persisly the - * provided list of resources and the single tag. - * @param resources the resources - * @param tag the tag - * @return whether this compare subscriber matches persisly the - * provided list of resources and the single tag - */ - protected boolean matches(IResource[] resources, CVSTag tag) { - CVSTag existingTag = getCVSCompareSubscriber().getTag(); - // The tag can be null if the compare participant has a different tag for each root - if (existingTag != null) { - IResource[] roots = getResources(); - Arrays.sort(resources, Utils.resourceComparator); - Arrays.sort(roots, Utils.resourceComparator); - if (Arrays.equals(resources, roots) && existingTag.equals(tag)) { - return true; - } - } - return false; - } - - /** - * Return the subscriber as an instance of CVSCompareSubscriber. - * @return the subscriber as an instance of CVSCompareSubscriber - */ - public CVSCompareSubscriber getCVSCompareSubscriber() { - return (CVSCompareSubscriber)getSubscriber(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP); - configuration.addActionContribution(new CompareParticipantActionContribution()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#dispose() - */ - public void dispose() { - super.dispose(); - CVSUIPlugin.getPlugin().getPluginPreferences().removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) { - if (CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) { - setSyncInfoFilter(contentComparison); - } else { - setSyncInfoFilter(new FastSyncInfoFilter()); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#getLongTaskName() - */ - protected String getLongTaskName() { - return getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#getShortTaskName() - */ - protected String getShortTaskName() { - return Policy.bind("Participant.comparing"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipant#createChangeSetCapability() - */ - protected CVSChangeSetCapability createChangeSetCapability() { - return new CVSChangeSetCapability() { - public SubscriberChangeSetCollector getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#enableActiveChangeSetsFor(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { - return super.enableActiveChangeSetsFor(configuration) || - configuration.getComparisonType() == ISynchronizePageConfiguration.TWO_WAY; - } - }; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java deleted file mode 100644 index 5d60a4cd8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -/** - * Action in compare editor that reverts the local contents to match the contents on the server. - */ -public class CompareRevertAction extends CVSParticipantAction { - - public CompareRevertAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new CompareRevertOperation(configuration, elements); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java deleted file mode 100644 index fb34070b3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - - -public class CompareRevertOperation extends CVSSubscriberOperation { - protected CompareRevertOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(configuration, elements); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName() - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("CompareRevertAction.0", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#run(org.eclipse.team.core.subscribers.MutableSyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { - SyncInfo[] changed = syncSet.getSyncInfos(); - if (changed.length == 0) return; - - if(! promptForOverwrite(syncSet)) return; - - // The list of sync resources to be updated using "cvs update" - List updateShallow = new ArrayList(); - // A list of sync resource folders which need to be created locally - // (incoming addition or previously pruned) - Set parentCreationElements = new HashSet(); - - for (int i = 0; i < changed.length; i++) { - SyncInfo changedNode = changed[i]; - - // Make sure that parent folders exist - SyncInfo parent = getParent(changedNode); - if (parent != null && isOutOfSync(parent)) { - // We need to ensure that parents that are either incoming folder additions - // or previously pruned folders are recreated. - parentCreationElements.add(parent); - } - - IResource resource = changedNode.getLocal(); - if (resource.getType() == IResource.FILE) { - if (changedNode.getLocal().exists()) { - updateShallow.add(changedNode); - } else if (changedNode.getRemote() != null) { - updateShallow.add(changedNode); - } - } else { - // Special handling for folders to support shallow operations on files - // (i.e. folder operations are performed using the sync info already - // contained in the sync info. - if (isOutOfSync(changedNode)) { - parentCreationElements.add(changedNode); - } - } - - } - try { - monitor.beginTask(null, 100); - - if (parentCreationElements.size() > 0) { - makeInSync((SyncInfo[]) parentCreationElements.toArray(new SyncInfo[parentCreationElements.size()]), Policy.subMonitorFor(monitor, 25)); - } - if (updateShallow.size() > 0) { - runUpdate((SyncInfo[])updateShallow.toArray(new SyncInfo[updateShallow.size()]), Policy.subMonitorFor(monitor, 75)); - } - } finally { - monitor.done(); - } - return; - } - - private void runUpdate(SyncInfo[] infos, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100 * infos.length); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - makeRemoteLocal(info, Policy.subMonitorFor(monitor, 100)); - } - monitor.done(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedAction.java deleted file mode 100644 index 3ceb50829..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -public class ConfirmMergedAction extends CVSParticipantAction { - - public ConfirmMergedAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING}); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new ConfirmMergedOperation(configuration, elements); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedOperation.java deleted file mode 100644 index 52e245920..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ConfirmMergedOperation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * This action marks the local resource as merged by updating the base - * resource revision to match the remote resource revision - */ -public class ConfirmMergedOperation extends CVSSubscriberOperation { - - public ConfirmMergedOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(configuration, elements); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamOperation#getJobName() - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("SubscriberConfirmMergedAction.jobName", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws CVSException { - SyncInfo[] syncResources = syncSet.getSyncInfos(); - monitor.beginTask(null, 100 * syncResources.length); - try { - for (int i = 0; i < syncResources.length; i++) { - SyncInfo info = syncResources[i]; - if (!makeOutgoing(info, Policy.subMonitorFor(monitor, 100))) { - // Failure was logged in makeOutgoing - } - } - } catch (TeamException e) { - handle(e); - } finally { - monitor.done(); - } - } - - private boolean makeOutgoing(SyncInfo info, IProgressMonitor monitor) throws CVSException, TeamException { - monitor.beginTask(null, 100); - try { - CVSSyncInfo cvsInfo = getCVSSyncInfo(info); - if (cvsInfo == null) { - CVSUIPlugin.log(IStatus.ERROR, Policy.bind("SubscriberConfirmMergedAction.0", cvsInfo.getLocal().getFullPath().toString()), null); //$NON-NLS-1$ - return false; - } - // Make sure the parent is managed - ICVSFolder parent = CVSWorkspaceRoot.getCVSFolderFor(cvsInfo.getLocal().getParent()); - if (!parent.isCVSFolder()) { - // the parents must be made outgoing before the child can - SyncInfo parentInfo = cvsInfo.getSubscriber().getSyncInfo(parent.getIResource()); - if (!makeOutgoing(parentInfo, Policy.subMonitorFor(monitor, 20))) { - return false; - } - } - IStatus status = cvsInfo.makeOutgoing(Policy.subMonitorFor(monitor, 80)); - if (status.getSeverity() == IStatus.ERROR) { - logError(status); - return false; - } - return true; - } finally { - monitor.done(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java deleted file mode 100644 index b25c68d05..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java +++ /dev/null @@ -1,666 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.ref.SoftReference; -import java.util.*; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; -import org.eclipse.team.internal.core.BackgroundEventHandler; -import org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector; -import org.eclipse.team.ui.synchronize.*; - -/** - * This class wraps a LogEntryCache in order to clear entries once they are no longer - * in the subscriber. - */ -public class LogEntryCacheUpdateHandler extends BackgroundEventHandler { - - private static final int REMOVAL = 1; - private static final int CHANGE = 2; - private static final int FETCH_REQUEST = 3; - private static final int PAUSE = 4; - - /* - * Lock used to ensure that fetches are queued when the job is - * a non-system job. - */ - private final Object queueLock = new Object(); - - /* - * Exception used to stop processing so the job can be restarted as a non-system job - */ - private static final OperationCanceledException PAUSE_EXCEPTION = new OperationCanceledException(); - - /* - * Contants for configuring how long to wait for the job to be paused - * when a fetch is required and the job needs to be converted to a non-system - * job. If the wait time is elapsed, an exception is thrown. - */ - private static final int WAIT_INCREMENT = 10; - private static final int MAX_WAIT = 1000; - - /* - * Set that keeps track of all resource for which we haved fetched log entries - */ - private final SyncInfoTree collectedInfos = new SyncInfoTree(); - - /* - * The cache that hold the log entries while the job is running - */ - //private LogEntryCache logEntriesCache; - - /* - * SoftReference used to hold on to the log entry cache while - * the job is not running so the cache can be cleared if memory is low. - */ - private SoftReference cacheReference; - - /* - * Collector that forewards subscriber changes so that - * stale cache entries can be cleared. - */ - private final LogEntryResourceCollector collector; - - /* - * The subscriber generating the SyncInfo and log entries - */ - private final Subscriber subscriber; - - /* - * The accumulated list of updates that need to be dispatched - * (i.e. the cache should be purged of out-of-date resources). - * This list is only modified and accessed from the event processing - * thread. - */ - private final List updates = new ArrayList(); - - /* - * The accumulated list of fetches that have been requested - */ - private final List fetches = new ArrayList(); - private final ISynchronizePageConfiguration configuration; - - - /* - * Interface for notifying a single client that the infos have been fetched - */ - public interface ILogsFetchedListener { - - void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor); - - } - - /* - * The listener or null if noone is listening - */ - private ILogsFetchedListener listener; - - /* - * Subscriber resource collector that forwards subscriber changes - * through the handler so that stale cache entries can be cleared - */ - private class LogEntryResourceCollector extends SubscriberResourceCollector { - - public LogEntryResourceCollector(Subscriber subscriber) { - super(subscriber); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#remove(org.eclipse.core.resources.IResource) - */ - protected void remove(IResource resource) { - queueEvent(new ResourceEvent(resource, REMOVAL, IResource.DEPTH_INFINITE), false /* do not put in on the front of the queue*/); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.subscribers.SubscriberResourceCollector#change(org.eclipse.core.resources.IResource, int) - */ - protected void change(IResource resource, int depth) { - queueEvent(new ResourceEvent(resource, CHANGE, depth), false /* do not put in on the front of the queue*/); - } - } - - /* - * Custom event for queue a log entry fetch request - */ - private class FetchRequest extends Event { - private final SyncInfo[] infos; - public FetchRequest(SyncInfo[] infos) { - super(FETCH_REQUEST); - this.infos = infos; - } - public SyncInfo[] getInfos() { - return infos; - } - } - - public LogEntryCacheUpdateHandler(ISynchronizePageConfiguration configuration) { - super(Policy.bind("LogEntryCacheUpdateHandler.1"), Policy.bind("LogEntryCacheUpdateHandler.0")); //$NON-NLS-1$ //$NON-NLS-2$ - this.configuration = configuration; - this.subscriber = getSubscriber(configuration); - cacheReference = new SoftReference(new LogEntryCache()); - collector = new LogEntryResourceCollector(subscriber); - } - - private Subscriber getSubscriber(ISynchronizePageConfiguration configuration) { - return ((SubscriberParticipant)configuration.getParticipant()).getSubscriber(); - } - - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - public Subscriber getSubscriber() { - return subscriber; - } - - /** - * Set the listener that should receive notification when log entries - * have been fetched and are avalable. - * @param listener the listener or null - */ - public void setListener(ILogsFetchedListener listener) { - this.listener = listener; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#getJobFamiliy() - */ - protected Object getJobFamiliy() { - return ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#createEventHandlingJob() - */ - protected void createEventHandlingJob() { - super.createEventHandlingJob(); - Job job = getEventHandlerJob(); - job.setSystem(false); - job.setUser(false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#processEvent(org.eclipse.team.internal.core.BackgroundEventHandler.Event, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void processEvent(Event event, IProgressMonitor monitor) throws CoreException { - switch (event.getType()) { - case REMOVAL: - case CHANGE: - updates.add(event); - break; - case FETCH_REQUEST: - fetches.add(event); - break; - case PAUSE: - throw PAUSE_EXCEPTION; - } - - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#doDispatchEvents(org.eclipse.core.runtime.IProgressMonitor) - */ - protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { - boolean dispatched = false; - monitor.beginTask(null, 50); - dispatched |= updateCache(Policy.subMonitorFor(monitor, 20)); - dispatched |= processQueuedFetches(Policy.subMonitorFor(monitor, 80)); - monitor.done(); - return dispatched; - } - - /* - * Remove any stale or unneeded log entries from the cache. - * Return whether there were any entries to purge. - */ - private boolean updateCache(IProgressMonitor monitor) { - if (updates.isEmpty()) return false; - try { - collectedInfos.beginInput(); - // Cycle through the update events - for (Iterator iter = updates.iterator(); iter.hasNext();) { - Event event = (Event) iter.next(); - Policy.checkCanceled(monitor); - if (event.getType() == REMOVAL) { - remove(event.getResource(), ((ResourceEvent)event).getDepth()); - } else if (event.getType() == CHANGE) { - change(event.getResource(), ((ResourceEvent)event).getDepth()); - } - // Use the iterator to remove so that updates will not be lost - // if the job is cancelled and then restarted. - iter.remove(); - } - } finally { - collectedInfos.endInput(monitor); - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#shutdown() - */ - public void shutdown() { - super.shutdown(); - collector.dispose(); - // Probably not necessary as GC would take care of it but we'll do it anyway - if (cacheReference != null) { - LogEntryCache cache = (LogEntryCache)cacheReference.get(); - if (cache != null) { - cache.clearEntries(); - } - } - collectedInfos.clear(); - - } - - private void remove(IResource resource, int depth) { - collectedInfos.remove(resource, depth); - } - - private void remove(SyncInfo info) { - if (info != null) { - collectedInfos.remove(info.getLocal()); - LogEntryCache cache = (LogEntryCache)cacheReference.get(); - if (cache != null) - cache.clearEntries(getRemoteResource(info)); - } - } - - protected ICVSRemoteResource getRemoteResource(SyncInfo info) { - try { - ICVSRemoteResource remote = (ICVSRemoteResource) info.getRemote(); - ICVSRemoteResource local = CVSWorkspaceRoot.getRemoteResourceFor(info.getLocal()); - if(local == null) { - local = (ICVSRemoteResource)info.getBase(); - } - - boolean useRemote = true; - if (local != null && remote != null) { - String remoteRevision = getRevisionString(remote); - String localRevision = getRevisionString(local); - useRemote = useRemote(localRevision, remoteRevision); - } else if (remote == null) { - useRemote = false; - } - if (useRemote) { - return remote; - } else if (local != null) { - return local; - } - return null; - } catch (CVSException e) { - CVSUIPlugin.log(e); - return null; - } - } - - private boolean useRemote(String localRevision, String remoteRevision) { - boolean useRemote; - if (remoteRevision == null && localRevision == null) { - useRemote = true; - } else if (localRevision == null) { - useRemote = true; - } else if (remoteRevision == null) { - useRemote = false; - } else { - useRemote = ResourceSyncInfo.isLaterRevision(remoteRevision, localRevision); - } - return useRemote; - } - - private String getRevisionString(ICVSRemoteResource remoteFile) { - if(remoteFile instanceof RemoteFile) { - return ((RemoteFile)remoteFile).getRevision(); - } - return null; - } - - private void change(IResource resource, int depth) { - // We only need to remove collected log entries that don't apply - // any longer. They will be refetched when they are required. - SyncInfo[] collected = collectedInfos.getSyncInfos(resource, depth); - change(collected); - } - - private void change(SyncInfo[] collected) { - Subscriber subscriber = getSubscriber(); - for (int i = 0; i < collected.length; i++) { - try { - SyncInfo info = collected[i]; - SyncInfo newInfo = subscriber.getSyncInfo(info.getLocal()); - if (newInfo == null || !newInfo.equals(info)) { - // The cached log entry no longer applies to the new sync info. - // It will be refetched when required. - remove(info); - } - } catch (TeamException e) { - // Log and continue - CVSUIPlugin.log(e); - } - } - } - - /** - * Queue a request to fetch log entries for the given SyncInfo nodes. - * The event handler must be a non-system job when revision histories - * are fetched. - * @param infos the nodes whose log entries are to be fetched - */ - public void fetch(SyncInfo[] infos) throws CVSException { - synchronized(queueLock) { - Job job = getEventHandlerJob(); - if (job.isSystem() && job.getState() != Job.NONE) { - // queue an event to pause the processor - super.queueEvent(new Event(PAUSE), true /* put on the front of the queue */); - int count = 0; - while (job.getState() != Job.NONE && count < MAX_WAIT) { - count += WAIT_INCREMENT; - try { - Thread.sleep(WAIT_INCREMENT); // Wait a little while - } catch (InterruptedException e) { - // Ignore - } - } - if (job.getState() != Job.NONE) { - // The job never completed in the time aloted so throw an exception - throw new CVSException(Policy.bind("LogEntryCacheUpdateHandler.2")); //$NON-NLS-1$ - } - } - // Queue the event even if the job didn't stop in the time aloted - queueEvent(new FetchRequest(infos), false /* don't place at the end */); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.core.BackgroundEventHandler#queueEvent(org.eclipse.team.internal.core.BackgroundEventHandler.Event, boolean) - */ - protected void queueEvent(Event event, boolean front) { - // Override to snure that queues by this handler are serialized - synchronized(queueLock) { - Job job = getEventHandlerJob(); - if (job.getState() == Job.NONE) { - job.setSystem(event.getType() != FETCH_REQUEST); - } - super.queueEvent(event, front); - } - } - - /* - * Method invoked during event dispatch to fetch log entries - */ - private boolean processQueuedFetches(IProgressMonitor monitor) { - if (fetches.isEmpty()) return false; - try { - // Now perform the fetching - Map projectMapping = getFetchesByProject(); - if (projectMapping.isEmpty()) return true; - LogEntryCache logEntriesCache = (LogEntryCache)cacheReference.get(); - if (logEntriesCache == null) { - logEntriesCache = new LogEntryCache(); - cacheReference = new SoftReference(logEntriesCache); - } - monitor.beginTask(Policy.bind("CVSChangeSetCollector.4"), 100 * projectMapping.size()); //$NON-NLS-1$ - monitor.setTaskName(Policy.bind("CVSChangeSetCollector.4")); //$NON-NLS-1$ - for (Iterator iter = projectMapping.values().iterator(); iter.hasNext();) { - SyncInfoSet set = (SyncInfoSet) iter.next(); - fetchLogEntries(logEntriesCache, set, Policy.subMonitorFor(monitor, 90)); - fireFetchedNotification(logEntriesCache, set, Policy.subMonitorFor(monitor, 10)); - } - } finally { - // Clear the fetches even if we were cancelled. - // Restarting will need to re-request all infos - fetches.clear(); - monitor.done(); - } - return true; - } - - private void fireFetchedNotification(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { - if (listener != null) { - listener.logEntriesFetched(set, logEntriesCache, monitor); - } - } - - /* - * Return a map of IProject to SyncInfoSet as that is how entries are fetched. - * The set for each project includes all infos from the original set. - * This is one so that the completion notification contains all infos - * including those were a fetch was not required either because the - * entry was already cached or the resource has no history. - */ - private Map getFetchesByProject() { - Map result = new HashMap(); - for (Iterator iter = fetches.iterator(); iter.hasNext();) { - FetchRequest request = (FetchRequest) iter.next(); - SyncInfo[] infos = request.getInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IProject project = info.getLocal().getProject(); - SyncInfoSet infoSet = (SyncInfoSet)result.get(project); - if (infoSet == null) { - infoSet = new SyncInfoSet(); - result.put(project, infoSet); - } - infoSet.add(info); - } - } - return result; - } - - private boolean isFetchRequired(SyncInfo info) { - // We only need to fetch if we don't have the log entry already - // and the change is a remote change - return info.getLocal().getType() == IResource.FILE && !isLogEntryCached(info) && isRemoteChange(info); - - } - - /* - * Return whether the given SyncInfo is cached. If there is - * an info for the resource that does not match the given info, - * it is removed and false is returned. - */ - private boolean isLogEntryCached(SyncInfo info) { - SyncInfo collectedInfo = collectedInfos.getSyncInfo(info.getLocal()); - if (collectedInfo != null && !collectedInfo.equals(info)) { - remove(collectedInfo); - collectedInfo = null; - } - return collectedInfo != null; - } - - /* - * Return if this sync info should be considered as part of a remote change - * meaning that it can be placed inside an incoming commit set (i.e. the - * set is determined using the comments from the log entry of the file). - */ - protected boolean isRemoteChange(SyncInfo info) { - int kind = info.getKind(); - if(info.getLocal().getType() != IResource.FILE) return false; - if(info.getComparator().isThreeWay()) { - return (kind & SyncInfo.DIRECTION_MASK) != SyncInfo.OUTGOING; - } - // For two-way, the change is only remote if it has a remote or has a base locally - if (info.getRemote() != null) return true; - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)info.getLocal()); - try { - return file.getSyncBytes() != null; - } catch (CVSException e) { - // Log the error and exclude the file from consideration - CVSUIPlugin.log(e); - return false; - } - } - - /* - * Fetch the log entries for the info in the given set - */ - private void fetchLogEntries(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { - try { - if (subscriber instanceof CVSCompareSubscriber) { - CVSCompareSubscriber compareSubscriber = (CVSCompareSubscriber)subscriber; - fetchLogEntries(logEntriesCache, compareSubscriber, set, monitor); - } else { - // Run the log command once with no tags - fetchLogs(logEntriesCache, set, null, null, monitor); - } - } catch (CVSException e) { - handleException(e); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - - } - - private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, IProgressMonitor monitor) throws CVSException, InterruptedException { - Map localTagMap = getLocalTagMap(set); - monitor.beginTask(null, 100 * localTagMap.size()); - for (Iterator iter = localTagMap.keySet().iterator(); iter.hasNext();) { - CVSTag localTag = (CVSTag) iter.next(); - fetchLogEntries(logEntriesCache, compareSubscriber, set, localTag, Policy.subMonitorFor(monitor, 100)); - } - Policy.checkCanceled(monitor); - monitor.done(); - } - - /* - * Return the resources grouped by the tag found in the - * workspace. The map is CVSTag->SyncInfoSet - */ - private Map getLocalTagMap(SyncInfoSet set) { - Map result = new HashMap(); - for (Iterator iter = set.iterator(); iter.hasNext();) { - SyncInfo info = (SyncInfo) iter.next(); - CVSTag tag = getLocalTag(info); - SyncInfoSet tagSet = (SyncInfoSet)result.get(tag); - if (tagSet == null) { - tagSet = new SyncInfoSet(); - result.put(tag, tagSet); - } - tagSet.add(info); - } - return result; - } - - private CVSTag getLocalTag(SyncInfo syncInfo) { - try { - IResource local = syncInfo.getLocal(); - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(local); - CVSTag tag = null; - if(cvsResource.isFolder()) { - FolderSyncInfo info = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - if(info != null) { - tag = info.getTag(); - } - if (tag != null && tag.getType() == CVSTag.BRANCH) { - tag = Util.getAccurateFolderTag(local, tag); - } - } else { - tag = Util.getAccurateFileTag(cvsResource); - } - if(tag == null) { - tag = new CVSTag(); - } - return tag; - } catch (CVSException e) { - CVSUIPlugin.log(e); - return new CVSTag(); - } - } - - private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, CVSTag localTag, IProgressMonitor monitor) throws CVSException, InterruptedException { - if (compareSubscriber.isMultipleTagComparison()) { - Map rootToInfoMap = getRootToInfoMap(compareSubscriber, set); - monitor.beginTask(null, 100 * rootToInfoMap.size()); - for (Iterator iterator = rootToInfoMap.keySet().iterator(); iterator.hasNext();) { - IResource root = (IResource) iterator.next(); - Policy.checkCanceled(monitor); - fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(root), Policy.subMonitorFor(monitor, 100)); - } - monitor.done(); - } else { - Policy.checkCanceled(monitor); - fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(), monitor); - } - } - - private Map getRootToInfoMap(CVSCompareSubscriber compareSubscriber, SyncInfoSet set) { - Map rootToInfosMap = new HashMap(); - IResource[] roots = compareSubscriber.roots(); - for (Iterator iter = set.iterator(); iter.hasNext();) { - SyncInfo info = (SyncInfo) iter.next(); - IPath localPath = info.getLocal().getFullPath(); - for (int j = 0; j < roots.length; j++) { - IResource resource = roots[j]; - if (resource.getFullPath().isPrefixOf(localPath)) { - SyncInfoSet infoList = (SyncInfoSet)rootToInfosMap.get(resource); - if (infoList == null) { - infoList = new SyncInfoSet(); - rootToInfosMap.put(resource, infoList); - } - infoList.add(info); - break; // out of inner loop - } - } - - } - return rootToInfosMap; - } - - private void fetchLogs(LogEntryCache logEntriesCache, SyncInfoSet set, CVSTag localTag, CVSTag remoteTag, IProgressMonitor monitor) throws CVSException, InterruptedException { - ICVSRemoteResource[] remoteResources = getRemotesToFetch(set.getSyncInfos()); - if (remoteResources.length > 0) { - RemoteLogOperation logOperation = new RemoteLogOperation(getConfiguration().getSite().getPart(), remoteResources, localTag, remoteTag, logEntriesCache); - logOperation.execute(monitor); - } - } - - private ICVSRemoteResource[] getRemotesToFetch(SyncInfo[] infos) { - List remotes = new ArrayList(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - if (isFetchRequired(info)) { - ICVSRemoteResource remote = getRemoteResource(info); - if(remote != null) { - remotes.add(remote); - } - } - } - return (ICVSRemoteResource[]) remotes.toArray(new ICVSRemoteResource[remotes.size()]); - } - - /** - * Stop any current fetch in process. - */ - public void stopFetching() { - try { - getEventHandlerJob().cancel(); - getEventHandlerJob().join(); - } catch (InterruptedException e) { - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java deleted file mode 100644 index 16ce5a9af..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction; -import org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.PartInitException; - -public class MergeSynchronizeParticipant extends CVSParticipant { - - /** - * The id of a workspace action group to which additions actions can - * be added. - */ - public static final String TOOLBAR_CONTRIBUTION_GROUP = "toolbar_group"; //$NON-NLS-1$ - - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_1"; //$NON-NLS-1$ - public static final String NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_2"; //$NON-NLS-1$ - - private final static String CTX_ROOT = "root"; //$NON-NLS-1$ - private final static String CTX_ROOT_PATH = "root_resource"; //$NON-NLS-1$ - private final static String CTX_START_TAG = "start_tag"; //$NON-NLS-1$ - private final static String CTX_START_TAG_TYPE = "start_tag_type"; //$NON-NLS-1$ - private final static String CTX_END_TAG = "end_tag"; //$NON-NLS-1$ - private final static String CTX_END_TAG_TYPE = "end_tag_type"; //$NON-NLS-1$ - - /** - * Actions for the merge particpant's toolbar - */ - public class MergeParticipantActionContribution extends SynchronizePageActionGroup { - private MergeUpdateAction updateAction; - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - - updateAction = new MergeUpdateAction( - configuration, - getVisibleRootsSelectionProvider(), - "WorkspaceToolbarUpdateAction."); //$NON-NLS-1$ - updateAction.setPromptBeforeUpdate(true); - appendToGroup( - ISynchronizePageConfiguration.P_TOOLBAR_MENU, - TOOLBAR_CONTRIBUTION_GROUP, - updateAction); - - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP, - new MergeUpdateAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP, - new ConfirmMergedAction(configuration)); - - if (!configuration.getSite().isModal()) { - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP, - new CVSActionDelegateWrapper(new ShowAnnotationAction(), configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP, - new CVSActionDelegateWrapper(new ShowResourceInHistoryAction(), configuration)); - } - - } - } - - public MergeSynchronizeParticipant() { - super(); - } - - public MergeSynchronizeParticipant(CVSMergeSubscriber subscriber) { - setSubscriber(subscriber); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.TeamSubscriber) - */ - public void setSubscriber(Subscriber subscriber) { - super.setSubscriber(subscriber); - try { - ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSMergeSubscriber.ID); - setInitializationData(descriptor); - CVSMergeSubscriber s = (CVSMergeSubscriber)getSubscriber(); - setSecondaryId(s.getId().getLocalName()); - } catch (CoreException e) { - CVSUIPlugin.log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) - */ - public void init(String secondayId, IMemento memento) throws PartInitException { - super.init(secondayId, memento); - if(memento != null) { - ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSMergeSubscriber.ID); - String qualifier = descriptor.getId(); - String localname = secondayId; - if(qualifier == null || localname == null) { - throw new PartInitException(Policy.bind("MergeSynchronizeParticipant.8")); //$NON-NLS-1$ - } - try { - setSubscriber(read(new QualifiedName(qualifier, localname), memento)); - } catch (CVSException e) { - throw new PartInitException(Policy.bind("MergeSynchronizeParticipant.9"), e); //$NON-NLS-1$ - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) - */ - public void saveState(IMemento memento) { - super.saveState(memento); - CVSMergeSubscriber s = (CVSMergeSubscriber)getSubscriber(); - write(s, memento); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.AbstractSynchronizeParticipant#dispose() - */ - public void dispose() { - super.dispose(); - if(TeamUI.getSynchronizeManager().get(getId(), getSecondaryId()) == null) { - // If the participant isn't managed by the synchronize manager then we - // must ensure that the state cached in the synchronizer is flushed. - flushStateCache(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#getName() - */ - public String getName() { - return Policy.bind("CompareParticipant.0", ((CVSMergeSubscriber)getSubscriber()).getName(), Utils.convertSelection(getSubscriber().roots())); //$NON-NLS-1$ - } - - /* - * Returns the start tag for this merge participant. The start tag is actually stored with the subscriber. - */ - protected CVSTag getStartTag() { - return ((CVSMergeSubscriber)getSubscriber()).getStartTag(); - } - - /* - * Returns the end tag for this merge participant. The end tag is actually stored with the subscriber. - */ - protected CVSTag getEndTag() { - return ((CVSMergeSubscriber)getSubscriber()).getEndTag(); - } - - /* - * Returns a merge participant that exist and is configured with the given set of resources, start, and end tags. - */ - public static MergeSynchronizeParticipant getMatchingParticipant(IResource[] resources, CVSTag startTag, CVSTag endTag) { - ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - if (reference.getId().equals(CVSMergeSubscriber.ID)) { - MergeSynchronizeParticipant p; - try { - p = (MergeSynchronizeParticipant) reference.getParticipant(); - } catch (TeamException e) { - continue; - } - IResource[] roots = p.getResources(); - Arrays.sort(resources, Utils.resourceComparator); - Arrays.sort(roots, Utils.resourceComparator); - if (Arrays.equals(resources, roots) && p.getStartTag().equals(startTag) && p.getEndTag().equals(endTag)) { - return p; - } - } - } - return null; - } - - private void write(CVSMergeSubscriber s, IMemento memento) { - // start and end tags - CVSTag start = s.getStartTag(); - CVSTag end = s.getEndTag(); - memento.putString(CTX_START_TAG, start.getName()); - memento.putInteger(CTX_START_TAG_TYPE, start.getType()); - memento.putString(CTX_END_TAG, end.getName()); - memento.putInteger(CTX_END_TAG_TYPE, end.getType()); - - // resource roots - IResource[] roots = s.roots(); - for (int i = 0; i < roots.length; i++) { - IResource resource = roots[i]; - IMemento rootNode = memento.createChild(CTX_ROOT); - rootNode.putString(CTX_ROOT_PATH, resource.getFullPath().toString()); - } - } - - private CVSMergeSubscriber read(QualifiedName id, IMemento memento) throws CVSException { - CVSTag start = new CVSTag(memento.getString(CTX_START_TAG), memento.getInteger(CTX_START_TAG_TYPE).intValue()); //$NON-NLS-1$ //$NON-NLS-2$ - CVSTag end = new CVSTag(memento.getString(CTX_END_TAG), memento.getInteger(CTX_END_TAG_TYPE).intValue()); //$NON-NLS-1$ //$NON-NLS-2$ - - IMemento[] rootNodes = memento.getChildren(CTX_ROOT); - if(rootNodes == null || rootNodes.length == 0) { - throw new CVSException(Policy.bind("MergeSynchronizeParticipant.10", id.toString())); //$NON-NLS-1$ - } - - List resources = new ArrayList(); - for (int i = 0; i < rootNodes.length; i++) { - IMemento rootNode = rootNodes[i]; - IPath path = new Path(rootNode.getString(CTX_ROOT_PATH)); //$NON-NLS-1$ - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path, true /* include phantoms */); - if(resource != null) { - resources.add(resource); - } else { - // log that a resource previously in the merge set is no longer in the workspace - CVSProviderPlugin.log(CVSStatus.INFO, Policy.bind("MergeSynchronizeParticipant.11", path.toString()), null); //$NON-NLS-1$ - } - } - if(resources.isEmpty()) { - throw new CVSException(Policy.bind("MergeSynchronizeParticipant.12", id.toString())); //$NON-NLS-1$ - } - IResource[] roots = (IResource[]) resources.toArray(new IResource[resources.size()]); - return new CVSMergeSubscriber(id, roots, start, end); - } - - private void flushStateCache() { - ((CVSMergeSubscriber)getSubscriber()).cancel(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, TOOLBAR_CONTRIBUTION_GROUP); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP); - configuration.setSupportedModes(ISynchronizePageConfiguration.INCOMING_MODE | ISynchronizePageConfiguration.CONFLICTING_MODE); - configuration.setMode(ISynchronizePageConfiguration.INCOMING_MODE); - configuration.addActionContribution(new MergeParticipantActionContribution()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#getLongTaskName() - */ - protected String getLongTaskName() { - return getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#getShortTaskName() - */ - protected String getShortTaskName() { - return Policy.bind("Participant.merging"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java deleted file mode 100644 index d844a77c6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.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.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - - -public class MergeUpdateAction extends CVSParticipantAction { - - public MergeUpdateAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - public MergeUpdateAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) { - super(configuration, provider, bundleKey); - } - - private boolean promptBeforeUpdate; - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - // Update works for all incoming and conflicting nodes - return new OrSyncInfoFilter(new FastSyncInfoFilter[] { - new SyncInfoDirectionFilter(SyncInfo.INCOMING), - new SyncInfoDirectionFilter(SyncInfo.CONFLICTING) - }); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new MergeUpdateOperation(configuration, elements, promptBeforeUpdate); - } - - public void setPromptBeforeUpdate(boolean prompt) { - promptBeforeUpdate = prompt; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateOperation.java deleted file mode 100644 index 3bc038108..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateOperation.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.team.internal.ccvs.ui.subscriber; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber; -import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * This action performs a "cvs update -j start -j end ..." to merge changes - * into the local workspace. - */ -public class MergeUpdateOperation extends SafeUpdateOperation { - - Subscriber currentSubcriber = null; - - protected MergeUpdateOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements, boolean promptBeforeUpdate) { - super(configuration, elements, promptBeforeUpdate); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("MergeUpdateAction.jobName", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#getOverwriteLocalChanges() - */ - protected boolean getOverwriteLocalChanges() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#updated(org.eclipse.core.resources.IResource[]) - */ - protected void updated(IResource[] resources) throws TeamException { - // Mark all succesfully updated resources as merged - if(resources.length > 0 && currentSubcriber != null) { - ((CVSMergeSubscriber)currentSubcriber).merged(resources); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#runUpdateDeletions(org.eclipse.team.core.synchronize.SyncInfo[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void runUpdateDeletions(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException { - // When merging, update deletions become outgoing deletions so just delete - // the files locally without unmanaging (so the sync info is kept to - // indicate an outgoing deletion - try { - monitor.beginTask(null, 100 * nodes.length); - for (int i = 0; i < nodes.length; i++) { - IResource resource = nodes[i].getLocal(); - if (resource.getType() == IResource.FILE) { - ((IFile)resource).delete(false /* force */, true /* keep local history */, Policy.subMonitorFor(monitor, 100)); - } - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#runSafeUpdate(org.eclipse.team.core.synchronize.SyncInfo[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void runSafeUpdate(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException { - if(nodes.length > 0) { - setSubscriber(nodes[0]); - CVSTag startTag = ((CVSMergeSubscriber)currentSubcriber).getStartTag(); - CVSTag endTag = ((CVSMergeSubscriber)currentSubcriber).getEndTag(); - - // Incoming additions require different handling then incoming changes and deletions - List additions = new ArrayList(); - List changes = new ArrayList(); - for (int i = 0; i < nodes.length; i++) { - SyncInfo resource = nodes[i]; - int kind = resource.getKind(); - if ((kind & SyncInfo.CHANGE_MASK) == SyncInfo.ADDITION) { - additions.add(resource); - } else { - changes.add(resource); - } - } - - try { - monitor.beginTask(null, (additions.size() + changes.size()) * 100); - if (!additions.isEmpty()) { - safeUpdate( - getIResourcesFrom((SyncInfo[]) additions.toArray(new SyncInfo[additions.size()])), - new Command.LocalOption[] { - Command.DO_NOT_RECURSE, - Command.makeArgumentOption(Update.JOIN, endTag.getName()) - }, - Policy.subMonitorFor(monitor, additions.size() * 100)); - } - if (!changes.isEmpty()) { - safeUpdate( - getIResourcesFrom((SyncInfo[]) changes.toArray(new SyncInfo[changes.size()])), - new Command.LocalOption[] { - Command.DO_NOT_RECURSE, - Command.makeArgumentOption(Update.JOIN, startTag.getName()), - Command.makeArgumentOption(Update.JOIN, endTag.getName()) - }, - Policy.subMonitorFor(monitor, changes.size() * 100)); - } - } finally { - monitor.done(); - } - } - } - - /** - * @param nodes - * @throws CVSException - */ - private void setSubscriber(SyncInfo node) throws CVSException { - // Assumption that all nodes are from the same subscriber. - currentSubcriber = ((CVSSyncInfo)node).getSubscriber(); - if (!(currentSubcriber instanceof CVSMergeSubscriber)) { - throw new CVSException(Policy.bind("MergeUpdateAction.invalidSubscriber", currentSubcriber.toString())); //$NON-NLS-1$ - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#overwriteUpdate(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void overwriteUpdate(SyncInfoSet set, IProgressMonitor monitor) throws TeamException { - SyncInfo[] nodes = set.getSyncInfos(); - if (nodes.length == 0) return; - setSubscriber(nodes[0]); - monitor.beginTask(null, 1000 * nodes.length); - try { - for (int i = 0; i < nodes.length; i++) { - makeRemoteLocal(nodes[i], Policy.subMonitorFor(monitor, 1000)); - } - } finally { - monitor.done(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java deleted file mode 100644 index 753a7db46..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; -import java.text.DateFormat; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ChangeSet; -import org.eclipse.team.core.subscribers.CheckedInChangeSet; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation.CompareTreeBuilder; -import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode; -import org.eclipse.team.ui.synchronize.*; - -class OpenChangeSetAction extends SynchronizeModelAction { - - protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) { - super(Policy.bind("OpenCommitSetAction.20"), configuration); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new AndSyncInfoFilter(new FastSyncInfoFilter[] { - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - return info.getLocal().getType() == IResource.FILE; - } - }, - new OrSyncInfoFilter(new FastSyncInfoFilter[] { - new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING }), - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - return !info.getComparator().isThreeWay(); - } - } - }) - }); - } - - private ChangeSet getChangeSet(IStructuredSelection selection) { - // First, check to see if a change set is selected directly - if (selection.size() == 1) { - Object o = selection.getFirstElement(); - if (o instanceof IAdaptable) { - ChangeSet set = (ChangeSet)((IAdaptable)o).getAdapter(ChangeSet.class); - if (set != null) - return set; - } - } - // Failing that, check to see if all the selected elements and their childen are in the same change set - return getChangeSet(selection.toArray()); - } - - private ChangeSet getChangeSet(Object[] elements) { - ChangeSet foundSet = null; - for (int i = 0; i < elements.length; i++) { - Object object = elements[i]; - ChangeSet set = getChangeSet((ISynchronizeModelElement)object); - if (set == null) return null; - if (foundSet == null) { - foundSet = set; - } else if (foundSet != set) { - return null; - } - } - return foundSet; - } - - private ChangeSet getChangeSet(ISynchronizeModelElement element) { - if (element == null) return null; - if (element instanceof IAdaptable) { - ChangeSet set = (ChangeSet)((IAdaptable)element).getAdapter(ChangeSet.class); - if (set != null) - return set; - } - return getChangeSet((ISynchronizeModelElement)element.getParent()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - boolean enabled = super.updateSelection(selection); - if (enabled) { - // The selection only contains appropriate files so - // only enable if the selection is contained within a single change set - ChangeSet set = getChangeSet(selection); - return set != null; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new SynchronizeModelOperation(configuration, elements) { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - SyncInfoSet set = getSyncInfoSet(); - SyncInfo[] infos = set.getSyncInfos(); - if (infos.length > 0) { - ICVSRepositoryLocation location = getLocation(infos[0]); - if (location == null) { - handle(new CVSException(Policy.bind("OpenCommitSetAction.21"))); //$NON-NLS-1$ - return; - } - CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null); - if (buildTrees(builder, infos)) { - try { - builder.cacheContents(monitor); - builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip()); - } catch (CVSException e) { - handle(e); - return; - } - } - } - } - - private String getCompareToolTip() { - IDiffElement[] elements = getSelectedDiffElements(); - for (int i = 0; i < elements.length; i++) { - IDiffElement element = elements[i]; - while (element != null) { - if (element instanceof ChangeSetDiffNode) { - return ((ChangeSetDiffNode)element).getName(); - } - element = element.getParent(); - } - } - return null; - } - - private String getCompareTitle() { - IDiffElement[] elements = getSelectedDiffElements(); - ChangeSet set = getChangeSet(elements); - if (set instanceof CheckedInChangeSet) { - CheckedInChangeSet cics = (CheckedInChangeSet)set; - String date = DateFormat.getDateTimeInstance().format(cics.getDate()); - return "[" + cics.getAuthor() + "] (" + date + ")"; - } - return "CVS Change"; - } - - private ICVSRepositoryLocation getLocation(SyncInfo info) { - IResourceVariant remote = info.getRemote(); - if (remote == null) { - remote = info.getBase(); - } - if (remote != null) { - return ((ICVSRemoteResource)remote).getRepository(); - } - return null; - } - - /* - * Build the trees that will be compared - */ - private boolean buildTrees(CompareTreeBuilder builder, SyncInfo[] infos) { - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IResourceVariant remote = info.getRemote(); - if (remote == null) { - IResourceVariant predecessor = info.getBase(); - if (predecessor instanceof ICVSRemoteFile) { - builder.addToTrees((ICVSRemoteFile)predecessor, null); - } - } else if (remote instanceof ICVSRemoteFile) { - try { - ICVSRemoteFile predecessor = getImmediatePredecessor(remote); - builder.addToTrees(predecessor, (ICVSRemoteFile)remote); - } catch (TeamException e) { - handle(e); - return false; - } - } - } - return true; - } - }; - } - - private ICVSRemoteFile getImmediatePredecessor(IResourceVariant remote) throws TeamException { - CVSChangeSetCollector changeSetCollector = getChangeSetCollector(); - if (changeSetCollector != null) { - return changeSetCollector.getImmediatePredecessor((ICVSRemoteFile)remote); - } - return null; - } - - private CVSChangeSetCollector getChangeSetCollector() { - return (CVSChangeSetCollector)getConfiguration().getProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR); - } - -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndCommitAction.java deleted file mode 100644 index 6ad1b6448..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndCommitAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -public class OverrideAndCommitAction extends CVSParticipantAction { - - public OverrideAndCommitAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new WorkspaceCommitOperation(configuration, elements, true /* override */); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java deleted file mode 100644 index 3b74f7522..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -/** - * Runs an update command that will prompt the user for overwritting local - * changes to files that have non-mergeable conflicts. All the prompting logic - * is in the super class. - */ -public class OverrideAndUpdateAction extends CVSParticipantAction { - - public OverrideAndUpdateAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}); - } - - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new OverrideAndUpdateSubscriberOperation(configuration, elements); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateSubscriberOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateSubscriberOperation.java deleted file mode 100644 index e744c406f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateSubscriberOperation.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.OverrideAndUpdateOperation; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -public class OverrideAndUpdateSubscriberOperation extends CVSSubscriberOperation { - protected OverrideAndUpdateSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(configuration, elements); - } - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#shouldRun() - */ - public boolean shouldRun() { - SyncInfoSet syncSet = getSyncInfoSet(); - return(promptForOverwrite(syncSet)); - } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void run(SyncInfoSet set, IProgressMonitor monitor) throws TeamException { - try { - SyncInfo[] conflicts = set.getNodes(getConflictingAdditionFilter()); - List conflictingResources = new ArrayList(); - for (int i = 0; i < conflicts.length; i++) { - SyncInfo info = conflicts[i]; - conflictingResources.add(info.getLocal()); - } - new OverrideAndUpdateOperation(getPart(), set.getResources(), (IResource[]) conflictingResources.toArray(new IResource[conflictingResources.size()]), null /* tag */, false /* recurse */).run(monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - Policy.cancelOperation(); - } - } - private FastSyncInfoFilter getConflictingAdditionFilter() { - return new FastSyncInfoFilter.AndSyncInfoFilter( - new FastSyncInfoFilter[] { - new FastSyncInfoFilter.SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING}), - new FastSyncInfoFilter.SyncInfoChangeTypeFilter(new int[] {SyncInfo.ADDITION}) - }); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("UpdateAction.jobName", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java deleted file mode 100644 index 160aca024..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoChangeTypeFilter; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -/** - * Resets the dirty state of files whose contents match their base. - */ -public class RefreshDirtyStateAction extends CVSParticipantAction { - - public RefreshDirtyStateAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - // Only interested in outgoing changes - return new AndSyncInfoFilter(new FastSyncInfoFilter[] { - new SyncInfoDirectionFilter(new int[] {SyncInfo.OUTGOING, SyncInfo.CONFLICTING }), - new SyncInfoChangeTypeFilter(SyncInfo.CHANGE) - }); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.ui.IWorkbenchPart, org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation( - ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new RefreshDirtyStateOperation(configuration, elements); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java deleted file mode 100644 index a211580b2..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.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.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * Resets the dirty state of files whose contents match their base. - */ -public class RefreshDirtyStateOperation extends CVSSubscriberOperation { - - protected RefreshDirtyStateOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(configuration, elements); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void run(SyncInfoSet set, IProgressMonitor monitor) throws TeamException { - final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); - final SyncInfo[] infos = set.getSyncInfos(); - if (infos.length == 0) return; - IProject project = infos[0].getLocal().getProject(); - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - folder.run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, infos.length * 100); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IResource resource = info.getLocal(); - if (resource.getType() == IResource.FILE) { - if (comparator.compareContents((IFile)resource, info.getBase(), Policy.subMonitorFor(monitor, 100))) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - cvsFile.checkedIn(null, false /* not a commit */); - } - } - } - monitor.done(); - } - }, monitor); - - } - - protected String getErrorTitle() { - return Policy.bind("RefreshDirtyStateOperation.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) - */ - protected String getJobName() { - return Policy.bind("RefreshDirtyStateOperation.1"); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java deleted file mode 100644 index c3ef314cc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java +++ /dev/null @@ -1,434 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * This update action will update all mergable resources first and then prompt the - * user to overwrite any resources that failed the safe update. - * - * Subclasses should determine how the update should handle conflicts by implementing - * the getOverwriteLocalChanges() method. - */ -public abstract class SafeUpdateOperation extends CVSSubscriberOperation { - - private boolean promptBeforeUpdate = false; - - private SyncInfoSet skipped = new SyncInfoSet(); - - protected SafeUpdateOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements, boolean promptBeforeUpdate) { - super(configuration, elements); - this.promptBeforeUpdate = promptBeforeUpdate; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#shouldRun() - */ - public boolean shouldRun() { - return promptIfNeeded(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - skipped.clear(); - super.run(monitor); - try { - handleFailedUpdates(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#run(org.eclipse.team.ui.sync.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { - try { - monitor.beginTask(null, 100); - - // Remove the cases that are known to fail (adding them to skipped list) - removeKnownFailureCases(syncSet); - - // Run the update on the remaining nodes in the set - // The update will fail for conflicts that turn out to be non-automergable - safeUpdate(syncSet, Policy.subMonitorFor(monitor, 100)); - - // Remove all failed conflicts from the original sync set - syncSet.rejectNodes(new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - return skipped.getSyncInfo(info.getLocal()) != null; - } - }); - - // Signal for the ones that were updated - updated(syncSet.getResources()); - } finally { - monitor.done(); - } - } - - /** - * @param syncSet - * @return - */ - private SyncInfoSet removeKnownFailureCases(SyncInfoSet syncSet) { - // First, remove any known failure cases - FastSyncInfoFilter failFilter = getKnownFailureCases(); - SyncInfo[] willFail = syncSet.getNodes(failFilter); - syncSet.rejectNodes(failFilter); - for (int i = 0; i < willFail.length; i++) { - SyncInfo info = willFail[i]; - skipped.add(info); - } - return syncSet; - } - - private void handleFailedUpdates(IProgressMonitor monitor) throws TeamException { - // Handle conflicting files that can't be merged, ask the user what should be done. - if(! skipped.isEmpty()) { - if(getOverwriteLocalChanges()) { - // Ask the user if a replace should be performed on the remaining nodes - if(promptForOverwrite(skipped)) { - overwriteUpdate(skipped, monitor); - if (!skipped.isEmpty()) { - updated(skipped.getResources()); - } - } - } else { - // Warn the user that some nodes could not be updated. This can happen if there are - // files with conflicts that are not auto-mergeable. - warnAboutFailedResources(skipped); - } - } - } - - protected boolean getOverwriteLocalChanges(){ - return false; - } - - /** - * Perform a safe update on the resources in the provided set. Any included resources - * that cannot be updated safely wil be added to the skippedFiles list. - * @param syncSet the set containing the resources to be updated - * @param monitor - */ - protected void safeUpdate(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { - SyncInfo[] changed = syncSet.getSyncInfos(); - if (changed.length == 0) return; - - // The list of sync resources to be updated using "cvs update" - List updateShallow = new ArrayList(); - // A list of sync resource folders which need to be created locally - // (incoming addition or previously pruned) - Set parentCreationElements = new HashSet(); - // A list of sync resources that are incoming deletions. - // We do these first to avoid case conflicts - List updateDeletions = new ArrayList(); - - for (int i = 0; i < changed.length; i++) { - SyncInfo changedNode = changed[i]; - - // Make sure that parent folders exist - SyncInfo parent = getParent(changedNode); - if (parent != null && isOutOfSync(parent)) { - // We need to ensure that parents that are either incoming folder additions - // or previously pruned folders are recreated. - parentCreationElements.add(parent); - } - - IResource resource = changedNode.getLocal(); - int kind = changedNode.getKind(); - boolean willBeAttempted = false; - if (resource.getType() == IResource.FILE) { - // Not all change types will require a "cvs update" - // Some can be deleted locally without performing an update - switch (kind & SyncInfo.DIRECTION_MASK) { - case SyncInfo.INCOMING: - switch (kind & SyncInfo.CHANGE_MASK) { - case SyncInfo.DELETION: - // Incoming deletions can just be deleted instead of updated - updateDeletions.add(changedNode); - willBeAttempted = true; - break; - default: - // add the file to the list of files to be updated - updateShallow.add(changedNode); - willBeAttempted = true; - break; - } - break; - case SyncInfo.CONFLICTING: - switch (kind & SyncInfo.CHANGE_MASK) { - case SyncInfo.CHANGE: - // add the file to the list of files to be updated - updateShallow.add(changedNode); - willBeAttempted = true; - break; - } - break; - } - if (!willBeAttempted) { - skipped.add(syncSet.getSyncInfo(resource)); - } - } else { - // Special handling for folders to support shallow operations on files - // (i.e. folder operations are performed using the sync info already - // contained in the sync info. - if (isOutOfSync(changedNode)) { - parentCreationElements.add(changedNode); - } - } - - } - try { - monitor.beginTask(null, 100); - - if (parentCreationElements.size() > 0) { - makeInSync((SyncInfo[]) parentCreationElements.toArray(new SyncInfo[parentCreationElements.size()]), Policy.subMonitorFor(monitor, 25)); - } - if (updateDeletions.size() > 0) { - runUpdateDeletions((SyncInfo[])updateDeletions.toArray(new SyncInfo[updateDeletions.size()]), Policy.subMonitorFor(monitor, 25)); - } - if (updateShallow.size() > 0) { - runSafeUpdate((SyncInfo[])updateShallow.toArray(new SyncInfo[updateShallow.size()]), Policy.subMonitorFor(monitor, 50)); - } - } finally { - monitor.done(); - } - return; - } - - /** - * Perform an overwrite (unsafe) update on the resources in the provided set. - * The passed sync set may containe resources from multiple projects and - * it cannot be assumed that any scheduling rule is held when this method - * is invoked. - * @param syncSet the set containing the resources to be updated - * @param monitor - */ - protected abstract void overwriteUpdate(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException; - - /* - * Return a filter which selects the cases that we know ahead of time - * will fail on an update - */ - protected FastSyncInfoFilter getKnownFailureCases() { - return new OrSyncInfoFilter(new FastSyncInfoFilter[] { - // Conflicting additions of files will fail - new AndSyncInfoFilter(new FastSyncInfoFilter[] { - FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.ADDITION), - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - return info.getLocal().getType() == IResource.FILE; - } - } - }), - // Conflicting changes of files will fail if the local is not managed - // or is an addition - new AndSyncInfoFilter(new FastSyncInfoFilter[] { - FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - if (info.getLocal().getType() == IResource.FILE) { - try { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)info.getLocal()); - byte[] syncBytes = cvsFile.getSyncBytes(); - return (syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)); - } catch (CVSException e) { - CVSUIPlugin.log(e); - // Fall though and try to update - } - } - return false; - } - } - }), - // Conflicting changes involving a deletion on one side will aways fail - new AndSyncInfoFilter(new FastSyncInfoFilter[] { - FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - IResourceVariant remote = info.getRemote(); - IResourceVariant base = info.getBase(); - if (info.getLocal().exists()) { - // local != base and no remote will fail - return (base != null && remote == null); - } else { - // no local and base != remote - return (base != null && remote != null && !base.equals(remote)); - } - } - } - }), - // Conflicts where the file type is binary will work but are not merged - // so they should be skipped - new AndSyncInfoFilter(new FastSyncInfoFilter[] { - FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), - new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - IResource local = info.getLocal(); - if (local.getType() == IResource.FILE) { - try { - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local); - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes != null) { - return ResourceSyncInfo.isBinary(syncBytes); - } - } catch (CVSException e) { - // There was an error obtaining or interpreting the sync bytes - // Log it and skip the file - CVSProviderPlugin.log(e); - return true; - } - } - return false; - } - } - }), - // Outgoing changes may not fail but they are skipped as well - new SyncInfoDirectionFilter(SyncInfo.OUTGOING) - }); - } - - /** - * Warn user that some files could not be updated. - * Note: This method is designed to be overridden by test cases. - */ - protected void warnAboutFailedResources(final SyncInfoSet syncSet) { - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog.openInformation(getShell(), - Policy.bind("SafeUpdateAction.warnFilesWithConflictsTitle"), //$NON-NLS-1$ - Policy.bind("SafeUpdateAction.warnFilesWithConflictsDescription")); //$NON-NLS-1$ - } - }); - } - - /** - * This method is invoked for all resources in the sync set that are incoming deletions. - * It is done separately to allow deletions to be performed before additions that may - * be the same name with different letter case. - * @param nodes the SyncInfo nodes that are incoming deletions - * @param monitor - * @throws TeamException - */ - protected abstract void runUpdateDeletions(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException; - - /** - * This method is invoked for all resources in the sync set that are incoming changes - * (but not deletions: @see runUpdateDeletions) or conflicting changes. - * This method should only update those conflicting resources that are automergable. - * @param nodes the incoming or conflicting SyncInfo nodes - * @param monitor - * @throws TeamException - */ - protected abstract void runSafeUpdate(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException; - - protected void safeUpdate(IResource[] resources, LocalOption[] localOptions, IProgressMonitor monitor) throws TeamException { - try { - UpdateOnlyMergableOperation operation = new UpdateOnlyMergableOperation(getPart(), resources, localOptions); - operation.run(monitor); - addSkippedFiles(operation.getSkippedFiles()); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - Policy.cancelOperation(); - } - } - - /** - * Notification of all resource that were updated (either safely or othrwise) - */ - protected abstract void updated(IResource[] resources) throws TeamException; - - private void addSkippedFiles(IFile[] files) { - SyncInfoSet set = getSyncInfoSet(); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - skipped.add(set.getSyncInfo(file)); - } - } - - protected String getErrorTitle() { - return Policy.bind("UpdateAction.update"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("UpdateAction.jobName", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - } - - /** - * Confirm with the user what we are going to be doing. By default the update action doesn't - * prompt because the user has usually selected resources first. But in some cases, for example - * when performing a toolbar action, a confirmation prompt is nice. - * @param set the resources to be updated - * @return true if the update operation can continue, and false - * if the update has been cancelled by the user. - */ - private boolean promptIfNeeded() { - final SyncInfoSet set = getSyncInfoSet(); - final boolean[] result = new boolean[] {true}; - if(getPromptBeforeUpdate()) { - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - String sizeString = Integer.toString(set.size()); - String message = set.size() > 1 ? Policy.bind("UpdateAction.promptForUpdateSeveral", sizeString) : Policy.bind("UpdateAction.promptForUpdateOne", sizeString); //$NON-NLS-1$ //$NON-NLS-2$ - result[0] = MessageDialog.openQuestion(getShell(), Policy.bind("UpdateAction.promptForUpdateTitle", sizeString), message); //$NON-NLS-1$ - } - }); - } - return result[0]; - } - - public void setPromptBeforeUpdate(boolean prompt) { - this.promptBeforeUpdate = prompt; - } - - public boolean getPromptBeforeUpdate() { - return promptBeforeUpdate; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SyncInfoSetDetailsDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SyncInfoSetDetailsDialog.java deleted file mode 100644 index 9a8200f5f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SyncInfoSetDetailsDialog.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ccvs.ui.AdaptableResourceList; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * DetailsDialog that has a details area which shows the SyncInfos - * in a SyncInfoSet. - */ -public abstract class SyncInfoSetDetailsDialog extends DetailsDialog { - - private static final int WIDTH_HINT = 350; - private final static int SELECTION_HEIGHT_HINT = 100; - - private CheckboxTableViewer listViewer; - - private SyncInfoSet syncSet; - private Object[] selectedResources; - - /** - * @param parentShell - * @param dialogTitle - */ - public SyncInfoSetDetailsDialog(Shell parentShell, String dialogTitle, String detailsTitle, SyncInfoSet syncSet) { - super(parentShell, dialogTitle); - this.syncSet = syncSet; - //this.detailsTitle = detailsTitle; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.DetailsDialog#createDropDownDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - Composite composite = createComposite(parent); - - addResourcesArea(composite); - - // TODO: set F1 help - //WorkbenchHelp.setHelp(composite, IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG); - - return composite; - } - - /** - * @param composite - */ - private void addResourcesArea(Composite composite) { - //createWrappingLabel(composite, detailsTitle); - // add the selectable checkbox list - - listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = SELECTION_HEIGHT_HINT; - data.widthHint = WIDTH_HINT; - listViewer.getTable().setLayoutData(data); - - // set the contents of the list - listViewer.setLabelProvider(new WorkbenchLabelProvider() { - protected String decorateText(String input, Object element) { - if (element instanceof IResource) - return ((IResource)element).getFullPath().toString(); - else - return input; - } - }); - listViewer.setContentProvider(new WorkbenchContentProvider()); - setViewerInput(); - listViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - selectedResources = listViewer.getCheckedElements(); - } - }); - - addSelectionButtons(composite); - - } - - /** - * Add the selection and deselection buttons to the dialog. - * @param composite org.eclipse.swt.widgets.Composite - */ - private void addSelectionButtons(Composite composite) { - - Composite buttonComposite = new Composite(composite, SWT.RIGHT); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - buttonComposite.setLayout(layout); - GridData data = - new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); - data.grabExcessHorizontalSpace = true; - composite.setData(data); - - Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, Policy.bind("ReleaseCommentDialog.selectAll"), false); //$NON-NLS-1$ - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(true); - selectedResources = null; - } - }; - selectButton.addSelectionListener(listener); - - Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, Policy.bind("ReleaseCommentDialog.deselectAll"), false); //$NON-NLS-1$ - listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - listViewer.setAllChecked(false); - selectedResources = new Object[0]; - - } - }; - deselectButton.addSelectionListener(listener); - } - - protected void setViewerInput() { - if (listViewer == null || listViewer.getControl().isDisposed()) return; - listViewer.setInput(new AdaptableResourceList(getAllResources())); - if (selectedResources == null) { - listViewer.setAllChecked(true); - } else { - listViewer.setCheckedElements(selectedResources); - } - } - - protected void resetViewerInput() { - selectedResources = null; - setViewerInput(); - } - /** - * Return a list of all the resources that are currently under consideration by the dialog - */ - protected IResource[] getAllResources() { - return syncSet.getResources(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.team.internal.ui.DetailsDialog#updateEnablements() - */ - protected void updateEnablements() { - } - - /** - * @return - */ - public SyncInfoSet getSyncSet() { - return syncSet; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int id) { - if (id == IDialogConstants.OK_ID) { - filterSyncSet(); - } - super.buttonPressed(id); - } - - protected void filterSyncSet() { - // Keep only the checked resources - if (selectedResources != null) { - getSyncSet().selectNodes(new FastSyncInfoFilter() { - public boolean select(SyncInfo info) { - IResource local = info.getLocal(); - for (int i = 0; i < selectedResources.length; i++) { - if (local.equals(selectedResources[i])) return true; - } - return false; - } - }); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/UpdateDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/UpdateDialog.java deleted file mode 100644 index bd1ca383a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/UpdateDialog.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.team.internal.ccvs.ui.subscriber; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * This dialog prompts for the type of update which should take place - * (i.e. update of auto-mergable files or update of all ignore local - * changes. - */ -public class UpdateDialog extends SyncInfoSetDetailsDialog { - - public static final int YES = IDialogConstants.YES_ID; - - public UpdateDialog(Shell parentShell, SyncInfoSet syncSet) { - super(parentShell, Policy.bind("UpdateDialog.overwriteTitle"), Policy.bind("UpdateDialog.overwriteDetailsTitle"), syncSet); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.DetailsDialog#createMainDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected void createMainDialogArea(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - - // TODO: set F1 help - //WorkbenchHelp.setHelp(composite, IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG); - - createWrappingLabel(composite, Policy.bind("UpdateDialog.overwriteMessage")); //$NON-NLS-1$ - } - - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, YES, IDialogConstants.YES_LABEL, true); - createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); - super.createButtonsForButtonBar(parent); - } - - protected boolean includeOkButton() { - return false; - } - - protected boolean includeCancelButton() { - return false; - } - - protected void buttonPressed(int id) { - // hijack yes and no buttons to set the correct return - // codes. - if(id == YES || id == IDialogConstants.NO_ID) { - setReturnCode(id); - filterSyncSet(); - close(); - } else { - super.buttonPressed(id); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java deleted file mode 100644 index eea6dc9e7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -public class WorkspaceCommitAction extends CVSParticipantAction { - - public WorkspaceCommitAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - public WorkspaceCommitAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) { - super(configuration, provider, bundleKey); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.OUTGOING}); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new WorkspaceCommitOperation(configuration, elements, false /* override */); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java deleted file mode 100644 index 5079542d6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java +++ /dev/null @@ -1,354 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ChangeSet; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Commit; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.AddOperation; -import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.sync.ToolTipMessageDialog; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -public class WorkspaceCommitOperation extends CVSSubscriberOperation { - - private String comment; - private SyncInfoSet syncSet; - private boolean override; - - public WorkspaceCommitOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements, boolean override) { - super(configuration, elements); - this.override = override; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#getErrorTitle() - */ - protected String getErrorTitle() { - return Policy.bind("CommitAction.commitFailed"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.TeamOperation#getJobName() - */ - protected String getJobName() { - SyncInfoSet syncSet = getSyncInfoSet(); - return Policy.bind("CommitAction.jobName", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.TeamOperation#shouldRun() - */ - public boolean shouldRun() { - SyncInfoSet set = getSyncInfoSet(); - return !set.isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberOperation#getSyncInfoSet() - */ - protected SyncInfoSet getSyncInfoSet() { - if (syncSet == null) { - syncSet = super.getSyncInfoSet(); - if (!promptForConflictHandling(syncSet)) { - syncSet.clear(); - return syncSet; - } - try { - if (!promptForUnaddedHandling(syncSet)) { - syncSet.clear(); - return syncSet; - } - } catch (CVSException e) { - Utils.handle(e); - syncSet.clear(); - } - } - return syncSet; - } - - protected boolean promptForConflictHandling(SyncInfoSet syncSet) { - if (syncSet.hasConflicts() || syncSet.hasIncomingChanges()) { - if (override) { - // If overriding, prompt to ensure that is what the user wants - switch (promptForConflicts(syncSet)) { - case 0: - // Yes, synchronize conflicts as well - break; - case 1: - // No, stop here - return false; - case 2: - default: - // Cancel - return false; - } - } else { - // If there is a conflict in the syncSet, remove from sync set. - syncSet.removeConflictingNodes(); - syncSet.removeIncomingNodes(); - } - } - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { - - final SyncInfo[] changed = syncSet.getSyncInfos(); - if (changed.length == 0) return; - - // A list of files to be committed - final List commits = new ArrayList(); // of IResource - // New resources that are not yet under CVS control and need a "cvs add" - final List additions = new ArrayList(); // of IResource - // A list of incoming or conflicting file changes to be made outgoing changes - final List makeOutgoing = new ArrayList(); // of SyncInfo - // A list of out-of-sync folders that must be made in-sync - final List makeInSync = new ArrayList(); // of SyncInfo - - for (int i = 0; i < changed.length; i++) { - SyncInfo changedNode = changed[i]; - int kind = changedNode.getKind(); - IResource resource = changedNode.getLocal(); - - // Any parent folders should be made in-sync. - // Steps will be taken after the commit to prune any empty folders - SyncInfo parent = getParent(changedNode); - if (parent != null) { - if (isOutOfSync(parent)) { - makeInSync.add(parent); - } - } - - if (resource.getType() == IResource.FILE) { - // By default, all files are committed - commits.add(resource); - // Determine what other work needs to be done for the file - switch (kind & SyncInfo.DIRECTION_MASK) { - case SyncInfo.INCOMING: - // Convert the incoming change to an outgoing change - makeOutgoing.add(changedNode); - break; - case SyncInfo.OUTGOING: - switch (kind & SyncInfo.CHANGE_MASK) { - case SyncInfo.ADDITION: - // Outgoing addition. 'add' it before committing. - if (!isAdded(resource)) - additions.add(resource); - break; - case SyncInfo.DELETION: - // Outgoing deletion is handled by move/delete - // hook and EclipseSynchronizer - break; - case SyncInfo.CHANGE: - // Outgoing change. Just commit it. - break; - } - break; - case SyncInfo.CONFLICTING: - // Convert the conflicting change to an outgoing change - makeOutgoing.add(changedNode); - break; - } - } else { - if (((kind & SyncInfo.DIRECTION_MASK) == SyncInfo.OUTGOING) - && ((kind & SyncInfo.CHANGE_MASK) == SyncInfo.ADDITION)) { - // Outgoing folder additions must be added - additions.add(changedNode.getLocal()); - } else if (isOutOfSync(changedNode)) { - // otherwise, make any out-of-sync folders in-sync using the remote info - makeInSync.add(changedNode); - } - } - } - monitor.beginTask(null, 200); - - if (makeInSync.size() > 0) { - makeInSync((SyncInfo[]) makeInSync.toArray(new SyncInfo[makeInSync.size()]), Policy.subMonitorFor(monitor, 25)); - } - - if (makeOutgoing.size() > 0) { - makeOutgoing((SyncInfo[]) makeOutgoing.toArray(new SyncInfo[makeInSync.size()]), Policy.subMonitorFor(monitor, 25)); - } - - if (additions.size() != 0) { - add((IResource[])additions.toArray(new IResource[0]), Policy.subMonitorFor(monitor, 50)); - } - commit((IResource[])commits.toArray(new IResource[commits.size()]), Policy.subMonitorFor(monitor, 100)); - } - - private void commit(IResource[] commits, IProgressMonitor monitor) throws TeamException { - try { - new CommitOperation(getPart(), commits, - new Command.LocalOption[] { Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment) }) - .run(monitor); - } catch (InvocationTargetException e) { - throw TeamException.asTeamException(e); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - } - - private void add(IResource[] additions, IProgressMonitor monitor) throws TeamException { - try { - new AddOperation(getPart(), additions).run(monitor); - } catch (InvocationTargetException e1) { - throw TeamException.asTeamException(e1); - } catch (InterruptedException e1) { - throw new OperationCanceledException(); - } - } - - /** - * Prompts the user to determine how conflicting changes should be handled. - * Note: This method is designed to be overridden by test cases. - * @return 0 to sync conflicts, 1 to sync all non-conflicts, 2 to cancel - */ - protected int promptForConflicts(SyncInfoSet syncSet) { - String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}; - String question = Policy.bind("CommitSyncAction.questionRelease"); //$NON-NLS-1$ - String title = Policy.bind("CommitSyncAction.titleRelease"); //$NON-NLS-1$ - String[] tips = new String[] { - Policy.bind("CommitSyncAction.releaseAll"), //$NON-NLS-1$ - Policy.bind("CommitSyncAction.releasePart"), //$NON-NLS-1$ - Policy.bind("CommitSyncAction.cancelRelease") //$NON-NLS-1$ - }; - Shell shell = getShell(); - final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - dialog.open(); - } - }); - return dialog.getReturnCode(); - } - - /** - * Prompts the user for a release comment. - * Note: This method is designed to be overridden by test cases. - * @return the comment, or null to cancel - */ - protected String promptForComment(RepositoryManager manager, IResource[] resourcesToCommit) { - String proposedComment = getProposedComment(resourcesToCommit); - return manager.promptForComment(getShell(), resourcesToCommit, proposedComment); - } - - private String getProposedComment(IResource[] resourcesToCommit) { - StringBuffer comment = new StringBuffer(); - ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); - int numMatchedSets = 0; - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (containsOne(set, resourcesToCommit)) { - if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ - comment.append(set.getComment()); - numMatchedSets++; - } - } - return comment.toString(); - } - - private boolean containsOne(ChangeSet set, IResource[] resourcesToCommit) { - for (int j = 0; j < resourcesToCommit.length; j++) { - IResource resource = resourcesToCommit[j]; - if (set.contains(resource)) { - return true; - } - } - return false; - } - - protected IResource[] promptForResourcesToBeAdded(RepositoryManager manager, IResource[] unadded) { - return manager.promptForResourcesToBeAdded(getShell(), unadded); - } - - private boolean promptForUnaddedHandling(SyncInfoSet syncSet) throws CVSException { - if (syncSet.isEmpty()) return false; - - // accumulate any resources that are not under version control - IResource[] unadded = getUnaddedResources(syncSet); - - // prompt to get comment and any resources to be added to version control - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - IResource[] toBeAdded = promptForResourcesToBeAdded(manager, unadded); - if (toBeAdded == null) return false; // User cancelled. - comment = promptForComment(manager, syncSet.getResources()); - if (comment == null) return false; // User cancelled. - - // remove unshared resources that were not selected by the user - if (unadded != null && unadded.length > 0) { - List resourcesToRemove = new ArrayList(unadded.length); - for (int i = 0; i < unadded.length; i++) { - IResource unaddedResource = unadded[i]; - boolean included = false; - for (int j = 0; j < toBeAdded.length; j++) { - IResource resourceToAdd = toBeAdded[j]; - if (unaddedResource.equals(resourceToAdd)) { - included = true; - break; - } - } - if (!included) - resourcesToRemove.add(unaddedResource); - } - syncSet.removeAll((IResource[]) resourcesToRemove.toArray(new IResource[resourcesToRemove.size()])); - } - return true; - } - - private IResource[] getUnaddedResources(SyncInfoSet syncSet) throws CVSException { - // TODO: Should only get outgoing additions (since conflicting additions - // could be considered to be under version control already) - IResource[] resources = syncSet.getResources(); - List result = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (!isAdded(resource)) { - result.add(resource); - } - } - return (IResource[]) result.toArray(new IResource[result.size()]); - } - - private boolean isAdded(IResource resource) throws CVSException { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (cvsResource.isFolder()) { - return ((ICVSFolder)cvsResource).isCVSFolder(); - } else { - return cvsResource.isManaged(); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java deleted file mode 100644 index b40f36d70..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ActiveChangeSet; -import org.eclipse.team.core.subscribers.SubscriberChangeSetCollector; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.*; -import org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; - -public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipant { - - public static final String ID = "org.eclipse.team.cvs.ui.cvsworkspace-participant"; //$NON-NLS-1$ - - /** - * The id of a workspace action group to which additions actions can - * be added. - */ - public static final String TOOLBAR_CONTRIBUTION_GROUP = "toolbar_group_1"; //$NON-NLS-1$ - - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_1 = "context_group_1"; //$NON-NLS-1$ - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_2 = "context_group_2"; //$NON-NLS-1$ - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_3 = "context_group_3"; //$NON-NLS-1$ - public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_4 = "context_group_4"; //$NON-NLS-1$ - - private WorkspaceChangeSetCapability capability; - - /** - * CVS workspace action contribution - */ - public class WorkspaceActionContribution extends SynchronizePageActionGroup { - private WorkspaceCommitAction commitToolbar; - private WorkspaceUpdateAction updateToolbar; - - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - - updateToolbar = new WorkspaceUpdateAction( - configuration, - getVisibleRootsSelectionProvider(), - "WorkspaceToolbarUpdateAction."); //$NON-NLS-1$ - updateToolbar.setPromptBeforeUpdate(true); - appendToGroup( - ISynchronizePageConfiguration.P_TOOLBAR_MENU, - TOOLBAR_CONTRIBUTION_GROUP, - updateToolbar); - - commitToolbar = new WorkspaceCommitAction( - configuration, - getVisibleRootsSelectionProvider(), - "WorkspaceToolbarCommitAction."); //$NON-NLS-1$ - appendToGroup( - ISynchronizePageConfiguration.P_TOOLBAR_MENU, - TOOLBAR_CONTRIBUTION_GROUP, - commitToolbar); - - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_1, - new WorkspaceUpdateAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_1, - new WorkspaceCommitAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_2, - new OverrideAndUpdateAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_2, - new OverrideAndCommitAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_2, - new ConfirmMergedAction(configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new IgnoreAction(), configuration)); - if (!configuration.getSite().isModal()) { - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new GenerateDiffFileAction(), configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new BranchAction(), configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new ShowAnnotationAction(), configuration)); - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new ShowResourceInHistoryAction(), configuration)); - } - appendToGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_4, - new RefreshDirtyStateAction(configuration)); - } - } - - public class WorkspaceChangeSetCapability extends CVSChangeSetCapability { - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#createChangeSet(org.eclipse.team.core.synchronize.SyncInfo[]) - */ - public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, SyncInfo[] infos) { - ActiveChangeSet set = getActiveChangeSetManager().createSet(Policy.bind("WorkspaceChangeSetCapability.1"), new SyncInfo[0]); //$NON-NLS-1$ - CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, getResources(infos), - Policy.bind("WorkspaceChangeSetCapability.2"), Policy.bind("WorkspaceChangeSetCapability.3")); //$NON-NLS-1$ //$NON-NLS-2$ - dialog.open(); - if (dialog.getReturnCode() != InputDialog.OK) return null; - set.add(infos); - return set; - } - - private IResource[] getResources(SyncInfo[] infos) { - IResource[] resources = new IResource[infos.length]; - for (int i = 0; i < resources.length; i++) { - resources[i] = infos[i].getLocal(); - } - return resources; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#editChangeSet(org.eclipse.team.core.subscribers.ActiveChangeSet) - */ - public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) { - CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), - Policy.bind("WorkspaceChangeSetCapability.7"), Policy.bind("WorkspaceChangeSetCapability.8")); //$NON-NLS-1$ //$NON-NLS-2$ - dialog.open(); - if (dialog.getReturnCode() != InputDialog.OK) return; - // Nothing to do here as the set was updated by the dialog - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#getActiveChangeSetManager() - */ - public SubscriberChangeSetCollector getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } - } - - /** - * No arg contructor used for - * creation of persisted participant after startup - */ - public WorkspaceSynchronizeParticipant() { - } - - public WorkspaceSynchronizeParticipant(ISynchronizeScope scope) { - super(scope); - setSubscriber(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) - */ - public void init(String secondaryId, IMemento memento) throws PartInitException { - super.init(secondaryId, memento); - setSubscriber(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - ILabelDecorator labelDecorator = new CVSParticipantLabelDecorator(configuration); - configuration.addLabelDecorator(labelDecorator); - configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, TOOLBAR_CONTRIBUTION_GROUP); - configuration.addActionContribution(new WorkspaceActionContribution()); - configuration.setSupportedModes(ISynchronizePageConfiguration.ALL_MODES); - configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE); - - // Add context menu groups here to give the client displaying the - // page a chance to remove the context menu - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_1); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_2); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_3); - configuration.addMenuGroup( - ISynchronizePageConfiguration.P_CONTEXT_MENU, - CONTEXT_MENU_CONTRIBUTION_GROUP_4); - } - - protected ISynchronizeParticipantDescriptor getDescriptor() { - return TeamUI.getSynchronizeManager().getParticipantDescriptor(ID); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#updateLabels(org.eclipse.team.ui.synchronize.ISynchronizeModelElement, org.eclipse.compare.CompareConfiguration, org.eclipse.core.runtime.IProgressMonitor) - */ - public void prepareCompareInput(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - CVSParticipant.deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); - super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); - CVSParticipant.updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getPreferencePages() - */ - public PreferencePage[] getPreferencePages() { - return CVSParticipant.addCVSPreferencePages(super.getPreferencePages()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getChangeSetCapability() - */ - public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = new WorkspaceChangeSetCapability(); - } - return capability; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#isViewerContributionsSupported() - */ - protected boolean isViewerContributionsSupported() { - return true; - } - - public void refresh(IResource[] resources, IWorkbenchPartSite site) { - refresh(resources, getShortTaskName(), getLongTaskName(resources), site); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java deleted file mode 100644 index 6682d6ffe..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.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.team.internal.ccvs.ui.subscriber; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -public class WorkspaceUpdateAction extends CVSParticipantAction { - - private boolean promptBeforeUpdate; - - public WorkspaceUpdateAction(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - public WorkspaceUpdateAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) { - super(configuration, provider, bundleKey); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter() - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.INCOMING, SyncInfo.CONFLICTING}); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.SubscriberAction#getSubscriberOperation(org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new WorkspaceUpdateOperation(configuration, elements, promptBeforeUpdate); - } - - public void setPromptBeforeUpdate(boolean prompt) { - promptBeforeUpdate = prompt; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateOperation.java deleted file mode 100644 index 4a510bf6d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateOperation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.subscriber; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * This action performs an update for the CVSWorkspaceSubscriber. - */ -public class WorkspaceUpdateOperation extends SafeUpdateOperation { - - protected WorkspaceUpdateOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements, boolean promptBeforeUpdate) { - super(configuration, elements, promptBeforeUpdate); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#runUpdateDeletions(org.eclipse.team.core.synchronize.SyncInfo[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void runUpdateDeletions(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, nodes.length * 100); - for (int i = 0; i < nodes.length; i++) { - SyncInfo node = nodes[i]; - unmanage(node, Policy.subMonitorFor(monitor, 50)); - deleteAndKeepHistory(node.getLocal(), Policy.subMonitorFor(monitor, 50)); - } - pruneEmptyParents(nodes); - monitor.done(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#runSafeUpdate(org.eclipse.team.core.synchronize.SyncInfo[], org.eclipse.core.runtime.IProgressMonitor) - */ - protected void runSafeUpdate(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException { - safeUpdate(getIResourcesFrom(nodes), new LocalOption[] { Command.DO_NOT_RECURSE }, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#overwriteUpdate(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void overwriteUpdate(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { - try { - new ReplaceOperation(getPart(), syncSet.getResources(), null /* tag */, false /* recurse */) - .run(monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - Policy.cancelOperation(); - } - - } - - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#updated(org.eclipse.core.resources.IResource[]) - */ - protected void updated(IResource[] resources) throws TeamException { - // Do nothing - } - - private void unmanage(SyncInfo element, IProgressMonitor monitor) throws CVSException { - CVSWorkspaceRoot.getCVSResourceFor(element.getLocal()).unmanage(monitor); - } - - private void deleteAndKeepHistory(IResource resource, IProgressMonitor monitor) throws CVSException { - try { - if (!resource.exists()) return; - if (resource.getType() == IResource.FILE) - ((IFile)resource).delete(false /* force */, true /* keep history */, monitor); - else if (resource.getType() == IResource.FOLDER) - ((IFolder)resource).delete(false /* force */, true /* keep history */, monitor); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ToolTipMessageDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ToolTipMessageDialog.java deleted file mode 100644 index 1e06ab5e6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ToolTipMessageDialog.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.sync; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -/** - * A class that adds tool-tips to the buttons of a standard message dialog. - */ -public class ToolTipMessageDialog extends MessageDialog { - private String[] buttonToolTips; - /** - * Same as the MessageDialog constructor, with the addition of a button tooltip - * argument. The number of button tool tips must match the number of button labels. - */ - public ToolTipMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, String[] buttonToolTips, int defaultIndex) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); - this.buttonToolTips = buttonToolTips; - } - /** - * Method declared on MessageDialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - if (buttonToolTips != null) { - for (int i = 0; i < buttonToolTips.length; i++) { - getButton(i).setToolTipText(buttonToolTips[i]); - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java deleted file mode 100644 index 4a052014a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.ui.help.WorkbenchHelp; - -public class BranchPromptDialog extends DetailsDialog { - - private String branchTag = ""; //$NON-NLS-1$ - private String versionTag= ""; //$NON-NLS-1$ - private String versionName= ""; //$NON-NLS-1$ - - private boolean allStickyResources; - private boolean update; - - private Text versionText; - private Text branchText; - - private static final int TAG_AREA_HEIGHT_HINT = 200; - - // widgets; - private TagSource tagSource; - private TagSelectionArea tagArea; - private final IResource[] resources; - - public BranchPromptDialog(Shell parentShell, String title, IResource[] resources, boolean allResourcesSticky, String versionName) { - super(parentShell, title); - this.resources = resources; - this.tagSource = TagSource.create(resources); - this.allStickyResources = allResourcesSticky; - this.versionName = versionName; - } - - /** - * @see DetailsDialog#createMainDialogArea(Composite) - */ - protected void createMainDialogArea(Composite composite) { - // create message - Label label = new Label(composite, SWT.WRAP); - String message; - if(allStickyResources) { - message = Policy.bind("BranchWizardPage.pageDescriptionVersion"); //$NON-NLS-1$ - } else { - message = Policy.bind("BranchWizardPage.pageDescription"); //$NON-NLS-1$ - } - label.setText(message); - GridData data = new GridData( - GridData.GRAB_HORIZONTAL | - GridData.HORIZONTAL_ALIGN_FILL | - GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - - CVSWizardPage.createLabel(composite, Policy.bind("BranchWizardPage.branchName")); //$NON-NLS-1$ - branchText = CVSWizardPage.createTextField(composite); - branchText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - branchTag = branchText.getText(); - updateEnablements(); - updateVersionName(branchTag); - } - }); - addBranchContentAssist(); - - final Button check = new Button(composite, SWT.CHECK); - data = new GridData(); - data.horizontalSpan = 2; - check.setLayoutData(data); - check.setText(Policy.bind("BranchWizardPage.startWorking")); //$NON-NLS-1$ - check.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - update = check.getSelection(); - } - }); - check.setSelection(true); - update = true; - - label = new Label(composite, SWT.WRAP); - label.setText(Policy.bind("BranchWizardPage.specifyVersion")); //$NON-NLS-1$ - data = new GridData( - GridData.GRAB_HORIZONTAL | - GridData.HORIZONTAL_ALIGN_FILL | - GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - data.horizontalSpan = 2; - label.setLayoutData(data); - - CVSWizardPage.createLabel(composite, Policy.bind("BranchWizardPage.versionName")); //$NON-NLS-1$ - versionText = CVSWizardPage.createTextField(composite); - versionText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - versionTag = versionText.getText(); - updateEnablements(); - } - }); - - if(allStickyResources) { - versionText.setEditable(false); - versionText.setText(versionName); - } - - // F1 Help - WorkbenchHelp.setHelp(composite, IHelpContextIds.BRANCH_DIALOG); - Dialog.applyDialogFont(composite); - branchText.setFocus(); - } - - private void addBranchContentAssist() { - TagSource projectTagSource = LocalProjectTagSource.create(getSeedProject()); - if (projectTagSource != null) - TagContentAssistProcessor.createContentAssistant(branchText, projectTagSource, TagSelectionArea.INCLUDE_BRANCHES); - } - - private IProject getSeedProject() { - return resources[0].getProject(); - } - - /** - * Updates version name - */ - protected void updateVersionName(String branchName) { - if(versionText!=null && !allStickyResources) { - versionText.setText(Policy.bind("BranchWizardPage.versionPrefix") + branchName); //$NON-NLS-1$ - } - } - - /** - * @see DetailsDialog#createDropDownDialogArea(Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = TAG_AREA_HEIGHT_HINT; - composite.setLayoutData(gridData); - - tagArea = new TagSelectionArea(getShell(), tagSource, TagSelectionArea.INCLUDE_VERSIONS | TagSelectionArea.INCLUDE_BRANCHES, null); - tagArea.setTagAreaLabel(Policy.bind("BranchWizardPage.existingVersionsAndBranches")); //$NON-NLS-1$ - tagArea.setIncludeFilterInputArea(false); - tagArea.createArea(composite); - - return composite; - } - - /** - * Validates branch and version names - */ - protected void updateEnablements() { - String message = null; - - if (branchTag.length() == 0) { - message = ""; //$NON-NLS-1$ - } else { - IStatus status = CVSTag.validateTagName(branchTag); - if (!status.isOK()) { - message = Policy.bind("BranchWizard.branchNameWarning", status.getMessage()); //$NON-NLS-1$ - } else { - if(versionText!=null) { - status = CVSTag.validateTagName(versionText.getText()); - if (!status.isOK()) { - message = Policy.bind("BranchWizard.versionNameWarning", status.getMessage()); //$NON-NLS-1$ - } else { - if(versionTag.length() != 0 && versionTag.equals(branchTag)) { - message = Policy.bind("BranchWizard.branchAndVersionMustBeDifferent"); //$NON-NLS-1$ - } - } - } - } - } - setPageComplete(message == null); - setErrorMessage(message); - } - - /** - * Returns the branch tag name - */ - public String getBranchTagName() { - return branchTag; - } - - /** - * Returns the version tag name - */ - public String getVersionTagName() { - return versionTag; - } - - /** - * Returns the state of the update checkbox - */ - public boolean getUpdate() { - return update; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#isMainGrabVertical() - */ - protected boolean isMainGrabVertical() { - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFileElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFileElement.java deleted file mode 100644 index 4b4e05700..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFileElement.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.model.CVSResourceElement; -import org.eclipse.ui.PlatformUI; - -public class CVSFileElement extends CVSResourceElement { - - private ICVSFile file; - - public CVSFileElement(ICVSFile file) { - this.file = file; - } - - /** - * Initial implementation: return null; - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) { - return new Object[0]; - } - /** - * Initial implementation: return null. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(file.getName()); - } - /** - * Initial implementation: return the file's name and version - */ - public String getLabel(Object o) { - try { - ResourceSyncInfo info = file.getSyncInfo(); - if(info!=null) { - return file.getName() + " " + info.getRevision(); //$NON-NLS-1$ - } else { - return file.getName(); - } - } catch (TeamException e) { - handle(null, null, e); - return null; - } - } - /** - * @see IWorkbenchAdapter#getParent(Object) - */ - public Object getParent(Object o) { - return null; - } - - public ICVSFile getCVSFile() { - return file; - } - /** - * @see CVSResourceElement#getCVSResource() - */ - public ICVSResource getCVSResource() { - return file; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFolderElement.java deleted file mode 100644 index 865b95801..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/CVSFolderElement.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.model.CVSResourceElement; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.IWorkbenchAdapter; - -public class CVSFolderElement extends CVSResourceElement { - - private ICVSFolder folder; - private boolean includeUnmanaged; - - public CVSFolderElement(ICVSFolder folder, boolean includeUnmanaged) { - this.folder = folder; - this.includeUnmanaged = includeUnmanaged; - } - - /** - * Returns CVSResourceElement instances - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - ICVSResource[] children = folder.fetchChildren(monitor); - CVSResourceElement[] elements = new CVSResourceElement[children.length]; - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if(resource.isFolder()) { - elements[i] = new CVSFolderElement((ICVSFolder)resource, includeUnmanaged); - } else { - elements[i] = new CVSFileElement((ICVSFile)resource); - } - } - return elements; - } - - /** - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#isRemoteElement() - */ - public boolean isRemoteElement() { - return true; - } - - /** - * Overridden to append the version name to remote folders which - * have version tags and are top-level folders. - */ - public String getLabel(Object o) { - return folder.getName(); - } - - public ImageDescriptor getImageDescriptor(Object object) { - return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); - } - - /** - * @see IWorkbenchAdapter#getParent(Object) - */ - public Object getParent(Object o) { - return new CVSFolderElement(folder.getParent(), includeUnmanaged); - } - - /** - * @see CVSResourceElement#getCVSResource() - */ - public ICVSResource getCVSResource() { - return folder ; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java deleted file mode 100644 index a8266373d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.util.StringMatcher; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Workbench model element that returns a filtered list of tags - */ -public class FilteredTagList implements IWorkbenchAdapter, IAdaptable { - - private final TagSource tagSource; - private final int[] types; - private StringMatcher matcher; - - public FilteredTagList(TagSource tagSource, int[] types) { - this.tagSource = tagSource; - this.types = types; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - CVSTag[] tags = getTags(); - List filtered = new ArrayList(); - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (select(tag)) { - filtered.add(new TagElement(this, tag)); - } - } - return filtered.toArray(new Object[filtered.size()]); - } - - private boolean select(CVSTag tag) { - if (matcher == null) return true; - return matcher.match(tag.getName()); - } - - private CVSTag[] getTags() { - return tagSource.getTags(types); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - - public void setPattern(String pattern) { - if (!pattern.endsWith("*")) { //$NON-NLS-1$ - pattern += "*"; //$NON-NLS-1$ - } - matcher = new StringMatcher(pattern, true, false); - } - - public CVSTag[] getMatchingTags() { - CVSTag[] tags = getTags(); - List filtered = new ArrayList(); - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (select(tag)) { - filtered.add(tag); - } - } - return (CVSTag[])filtered.toArray(new CVSTag[filtered.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java deleted file mode 100644 index 1ffa1c7f1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.*; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * Tag source that gets its tags from the projects exist in the workspace - * and are mapped to the same repository as the seed project - */ -public class LocalProjectTagSource extends TagSource { - - public static TagSource create(IProject seedProject) { - try { - ICVSRemoteFolder seedFolder = ((ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(seedProject)); - ICVSRemoteFolder[] remoteFolders = getProjectRemoteFolders(seedFolder.getRepository()); - if (remoteFolders.length == 1) { - // There are no other projects to get tags from so return null - return null; - } - return new LocalProjectTagSource(seedFolder, remoteFolders); - } catch (CVSException e) { - // Log and return null - CVSUIPlugin.log(e); - return null; - } - } - - private ICVSRemoteFolder seedFolder; - private ICVSRemoteFolder[] remoteFolders; - - private LocalProjectTagSource(ICVSRemoteFolder seedFolder, ICVSRemoteFolder[] remoteFolders) { - this.seedFolder = seedFolder; - this.remoteFolders = remoteFolders; - } - - /* - * Return the list of remote folders for the projects in the workspace mapped to the given repository - */ - private static ICVSRemoteFolder[] getProjectRemoteFolders(ICVSRepositoryLocation repository) { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List result = new ArrayList(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - try { - if (project.isAccessible() && RepositoryProvider.isShared(project)) { - ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); - if (remote != null && remote.getRepository().equals(repository)) { - result.add(remote); - } - } - } catch (CVSException e) { - // Log and continue - CVSUIPlugin.log(e); - } - } - return (ICVSRemoteFolder[]) result.toArray(new ICVSRemoteFolder[result.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#refresh(boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - // This tag source should not be refreshed - return new CVSTag[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getLocation() - */ - public ICVSRepositoryLocation getLocation() { - return seedFolder.getRepository(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getShortDescription() - */ - public String getShortDescription() { - return Policy.bind("LocalProjectTagSource.0", Integer.toString(remoteFolders.length)); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // Does not commit tags - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getCVSResources() - */ - public ICVSResource[] getCVSResources() { - return remoteFolders; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getTags(int) - */ - public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } - // Accumulate the tags for all folders - Set allTags = new HashSet(); - for (int i = 0; i < remoteFolders.length; i++) { - ICVSRemoteFolder folder = remoteFolders[i]; - CVSTag[] tags = SingleFolderTagSource.getTags(folder, type); - allTags.addAll(Arrays.asList(tags)); - } - // Exclude the tags for the seedFolder - CVSTag[] tags = SingleFolderTagSource.getTags(seedFolder, type); - allTags.removeAll(Arrays.asList(tags)); - return (CVSTag[]) allTags.toArray(new CVSTag[allTags.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java deleted file mode 100644 index ac8f949a3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * A tag source for multiple folders. - * - * TODO: Temporarily a subclass of single folder until I - * can figure out how to handle the multi-folder case. - */ -public class MultiFolderTagSource extends SingleFolderTagSource { - - private final ICVSFolder[] folders; - - /* package */ MultiFolderTagSource(ICVSFolder[] folders) { - super(folders[0]); - this.folders = folders; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.SingleFolderTagSource#getShortDescription() - */ - public String getShortDescription() { - return Policy.bind("MultiFolderTagSource.0", Integer.toString(folders.length)); //$NON-NLS-1$ - } - - /** - * Return the folders of this tag source - * @return - */ - public ICVSFolder[] getFolders() { - return folders; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.SingleFolderTagSource#getCVSResources() - */ - public ICVSResource[] getCVSResources() { - return folders; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java deleted file mode 100644 index 30cd23307..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; - -/** - * A tag source for a single ICVSFile - */ -public class SingleFileTagSource extends TagSource { - - public static CVSTag[] fetchTagsFor(ICVSFile file, IProgressMonitor monitor) throws TeamException { - Set tagSet = new HashSet(); - ILogEntry[] entries = file.getLogEntries(monitor); - for (int j = 0; j < entries.length; j++) { - CVSTag[] tags = entries[j].getTags(); - for (int k = 0; k < tags.length; k++) { - tagSet.add(tags[k]); - } - } - return (CVSTag[])tagSet.toArray(new CVSTag[tagSet.size()]); - } - - private ICVSFile file; - private TagSource parentFolderTagSource; - - /* package */ /** - * - */ - public SingleFileTagSource(ICVSFile file) { - this.file = file; - parentFolderTagSource = TagSource.create(new ICVSResource[] { file.getParent() }); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getTags(int) - */ - public CVSTag[] getTags(int type) { - return parentFolderTagSource.getTags(type); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#refresh(org.eclipse.core.runtime.IProgressMonitor) - */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - CVSTag[] tags = fetchTagsFor(file, monitor); - commit(tags, false, monitor); - fireChange(); - return tags; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getLocation() - */ - public ICVSRepositoryLocation getLocation() { - RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); - ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(file); - return location; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getShortDescription() - */ - public String getShortDescription() { - return file.getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - parentFolderTagSource.commit(tags, replace, monitor); - fireChange(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getCVSResources() - */ - public ICVSResource[] getCVSResources() { - return new ICVSResource[] { file }; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java deleted file mode 100644 index 1c6bb08a8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.ui.PlatformUI; - -/** - * A tag source that returns the tags associated with a single remote folder - */ -public class SingleFolderTagSource extends TagSource { - - public static CVSTag[] getTags(ICVSFolder folder, int type) { - if (type == CVSTag.HEAD) - return new CVSTag[] { CVSTag.DEFAULT } ; - return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(folder, type); - } - - private ICVSFolder folder; - - /* package */ SingleFolderTagSource(ICVSFolder folder) { - this.folder = folder; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getTags(int) - */ - public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } - return getTags(getFolder(), type); - } - - /** - * Return the folder the tags are obtained from - * @return the folder the tags are obtained from - */ - public ICVSFolder getFolder() { - return folder; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#refresh(org.eclipse.core.runtime.IProgressMonitor) - */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(getFolder(), bestEffort /* recurse */, true /* notify */, monitor); - fireChange(); - return tags; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getLocation() - */ - public ICVSRepositoryLocation getLocation() { - RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); - ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(getFolder()); - return location; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getShortDescription() - */ - public String getShortDescription() { - return getFolder().getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { - try { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = getFolder(); - if (replace) { - CVSTag[] oldTags = manager.getKnownTags(folder); - manager.removeTags(folder, oldTags); - } - manager.addTags(folder, tags); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }, monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Ignore - } - fireChange(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getCVSResources() - */ - public ICVSResource[] getCVSResources() { - final ICVSResource[][] resources = new ICVSResource[][] { null }; - try { - getRunnableContext().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - resources[0] = folder.fetchChildren(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - return resources[0]; - } catch (InvocationTargetException e) { - CVSUIPlugin.log(CVSException.wrapException(e)); - } catch (InterruptedException e) { - // Ignore - } - return new ICVSResource[] { folder }; - } - - private IRunnableContext getRunnableContext() { - return PlatformUI.getWorkbench().getProgressService(); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java deleted file mode 100644 index 3a59a7026..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; -import org.eclipse.ui.help.WorkbenchHelp; - -public class TagAsVersionDialog extends DetailsDialog { - - private static final int TAG_AREA_HEIGHT_HINT = 200; - - private ITagOperation operation; - - private Text tagText; - private Button moveTagButton; - - private String tagName = ""; //$NON-NLS-1$ - private boolean moveTag = false; - - private TagSource tagSource; - - private TagSelectionArea tagArea; - - public TagAsVersionDialog(Shell parentShell, String title, ITagOperation operation) { - super(parentShell, title); - this.tagSource = operation.getTagSource(); - this.operation = operation; - } - - /** - * @see DetailsDialog#createMainDialogArea(Composite) - */ - protected void createMainDialogArea(Composite parent) { - // create message - Label label = new Label(parent, SWT.WRAP); - label.setText(Policy.bind("TagAction.enterTag")); //$NON-NLS-1$ - GridData data = new GridData( - GridData.GRAB_HORIZONTAL | - GridData.HORIZONTAL_ALIGN_FILL | - GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);; - label.setLayoutData(data); - - tagText = new Text(parent, SWT.SINGLE | SWT.BORDER); - tagText.setLayoutData(new GridData( - GridData.GRAB_HORIZONTAL | - GridData.HORIZONTAL_ALIGN_FILL)); - tagText.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - tagName = tagText.getText(); - updateEnablements(); - } - } - ); - - moveTagButton = new Button(parent, SWT.CHECK); - moveTagButton.setText(Policy.bind("TagAction.moveTag")); //$NON-NLS-1$ - moveTagButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - moveTagButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - moveTag = moveTagButton.getSelection(); - } - }); - - // Add F1 help - WorkbenchHelp.setHelp(parent, IHelpContextIds.TAG_AS_VERSION_DIALOG); - Dialog.applyDialogFont(parent); - } - - public boolean shouldMoveTag() { - return moveTag; - } - - /** - * @see DetailsDialog#createDropDownDialogArea(Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = TAG_AREA_HEIGHT_HINT; - composite.setLayoutData(gridData); - - tagArea = new TagSelectionArea(getShell(), tagSource, TagSelectionArea.INCLUDE_VERSIONS, null); - tagArea.setTagAreaLabel(Policy.bind("TagAction.existingVersions")); //$NON-NLS-1$ - tagArea.setIncludeFilterInputArea(false); - tagArea.createArea(composite); - tagArea.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) { - CVSTag tag = tagArea.getSelection(); - if (tag != null) { - tagText.setText(tag.getName()); - } - } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) { - CVSTag tag = tagArea.getSelection(); - if (tag != null) { - tagText.setText(tag.getName()); - okPressed(); - } - } - } - }); - return composite; - } - - /** - * Validates tag name - */ - protected void updateEnablements() { - String message = null; - if(tagName.length() == 0) { - message = ""; //$NON-NLS-1$ - } else { - IStatus status = CVSTag.validateTagName(tagName); - if (!status.isOK()) { - message = status.getMessage(); - } - } - setPageComplete(message == null); - setErrorMessage(message); - if (tagArea != null) { - tagArea.setFilter(tagName); - } - } - - /** - * Returns the tag name entered into this dialog - */ - public String getTagName() { - return tagName; - } - - /** - * @return - */ - public ITagOperation getOperation() { - operation.setTag(new CVSTag(tagName, CVSTag.VERSION)); - if (moveTag) { - operation.moveTag(); - } - return operation; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#isMainGrabVertical() - */ - protected boolean isMainGrabVertical() { - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java deleted file mode 100644 index 0f3a41d3e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java +++ /dev/null @@ -1,763 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -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.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider; -import org.eclipse.team.internal.ccvs.ui.repo.NewDateTagAction; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter.ProjectElementSorter; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * Allows configuration of the CVS tags that are shown within the workbench. - */ -public class TagConfigurationDialog extends Dialog { - - // show the resource contained within the roots - private TreeViewer cvsResourceTree; - - // shows the tags found on the selected resources - private CheckboxTableViewer cvsTagTree; - - // shows the defined tags for the given root - private TreeViewer cvsDefinedTagsTree; - - // remember the root element in the defined tags tree - private TagSourceWorkbenchAdapter cvsDefinedTagsRootElement; - - // list of auto-refresh files - private org.eclipse.swt.widgets.List autoRefreshFileList; - - // enable selecting auto-refresh files - private boolean allowSettingAutoRefreshFiles = true; - - // preference keys - private final String ALLOWREFRESH_WIDTH_KEY = "AllowRefreshWidth"; //$NON-NLS-1$ - private final String ALLOWREFRESH_HEIGHT_KEY = "AllowRefreshHeight"; //$NON-NLS-1$ - private final String NOREFRESH_WIDTH_KEY = "NoRefreshWidth"; //$NON-NLS-1$ - private final String NOREFRESH_HEIGHT_KEY = "NoRefreshHeight"; //$NON-NLS-1$ - - // buttons - private Button addSelectedTagsButton; - private Button addSelectedFilesButton; - private Button removeFileButton; - private Button removeTagButton; - - // dialogs settings that are persistent between workbench sessions - private IDialogSettings settings; - - private final TagSource tagSource; - - private final TagSourceWrapper wrappedTagSource; - - class FileSorter extends ViewerSorter { - public int compare(Viewer viewer, Object e1, Object e2) { - boolean oneIsFile = e1 instanceof CVSFileElement; - boolean twoIsFile = e2 instanceof CVSFileElement; - if (oneIsFile != twoIsFile) { - return oneIsFile ? 1 : -1; - } - return super.compare(viewer, e1, e2); - } - } - - /* - * Create a tag source that cahces the added and removed tags - * so that the changes can be propogated to the repository - * manager when OK is pressed - */ - class TagSourceWrapper extends TagSource { - - private final TagSource tagSource; - private final List branches = new ArrayList(); - private final List versions = new ArrayList(); - private final List dates = new ArrayList(); - - public TagSourceWrapper(TagSource tagSource) { - this.tagSource = tagSource; - branches.addAll(Arrays.asList(tagSource.getTags(CVSTag.BRANCH))); - versions.addAll(Arrays.asList(tagSource.getTags(CVSTag.VERSION))); - dates.addAll(Arrays.asList(tagSource.getTags(CVSTag.DATE))); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getTags(int) - */ - public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } - List list = getTagList(type); - if (list != null) - return (CVSTag[]) list.toArray(new CVSTag[list.size()]); - return tagSource.getTags(type); - } - - private List getTagList(int type) { - switch (type) { - case CVSTag.VERSION: - return versions; - case CVSTag.BRANCH: - return branches; - case CVSTag.DATE: - return dates; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#refresh(org.eclipse.core.runtime.IProgressMonitor) - */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - // The wrapper is never refreshed - return new CVSTag[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getLocation() - */ - public ICVSRepositoryLocation getLocation() { - return tagSource.getLocation(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getShortDescription() - */ - public String getShortDescription() { - return tagSource.getShortDescription(); - } - - public void remove(CVSTag[] tags) { - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - List list = getTagList(tag.getType()); - if (list != null) - list.remove(tag); - } - } - - public void add(CVSTag[] tags) { - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - List list = getTagList(tag.getType()); - if (list != null) - list.add(tag); - } - } - - public void removeAll() { - versions.clear(); - branches.clear(); - dates.clear(); - } - - /** - * Remember the state that has been accumulated - * @param monitor - * @throws CVSException - */ - public void commit(IProgressMonitor monitor) throws CVSException { - tagSource.commit(getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }), true /* replace */, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // Not invoked - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getCVSResources() - */ - public ICVSResource[] getCVSResources() { - return tagSource.getCVSResources(); - } - } - - public TagConfigurationDialog(Shell shell, TagSource tagSource) { - super(shell); - this.tagSource = tagSource; - wrappedTagSource = new TagSourceWrapper(tagSource); - setShellStyle(SWT.CLOSE|SWT.RESIZE|SWT.APPLICATION_MODAL); - allowSettingAutoRefreshFiles = getSingleFolder(tagSource, false) != null; - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - this.settings = workbenchSettings.getSection("TagConfigurationDialog");//$NON-NLS-1$ - if (settings == null) { - this.settings = workbenchSettings.addNewSection("TagConfigurationDialog");//$NON-NLS-1$ - } - } - - /** - * @see Window#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Policy.bind("TagConfigurationDialog.1", tagSource.getShortDescription())); //$NON-NLS-1$ - } - - /** - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite shell = new Composite(parent, SWT.NONE); - GridData data = new GridData (GridData.FILL_BOTH); - shell.setLayoutData(data); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.makeColumnsEqualWidth = true; - gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - shell.setLayout (gridLayout); - - Composite comp = new Composite(shell, SWT.NULL); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginWidth = 0; - gridLayout.marginHeight = 0; - comp.setLayout(gridLayout); - comp.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label cvsResourceTreeLabel = new Label(comp, SWT.NONE); - cvsResourceTreeLabel.setText(Policy.bind("TagConfigurationDialog.5")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalSpan = 1; - cvsResourceTreeLabel.setLayoutData(data); - - Tree tree = new Tree(comp, SWT.BORDER | SWT.MULTI); - cvsResourceTree = new TreeViewer (tree); - cvsResourceTree.setContentProvider(new RemoteContentProvider()); - cvsResourceTree.setLabelProvider(new WorkbenchLabelProvider()); - data = new GridData (GridData.FILL_BOTH); - data.heightHint = 150; - data.horizontalSpan = 1; - cvsResourceTree.getTree().setLayoutData(data); - cvsResourceTree.setInput(TagSourceResourceAdapter.getViewerInput(tagSource)); - cvsResourceTree.setSorter(new FileSorter()); - cvsResourceTree.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateShownTags(); - updateEnablements(); - } - }); - - comp = new Composite(shell, SWT.NULL); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginWidth = 0; - gridLayout.marginHeight = 0; - comp.setLayout(gridLayout); - comp.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label cvsTagTreeLabel = new Label(comp, SWT.NONE); - cvsTagTreeLabel.setText(Policy.bind("TagConfigurationDialog.6")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalSpan = 1; - cvsTagTreeLabel.setLayoutData(data); - - final Table table = new Table(comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); - data = new GridData(GridData.FILL_BOTH); - data.heightHint = 150; - data.horizontalSpan = 1; - table.setLayoutData(data); - cvsTagTree = new CheckboxTableViewer(table); - cvsTagTree.setContentProvider(new WorkbenchContentProvider()); - cvsTagTree.setLabelProvider(new WorkbenchLabelProvider()); - cvsTagTree.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateEnablements(); - } - }); - - Composite selectComp = new Composite(comp, SWT.NONE); - GridLayout selectLayout = new GridLayout(2, true); - selectLayout.marginHeight = selectLayout.marginWidth = 0; - selectComp.setLayout(selectLayout); - selectComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Button selectAllButton = new Button(selectComp, SWT.PUSH); - selectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - selectAllButton.setText(Policy.bind("ReleaseCommentDialog.selectAll")); //$NON-NLS-1$ - selectAllButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int nItems = table.getItemCount(); - for (int j=0; j 0) { - List proposals = new ArrayList(); - for (int i = 0; i < matching.length; i++) { - CVSTag tag = matching[i]; - String name = tag.getName(); - ImageDescriptor desc = TagElement.getImageDescriptor(tag); - Image image = null; - if (desc != null) { - image = (Image)images.get(desc); - if (image == null) { - image = desc.createImage(); - images.put(desc, image); - } - } - CompletionProposal proposal = new CompletionProposal(name, 0, docLength, name.length(), image, name, null, null); - proposals.add(proposal); - } - return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor#computeContextInformation(org.eclipse.jface.contentassist.IContentAssistSubjectControl, int) - */ - public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int) - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ - public char[] getCompletionProposalAutoActivationCharacters() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() - */ - public String getErrorMessage() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() - */ - public IContextInformationValidator getContextInformationValidator() { - return null; - } - - /** - * Dispose of any images created by the assistant - */ - public void dispose() { - for (Iterator iter = images.values().iterator(); iter.hasNext();) { - Image image = (Image) iter.next(); - image.dispose(); - } - } - -} \ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java deleted file mode 100644 index 139144450..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.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.team.internal.ccvs.ui.tags; - -import java.util.Date; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement; -import org.eclipse.ui.model.IWorkbenchAdapter; - -public class TagElement implements IWorkbenchAdapter, IAdaptable { - Object parent; - CVSTag tag; - - public static ImageDescriptor getImageDescriptor(CVSTag tag) { - if (tag.getType() == CVSTag.BRANCH || tag.equals(CVSTag.DEFAULT)) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_TAG); - } else if (tag.getType() == CVSTag.DATE){ - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE); - }else { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION); - } - } - - /** - * @deprecated - * @param tag - */ - public TagElement(CVSTag tag) { - this(null, tag); - } - public TagElement(Object parent, CVSTag tag) { - this.parent = parent; - this.tag = tag; - } - public Object[] getChildren(Object o) { - return new Object[0]; - } - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - public ImageDescriptor getImageDescriptor(Object object) { - return getImageDescriptor(tag); - } - public String getLabel(Object o) { - if(tag.getType() == CVSTag.DATE){ - Date date = tag.asDate(); - if (date != null){ - return CVSTagElement.toDisplayString(date); - } - } - return tag.getName(); - } - public Object getParent(Object o) { - return parent; - } - public CVSTag getTag() { - return tag; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return tag.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (obj instanceof TagElement) { - return tag.equals(((TagElement)obj).getTag()); - } - return super.equals(obj); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java deleted file mode 100644 index a4506ed9f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.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.team.internal.ccvs.ui.tags; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.util.Assert; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ui.dialogs.DialogArea; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * An area that displays the Refresh and Configure Tags buttons - */ -public class TagRefreshButtonArea extends DialogArea { - - private TagSource tagSource; - private final Shell shell; - private Button refreshButton; - private IRunnableContext context; - - public TagRefreshButtonArea(Shell shell, TagSource tagSource) { - Assert.isNotNull(shell); - Assert.isNotNull(tagSource); - this.shell = shell; - this.tagSource = tagSource; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DialogArea#createArea(org.eclipse.swt.widgets.Composite) - */ - public void createArea(Composite parent) { - Composite buttonComp = new Composite(parent, SWT.NONE); - GridData data = new GridData (); - data.horizontalAlignment = GridData.END; - buttonComp.setLayoutData(data); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - buttonComp.setLayout (layout); - - refreshButton = createTagRefreshButton(buttonComp, Policy.bind("TagConfigurationDialog.20")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.END; - data.horizontalSpan = 1; - refreshButton.setLayoutData (data); - - Button addButton = new Button(buttonComp, SWT.PUSH); - addButton.setText (Policy.bind("TagConfigurationDialog.21")); //$NON-NLS-1$ - data = new GridData (); - data.horizontalAlignment = GridData.END; - data.horizontalSpan = 1; - addButton.setLayoutData (data); - addButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); - d.open(); - } - }); - - WorkbenchHelp.setHelp(refreshButton, IHelpContextIds.TAG_CONFIGURATION_REFRESHACTION); - WorkbenchHelp.setHelp(addButton, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); - Dialog.applyDialogFont(buttonComp); - } - - /* - * Returns a button that implements the standard refresh tags operation. The runnable is run immediatly after - * the tags are fetched from the server. A client should refresh their widgets that show tags because they - * may of changed. - */ - private Button createTagRefreshButton(Composite composite, String title) { - Button refreshButton = new Button(composite, SWT.PUSH); - refreshButton.setText (title); - refreshButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - try { - getRunnableContext().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(Policy.bind("TagRefreshButtonArea.5"), 100); //$NON-NLS-1$ - CVSTag[] tags = tagSource.refresh(false, Policy.subMonitorFor(monitor, 70)); - if (tags.length == 0 && promptForBestEffort()) { - tagSource.refresh(true, Policy.subMonitorFor(monitor, 30)); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - } catch (InterruptedException e) { - // operation cancelled - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(shell, Policy.bind("TagConfigurationDialog.14"), null, e); //$NON-NLS-1$ - } - } - }); - return refreshButton; - } - - private boolean promptForBestEffort() { - final boolean[] prompt = new boolean[] { false }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(shell, Policy.bind("TagRefreshButtonArea.0"), null, //$NON-NLS-1$ - getNoTagsFoundMessage(), - MessageDialog.INFORMATION, - new String[] { - Policy.bind("TagRefreshButtonArea.1"), //$NON-NLS-1$ - Policy.bind("TagRefreshButtonArea.2"), //$NON-NLS-1$ - Policy.bind("TagRefreshButtonArea.3") //$NON-NLS-1$ - }, 1); - int code = dialog.open(); - if (code == 0) { - prompt[0] = true; - } else if (code == 1) { - TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); - d.open(); - } - - } - }); - return prompt[0]; - } - - private String getNoTagsFoundMessage() { - return Policy.bind("TagRefreshButtonArea.4", tagSource.getShortDescription()); //$NON-NLS-1$ - } - - protected static ICVSFolder getSingleFolder(TagSource tagSource) { - if (tagSource instanceof SingleFolderTagSource) - return ((SingleFolderTagSource)tagSource).getFolder(); - return null; - } - public TagSource getTagSource() { - return tagSource; - } - public void setTagSource(TagSource tagSource) { - Assert.isNotNull(tagSource); - this.tagSource = tagSource; - } - - public IRunnableContext getRunnableContext() { - if (context == null) - return PlatformUI.getWorkbench().getProgressService(); - return context; - } - - public void setRunnableContext(IRunnableContext context) { - this.context = context; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java deleted file mode 100644 index c9464dde9..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Workbench model element that contains a list of tags - * of the same type (BRANCH, VERSION or DATE). - */ -public class TagRootElement implements IWorkbenchAdapter, IAdaptable { - private TagSource tagSource; - private int typeOfTagRoot; - private final Object parent; - - public TagRootElement(Object parent, TagSource tagSource, int typeOfTagRoot) { - this.parent = parent; - this.typeOfTagRoot = typeOfTagRoot; - this.tagSource = tagSource; - } - - public Object[] getChildren(Object o) { - CVSTag[] childTags = tagSource.getTags(typeOfTagRoot); - TagElement[] result = new TagElement[childTags.length]; - for (int i = 0; i < childTags.length; i++) { - result[i] = new TagElement(this, childTags[i]); - } - return result; - } - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - public ImageDescriptor getImageDescriptor(Object object) { - if(typeOfTagRoot==CVSTag.BRANCH) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY); - } else if(typeOfTagRoot==CVSTag.DATE){ - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY); - }else { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY); - } - } - public String getLabel(Object o) { - if(typeOfTagRoot==CVSTag.BRANCH) { - return Policy.bind("MergeWizardEndPage.branches"); //$NON-NLS-1$ - } else if(typeOfTagRoot==CVSTag.DATE){ - return Policy.bind("TagRootElement.0"); //$NON-NLS-1$ - }else { - return Policy.bind("VersionsElement.versions"); //$NON-NLS-1$ - } - } - public Object getParent(Object o) { - return parent; - } - /** - * Gets the typeOfTagRoot. - * @return Returns a int - */ - public int getTypeOfTagRoot() { - return typeOfTagRoot; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java deleted file mode 100644 index 3f165b816..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java +++ /dev/null @@ -1,612 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.*; -import java.util.List; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; -import org.eclipse.team.internal.ccvs.ui.repo.NewDateTagAction; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter.ProjectElementSorter; -import org.eclipse.team.internal.ui.dialogs.DialogArea; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.part.PageBook; - -/** - * A dialog area that displays a list of tags for selection and supports - * filtering of the displayed tags. - */ -public class TagSelectionArea extends DialogArea { - - /* - * Property constant which identifies the selected tag or - * null if no tag is selected - */ - public static final String SELECTED_TAG = "selectedTag"; //$NON-NLS-1$ - - /* - * Property constant which indicates that a tag has been selected in such - * a way as to indicate that this is the desired tag (e.g double-click) - */ - public static final String OPEN_SELECTED_TAG = "openSelectedTag"; //$NON-NLS-1$ - - /* - * Constants used to configure which tags are shown - */ - public static final int INCLUDE_HEAD_TAG = TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG; - public static final int INCLUDE_BASE_TAG = TagSourceWorkbenchAdapter.INCLUDE_BASE_TAG; - public static final int INCLUDE_BRANCHES = TagSourceWorkbenchAdapter.INCLUDE_BRANCHES; - public static final int INCLUDE_VERSIONS = TagSourceWorkbenchAdapter.INCLUDE_VERSIONS; - public static final int INCLUDE_DATES = TagSourceWorkbenchAdapter.INCLUDE_DATES; - public static final int INCLUDE_ALL_TAGS = TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS; - - private String tagAreaLabel; - private final int includeFlags; - private CVSTag selection; - private String helpContext; - private Text filterText; - private TagSource tagSource; - private final Shell shell; - private TagRefreshButtonArea tagRefreshArea; - private final TagSource.ITagSourceChangeListener listener = new TagSource.ITagSourceChangeListener() { - public void tagsChanged(TagSource source) { - Shell shell = getShell(); - if (!shell.isDisposed()) { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - refresh(); - } - }); - } - } - }; - private final DisposeListener disposeListener = new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (tagSource != null) - tagSource.removeListener(listener); - } - }; - - private PageBook switcher; - private TreeViewer tagTree; - private TableViewer tagTable; - private boolean treeVisible = true; - private boolean includeFilterInputArea = true; - private String filterPattern = ""; //$NON-NLS-1$ - - private IRunnableContext context; - - public TagSelectionArea(Shell shell, TagSource tagSource, int includeFlags, String helpContext) { - this.shell = shell; - this.includeFlags = includeFlags; - this.helpContext = helpContext; - this.tagSource = tagSource; - setSelection(null); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DialogArea#createArea(org.eclipse.swt.widgets.Composite) - */ - public void createArea(Composite parent) { - // Create a composite for the entire area - Composite outer = createComposite(parent, 1, true); - initializeDialogUnits(outer); - // Add F1 help - if (helpContext != null) { - WorkbenchHelp.setHelp(outer, helpContext); - } - - // Create the tree area and refresh buttons with the possibility to add stuff in between - createTagDisplayArea(outer); - createCustomArea(outer); - createRefreshButtons(outer); - - Dialog.applyDialogFont(parent); - updateTagDisplay(true); - } - - private void createTagDisplayArea(Composite parent) { - Composite inner = createGrabbingComposite(parent, 1); - if (isIncludeFilterInputArea()) { - createFilterInput(inner); - createWrappingLabel(inner, Policy.bind("TagSelectionArea.0"), 1); //$NON-NLS-1$ - } else { - createWrappingLabel(inner, Policy.bind("TagSelectionArea.1", getTagAreaLabel()), 1); //$NON-NLS-1$ - } - switcher = new PageBook(inner, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = 0; - gridData.widthHint = 0; - switcher.setLayoutData(gridData); - tagTree = createTree(switcher); - tagTable = createTable(switcher); - } - - private void createFilterInput(Composite inner) { - createWrappingLabel(inner, Policy.bind("TagSelectionArea.2", getTagAreaLabel()), 1); //$NON-NLS-1$ - filterText = createText(inner, 1); - filterText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - setFilter(filterText.getText()); - } - }); - filterText.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - if (e.keyCode == SWT.ARROW_DOWN && e.stateMask == 0) { - tagTable.getControl().setFocus(); - } - } - public void keyReleased(KeyEvent e) { - // Ignore - } - }); - } - - /** - * Return the label that should be used for the tag area. - * It should not have any trailing punctuations as the tag area - * may position it differently depending on whether the filter - * text input is included in the area. - * @return the tag area label - */ - public String getTagAreaLabel() { - if (tagAreaLabel == null) - tagAreaLabel = Policy.bind("TagSelectionArea.3"); //$NON-NLS-1$ - return tagAreaLabel; - } - - /** - * Set the label that should be used for the tag area. - * It should not have any trailing punctuations as the tag area - * may position it differently depending on whether the filter - * text input is included in the area. - * @param tagAreaLabel the tag area label - */ - public void setTagAreaLabel(String tagAreaLabel) { - this.tagAreaLabel = tagAreaLabel; - } - - /** - * Update the tag display to show the tags that match the - * include flags and the filter entered by the user. - */ - protected void updateTagDisplay(boolean firstTime) { - String filter = getFilterString(); - if ((filter != null && filter.length() > 0) || isTableOnly()) { - // Show the table and filter it accordingly - try { - switcher.setRedraw(false); - treeVisible = false; - switcher.showPage(tagTable.getControl()); - FilteredTagList list = (FilteredTagList)tagTable.getInput(); - list.setPattern(filter); - tagTable.refresh(); - if (filterText == null || filter == null || filter.length() == 0) { - setSelection(selection); - } else { - // Only set the top selection if there is a filter from the filter text - // of this area. This is done to avoid selection loops - selectTopElement(); - } - } finally { - switcher.setRedraw(true); - } - } else { - // Show the tree - if (!isTreeVisible() || firstTime) { - try { - switcher.setRedraw(false); - treeVisible = true; - switcher.showPage(tagTree.getControl()); - tagTree.refresh(); - setSelection(selection); - } finally { - switcher.setRedraw(true); - } - } - } - } - - /** - * Return whether only a table should be used - * @return whether only a table should be used - */ - protected boolean isTableOnly() { - return (includeFlags == INCLUDE_VERSIONS) || (includeFlags == INCLUDE_BRANCHES); - } - - private String getFilterString() { - return filterPattern; - } - - /* - * Select the top element in the tag table - */ - private void selectTopElement() { - if (tagTable.getTable().getItemCount() > 1) { - TableItem item = tagTable.getTable().getItem(0); - tagTable.getTable().setSelection(new TableItem[] { item }); - tagTable.setSelection(tagTable.getSelection()); - } - } - - private FilteredTagList createFilteredInput() { - return new FilteredTagList(tagSource, TagSource.convertIncludeFlaqsToTagTypes(includeFlags)); - } - - private Text createText(Composite parent, int horizontalSpan) { - Text text = new Text(parent, SWT.BORDER); - GridData data = new GridData(); - data.horizontalSpan = horizontalSpan; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint= 0; - text.setLayoutData(data); - return text; - } - - protected void createRefreshButtons(Composite parent) { - tagSource.addListener(listener); - parent.addDisposeListener(disposeListener); - tagRefreshArea = new TagRefreshButtonArea(shell, tagSource); - if (context != null) - tagRefreshArea.setRunnableContext(context); - tagRefreshArea.createArea(parent); - } - - protected void createTreeMenu(TreeViewer tagTree) { - if ((includeFlags & TagSourceWorkbenchAdapter.INCLUDE_DATES) != 0) { - // Create the popup menu - MenuManager menuMgr = new MenuManager(); - Tree tree = tagTree.getTree(); - Menu menu = menuMgr.createContextMenu(tree); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - addMenuItemActions(manager); - } - - }); - menuMgr.setRemoveAllWhenShown(true); - tree.setMenu(menu); - } - } - - /** - * Create aq custom area that is below the tag selection area but above the refresh busson group - * @param parent - */ - protected void createCustomArea(Composite parent) { - // No default custom area - } - - protected TreeViewer createTree(Composite parent) { - Tree tree = new Tree(parent, SWT.MULTI | SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - tree.setLayoutData(data); - TreeViewer result = new TreeViewer(tree); - initialize(result); - result.getControl().addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent event) { - handleKeyPressed(event); - } - public void keyReleased(KeyEvent event) { - handleKeyReleased(event); - } - }); - result.setInput(createUnfilteredInput()); - createTreeMenu(result); - return result; - } - - protected TableViewer createTable(Composite parent) { - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); - GridData data = new GridData(GridData.FILL_BOTH); - table.setLayoutData(data); - TableLayout layout = new TableLayout(); - layout.addColumnData(new ColumnWeightData(100, true)); - table.setLayout(layout); - TableColumn col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - TableViewer viewer = new TableViewer(table); - initialize(viewer); - viewer.setInput(createFilteredInput()); - return viewer; - - } - - private void initialize(StructuredViewer viewer) { - viewer.setContentProvider(new WorkbenchContentProvider()); - viewer.setLabelProvider(new WorkbenchLabelProvider()); - viewer.setSorter(new ProjectElementSorter()); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - handleSelectionChange(); - } - }); - // select and close on double click - // To do: use defaultselection instead of double click - viewer.getControl().addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - CVSTag tag = internalGetSelectedTag(); - if (tag != null) { - firePropertyChangeChange(OPEN_SELECTED_TAG, null, tag); - } - } - }); - } - - private Object createUnfilteredInput() { - return TagSourceWorkbenchAdapter.createInput(tagSource, includeFlags); - } - - public void handleKeyPressed(KeyEvent event) { - if (event.character == SWT.DEL && event.stateMask == 0) { - deleteDateTag(); - } - } - private void deleteDateTag() { - TagElement[] selectedDateTagElements = getSelectedDateTagElement(); - if (selectedDateTagElements.length == 0) return; - for(int i = 0; i < selectedDateTagElements.length; i++){ - RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); - CVSTag tag = selectedDateTagElements[i].getTag(); - if(tag.getType() == CVSTag.DATE){ - mgr.removeDateTag(getLocation(),tag); - } - } - tagTree.refresh(); - handleSelectionChange(); - } - - /** - * Returns the selected date tag elements - */ - private TagElement[] getSelectedDateTagElement() { - ArrayList dateTagElements = null; - IStructuredSelection selection = (IStructuredSelection)tagTree.getSelection(); - if (selection!=null && !selection.isEmpty()) { - dateTagElements = new ArrayList(); - Iterator elements = selection.iterator(); - while (elements.hasNext()) { - Object next = CVSAction.getAdapter(elements.next(), TagElement.class); - if (next instanceof TagElement) { - if(((TagElement)next).getTag().getType() == CVSTag.DATE){ - dateTagElements.add(next); - } - } - } - } - if (dateTagElements != null && !dateTagElements.isEmpty()) { - TagElement[] result = new TagElement[dateTagElements.size()]; - dateTagElements.toArray(result); - return result; - } - return new TagElement[0]; - } - private void addDateTag(CVSTag tag){ - if(tag == null) return; - List dateTags = new ArrayList(); - ICVSRepositoryLocation location = getLocation(); - dateTags.addAll(Arrays.asList(CVSUIPlugin.getPlugin().getRepositoryManager().getDateTags(location))); - if(!dateTags.contains( tag)){ - CVSUIPlugin.getPlugin().getRepositoryManager().addDateTag(location, tag); - } - try { - tagTree.getControl().setRedraw(false); - tagTree.refresh(); - setSelection(tag); - } finally { - tagTree.getControl().setRedraw(true); - } - handleSelectionChange(); - } - private void addMenuItemActions(IMenuManager manager) { - manager.add(new Action(Policy.bind("TagSelectionDialog.0")) { //$NON-NLS-1$ - public void run() { - CVSTag dateTag = NewDateTagAction.getDateTag(getShell(), getLocation()); - addDateTag(dateTag); - } - }); - if(getSelectedDateTagElement().length > 0){ - manager.add(new Action(Policy.bind("TagSelectionDialog.1")) { //$NON-NLS-1$ - public void run() { - deleteDateTag(); - } - }); - } - } - - protected void handleKeyReleased(KeyEvent event) { - } - - /** - * handle a selection change event from the visible tag display - * (which could be either the table or the tree). - */ - protected void handleSelectionChange() { - CVSTag newSelection = internalGetSelectedTag(); - if (selection != null && newSelection != null && selection.equals(newSelection)) { - // the selection hasn't change so return - return; - } - CVSTag oldSelection = selection; - selection = newSelection; - firePropertyChangeChange(SELECTED_TAG, oldSelection, selection); - } - - private CVSTag internalGetSelectedTag() { - IStructuredSelection selection; - if (isTreeVisible()) { - selection = (IStructuredSelection)tagTree.getSelection(); - } else { - selection = (IStructuredSelection)tagTable.getSelection(); - } - Object o = selection.getFirstElement(); - if (o instanceof TagElement) - return ((TagElement)o).getTag(); - return null; - } - - private boolean isTreeVisible() { - return treeVisible; - } - - private ICVSRepositoryLocation getLocation(){ - return tagSource.getLocation(); - } - public CVSTag getSelection() { - return selection; - } - public Shell getShell() { - return shell; - } - - /** - * Set the focus to the filter text widget - */ - public void setFocus() { - if (filterText != null) - filterText.setFocus(); - else if (switcher != null) - switcher.setFocus(); - - // Refresh in case tags were added since the last time the area had focus - refresh(); - } - - /** - * Select the given tag - * @param selectedTag the tag to be selected - */ - public void setSelection(CVSTag selectedTag) { - if (isTreeVisible()) - if (tagTree != null && !tagTree.getControl().isDisposed()) { - // TODO: Hack to instantiate the model before revealing the selection - tagTree.expandToLevel(2); - tagTree.collapseAll(); - // Reveal the selection - tagTree.reveal(new TagElement(selectedTag)); - tagTree.setSelection(new StructuredSelection(new TagElement(selectedTag))); - } - else - if (tagTable != null && !tagTable.getControl().isDisposed()) { - tagTable.setSelection(new StructuredSelection(new TagElement(selectedTag))); - } - } - - /** - * Refresh the state of the tag selection area - */ - public void refresh() { - if (isTreeVisible()) { - if (tagTree != null && !tagTree.getControl().isDisposed()) { - tagTree.refresh(); - } - } else { - if (tagTable != null && !tagTable.getControl().isDisposed()) { - tagTable.refresh(); - } - } - } - - /** - * Set the enablement state of the area - * @param enabled the enablement state - */ - public void setEnabled(boolean enabled) { - if (filterText != null) - filterText.setEnabled(enabled); - tagTree.getControl().setEnabled(enabled); - tagTable.getControl().setEnabled(enabled); - } - - /** - * Get the tag source for the tags being displayed - * @return the tag source for the tags being displayed - */ - public TagSource getTagSource() { - return tagSource; - } - - /** - * Set the tag source from which the displayed tags are determined - * @param tagSource the source of the tags being displayed - */ - public void setTagSource(TagSource tagSource) { - if (this.tagSource != null) { - this.tagSource.removeListener(listener); - } - this.tagSource = tagSource; - this.tagSource.addListener(listener); - tagRefreshArea.setTagSource(this.tagSource); - setTreeAndTableInput(); - } - - private void setTreeAndTableInput() { - if (tagTree != null) { - tagTree.setInput(createUnfilteredInput()); - } - if (tagTable != null) { - tagTable.setInput(createFilteredInput()); - } - - } - - /** - * Set whether the input filter text is to be included in the tag selection area. - * If excluded, clientscan still set the filter text directly using - * setFilter. - * @param include whether filter text input should be included - */ - public void setIncludeFilterInputArea(boolean include) { - includeFilterInputArea = include; - } - - /** - * Return whether the input filter text is to be included in the tag selection area. - * If excluded, clientscan still set the filter text directly using - * setFilter. - * @return whether filter text input should be included - */ - public boolean isIncludeFilterInputArea() { - return includeFilterInputArea; - } - - /** - * Set the text used to filter the tag list. - * @param filter the filter pattern - */ - public void setFilter(String filter) { - this.filterPattern = filter; - updateTagDisplay(false); - } - - public void setRunnableContext(IRunnableContext context) { - this.context = context; - if (tagRefreshArea != null) - tagRefreshArea.setRunnableContext(context); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java deleted file mode 100644 index 30050625d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * Dialog to prompt the user to choose a tag for a selected resource - */ -public class TagSelectionDialog extends Dialog implements IPropertyChangeListener { - - private TagSelectionArea tagSelectionArea; - - public static final int INCLUDE_HEAD_TAG = TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG; - public static final int INCLUDE_BASE_TAG = TagSourceWorkbenchAdapter.INCLUDE_BASE_TAG; - public static final int INCLUDE_BRANCHES = TagSourceWorkbenchAdapter.INCLUDE_BRANCHES; - public static final int INCLUDE_VERSIONS = TagSourceWorkbenchAdapter.INCLUDE_VERSIONS; - public static final int INCLUDE_DATES = TagSourceWorkbenchAdapter.INCLUDE_DATES; - public static final int INCLUDE_ALL_TAGS = TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS; - - private Button okButton; - - // dialog title, should indicate the action in which the tag selection - // dialog is being shown - private String title; - - private boolean recurse = true; - - // constants - private static final int SIZING_DIALOG_WIDTH = 400; - private static final int SIZING_DIALOG_HEIGHT = 400; - - private CVSTag selection; - - private TagSource tagSource; - - private String message; - - private int includeFlags; - - private String helpContext; - - private boolean showRecurse; - - public static CVSTag getTagToCompareWith(Shell shell, TagSource tagSource, int includeFlags) { - TagSelectionDialog dialog = new TagSelectionDialog(shell, tagSource, - Policy.bind("CompareWithTagAction.message"), //$NON-NLS-1$ - Policy.bind("TagSelectionDialog.Select_a_Tag_1"), //$NON-NLS-1$ - includeFlags, - false, /* show recurse*/ - IHelpContextIds.COMPARE_TAG_SELECTION_DIALOG); - dialog.setBlockOnOpen(true); - int result = dialog.open(); - if (result == Dialog.CANCEL) { - return null; - } - return dialog.getResult(); - } - - /** - * Creates a new TagSelectionDialog. - * @param resource The resource to select a version for. - */ - public TagSelectionDialog(Shell parentShell, TagSource tagSource, String title, String message, int includeFlags, final boolean showRecurse, String helpContext) { - super(parentShell); - - // Create a tag selection area with a custom recurse option - this.tagSource = tagSource; - this.message = message; - this.includeFlags = includeFlags; - this.helpContext = helpContext; - this.showRecurse = showRecurse; - this.title = title; - setShellStyle(getShellStyle() | SWT.RESIZE); - } - - /* (non-Javadoc) - * Method declared on Window. - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(title); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - return new Point(SIZING_DIALOG_WIDTH, SIZING_DIALOG_HEIGHT); - } - - /** - * Creates this window's widgetry. - *

              - * The default implementation of this framework method - * creates this window's shell (by calling createShell), - * its control (by calling createContents), - * and initializes this window's shell bounds - * (by calling initializeBounds). - * This framework method may be overridden; however, - * super.create must be called. - *

              - */ - public void create() { - super.create(); - initialize(); - } - - /** - * Add buttons to the dialog's button bar. - * - * @param parent the button bar composite - */ - protected void createButtonsForButtonBar(Composite parent) { - // create OK and Cancel buttons by default - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - okButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /** - * Creates and returns the contents of the upper part - * of this dialog (above the button bar). - *

              - * The default implementation of this framework method - * creates and returns a new Composite with - * standard margins and spacing. - * Subclasses should override. - *

              - * - * @param the parent composite to contain the dialog area - * @return the dialog area control - */ - protected Control createDialogArea(Composite parent) { - Composite top = (Composite)super.createDialogArea(parent); - - // Delegate most of the dialog to the tag selection area - tagSelectionArea = new TagSelectionArea(getShell(), tagSource, includeFlags, helpContext) { - protected void createCustomArea(Composite parent) { - if(showRecurse) { - final Button recurseCheck = new Button(parent, SWT.CHECK); - recurseCheck.setText(Policy.bind("TagSelectionDialog.recurseOption")); //$NON-NLS-1$ - recurseCheck.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - recurse = recurseCheck.getSelection(); - } - }); - recurseCheck.setSelection(true); - } - } - }; - if (message != null) - tagSelectionArea.setTagAreaLabel(message); - tagSelectionArea.addPropertyChangeListener(this); - tagSelectionArea.createArea(top); - - // Create a separator between the tag area and the button area - Label seperator = new Label(top, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData (GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - seperator.setLayoutData(data); - - updateEnablement(); - Dialog.applyDialogFont(parent); - - return top; - } - - - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - /** - * Returns the selected tag. - */ - public CVSTag getResult() { - return selection; - } - - public boolean getRecursive() { - return recurse; - } - - /** - * Initializes the dialog contents. - */ - protected void initialize() { - okButton.setEnabled(false); - } - - - /** - * Updates the dialog enablement. - */ - protected void updateEnablement() { - if(okButton!=null) { - okButton.setEnabled(selection != null); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if (property.equals(TagSelectionArea.SELECTED_TAG)) { - selection = (CVSTag)event.getNewValue(); - updateEnablement(); - } else if (property.equals(TagSelectionArea.OPEN_SELECTED_TAG)) { - okPressed(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java deleted file mode 100644 index f05330b3a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * General tag selection page that allows the selection of a tag - * for a particular remote folder - */ -public class TagSelectionWizardPage extends CVSWizardPage { - - private CVSTag selectedTag; - - // Needed to dynamicaly create refresh buttons - private Composite composite; - - private int includeFlags; - - // Fields for allowing the use of the tag from the local workspace - boolean allowNoTag = false; - private Button useResourceTagButton; - private Button selectTagButton; - private boolean useResourceTag = false; - private String helpContextId; - private TagSelectionArea tagArea; - private String tagLabel; - private TagSource tagSource; - - public TagSelectionWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, TagSource tagSource, int includeFlags) { - super(pageName, title, titleImage, description); - this.tagSource = tagSource; - this.includeFlags = includeFlags; - } - - /** - * Set the help context for the tag selection page. - * This method must be invoked before createControl - * @param helpContextId the help context id - */ - public void setHelpContxtId(String helpContextId) { - this.helpContextId = helpContextId; - } - - /** - * Set the label to appear over the tag list/tree. - * If not set, a default will be used. - * * This method must be invoked before createControl - * @param tagLabel the label to appear over the tag list/tree - */ - public void setTagLabel(String tagLabel) { - this.tagLabel = tagLabel; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - composite = createComposite(parent, 1, false); - setControl(composite); - - // set F1 help - if (helpContextId != null) - WorkbenchHelp.setHelp(composite, helpContextId); - - if (allowNoTag) { - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - useResourceTag = useResourceTagButton.getSelection(); - updateEnablement(); - } - }; - useResourceTag = true; - useResourceTagButton = createRadioButton(composite, Policy.bind("TagSelectionWizardPage.0"), 1); //$NON-NLS-1$ - selectTagButton = createRadioButton(composite, Policy.bind("TagSelectionWizardPage.1"), 1); //$NON-NLS-1$ - useResourceTagButton.setSelection(useResourceTag); - selectTagButton.setSelection(!useResourceTag); - useResourceTagButton.addSelectionListener(listener); - selectTagButton.addSelectionListener(listener); - } - - createTagArea(); - updateEnablement(); - Dialog.applyDialogFont(parent); - } - - private void createTagArea() { - tagArea = new TagSelectionArea(getShell(), tagSource, includeFlags, null); - if (tagLabel != null) - tagArea.setTagAreaLabel(tagLabel); - tagArea.setRunnableContext(getContainer()); - tagArea.createArea(composite); - tagArea.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) { - selectedTag = tagArea.getSelection(); - updateEnablement(); - } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) { - if (selectedTag != null) - gotoNextPage(); - } - - } - }); - refreshTagArea(); - } - - private void refreshTagArea() { - if (tagArea != null) { - tagArea.refresh(); - tagArea.setSelection(selectedTag); - } - } - - protected void updateEnablement() { - tagArea.setEnabled(!useResourceTag); - setPageComplete(useResourceTag || selectedTag != null); - } - - public CVSTag getSelectedTag() { - if (useResourceTag) - return null; - return selectedTag; - } - - protected void gotoNextPage() { - TagSelectionWizardPage.this.getContainer().showPage(getNextPage()); - } - - public void setAllowNoTag(boolean b) { - allowNoTag = b; - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible && tagArea != null) { - tagArea.setFocus(); - } - } - - /** - * Set the tag source used by this wizard page - * @param source the tag source - */ - public void setTagSource(TagSource source) { - this.tagSource = source; - tagArea.setTagSource(tagSource); - setSelection(null); - refreshTagArea(); - } - - /** - * Set the selection of the page to the given tag - * @param selectedTag - */ - public void setSelection(CVSTag selectedTag) { - if (selectedTag == null && (includeFlags & TagSelectionArea.INCLUDE_HEAD_TAG) > 0) { - this.selectedTag = CVSTag.DEFAULT; - } else { - this.selectedTag = selectedTag; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java deleted file mode 100644 index 0e9540bfb..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; - -/** - * A tag source provides access to a set of tags. - */ -public abstract class TagSource { - - /* - * Special constant representing the BASE tag - */ - public static final int BASE = -1; - - public static final TagSource EMPTY = new TagSource() { - public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // No-op - } - public ICVSRepositoryLocation getLocation() { - // TODO Auto-generated method stub - return null; - } - public String getShortDescription() { - return "Empty"; //$NON-NLS-1$ - } - public CVSTag[] getTags(int type) { - return new CVSTag[0]; - } - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - return new CVSTag[0]; - } - public ICVSResource[] getCVSResources() { - return new ICVSResource[0]; - } - }; - - private ListenerList listeners = new ListenerList(); - - /** - * Simple interface for providing notification when the tags - * for this source have changed. - */ - public interface ITagSourceChangeListener { - void tagsChanged(TagSource source); - } - - public static int[] convertIncludeFlaqsToTagTypes(int includeFlags) { - List types = new ArrayList(); - if ((includeFlags & TagSelectionArea.INCLUDE_BRANCHES) > 0) - types.add(new Integer(CVSTag.BRANCH)); - if ((includeFlags & TagSelectionArea.INCLUDE_VERSIONS) > 0) - types.add(new Integer(CVSTag.VERSION)); - if ((includeFlags & (TagSelectionArea.INCLUDE_HEAD_TAG)) > 0) - types.add(new Integer(CVSTag.HEAD)); - if ((includeFlags & (TagSelectionArea.INCLUDE_DATES)) > 0) - types.add(new Integer(CVSTag.DATE)); - if ((includeFlags & (TagSelectionArea.INCLUDE_BASE_TAG)) > 0) - types.add(new Integer(BASE)); - int[] result = new int[types.size()]; - for (int i = 0; i < result.length; i++) { - result[i] = ((Integer)types.get(i)).intValue(); - - } - return result; - } - - /** - * Create a tag source for the given folders - * @param folders one or more folders - * @return a tag source for the supplied folders - */ - public static TagSource create(ICVSFolder[] folders) { - if (folders.length == 1) { - return new SingleFolderTagSource(folders[0]); - } else { - return new MultiFolderTagSource(folders); - } - } - - /** - * Create a tag source for a list of resources - * @param resources one or more resources - * @return a tag source - */ - public static TagSource create(ICVSResource[] resources) { - if (resources.length == 1 && !resources[0].isFolder()) - return new SingleFileTagSource((ICVSFile)resources[0]); - return create(getFolders(resources)); - } - - private static ICVSFolder[] getFolders(ICVSResource[] resources) { - return new ICVSFolder[] { getFirstFolder(resources) } ; - } - - /** - * Create a tag source for a list of resources - * @param resources one or more resources - * @return a tag source - */ - public static TagSource create(IResource[] resources) { - return create(getCVSResources(getProjects(resources))); - } - - private static IResource[] getProjects(IResource[] resources) { - Set result = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - result.add(resource.getProject()); - } - return (IResource[]) result.toArray(new IResource[result.size()]); - } - - /** - * Return a tag source for a single remote folder - * @param remote the remote folder - * @return a tag source for that folder - */ - public static TagSource create(ICVSRemoteFolder remote) { - return new SingleFolderTagSource(remote); - } - - private static ICVSResource[] getCVSResources(IResource[] resources) { - List cvsResources = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - cvsResources.add(CVSWorkspaceRoot.getCVSResourceFor(resource)); - } - return (ICVSResource[]) cvsResources.toArray(new ICVSResource[cvsResources.size()]); - } - - private static ICVSFolder getFirstFolder(ICVSResource[] resources) { - if (resources[0].isFolder()) { - return (ICVSFolder)resources[0]; - } else { - return resources[0].getParent(); - } - } - - public CVSTag[] getTags(int type) { - switch (type) { - case BASE: - return new CVSTag[] { CVSTag.BASE }; - case CVSTag.HEAD: - return new CVSTag[] { CVSTag.DEFAULT }; - } - return new CVSTag[0]; - } - - public CVSTag[] getTags(int[] types) { - if (types.length == 0) { - return new CVSTag[0]; - } - if (types.length == 1) { - return getTags(types[0]); - } - List result = new ArrayList(); - for (int i = 0; i < types.length; i++) { - int type = types[i]; - CVSTag[] tags = getTags(type); - result.addAll(Arrays.asList(tags)); - } - return (CVSTag[]) result.toArray(new CVSTag[result.size()]); - } - - /** - * Refresh the tags by contacting the server if appropriate - * @param monitor a progress monitor - * @param bestEffort if best effort is true, then the whole folder contents may be searched - * @return any discovered tags - */ - public abstract CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException; - - public abstract ICVSRepositoryLocation getLocation(); - - /** - * Return a short description of the tag source for displaying in UI. - * @return a short description of the tag source for displaying in UI. - */ - public abstract String getShortDescription(); - - /** - * Commit a set of tag changes to the tag cache - * @param tags the tags that should be cached - * @param replace whether existing tags not in the list should be removed - * @param monitor a progress monitor - * @throws CVSException - */ - public abstract void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException; - - public void addListener(ITagSourceChangeListener listener) { - listeners.add(listener); - } - - public void removeListener(ITagSourceChangeListener listener) { - listeners.remove(listener); - } - - /** - * Notify all listeners that the tags from this source may have changed - */ - public void fireChange() { - Object[] list = listeners.getListeners(); - for (int i = 0; i < list.length; i++) { - final ITagSourceChangeListener listener = (ITagSourceChangeListener)list[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // logged by run - } - public void run() throws Exception { - listener.tagsChanged(TagSource.this); - } - }); - } - } - - public abstract ICVSResource[] getCVSResources(); -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java deleted file mode 100644 index d3902327f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java +++ /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 - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * A workbench adapter that can be used to view the resources that make up - * a tag source. It is used by the TagConfigurationDialog. - */ -public class TagSourceResourceAdapter implements IAdaptable, IWorkbenchAdapter { - - public static Object getViewerInput(TagSource tagSource) { - return new TagSourceResourceAdapter(tagSource); - } - - TagSource tagSource; - - private TagSourceResourceAdapter(TagSource tagSource) { - this.tagSource = tagSource; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - ICVSResource[] children = tagSource.getCVSResources(); - if (children.length == 0) return new Object[0]; - List result = new ArrayList(); - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if (resource.isFolder()) { - result.add(new CVSFolderElement((ICVSFolder)resource, false)); - } else { - result.add(new CVSFileElement((ICVSFile)resource)); - } - } - return result.toArray(new Object[result.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - // No imgae descriptor - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return tagSource.getShortDescription(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - // No parent - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) { - return this; - } - return null; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java deleted file mode 100644 index 24de6170e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.tags; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * A workbench adapter for a tag source that creates a model - * for displaying the tags from a tag source in a tree or table - * viewer. The workbench adapter is not a singleton since it needs - * to be configured to display certain types of tags. - */ -public class TagSourceWorkbenchAdapter implements IAdaptable, IWorkbenchAdapter { - - /** - * Constants for configuring which types of tags should be displayed. - */ - public static final int INCLUDE_HEAD_TAG = 1; - public static final int INCLUDE_BASE_TAG = 2; - public static final int INCLUDE_BRANCHES = 4; - public static final int INCLUDE_VERSIONS = 8; - public static final int INCLUDE_DATES = 16; - public static final int INCLUDE_ALL_TAGS = INCLUDE_HEAD_TAG | INCLUDE_BASE_TAG | INCLUDE_BRANCHES | INCLUDE_VERSIONS | INCLUDE_DATES; - - TagRootElement branches; - TagRootElement versions; - TagRootElement dates; - int includeFlags; - - public static class ProjectElementSorter extends ViewerSorter { - - /* - * The order in the diaog should be HEAD, Branches, Versions, Dates, BASE - */ - public int category(Object element) { - if (element instanceof TagElement) { - CVSTag tag = ((TagElement)element).getTag(); - if (tag == CVSTag.DEFAULT) return 1; - if (tag == CVSTag.BASE) return 5; - if (tag.getType() == CVSTag.BRANCH) return 2; - if (tag.getType() == CVSTag.VERSION) return 3; - if (tag.getType() == CVSTag.DATE) return 4; - } else if (element instanceof TagRootElement) { - if(((TagRootElement)element).getTypeOfTagRoot() == CVSTag.BRANCH) return 2; - if(((TagRootElement)element).getTypeOfTagRoot() == CVSTag.VERSION) return 3; - if(((TagRootElement)element).getTypeOfTagRoot() == CVSTag.DATE) return 4; - } - return 0; - } - public int compare(Viewer viewer, Object e1, Object e2) { - int cat1 = category(e1); - int cat2 = category(e2); - if (cat1 != cat2) return cat1 - cat2; - // Sort version tags in reverse order - if (e1 instanceof TagElement){ - CVSTag tag1 = ((TagElement)e1).getTag(); - int type = tag1.getType(); - if(type == CVSTag.VERSION) { - return -1 * super.compare(viewer, e1, e2); - }else if(type == CVSTag.DATE){ - return -1*tag1.compareTo(((TagElement)e2).getTag()); - } - } - return super.compare(viewer, e1, e2); - } - } - - - /** - * Create a viewer input for the tag source - * @param tagSource the tag source - * @param includeFlags the types of tags to include - * @return a tree viewer input - */ - public static Object createInput(TagSource tagSource, int includeFlags) { - if (includeFlags == INCLUDE_VERSIONS) { - // Versions only is requested by the merge start page. - // Only need to show version tags - return new TagRootElement(null, tagSource, CVSTag.VERSION); - } - return new TagSourceWorkbenchAdapter(tagSource, includeFlags); - } - - public TagSourceWorkbenchAdapter(TagSource tagSource, int includeFlags) { - this.includeFlags = includeFlags; - if (this.includeFlags == 0) this.includeFlags = INCLUDE_ALL_TAGS; - if ((includeFlags & INCLUDE_BRANCHES) > 0) { - branches = new TagRootElement(this, tagSource, CVSTag.BRANCH); - } - if ((includeFlags & INCLUDE_VERSIONS) > 0) { - versions = new TagRootElement(this, tagSource, CVSTag.VERSION); - } - if ((includeFlags & INCLUDE_DATES) > 0) { - dates = new TagRootElement(this, tagSource, CVSTag.DATE); - } - } - - public Object[] getChildren(Object o) { - ArrayList children = new ArrayList(4); - if ((includeFlags & INCLUDE_HEAD_TAG) > 0) { - children.add(new TagElement(this, CVSTag.DEFAULT)); - } - if ((includeFlags & INCLUDE_BASE_TAG) > 0) { - children.add(new TagElement(this, CVSTag.BASE)); - } - if ((includeFlags & INCLUDE_BRANCHES) > 0) { - children.add(branches); - } - if ((includeFlags & INCLUDE_VERSIONS) > 0) { - children.add(versions); - } - if ((includeFlags & INCLUDE_DATES) > 0) { - children.add(dates); - } - return children.toArray(new Object[children.size()]); - } - public int getIncludeFlags() { - return includeFlags; - } - public TagRootElement getBranches() { - return branches; - } - public TagRootElement getVersions() { - return versions; - } - public TagRootElement getDates(){ - return dates; - } - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) return this; - return null; - } - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - public String getLabel(Object o) { - return null; - } - public Object getParent(Object o) { - return null; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java deleted file mode 100644 index 3adf28015..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java +++ /dev/null @@ -1,382 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.ArrayList; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.model.WorkbenchViewerSorter; -import org.eclipse.ui.views.navigator.ResourceSorter; - -/** - * Common superclass for CVS wizard pages. Provides convenience methods - * for widget creation. - */ -public abstract class CVSWizardPage extends WizardPage { - - protected static final int LABEL_WIDTH_HINT = 400; - protected static final int LABEL_INDENT_WIDTH = 32; - protected static final int LIST_HEIGHT_HINT = 100; - protected static final int SPACER_HEIGHT = 8; - - private ICVSWizard wizard; - - /** - * CVSWizardPage constructor comment. - * @param pageName the name of the page - */ - public CVSWizardPage(String pageName) { - super(pageName); - } - - /** - * CVSWizardPage constructor comment. - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page - */ - public CVSWizardPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - /** - * CVSWizardPage constructor comment. - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page - * @param description the description of the page - */ - public CVSWizardPage(String pageName, String title, ImageDescriptor titleImage, String description) { - super(pageName, title, titleImage); - setDescription(description); - } - /** - * Creates a new checkbox instance and sets the default layout data. - * - * @param group the composite in which to create the checkbox - * @param label the string to set into the checkbox - * @return the new checkbox - */ - protected Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = 2; - button.setLayoutData(data); - return button; - } - /** - * Utility method that creates a combo box - * - * @param parent the parent for the new label - * @return the new widget - */ - protected Combo createCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - combo.setLayoutData(data); - return combo; - } - /** - * Creates composite control and sets the default layout data. - * @param parent the parent of the new composite - * @param numColumns the number of columns for the new composite - * @param grabExcess TODO - * - * @return the newly-created coposite - */ - protected Composite createComposite(Composite parent, int numColumns, boolean grabExcess) { - final Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(numColumns, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - return composite; - } - - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - public static Label createLabel(Composite parent, String text) { - return createIndentedLabel(parent, text, 0); - } - /** - * Utility method that creates a label instance indented by the specified - * number of pixels and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @param indent the indent in pixels, or 0 for none - * @return the new label - */ - public static Label createIndentedLabel(Composite parent, String text, int indent) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - data.horizontalIndent = indent; - label.setLayoutData(data); - return label; - } - /** - * Utility method that creates a label instance with word wrap and sets - * the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @param indent the indent in pixels, or 0 for none - * @param widthHint the nominal width of the label - * @return the new label - */ - protected Label createWrappingLabel(Composite parent, String text, int indent) { - return createWrappingLabel(parent, text, indent, 1); - } - - protected Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { - Label label = new Label(parent, SWT.LEFT | SWT.WRAP); - label.setText(text); - GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); - data.horizontalIndent = indent; - data.horizontalSpan = horizontalSpan; - data.widthHint = LABEL_WIDTH_HINT; - label.setLayoutData(data); - return label; - } - - /** - * Create a text field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - static public Text createTextField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); - return layoutTextField(text); - } - /** - * Create a password field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - static public Text createPasswordField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD); - return layoutTextField(text); - } - /** - * Layout a text or password field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - static public Text layoutTextField(Text text) { - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.verticalAlignment = GridData.CENTER; - data.grabExcessVerticalSpace = false; - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - text.setLayoutData(data); - return text; - } - - /** - * Utility method to create a radio button - * - * @param parent the parent of the radio button - * @param label the label of the radio button - * @param span the number of columns to span - * @return the created radio button - */ - protected Button createRadioButton(Composite parent, String label, int span) { - Button button = new Button(parent, SWT.RADIO); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = span; - button.setLayoutData(data); - return button; - } - /** - * Utility method to create a full width separator preceeded by a blank space - * - * @param parent the parent of the separator - * @param verticalSpace the vertical whitespace to insert before the label - */ - protected void createSeparator(Composite parent, int verticalSpace) { - // space - Label label = new Label(parent, SWT.NONE); - GridData data = new GridData(); - data.heightHint = verticalSpace; - label.setLayoutData(data); - // separator - label = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - data = new GridData(GridData.FILL_HORIZONTAL); - label.setLayoutData(data); - } - - /** - * Creates a ListViewer whose input is an array of IFiles. - * - * @param parent the parent of the viewer - * @param title the text for the title label - * @param heightHint the nominal height of the list - * @return the created list viewer - */ - public ListViewer createFileListViewer(Composite parent, String title, int heightHint) { - createLabel(parent, title); - ListViewer listViewer = new ListViewer(parent, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); - listViewer.setContentProvider(new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - return (Object[]) inputElement; - } - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - }); - listViewer.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - return ((IFile) element).getFullPath().toString(); - } - }); - listViewer.setSorter(new WorkbenchViewerSorter()); - - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = heightHint; - listViewer.getList().setLayoutData(data); - return listViewer; - } - - protected TreeViewer createResourceSelectionTree(Composite composite, int types, int span) { - TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - tree.setUseHashlookup(true); - tree.setContentProvider(getResourceProvider(types)); - tree.setLabelProvider( - new DecoratingLabelProvider( - new WorkbenchLabelProvider(), - CVSUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator())); - tree.setSorter(new ResourceSorter(ResourceSorter.NAME)); - - GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); - data.heightHint = LIST_HEIGHT_HINT; - data.horizontalSpan = span; - tree.getControl().setLayoutData(data); - return tree; - } - - /** - * Returns a content provider for IResources that returns - * only children of the given resource type. - */ - protected ITreeContentProvider getResourceProvider(final int resourceType) { - return new WorkbenchContentProvider() { - public Object[] getChildren(Object o) { - if (o instanceof IContainer) { - IResource[] members = null; - try { - members = ((IContainer)o).members(); - } catch (CoreException e) { - //just return an empty set of children - return new Object[0]; - } - - //filter out the desired resource types - ArrayList results = new ArrayList(); - for (int i = 0; i < members.length; i++) { - //And the test bits with the resource types to see if they are what we want - if ((members[i].getType() & resourceType) > 0) { - results.add(members[i]); - } - } - return results.toArray(); - } else { - return super.getChildren(o); - } - } - }; - } - - protected RepositoryManager getRepositoryManager() { - return CVSUIPlugin.getPlugin().getRepositoryManager(); - } - - protected ICVSWizard getCVSWizard() { - if (wizard != null) { - return wizard; - } - IWizard wizard = getWizard(); - if (wizard instanceof ICVSWizard) { - // This is the method that is invoked when the next button is pressed - // Hence, assume that the page s about to be shown - return ((ICVSWizard)wizard); - } - return null; - } - - public void setCVSWizard(ICVSWizard wizard) { - this.wizard = wizard; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.WizardPage#getNextPage() - */ - public IWizardPage getNextPage() { - ICVSWizard w = getCVSWizard(); - if (w != null) { - // This is the method that is invoked when the next button is pressed - // Hence, assume that the page s about to be shown - return w.getNextPage(this, true /* about to show */); - } - return super.getNextPage(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage() - */ - public boolean canFlipToNextPage() { - ICVSWizard w = getCVSWizard(); - if (w != null) { - return isPageComplete() && - w.getNextPage(this, false /* about to show */) != null; - } - return super.canFlipToNextPage(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java deleted file mode 100644 index 4cfe29bf4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java +++ /dev/null @@ -1,316 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import java.io.File; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * @author Administrator - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class CheckoutAsLocationSelectionPage extends CVSWizardPage { - - public static final String NAME = "CheckoutAsLocationSelectionPage"; //$NON-NLS-1$ - - private Button browseButton; - private Text locationPathField; - private Label locationLabel; - private boolean useDefaults = true; - private ICVSRemoteFolder[] remoteFolders; - private String targetLocation; - private IProject singleProject; - - // constants - private static final int SIZING_TEXT_FIELD_WIDTH = 250; - - /** - * @param pageName - * @param title - * @param titleImage - * @param description - */ - public CheckoutAsLocationSelectionPage(ImageDescriptor titleImage, ICVSRemoteFolder[] remoteFolders) { - super(NAME, Policy.bind("CheckoutAsLocationSelectionPage.title"), titleImage, Policy.bind("CheckoutAsLocationSelectionPage.description")); //$NON-NLS-1$ //$NON-NLS-2$ - this.remoteFolders = remoteFolders; - } - - /** - * @return - */ - private boolean isSingleFolder() { - return remoteFolders.length == 1; - } - - /** - * @param string - */ - public void setProject(IProject project) { - singleProject = project; - } - - /** - * @param string - */ - public void setProjectName(String string) { - if (string == null || string.equals(".")) return; //$NON-NLS-1$ - if (singleProject != null && singleProject.getName().equals(string)) return; - setProject(ResourcesPlugin.getWorkspace().getRoot().getProject(string)); - } - - private IProject getSingleProject() { - if (singleProject == null) { - setProjectName(remoteFolders[0].getName()); - } - return singleProject; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite= createComposite(parent, 1, false); - setControl(composite); - // required in order to use setButtonLayoutData - initializeDialogUnits(composite); - - WorkbenchHelp.setHelp(composite, IHelpContextIds.CHECKOUT_LOCATION_SELECTION_PAGE); - - final Button useDefaultsButton = - new Button(composite, SWT.CHECK | SWT.RIGHT); - useDefaultsButton.setText(Policy.bind("CheckoutAsLocationSelectionPage.useDefaultLabel")); //$NON-NLS-1$ - useDefaultsButton.setSelection(this.useDefaults); - - createUserSpecifiedProjectLocationGroup(composite, !this.useDefaults); - - SelectionListener listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - useDefaults = useDefaultsButton.getSelection(); - browseButton.setEnabled(!useDefaults); - locationPathField.setEnabled(!useDefaults); - locationLabel.setEnabled(!useDefaults); - setLocationForSelection(true); - setErrorMessage(useDefaults ? null : checkValidLocation()); - } - }; - useDefaultsButton.addSelectionListener(listener); - Dialog.applyDialogFont(parent); - } - - /** - * Creates the project location specification controls. - * - * @return the parent of the widgets created - * @param projectGroup the parent composite - * @param enabled - sets the initial enabled state of the widgets - */ - private Composite createUserSpecifiedProjectLocationGroup(Composite parent, boolean enabled) { - - // This group needs 3 columns - Composite projectGroup = createComposite(parent, 3, false); - - // location label - locationLabel = new Label(projectGroup, SWT.NONE); - if (isSingleFolder()) { - locationLabel.setText(Policy.bind("CheckoutAsLocationSelectionPage.locationLabel")); //$NON-NLS-1$ - } else { - locationLabel.setText(Policy.bind("CheckoutAsLocationSelectionPage.parentDirectoryLabel")); //$NON-NLS-1$ - } - locationLabel.setEnabled(enabled); - - // project location entry field - locationPathField = new Text(projectGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - locationPathField.setLayoutData(data); - locationPathField.setEnabled(enabled); - - // browse button - this.browseButton = new Button(projectGroup, SWT.PUSH); - this.browseButton.setText(Policy.bind("CheckoutAsLocationSelectionPage.browseLabel")); //$NON-NLS-1$ - this.browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - handleLocationBrowseButtonPressed(); - } - }); - this.browseButton.setEnabled(enabled); - setButtonLayoutData(this.browseButton); - - // Set the initial value first before listener - // to avoid handling an event during the creation. - setLocationForSelection(true); - locationPathField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - setErrorMessage(checkValidLocation()); - } - }); - return projectGroup; - } - - /** - * Check if the entry in the widget location is valid. If it is valid return null. Otherwise - * return a string that indicates the problem. - */ - private String checkValidLocation() { - - if (useDefaults) { - targetLocation = null; - return null; - } else { - targetLocation = locationPathField.getText(); - if (targetLocation.equals("")) {//$NON-NLS-1$ - return(Policy.bind("CheckoutAsLocationSelectionPage.locationEmpty")); //$NON-NLS-1$ - } - else{ - IPath path = new Path("");//$NON-NLS-1$ - if (!path.isValidPath(targetLocation)) { - return Policy.bind("CheckoutAsLocationSelectionPage.invalidLocation"); //$NON-NLS-1$ - } - } - - if (isSingleFolder()) { - IStatus locationStatus = - ResourcesPlugin.getWorkspace().validateProjectLocation( - getSingleProject(), - new Path(targetLocation)); - - if (!locationStatus.isOK()) - return locationStatus.getMessage(); - } else { - for (int i = 0; i < remoteFolders.length; i++) { - String projectName = remoteFolders[i].getName(); - IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocation( - ResourcesPlugin.getWorkspace().getRoot().getProject(projectName), - new Path(targetLocation).append(projectName)); - if (!locationStatus.isOK()) - return locationStatus.getMessage(); - } - } - - return null; - } - } - - /** - * Set the location to the default location if we are set to useDefaults. - */ - private void setLocationForSelection(boolean changed) { - if (useDefaults) { - IPath defaultPath = null; - if (isSingleFolder()) { - IProject singleProject = getSingleProject(); - if (singleProject != null) { - try { - defaultPath = singleProject.getDescription().getLocation(); - } catch (CoreException e) { - // ignore - } - if (defaultPath == null) { - defaultPath = Platform.getLocation().append(singleProject.getName()); - } - } - } else { - defaultPath = Platform.getLocation(); - } - if (defaultPath != null) { - locationPathField.setText(defaultPath.toOSString()); - } - targetLocation = null; - } else if (changed) { - IPath location = null; - IProject project = getSingleProject(); - if (project != null) { - try { - location = project.getDescription().getLocation(); - } catch (CoreException e) { - // ignore the exception - } - } - if (location == null) { - targetLocation = null; - locationPathField.setText(""); //$NON-NLS-1$ - } else { - if (isSingleFolder()) { - targetLocation = location.toOSString(); - } else { - targetLocation = location.removeLastSegments(1).toOSString(); - } - locationPathField.setText(targetLocation); - } - } - } - - /** - * Open an appropriate directory browser - */ - private void handleLocationBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell()); - if (isSingleFolder()) { - dialog.setMessage(Policy.bind("CheckoutAsLocationSelectionPage.messageForSingle", getSingleProject().getName())); //$NON-NLS-1$ - } else { - dialog.setMessage(Policy.bind("CheckoutAsLocationSelectionPage.messageForMulti", new Integer(remoteFolders.length).toString())); //$NON-NLS-1$ - } - - String dirName = locationPathField.getText(); - if (!dirName.equals("")) {//$NON-NLS-1$ - File path = new File(dirName); - if (path.exists()) - dialog.setFilterPath(dirName); - } - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - if (isSingleFolder()) { - locationPathField.setText(new Path(selectedDirectory).append(getSingleProject().getName()).toOSString()); - } else { - locationPathField.setText(new Path(selectedDirectory).toOSString()); - } - } - targetLocation = locationPathField.getText(); - } - - /** - * Return the custom location for a single project. In this case, the specified - * location is used as the location of the project. - * - * @param project - * @return - */ - public String getTargetLocation() { - if (isCustomLocationSpecified()) - return targetLocation; - else - return null; - } - - /** - * @return - */ - private boolean isCustomLocationSpecified() { - return !useDefaults; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java deleted file mode 100644 index 2bf436d1d..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * This is the main page of the Check Out As wizard. It allows the user to specify - * whether they want to check out the remote folder(s) as project(s) or into an - * existing project. For single project checkout, the page will also allow the user to - * choose whether to configure the new project (if it is missing a .project file). - */ -public class CheckoutAsMainPage extends CVSWizardPage { - - private String newProjectName; - private boolean allowProjectConfiguration; - private Button intoProjectButton; - private Button simpleProjectButton; - private Button configuredProjectButton; - private Text projectNameField; - private ICVSRemoteFolder[] folders; - - public static final String NAME = "CheckoutAsMainPage"; //$NON-NLS-1$ - - /** - * @param pageName - * @param title - * @param titleImage - * @param description - */ - public CheckoutAsMainPage(ImageDescriptor titleImage, ICVSRemoteFolder[] folders, boolean allowProjectConfiguration) { - super(NAME, Policy.bind("CheckoutAsMainPage.title"), titleImage, Policy.bind("CheckoutAsMainPage.description")); //$NON-NLS-1$ //$NON-NLS-2$ - this.folders = folders; - this.allowProjectConfiguration = allowProjectConfiguration; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - - Composite composite = createComposite(parent, 1, false); - setControl(composite); - - WorkbenchHelp.setHelp(composite, IHelpContextIds.CHECKOUT_CONFIGURATION_PAGE); - - if (isSingleFolder()) { - createSingleFolderArea(composite); - } else { - createMultipleFoldersArea(composite); - } - - updateEnablements(); - Dialog.applyDialogFont(parent); - } - - /* - * Is the input to the wizard a single folder or multiple folders - */ - private boolean isSingleFolder() { - return folders.length == 1; - } - - /* - * For the single folder case, return the name of the folder - */ - private String getFolderName() { - String name = folders[0].getName(); - if (name .equals(".")) { //$NON-NLS-1$ - name = new Path(null, folders[0].getRepository().getRootDirectory()).lastSegment(); - } - return name; - } - - /* - * Create the page contents for a single folder checkout - */ - private void createSingleFolderArea(Composite composite) { - createLabel(composite, Policy.bind("CheckoutAsMainPage.singleFolder", getFolderName())); //$NON-NLS-1$ - configuredProjectButton = createRadioButton(composite, Policy.bind("CheckoutAsMainPage.asConfiguredProject"), 1); //$NON-NLS-1$ - if (!allowProjectConfiguration) { - configuredProjectButton.setEnabled(false); - Label configuredLabel = createWrappingLabel(composite, Policy.bind("CheckoutAsMainPage.10"), 5); //$NON-NLS-1$ - configuredLabel.setEnabled(false); - } - createCheckoutAsProjectRadioArea(composite); - createCheckoutIntoRadioArea(composite); - if (allowProjectConfiguration) { - configuredProjectButton.setSelection(true); - } else { - simpleProjectButton.setSelection(true); - } - } - - /* - * Create the page contents for a multiple folder checkout - */ - private void createMultipleFoldersArea(Composite composite) { - createLabel(composite, Policy.bind("CheckoutAsMainPage.multipleFolders", new Integer(folders.length).toString())); //$NON-NLS-1$ - createCheckoutAsProjectRadioArea(composite); - createCheckoutIntoRadioArea(composite); - simpleProjectButton.setSelection(true); - } - - /** - * @param composite - */ - private void createCheckoutAsProjectRadioArea(Composite composite) { - if (isSingleFolder()) { - simpleProjectButton = createRadioButton(composite, Policy.bind("CheckoutAsMainPage.asSimpleProject"), 1); //$NON-NLS-1$ - createProjectNameGroup(composite); - } else { - simpleProjectButton = createRadioButton(composite, Policy.bind("CheckoutAsMainPage.asProjects"), 1); //$NON-NLS-1$ - } - } - - /** - * @param composite - */ - private void createCheckoutIntoRadioArea(Composite composite) { - intoProjectButton = createRadioButton(composite, Policy.bind("CheckoutAsMainPage.intoProject"), 1); //$NON-NLS-1$ - } - - /** - * Creates the project name specification controls. - * - * @param parent the parent composite - */ - private void createProjectNameGroup(Composite parent) { - // project specification group - Composite projectGroup = new Composite(parent,SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - projectGroup.setLayout(layout); - projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // new project label - Label projectLabel = new Label(projectGroup,SWT.NONE); - projectLabel.setText(Policy.bind("CheckoutAsMainPage.projectNameLabel")); //$NON-NLS-1$ - - // new project name entry field - projectNameField = new Text(projectGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - projectNameField.setLayoutData(data); - - // Set the initial value first before listener - // to avoid handling an event during the creation. - newProjectName = getFolderName(); - projectNameField.setText(newProjectName); - projectNameField.selectAll(); - - // Set the listener to capture modify events - projectNameField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateEnablements(); - } - }); - } - - /** - * Check if the entries in the widget are valid. If they are return null otherwise - * return a string that indicates the problem. - */ - private void updateEnablements() { - - if (projectNameField != null) { - projectNameField.setEnabled(simpleProjectButton.getSelection()); - if (projectNameField.isEnabled()) { - newProjectName = this.projectNameField.getText(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus nameStatus = workspace.validateName(newProjectName, IResource.PROJECT); - if (!nameStatus.isOK()) { - setErrorMessage(nameStatus.getMessage()); - setPageComplete(false); - } - } - } - setErrorMessage(null); - setPageComplete(true); - } - - public String getProjectName() { - if (isSingleFolder() && simpleProjectButton.getSelection()) return newProjectName; - return null; - } - - public boolean isPerformConfigure() { - if (configuredProjectButton == null) return false; - return configuredProjectButton.getSelection(); - } - - public boolean isPerformCheckoutInto() { - return intoProjectButton.getSelection(); - } - - public boolean isPerformCheckoutAs() { - return simpleProjectButton.getSelection(); - } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage#createRadioButton(org.eclipse.swt.widgets.Composite, java.lang.String, int) - */ - protected Button createRadioButton(Composite parent, String label, int span) { - Button radio = super.createRadioButton(parent, label, span); - radio.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateEnablements(); - } - }); - return radio; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java deleted file mode 100644 index 2b58b1c97..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * This page allows the user to select the target parent container for - * the folders being checked out. - */ -public class CheckoutAsProjectSelectionPage extends CVSWizardPage { - - public static final String NAME = "CheckoutAsProjectSelectionPage"; //$NON-NLS-1$ - - private TreeViewer tree; - private Text nameField; - private Combo filterList; - private Button recurseCheck; - - private IResource selection; - private ICVSRemoteFolder[] remoteFolders; - private String folderName; - private boolean recurse; - private int filter; - - /** - * Constructor for CheckoutIntoProjectSelectionPage. - * @param pageName - * @param title - * @param titleImage - */ - public CheckoutAsProjectSelectionPage(ImageDescriptor titleImage, ICVSRemoteFolder[] remoteFolders) { - super(NAME, Policy.bind("CheckoutAsProjectSelectionPage.title"), titleImage, Policy.bind("CheckoutAsProjectSelectionPage.description")); //$NON-NLS-1$ //$NON-NLS-2$ - this.remoteFolders = remoteFolders; - } - - /** - * @return - */ - private boolean isSingleFolder() { - return remoteFolders.length == 1; - } - - /* - * For the single folder case, return the name of the folder - */ - private String getInputFolderName() { - return remoteFolders[0].getName(); - } - - private String getRepository() throws CVSException { - return remoteFolders[0].getFolderSyncInfo().getRoot(); - } - - /** - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite= createComposite(parent, 2, false); - setControl(composite); - - WorkbenchHelp.setHelp(composite, IHelpContextIds.CHECKOUT_PROJECT_SELECTION_PAGE); - - if (isSingleFolder()) { - createLabel(composite, Policy.bind("CheckoutAsProjectSelectionPage.name")); //$NON-NLS-1$ - nameField = createTextField(composite); - nameField.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - folderName = nameField.getText(); - updateWidgetEnablements(); - } - }); - } - - createWrappingLabel(composite, Policy.bind("CheckoutAsProjectSelectionPage.treeLabel"), 0, 2); //$NON-NLS-1$ - - tree = createResourceSelectionTree(composite, IResource.PROJECT | IResource.FOLDER, 2 /* horizontal span */); - tree.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - handleResourceSelection(event); - } - }); - - Composite filterComposite = createComposite(composite, 2, false); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - filterComposite.setLayoutData(data); - createLabel(filterComposite, Policy.bind("CheckoutAsProjectSelectionPage.showLabel")); //$NON-NLS-1$ - filterList = createCombo(filterComposite); - filterList.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleFilterSelection(); - } - }); - - createWrappingLabel(composite, "", 0, 2); //$NON-NLS-1$ - - // Should subfolders of the folder be checked out? - recurseCheck = createCheckBox(composite, Policy.bind("CheckoutAsProjectSelectionPage.recurse")); //$NON-NLS-1$ - recurseCheck.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - recurse = recurseCheck.getSelection(); - updateWidgetEnablements(); - } - }); - - initializeValues(); - updateWidgetEnablements(); - tree.getControl().setFocus(); - Dialog.applyDialogFont(parent); - } - - /** - * Method initializeValues. - */ - private void initializeValues() { - if (isSingleFolder()) { - nameField.setText(getInputFolderName()); - } - tree.setInput(ResourcesPlugin.getWorkspace().getRoot()); - recurse = true; - recurseCheck.setSelection(recurse); - filter = 0; - updateTreeContents(filter); - filterList.add(Policy.bind("CheckoutAsProjectSelectionPage.showAll")); //$NON-NLS-1$ - filterList.add(Policy.bind("CheckoutAsProjectSelectionPage.showUnshared")); //$NON-NLS-1$ - filterList.add(Policy.bind("CheckoutAsProjectSelectionPage.showSameRepo")); //$NON-NLS-1$ - filterList.select(filter); - } - - private void handleResourceSelection(SelectionChangedEvent event) { - ISelection sel = event.getSelection(); - if (sel.isEmpty()) { - this.selection = null; - } else if (sel instanceof IStructuredSelection) { - this.selection = (IResource)((IStructuredSelection)sel).getFirstElement(); - } - updateWidgetEnablements(); - } - - /** - * Method updateWidgetEnablement. - */ - private void updateWidgetEnablements() { - if (isSingleFolder() && !Path.EMPTY.isValidSegment(folderName)) { - setPageComplete(false); - setErrorMessage(Policy.bind("CheckoutAsProjectSelectionPage.invalidFolderName", folderName)); //$NON-NLS-1$ - return; - } - boolean complete = selection != null && selection.getType() != IResource.FILE; - setErrorMessage(null); - setPageComplete(complete); - } - - /** - * Returns the selection. - * @return IResource - */ - public IResource getSelection() { - return selection; - } - - /** - * Returns the folderName. - * @return String - */ - public String getFolderName() { - return folderName; - } - - private void updateTreeContents(int selected) { - try { - if (selected == 0) { - tree.setInput(new AdaptableResourceList(getProjects(getRepository(), true))); - } else if (selected == 1) { - tree.setInput(new AdaptableResourceList(getProjects(null, true))); - } else if (selected == 2) { - tree.setInput(new AdaptableResourceList(getProjects(getRepository(), false))); - } - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - - /** - * Method getValidTargetProjects returns the set of projects that match the provided criteria. - * @return IResource - */ - private IProject[] getProjects(String root, boolean unshared) throws CVSException { - List validTargets = new ArrayList(); - try { - IResource[] projects = ResourcesPlugin.getWorkspace().getRoot().members(); - for (int i = 0; i < projects.length; i++) { - IResource resource = projects[i]; - if (resource instanceof IProject) { - IProject project = (IProject) resource; - if (project.isAccessible()) { - RepositoryProvider provider = RepositoryProvider.getProvider(project); - if (provider == null && unshared) { - validTargets.add(project); - } else if (provider != null && provider.getID().equals(CVSProviderPlugin.getTypeId())) { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(project); - FolderSyncInfo info = cvsFolder.getFolderSyncInfo(); - if (root != null && info != null && root.equals(info.getRoot())) { - validTargets.add(project); - } - } - } - } - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - return (IProject[]) validTargets.toArray(new IProject[validTargets.size()]); - } - - public IContainer getLocalFolder() { - if (Path.EMPTY.isValidSegment(folderName)) { - return ((IContainer)getSelection()).getFolder(new Path(null, folderName)); - } else { - return null; - } - } - - public IContainer getParentFolder() { - return ((IContainer)getSelection()); - } - - /** - * Returns the recurse. - * @return boolean - */ - public boolean isRecurse() { - return recurse; - } - - private void handleFilterSelection() { - filter = filterList.getSelectionIndex(); - updateTreeContents(filter); - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java deleted file mode 100644 index 0dfe5a4db..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.*; -import org.eclipse.team.internal.ccvs.ui.tags.*; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.NewProjectAction; - -/** - * @author Administrator - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class CheckoutAsWizard extends Wizard { - - private ICVSRemoteFolder[] remoteFolders; - private boolean allowProjectConfiguration; - - private CheckoutAsMainPage mainPage; - private CheckoutAsProjectSelectionPage projectSelectionPage; - private CheckoutAsLocationSelectionPage locationSelectionPage; - private TagSelectionWizardPage tagSelectionPage; - private IWorkbenchPart part; - - class NewProjectListener implements IResourceChangeListener { - private IProject newProject = null; - /** - * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta root = event.getDelta(); - IResourceDelta[] projectDeltas = root.getAffectedChildren(); - for (int i = 0; i < projectDeltas.length; i++) { - IResourceDelta delta = projectDeltas[i]; - IResource resource = delta.getResource(); - if (delta.getKind() == IResourceDelta.ADDED) { - newProject = (IProject)resource; - } - } - } - /** - * Gets the newProject. - * @return Returns a IProject - */ - public IProject getNewProject() { - return newProject; - } - } - - public CheckoutAsWizard(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, boolean allowProjectConfiguration) { - this.part = part; - this.remoteFolders = remoteFolders; - setWindowTitle(Policy.bind("CheckoutAsWizard.title")); //$NON-NLS-1$ - this.allowProjectConfiguration = allowProjectConfiguration; - } - - /** - * @see org.eclipse.jface.wizard.IWizard#addPages() - */ - public void addPages() { - setNeedsProgressMonitor(true); - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); - - mainPage = new CheckoutAsMainPage(substImage, remoteFolders, allowProjectConfiguration); - addPage(mainPage); - - projectSelectionPage = new CheckoutAsProjectSelectionPage(substImage, remoteFolders); - addPage(projectSelectionPage); - - locationSelectionPage = new CheckoutAsLocationSelectionPage(substImage, remoteFolders); - addPage(locationSelectionPage); - - tagSelectionPage = new TagSelectionWizardPage("tagPage", Policy.bind("CheckoutAsWizard.3"), substImage, Policy.bind("CheckoutAsWizard.4"), TagSource.create(remoteFolders), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - TagSelectionArea.INCLUDE_HEAD_TAG | - TagSelectionArea.INCLUDE_BRANCHES | - TagSelectionArea.INCLUDE_VERSIONS | - TagSelectionArea.INCLUDE_DATES - ); - if (remoteFolders.length > 0) { - try { - CVSTag selectedTag = remoteFolders[0].getFolderSyncInfo().getTag(); - tagSelectionPage.setSelection(selectedTag); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - tagSelectionPage.setHelpContxtId(IHelpContextIds.CHECKOUT_TAG_SELETION_PAGE); - addPage(tagSelectionPage); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - try { - if (mainPage.isPerformConfigure()) { - return performConfigureAndCheckout(); - } else if (mainPage.isPerformCheckoutAs()) { - if (isSingleFolder()) { - return performSingleCheckoutAs(); - } else { - return performMultipleCheckoutAs(); - } - } else if (mainPage.isPerformCheckoutInto()) { - return performCheckoutInto(); - } - } catch (InvocationTargetException e) { - handle(e); - // drop through - } catch (InterruptedException e) { - // drop through - } - return false; - } - - /** - * @return - */ - private boolean isSingleFolder() { - return remoteFolders.length == 1; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#canFinish() - */ - public boolean canFinish() { - return (mainPage.isPageComplete() - && (mainPage.isPerformConfigure() - || (mainPage.isPerformCheckoutInto() && projectSelectionPage.isPageComplete()) - || (mainPage.isPerformCheckoutAs() && locationSelectionPage.isPageComplete()))); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getNextPage(IWizardPage page) { - if (page == mainPage) { - if (mainPage.isPerformConfigure()) return tagSelectionPage; - if (mainPage.isPerformCheckoutInto()) return projectSelectionPage; - if (mainPage.isPerformCheckoutAs()) { - if (isSingleFolder()) { - locationSelectionPage.setProjectName(mainPage.getProjectName()); - } else { - locationSelectionPage.setProject(null); - } - return locationSelectionPage; - } - } - // The tag selection page is always shown as the last page - if (page != tagSelectionPage) { - return tagSelectionPage; - } - return null; - } - - private void handle(Throwable e) { - CVSUIPlugin.openError(getShell(), Policy.bind("CheckoutAsWizard.error"), null, e); //$NON-NLS-1$ - } - - /* - * Configure a local project and checkout the selected remote folder into the project. - * This only occurs for single folders. - */ - private boolean performConfigureAndCheckout() throws InvocationTargetException, InterruptedException { - IProject newProject = getNewProject(); - if (newProject == null) return false; - // Run the checkout in the background - ICVSRemoteFolder folder = getRemoteFolder(); - new CheckoutSingleProjectOperation(part, folder, newProject, null, true).run(); - return true; - } - - /* - * Return the single remote folder to be checked out - */ - private ICVSRemoteFolder getRemoteFolder() { - ICVSRemoteFolder folder = remoteFolders[0]; - folder = (ICVSRemoteFolder)folder.forTag(getSelectedTag()); - return folder; - } - - /* - * Return the remote folders to be checked out - */ - private ICVSRemoteFolder[] getRemoteFolders() { - ICVSRemoteFolder[] folders = new ICVSRemoteFolder[remoteFolders.length]; - for (int i = 0; i < remoteFolders.length; i++) { - ICVSRemoteFolder remote = remoteFolders[i]; - folders[i] = (ICVSRemoteFolder)remote.forTag(getSelectedTag()); - } - return folders; - } - - private CVSTag getSelectedTag() { - return tagSelectionPage.getSelectedTag(); - } - - private boolean performSingleCheckoutAs() throws InvocationTargetException, InterruptedException { - IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(mainPage.getProjectName()); - String targetLocation = locationSelectionPage.getTargetLocation(); - // Run the checkout in the background - ICVSRemoteFolder folder = getRemoteFolder(); - new CheckoutSingleProjectOperation(part, folder, newProject, targetLocation, false).run(); - return true; - } - - /** - * Check out multiple folders to the workspace using a custom location if one is - * specified. - */ - private boolean performMultipleCheckoutAs() throws InvocationTargetException, InterruptedException { - String targetLocation = locationSelectionPage.getTargetLocation(); - // Run the checkout in the background - new CheckoutMultipleProjectsOperation(part, getRemoteFolders(), targetLocation).run(); - return true; - } - - private boolean performCheckoutInto() throws InvocationTargetException, InterruptedException { - CheckoutIntoOperation operation; - boolean recursive = projectSelectionPage.isRecurse(); - if (isSingleFolder()) { - ICVSRemoteFolder folder = getRemoteFolder(); - operation = new CheckoutIntoOperation(part, folder, projectSelectionPage.getLocalFolder(), recursive); - } else { - operation = new CheckoutIntoOperation(part, getRemoteFolders(), projectSelectionPage.getParentFolder(), recursive); - } - // Run the checkout in the background - operation.run(); - return true; - } - - /** - * Get a new project that is configured by the new project wizard. - * This is currently the only way to do this. - */ - private IProject getNewProject() { - NewProjectListener listener = new NewProjectListener(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); - (new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow())).run(); - ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener); - IProject project = listener.getNewProject(); - return project; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java deleted file mode 100644 index 04bfdefe3..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java +++ /dev/null @@ -1,287 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; -import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; -import org.eclipse.ui.*; - -/** - * Gathers all information necesary for a checkout from a repository. - */ -public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { - - private RepositorySelectionPage locationPage; - private ConfigurationWizardMainPage createLocationPage; - private ModuleSelectionPage modulePage; - private CheckoutAsWizard wizard; - private ICVSRepositoryLocation location; - private boolean isNewLocation; - private CVSWizardPage dummyPage; - - public CheckoutWizard() { - setWindowTitle(Policy.bind("CheckoutWizard.0")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - public void addPages() { - setNeedsProgressMonitor(true); - - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); - - ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(); - if (locations.length > 0) { - locationPage = new RepositorySelectionPage("locationSelection", Policy.bind("CheckoutWizard.7"), substImage); //$NON-NLS-1$ //$NON-NLS-2$ - locationPage.setDescription(Policy.bind("SharingWizard.importTitleDescription")); //$NON-NLS-1$ - locationPage.setExtendedDescription(Policy.bind("CheckoutWizard.8")); //$NON-NLS-1$ - addPage(locationPage); - } - - createLocationPage = new ConfigurationWizardMainPage("createLocationPage", Policy.bind("SharingWizard.enterInformation"), substImage); //$NON-NLS-1$ //$NON-NLS-2$ - createLocationPage.setDescription(Policy.bind("SharingWizard.enterInformationDescription")); //$NON-NLS-1$ - addPage(createLocationPage); - createLocationPage.setDialogSettings(NewLocationWizard.getLocationDialogSettings()); - - modulePage = new ModuleSelectionPage("moduleSelection", Policy.bind("CheckoutWizard.10"), substImage); //$NON-NLS-1$ //$NON-NLS-2$ - modulePage.setDescription(Policy.bind("CheckoutWizard.11")); //$NON-NLS-1$ - modulePage.setHelpContxtId(IHelpContextIds.CHECKOUT_MODULE_SELECTION_PAGE); - modulePage.setSupportsMultiSelection(true); - addPage(modulePage); - - // Dummy page to allow lazy creation of CheckoutAsWizard - dummyPage = new CVSWizardPage("dummyPage") { //$NON-NLS-1$ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1, false); - setControl(composite); - } - }; - addPage(dummyPage); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#canFinish() - */ - public boolean canFinish() { - return (wizard == null && getSelectedModules().length > 0) || - (wizard != null && wizard.canFinish()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - if (wizard != null) { - // The finish of the child wizard will get called directly. - // We only get here if it completed successfully - if (isNewLocation) { - KnownRepositories.getInstance().addRepository(location, true /* broadcast */); - } - return true; - } else { - try { - new CheckoutMultipleProjectsOperation(getPart(), getSelectedModules(), null) - .run(); - if (isNewLocation) { - KnownRepositories.getInstance().addRepository(location, true /* broadcast */); - } - return true; - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - } catch (InterruptedException e) { - // Cancelled. fall through. - } - return false; - } - } - - private IWorkbenchPart getPart() { - // This wizard doesn't have a part - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#performCancel() - */ - public boolean performCancel() { - if (location != null && isNewLocation) { - KnownRepositories.getInstance().disposeRepository(location); - location = null; - } - return wizard == null || wizard.performCancel(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getNextPage(IWizardPage page) { - // Assume the page is about to be shown when this method is - // invoked - return getNextPage(page, true /* about to show*/); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.wizards.ICVSWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage, boolean) - */ - public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow) { - if (page == locationPage) { - if (locationPage.getLocation() == null) { - return createLocationPage; - } else { - if (aboutToShow) { - try { - modulePage.setLocation(getLocation()); - } catch (TeamException e1) { - CVSUIPlugin.log(e1); - } - } - return modulePage; - } - } - if (page == createLocationPage) { - if (aboutToShow) { - try { - ICVSRepositoryLocation l = getLocation(); - if (l != null) { - modulePage.setLocation(l); - } - } catch (TeamException e1) { - CVSUIPlugin.log(e1); - } - } - return modulePage; - } - if (page == modulePage) { - ICVSRemoteFolder[] selectedModules = getSelectedModules(); - if (selectedModules.length == 0) return null; - for (int i = 0; i < selectedModules.length; i++) { - ICVSRemoteFolder folder = selectedModules[i]; - if (folder.isDefinedModule()) { - // No further configuration is possible for defined modules - return null; - } - } - if (aboutToShow) { - try { - boolean hasMetafile = true; - if (selectedModules.length == 1) { - // Only allow configuration if one module is selected - hasMetafile = hasProjectMetafile(selectedModules[0]); - } - wizard = new CheckoutAsWizard(getPart(), selectedModules, ! hasMetafile /* allow configuration */); - wizard.addPages(); - return wizard.getStartingPage(); - } catch (InvocationTargetException e) { - // Show the error and fall through to return null as the next page - CVSUIPlugin.openError(getShell(), null, null, e); - } catch (InterruptedException e) { - // Cancelled by user. Fall through and return null - } - return null; - } else { - if (wizard == null) { - return dummyPage; - } else { - return wizard.getStartingPage(); - } - } - } - if (wizard != null) { - return wizard.getNextPage(page); - } - return null; - } - - private boolean hasProjectMetafile(final ICVSRemoteFolder selectedModule) throws InvocationTargetException, InterruptedException { - final boolean[] result = new boolean[] { true }; - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(getPart(), selectedModule); - op.run(monitor); - result[0] = op.metaFileExists(); - } - }); - return result[0]; - } - - private ICVSRemoteFolder[] getSelectedModules() { - if (modulePage == null) return null; - return modulePage.getSelectedModules(); - } - - /** - * Return an ICVSRepositoryLocation - */ - private ICVSRepositoryLocation getLocation() throws TeamException { - // If the location page has a location, use it. - if (locationPage != null) { - ICVSRepositoryLocation newLocation = locationPage.getLocation(); - if (newLocation != null) { - return recordLocation(newLocation); - } - } - - // Otherwise, get the location from the create location page - final ICVSRepositoryLocation[] locations = new ICVSRepositoryLocation[] { null }; - final CVSException[] exception = new CVSException[] { null }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - try { - locations[0] = createLocationPage.getLocation(); - } catch (CVSException e) { - exception[0] = e; - } - } - }); - if (exception[0] != null) { - throw exception[0]; - } - return recordLocation(locations[0]); - } - - private ICVSRepositoryLocation recordLocation(ICVSRepositoryLocation newLocation) { - if (newLocation == null) return location; - if (location == null || !newLocation.equals(location)) { - if (location != null && isNewLocation) { - // Dispose of the previous location - KnownRepositories.getInstance().disposeRepository(location); - } - location = newLocation; - isNewLocation = !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation()); - if (isNewLocation) { - // Add the location silently so we can work with it - location = KnownRepositories.getInstance().addRepository(location, false /* silently */); - } - } - return location; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java deleted file mode 100644 index 072d36252..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * This configuration page explains to the user that CVS/ directories already exists and - * it will attach the selected project to the repository that is specified in the CVS/ files. - * - * This is useful for people who have checked out a project using command-line tools. - */ -public class ConfigurationWizardAutoconnectPage extends CVSWizardPage { - private boolean validate = true; - private FolderSyncInfo info; - ICVSRepositoryLocation location; - - public ConfigurationWizardAutoconnectPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - - /* - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 2, false); - setControl(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARING_AUTOCONNECT_PAGE); - - Label description = new Label(composite, SWT.WRAP); - GridData data = new GridData(); - data.horizontalSpan = 2; - data.widthHint = 350; - description.setLayoutData(data); - description.setText(Policy.bind("ConfigurationWizardAutoconnectPage.description")); //$NON-NLS-1$ - - if (location == null) return; - - // Spacer - createLabel(composite, ""); //$NON-NLS-1$ - createLabel(composite, ""); //$NON-NLS-1$ - - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.user")); //$NON-NLS-1$ - createLabel(composite, location.getUsername()); - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.host")); //$NON-NLS-1$ - createLabel(composite, location.getHost()); - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.port")); //$NON-NLS-1$ - int port = location.getPort(); - if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.default")); //$NON-NLS-1$ - } else { - createLabel(composite, "" + port); //$NON-NLS-1$ - } - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.connectionType")); //$NON-NLS-1$ - createLabel(composite, location.getMethod().getName()); - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.repositoryPath")); //$NON-NLS-1$ - createLabel(composite, location.getRootDirectory()); - createLabel(composite, Policy.bind("ConfigurationWizardAutoconnectPage.module")); //$NON-NLS-1$ - createLabel(composite, info.getRepository()); - - // Spacer - createLabel(composite, ""); //$NON-NLS-1$ - createLabel(composite, ""); //$NON-NLS-1$ - - final Button check = new Button(composite, SWT.CHECK); - data = new GridData(); - data.horizontalSpan = 2; - check.setText(Policy.bind("ConfigurationWizardAutoconnectPage.validate")); //$NON-NLS-1$ - check.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - validate = check.getSelection(); - } - }); - check.setSelection(true); - Dialog.applyDialogFont(parent); - } - - public FolderSyncInfo getFolderSyncInfo() { - return info; - } - public boolean getValidate() { - return validate; - } - public void setProject(IProject project) { - try { - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); - info = folder.getFolderSyncInfo(); - if (info == null) { - // This should never happen - CVSUIPlugin.openError(null, Policy.bind("ConfigurationWizardAutoconnectPage.noSyncInfo"), Policy.bind("ConfigurationWizardAutoconnectPage.noCVSDirectory"), null); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - location = CVSRepositoryLocation.fromString(info.getRoot()); - } catch (TeamException e) { - CVSUIPlugin.openError(null, null, null, e); - } - } - - public FolderSyncInfo getSharing() { - return info; - } - - /** - * Gets the location. - * @return Returns a ICVSRepositoryLocation - */ - public ICVSRepositoryLocation getLocation() { - return location; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java deleted file mode 100644 index 24aa65f36..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java +++ /dev/null @@ -1,616 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.IConnectionMethod; -import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Wizard page for entering information about a CVS repository location. - */ -public class ConfigurationWizardMainPage extends CVSWizardPage { - private boolean showValidate; - private boolean validate; - - // Widgets - - // Connection Method - private Combo connectionMethodCombo; - // User - private Combo userCombo; - // Password - private Text passwordText; - // Port - private Text portText; - private Button useDefaultPort; - private Button useCustomPort; - // Host - private Combo hostCombo; - // Repository Path - private Combo repositoryPathCombo; - // Validation - private Button validateButton; - // Caching password - private Button allowCachingButton; - private boolean allowCaching = false; - - private static final int COMBO_HISTORY_LENGTH = 5; - - private Properties properties = null; - - // The previously created repository. - // It is recorded when asked for and - // nulled when the page is changed. - private ICVSRepositoryLocation location; - - // The previously created repository. - // It is recorded when fields are changed - private ICVSRepositoryLocation oldLocation; - - // Dialog store id constants - private static final String STORE_USERNAME_ID = - "ConfigurationWizardMainPage.STORE_USERNAME_ID";//$NON-NLS-1$ - private static final String STORE_HOSTNAME_ID = - "ConfigurationWizardMainPage.STORE_HOSTNAME_ID";//$NON-NLS-1$ - private static final String STORE_PATH_ID = - "ConfigurationWizardMainPage.STORE_PATH_ID";//$NON-NLS-1$ - private static final String STORE_DONT_VALIDATE_ID = - "ConfigurationWizardMainPage.STORE_DONT_VALIDATE_ID";//$NON-NLS-1$ - - // In case the page was launched from a different wizard - private IDialogSettings settings; - - /** - * ConfigurationWizardMainPage constructor. - * - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page - */ - public ConfigurationWizardMainPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - /** - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH. - * - * @param history the current history - * @param newEntry the entry to add to the history - * @return the history with the new entry appended - */ - private String[] addToHistory(String[] history, String newEntry) { - ArrayList l = new ArrayList(Arrays.asList(history)); - addToHistory(l, newEntry); - String[] r = new String[l.size()]; - l.toArray(r); - return r; - } - protected IDialogSettings getDialogSettings() { - return settings; - } - protected void setDialogSettings(IDialogSettings settings) { - this.settings = settings; - } - /** - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH. - * - * @param history the current history - * @param newEntry the entry to add to the history - */ - private void addToHistory(List history, String newEntry) { - history.remove(newEntry); - history.add(0,newEntry); - - // since only one new item was added, we can be over the limit - // by at most one item - if (history.size() > COMBO_HISTORY_LENGTH) - history.remove(COMBO_HISTORY_LENGTH); - } - /** - * Creates the UI part of the page. - * - * @param parent the parent of the created widgets - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 2, false); - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARING_NEW_REPOSITORY_PAGE); - - Listener listener = new Listener() { - public void handleEvent(Event event) { - if (location != null) { - oldLocation = location; - location = null; - } - updateWidgetEnablements(); - } - }; - - Group g = createGroup(composite, Policy.bind("ConfigurationWizardMainPage.Location_1")); //$NON-NLS-1$ - - // Host name - createLabel(g, Policy.bind("ConfigurationWizardMainPage.host")); //$NON-NLS-1$ - hostCombo = createEditableCombo(g); - hostCombo.addListener(SWT.Selection, listener); - hostCombo.addListener(SWT.Modify, listener); - - // Repository Path - createLabel(g, Policy.bind("ConfigurationWizardMainPage.repositoryPath")); //$NON-NLS-1$ - repositoryPathCombo = createEditableCombo(g); - repositoryPathCombo.addListener(SWT.Selection, listener); - repositoryPathCombo.addListener(SWT.Modify, listener); - - g = createGroup(composite, Policy.bind("ConfigurationWizardMainPage.Authentication_2")); //$NON-NLS-1$ - - // User name - createLabel(g, Policy.bind("ConfigurationWizardMainPage.userName")); //$NON-NLS-1$ - userCombo = createEditableCombo(g); - userCombo.addListener(SWT.Selection, listener); - userCombo.addListener(SWT.Modify, listener); - - // Password - createLabel(g, Policy.bind("ConfigurationWizardMainPage.password")); //$NON-NLS-1$ - passwordText = createPasswordField(g); - passwordText.addListener(SWT.Modify, listener); - - g = createGroup(composite, Policy.bind("ConfigurationWizardMainPage.Connection_3")); //$NON-NLS-1$ - - // Connection type - createLabel(g, Policy.bind("ConfigurationWizardMainPage.connection")); //$NON-NLS-1$ - connectionMethodCombo = createCombo(g); - connectionMethodCombo.addListener(SWT.Selection, listener); - - // Port number - // create a composite to ensure the radio buttons come in the correct order - Composite portGroup = new Composite(g, SWT.NONE); - GridData data = new GridData(); - data.horizontalSpan = 2; - portGroup.setLayoutData(data); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - portGroup.setLayout(layout); - useDefaultPort = createRadioButton(portGroup, Policy.bind("ConfigurationWizardMainPage.useDefaultPort"), 2); //$NON-NLS-1$ - useCustomPort = createRadioButton(portGroup, Policy.bind("ConfigurationWizardMainPage.usePort"), 1); //$NON-NLS-1$ - useCustomPort.addListener(SWT.Selection, listener); - portText = createTextField(portGroup); - portText.addListener(SWT.Modify, listener); - - // create a composite to ensure the validate button is in its own tab group - if (showValidate) { - Composite validateButtonTabGroup = new Composite(composite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 2; - validateButtonTabGroup.setLayoutData(data); - validateButtonTabGroup.setLayout(new FillLayout()); - - validateButton = new Button(validateButtonTabGroup, SWT.CHECK); - validateButton.setText(Policy.bind("ConfigurationWizardAutoconnectPage.validate")); //$NON-NLS-1$ - validateButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - validate = validateButton.getSelection(); - } - }); - } - - allowCachingButton = new Button(composite, SWT.CHECK); - allowCachingButton.setText(Policy.bind("UserValidationDialog.6")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - allowCachingButton.setLayoutData(data); - allowCachingButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - allowCaching = allowCachingButton.getSelection(); - } - }); - - Composite warningComposite = new Composite(composite, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginHeight = 0; - warningComposite.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - warningComposite.setLayoutData(data); - Label warningLabel = new Label(warningComposite, SWT.NONE); - warningLabel.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); - warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); - Label warningText = new Label(warningComposite, SWT.WRAP); - warningText.setText(Policy.bind("UserValidationDialog.7")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 300; - GC gc= new GC(composite); - gc.setFont(parent.getFont()); - FontMetrics fontMetrics= gc.getFontMetrics(); - gc.dispose(); - data.heightHint= Dialog.convertHeightInCharsToPixels(fontMetrics, 3); - warningText.setLayoutData(data); - - initializeValues(); - updateWidgetEnablements(); - hostCombo.setFocus(); - - setControl(composite); - Dialog.applyDialogFont(parent); - } - /** - * Utility method to create an editable combo box - * - * @param parent the parent of the combo box - * @return the created combo - */ - protected Combo createEditableCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.NULL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - combo.setLayoutData(data); - return combo; - } - - protected Group createGroup(Composite parent, String text) { - Group group = new Group(parent, SWT.NULL); - group.setText(text); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - //data.widthHint = GROUP_WIDTH; - - group.setLayoutData(data); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - group.setLayout(layout); - return group; - } - - /* - * Create a Proeprties node that contains everything needed to create a repository location - */ - private Properties createProperties() { - Properties result = new Properties(); - result.setProperty("connection", connectionMethodCombo.getText()); //$NON-NLS-1$ - result.setProperty("user", userCombo.getText()); //$NON-NLS-1$ - result.setProperty("password", passwordText.getText()); //$NON-NLS-1$ - result.setProperty("host", hostCombo.getText()); //$NON-NLS-1$ - if (useCustomPort.getSelection()) { - result.setProperty("port", portText.getText()); //$NON-NLS-1$ - } - result.setProperty("root", repositoryPathCombo.getText()); //$NON-NLS-1$ - return result; - } - - /** - * Crate a new location with the information entered on the page. - * The location will exists and can be sed for connecting but is not - * registered for persistance. This method must be called from the UI - * thread. - * @return a location or null - * @throws CVSException - */ - public ICVSRepositoryLocation getLocation() throws CVSException { - if (location == null) { - if (!isPageComplete()) return null; - location = CVSRepositoryLocation.fromProperties(createProperties()); - if (location.equals(oldLocation)) { - location = oldLocation; - } - location.setAllowCaching(allowCaching); - oldLocation = null; - saveWidgetValues(); - } - return location; - } - - /** - * Initializes states of the controls. - */ - private void initializeValues() { - // Set remembered values - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] hostNames = settings.getArray(STORE_HOSTNAME_ID); - if (hostNames != null) { - for (int i = 0; i < hostNames.length; i++) { - hostCombo.add(hostNames[i]); - } - } - String[] paths = settings.getArray(STORE_PATH_ID); - if (paths != null) { - for (int i = 0; i < paths.length; i++) { - repositoryPathCombo.add(paths[i]); - } - } - String[] userNames = settings.getArray(STORE_USERNAME_ID); - if (userNames != null) { - for (int i = 0; i < userNames.length; i++) { - userCombo.add(userNames[i]); - } - } - if (showValidate) { - validate = !settings.getBoolean(STORE_DONT_VALIDATE_ID); - validateButton.setSelection(validate); - } - } - - // Initialize other values and widget states - IConnectionMethod[] methods = CVSRepositoryLocation.getPluggedInConnectionMethods(); - for (int i = 0; i < methods.length; i++) { - connectionMethodCombo.add(methods[i].getName()); - } - - connectionMethodCombo.select(0); - useDefaultPort.setSelection(true); - - if(properties != null) { - String method = properties.getProperty("connection"); //$NON-NLS-1$ - if (method == null) { - connectionMethodCombo.select(0); - } else { - connectionMethodCombo.select(connectionMethodCombo.indexOf(method)); - } - - String user = properties.getProperty("user"); //$NON-NLS-1$ - if (user != null) { - userCombo.setText(user); - } - - String password = properties.getProperty("password"); //$NON-NLS-1$ - if (password != null) { - passwordText.setText(password); - } - - String host = properties.getProperty("host"); //$NON-NLS-1$ - if (host != null) { - hostCombo.setText(host); - } - - String port = properties.getProperty("port"); //$NON-NLS-1$ - if (port != null) { - useCustomPort.setSelection(true); - portText.setText(port); - } - - String repositoryPath = properties.getProperty("root"); //$NON-NLS-1$ - if (repositoryPath != null) { - repositoryPathCombo.setText(repositoryPath); - } - } - } - /** - * Saves the widget values - */ - private void saveWidgetValues() { - // Update history - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] userNames = settings.getArray(STORE_USERNAME_ID); - if (userNames == null) userNames = new String[0]; - userNames = addToHistory(userNames, userCombo.getText()); - settings.put(STORE_USERNAME_ID, userNames); - - String[] hostNames = settings.getArray(STORE_HOSTNAME_ID); - if (hostNames == null) hostNames = new String[0]; - hostNames = addToHistory(hostNames, hostCombo.getText()); - settings.put(STORE_HOSTNAME_ID, hostNames); - - String[] paths = settings.getArray(STORE_PATH_ID); - if (paths == null) paths = new String[0]; - paths = addToHistory(paths, repositoryPathCombo.getText()); - settings.put(STORE_PATH_ID, paths); - - if (showValidate) { - settings.put(STORE_DONT_VALIDATE_ID, !validate); - } - } - } - - public void setShowValidate(boolean showValidate) { - this.showValidate = showValidate; - } - - /** - * Sets the properties for the repository connection - * - * @param properties the properties or null - */ - public void setProperties(Properties properties) { - this.properties = properties; - } - - /** - * Updates widget enablements and sets error message if appropriate. - */ - protected void updateWidgetEnablements() { - if (useDefaultPort.getSelection()) { - portText.setEnabled(false); - } else { - portText.setEnabled(true); - } - - validateFields(); - } - /** - * Validates the contents of the editable fields and set page completion - * and error messages appropriately. - */ - private void validateFields() { - String user = userCombo.getText(); - IStatus status = validateUserName(user); - if (!isStatusOK(status)) { - return; - } - - String host = hostCombo.getText(); - status = validateHost(host); - if (!isStatusOK(status)) { - return; - } - - if (portText.isEnabled()) { - String port = portText.getText(); - status = validatePort(port); - if (!isStatusOK(status)) { - return; - } - } - - String pathString = repositoryPathCombo.getText(); - status = validatePath(pathString); - if (!isStatusOK(status)) { - return; - } - - try { - CVSRepositoryLocation l = CVSRepositoryLocation.fromProperties(createProperties()); - if (!l.equals(oldLocation) && KnownRepositories.getInstance().isKnownRepository(l.getLocation())) { - setErrorMessage(Policy.bind("ConfigurationWizardMainPage.0")); //$NON-NLS-1$ - setPageComplete(false); - return; - } - } catch (CVSException e) { - CVSUIPlugin.log(e); - // Let it pass. Creation should fail - } - - // Everything passed so we're good to go - setErrorMessage(null); - setPageComplete(true); - } - - private boolean isStatusOK(IStatus status) { - if (!status.isOK()) { - if (status.getCode() == REQUIRED_FIELD) { - // Don't set the message for an empty field - setErrorMessage(null); - } else { - setErrorMessage(status.getMessage()); - } - setPageComplete(false); - return false; - } - return true; - } - - public boolean getValidate() { - return validate; - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - hostCombo.setFocus(); - } - } - - public static final int REQUIRED_FIELD = 1; - public static final int INVALID_FIELD_CONTENTS = 2; - public static final IStatus validateUserName(String user) { - if (user.length() == 0) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, REQUIRED_FIELD, Policy.bind("ConfigurationWizardMainPage.1"), null); //$NON-NLS-1$ - } - if ((user.indexOf('@') != -1) || (user.indexOf(':') != -1)) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.invalidUserName"), null); //$NON-NLS-1$ - } - return Status.OK_STATUS; - } - public static final IStatus validateHost(String host) { - if (host.length() == 0) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, REQUIRED_FIELD, Policy.bind("ConfigurationWizardMainPage.2"), null); //$NON-NLS-1$ - } - if (host.indexOf(':') != -1) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.invalidHostName"), null); //$NON-NLS-1$ - } - if (host.startsWith(" ") || host.endsWith(" ")) { //$NON-NLS-1$ //$NON-NLS-2$ - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.5"), null); //$NON-NLS-1$ - } - return Status.OK_STATUS; - } - public static final IStatus validatePort(String port) { - if (port.length() == 0) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, REQUIRED_FIELD, Policy.bind("ConfigurationWizardMainPage.3"), null); //$NON-NLS-1$ - } - try { - Integer.parseInt(port); - } catch (NumberFormatException e) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.invalidPort"), null); //$NON-NLS-1$ - } - return Status.OK_STATUS; - } - public static final IStatus validatePath(String pathString) { - if (pathString.length() == 0) { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, REQUIRED_FIELD, Policy.bind("ConfigurationWizardMainPage.4"), null); //$NON-NLS-1$ - } - IPath path = new Path(null, pathString); - String[] segments = path.segments(); - for (int i = 0; i < segments.length; i++) { - String string = segments[i]; - if (string.charAt(0) == ' ' || string.charAt(string.length() -1) == ' ') { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.invalidPathWithSpaces"), null); //$NON-NLS-1$ - } - } - // look for // and inform the user that we support use of C:\cvs\root instead of /c//cvs/root - if (pathString.indexOf("//") != -1) { //$NON-NLS-1$ - if (pathString.indexOf("//") == 2) { //$NON-NLS-1$ - // The user is probably trying to specify a CVSNT path - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.useNTFormat"), null); //$NON-NLS-1$ - } else { - return new Status(IStatus.ERROR, CVSUIPlugin.ID, INVALID_FIELD_CONTENTS, - Policy.bind("ConfigurationWizardMainPage.invalidPathWithSlashes"), null); //$NON-NLS-1$ - } - } - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java deleted file mode 100644 index ba77d16d7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * An operation to run the CVS diff operation on a set of resources. The result - * of the diff is written to a file. If there are no differences found, the - * user is notified and the output file is not created. - */ -public class GenerateDiffFileOperation implements IRunnableWithProgress { - - private File outputFile; - private IResource resource; - private Shell shell; - private LocalOption[] options; - - GenerateDiffFileOperation(IResource resource, File file, LocalOption[] options, Shell shell) { - this.resource = resource; - this.outputFile = file; - this.shell = shell; - this.options = options; - } - - /** - * @see IRunnableWithProgress#run(IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - - final CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()); - monitor.beginTask("", 500); //$NON-NLS-1$ - monitor.setTaskName(Policy.bind("GenerateCVSDiff.working")); //$NON-NLS-1$ - try { - if (outputFile != null) { - generateDiffToFile(monitor, provider, outputFile); - } else { - generateDiffToClipboard(monitor, provider); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - - private void generateDiffToFile(IProgressMonitor monitor, CVSTeamProvider provider, File file) throws TeamException { - - final FileOutputStream os; - try { - os= new FileOutputStream(file); - try { - provider.diff(resource, options, new PrintStream(os), new SubProgressMonitor(monitor, 500)); - } finally { - os.close(); - } - } catch (FileNotFoundException e) { - throw new TeamException(Policy.bind("GenerateDiffFileOperation.0"), e); //$NON-NLS-1$ - } catch (IOException e) { - throw new TeamException(Policy.bind("GenerateDiffFileOperation.1"), e); //$NON-NLS-1$ - } - - if (file.length() == 0) { - outputFile.delete(); - reportEmptyDiff(); - } - } - - private void generateDiffToClipboard(IProgressMonitor monitor, CVSTeamProvider provider) throws TeamException { - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - try { - try { - provider.diff(resource, options, new PrintStream(os), new SubProgressMonitor(monitor, 500)); - } finally { - os.close(); - } - } catch (IOException e) { - throw new TeamException(Policy.bind("GenerateDiffFileOperation.2"), e); //$NON-NLS-1$ - } - if (os.size() == 0) { - reportEmptyDiff(); - } else { - copyToClipboard(os); - } - } - - private void copyToClipboard(final ByteArrayOutputStream baos) { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - TextTransfer plainTextTransfer = TextTransfer.getInstance(); - Clipboard clipboard = new Clipboard(shell.getDisplay()); - clipboard.setContents( - new String[]{baos.toString()}, - new Transfer[]{plainTextTransfer}); - clipboard.dispose(); - } - }); - } - - private void reportEmptyDiff() { - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - MessageDialog.openInformation( - shell, - Policy.bind("GenerateCVSDiff.noDiffsFoundTitle"), //$NON-NLS-1$ - Policy.bind("GenerateCVSDiff.noDiffsFoundMsg")); //$NON-NLS-1$ - } - }, CVSUIPlugin.PERFORM_SYNC_EXEC); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java deleted file mode 100644 index b537c83d0..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java +++ /dev/null @@ -1,775 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -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.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Diff; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.ide.misc.ContainerContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * A wizard for creating a patch file by running the CVS diff command. - */ -public class GenerateDiffFileWizard extends Wizard { - - /** - * Page to select a patch file. Overriding validatePage was necessary to allow - * entering a file name that already exists. - */ - private class LocationPage extends WizardPage { - - /** - * The possible locations to save a patch. - */ - public final static int CLIPBOARD = 1; - public final static int FILESYSTEM = 2; - public final static int WORKSPACE = 3; - - /** - * GUI controls for clipboard (cp), filesystem (fs) and workspace (ws). - */ - private Button cpRadio; - - private Button fsRadio; - protected Text fsPathText; - private Button fsBrowseButton; - - private Button wsRadio; - protected TreeViewer wsTreeViewer; - private Text wsFilenameText; - - - /** - * State information of this page, updated by the listeners. - */ - protected boolean pageValid; - protected IContainer wsSelectedContainer; - protected int selectedLocation; - - /** - * The default values store used to initialize the selections. - */ - private final DefaultValuesStore store; - - LocationPage(String pageName, String title, ImageDescriptor image, DefaultValuesStore store) { - super(pageName, title, image); - setPageComplete(false); - this.store= store; - } - - /** - * Allow the user to finish if a valid file has been entered. - */ - protected boolean validatePage() { - - switch (selectedLocation) { - case WORKSPACE: - pageValid= validateWorkspaceLocation(); - break; - case FILESYSTEM: - pageValid= validateFilesystemLocation(); - break; - case CLIPBOARD: - pageValid= true; - break; - } - - /** - * Avoid draw flicker by clearing error message - * if all is valid. - */ - if (pageValid) { - setMessage(null); - setErrorMessage(null); - } - setPageComplete(pageValid); - return pageValid; - } - - /** - * The following conditions must hold for the file system location - * to be valid: - * - the path must be valid and non-empty - * - the path must be absolute - * - the specified file must be of type file - * - the parent must exist (new folders can be created via the browse button) - */ - private boolean validateFilesystemLocation() { - final String pathString= fsPathText.getText().trim(); - if (pathString.length() == 0 || !new Path("").isValidPath(pathString)) { //$NON-NLS-1$ - setErrorMessage(Policy.bind("GenerateDiffFileWizard.0")); //$NON-NLS-1$ - return false; - } - - final File file= new File(pathString); - if (!file.isAbsolute()) { - setErrorMessage(Policy.bind("GenerateDiffFileWizard.0")); //$NON-NLS-1$ - return false; - } - - if (file.isDirectory()) { - setErrorMessage(Policy.bind("GenerateDiffFileWizard.2")); //$NON-NLS-1$ - return false; - } - - if (pathString.endsWith("/") || pathString.endsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ - setErrorMessage(Policy.bind("GenerateDiffFileWizard.3")); //$NON-NLS-1$ - return false; - } - - final File parent= file.getParentFile(); - if (!(parent.exists() && parent.isDirectory())) { - setErrorMessage(Policy.bind("GenerateDiffFileWizard.3")); //$NON-NLS-1$ - return false; - } - return true; - } - - /** - * The following conditions must hold for the file system location to be valid: - * - a parent must be selected in the workspace tree view - * - the resource name must be valid - */ - private boolean validateWorkspaceLocation() { - if (wsSelectedContainer == null) { - setErrorMessage(Policy.bind("GenerateDiffFileWizard.4")); //$NON-NLS-1$ - return false; - } - final String filename= wsFilenameText.getText().trim(); - if (!new Path("").isValidSegment(filename)) { //$NON-NLS-1$ - setErrorMessage(Policy.bind("GenerateDiffFileWizard.5")); //$NON-NLS-1$ - return false; - } - return true; - } - - /** - * Answers a full path to a file system file or null if the user - * selected to save the patch in the clipboard. - */ - public File getFile() { - if (pageValid && selectedLocation == FILESYSTEM) { - return new File(fsPathText.getText().trim()); - } - if (pageValid && selectedLocation == WORKSPACE) { - final String filename= wsFilenameText.getText().trim(); - final IFile file= wsSelectedContainer.getFile(new Path(filename)); - return file.getLocation().toFile(); - } - return null; - } - - /** - * Get the selected workspace resource if the patch is to be saved in the - * workspace, or null otherwise. - */ - public IResource getResource() { - if (pageValid && selectedLocation == WORKSPACE) { - final String filename= wsFilenameText.getText().trim(); - return wsSelectedContainer.getFile(new Path(null, filename)); - } - return null; - } - - /** - * Allow the user to chose to save the patch to the workspace or outside - * of the workspace. - */ - public void createControl(Composite parent) { - - final Composite composite= new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - setControl(composite); - initializeDialogUnits(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.PATCH_SELECTION_PAGE); - - setupClipboardControls(composite); - setupFilesystemControls(composite); - setupWorkspaceControls(composite); - - Dialog.applyDialogFont(parent); - - initializeDefaultValues(); - - /** - * Ensure the page is in a valid state. - */ - if (!validatePage()) { - store.storeRadioSelection(CLIPBOARD); - initializeDefaultValues(); - validatePage(); - } - pageValid= true; - - updateEnablements(); - setupListeners(); - } - - - /** - * Setup the controls for the workspace option. - */ - private void setupWorkspaceControls(Composite composite) { - wsRadio= new Button(composite, SWT.RADIO); - wsRadio.setText(Policy.bind("Save_In_Workspace_7")); //$NON-NLS-1$ - - new Label(composite, SWT.LEFT).setText(Policy.bind("Select_a_folder_then_type_in_the_file_name__8")); //$NON-NLS-1$ - - wsTreeViewer = new TreeViewer(composite, SWT.BORDER); - final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint= 0; - gd.heightHint= 0; - wsTreeViewer.getTree().setLayoutData(gd); - - final ContainerContentProvider cp = new ContainerContentProvider(); - cp.showClosedProjects(false); - wsTreeViewer.setContentProvider(cp); - wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); - wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); - - final Composite group = new Composite(composite, SWT.NONE); - final GridLayout layout = new GridLayout(2, false); - layout.marginWidth = 0; - group.setLayout(layout); - group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - - final Label label = new Label(group, SWT.NONE); - label.setLayoutData(new GridData()); - label.setText(Policy.bind("Fi&le_name__9")); //$NON-NLS-1$ - - wsFilenameText = new Text(group,SWT.BORDER); - wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - } - - /** - * Setup the controls for the file system option. - */ - private void setupFilesystemControls(final Composite composite) { - GridLayout layout; - fsRadio= new Button(composite, SWT.RADIO); - - fsRadio.setText(Policy.bind("Save_In_File_System_3")); //$NON-NLS-1$ - - final Composite nameGroup = new Composite(composite,SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - nameGroup.setLayout(layout); - final GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - nameGroup.setLayoutData(data); - - fsPathText= new Text(nameGroup, SWT.BORDER); - GridData gd= new GridData(GridData.FILL_HORIZONTAL); - fsPathText.setLayoutData(gd); - - fsBrowseButton = new Button(nameGroup, SWT.NULL); - fsBrowseButton.setText(Policy.bind("Browse..._4")); //$NON-NLS-1$ - } - - /** - * Setup the controls for the clipboard option. - */ - private void setupClipboardControls(final Composite composite) { - cpRadio= new Button(composite, SWT.RADIO); - cpRadio.setText(Policy.bind("Save_To_Clipboard_2")); //$NON-NLS-1$ - } - - - /** - * Initialize the controls with the saved default values which are - * obtained from the DefaultValuesStore. - */ - private void initializeDefaultValues() { - - selectedLocation= store.getRadioSelection(); - wsSelectedContainer= store.getWorkspaceSelection(); - - /** - * Radio buttons - */ - cpRadio.setSelection(selectedLocation == CLIPBOARD); - fsRadio.setSelection(selectedLocation == FILESYSTEM); - wsRadio.setSelection(selectedLocation == WORKSPACE); - - /** - * Text fields. - */ - fsPathText.setText(store.getFilesystemPath()); - wsFilenameText.setText(store.getWorkspaceFilename()); - - /** - * Tree viewer. - */ - if (wsSelectedContainer != null) { - final ISelection selection= new StructuredSelection(wsSelectedContainer); - wsTreeViewer.setSelection(selection, true); - } - } - - /** - * Setup all the listeners for the controls. - */ - private void setupListeners() { - - cpRadio.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - selectedLocation= CLIPBOARD; - validatePage(); - updateEnablements(); - } - }); - fsRadio.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - selectedLocation= FILESYSTEM; - validatePage(); - updateEnablements(); - } - }); - - wsRadio.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - selectedLocation= WORKSPACE; - validatePage(); - updateEnablements(); - } - }); - - fsPathText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validatePage(); - } - }); - - fsBrowseButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - final FileDialog dialog = new FileDialog(getShell(), SWT.PRIMARY_MODAL | SWT.SAVE); - if (pageValid) { - final File file= new File(fsPathText.getText()); - dialog.setFilterPath(file.getParent()); - } - dialog.setText(Policy.bind("Save_Patch_As_5")); //$NON-NLS-1$ - dialog.setFileName(Policy.bind("patch.txt_6")); //$NON-NLS-1$ - final String path = dialog.open(); - if (path != null) { - fsPathText.setText(new Path(path).toOSString()); - } - } - }); - - wsTreeViewer.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection s = (IStructuredSelection)event.getSelection(); - wsSelectedContainer = ((IContainer) s.getFirstElement()); - validatePage(); - } - }); - - wsTreeViewer.addDoubleClickListener( - new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - ISelection s= event.getSelection(); - if (s instanceof IStructuredSelection) { - Object item = ((IStructuredSelection)s).getFirstElement(); - if (wsTreeViewer.getExpandedState(item)) - wsTreeViewer.collapseToLevel(item, 1); - else - wsTreeViewer.expandToLevel(item, 1); - } - } - }); - - wsFilenameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validatePage(); - } - }); - } - - /** - * Enable and disable controls based on the selected radio button. - */ - protected void updateEnablements() { - fsBrowseButton.setEnabled(selectedLocation == FILESYSTEM); - fsPathText.setEnabled(selectedLocation == FILESYSTEM); - wsTreeViewer.getTree().setEnabled(selectedLocation == WORKSPACE); - wsFilenameText.setEnabled(selectedLocation == WORKSPACE); - } - - public int getSelectedLocation() { - return selectedLocation; - } - } - - /** - * Page to select the options for creating the patch. - */ - private class OptionsPage extends WizardPage { - - private Button recurseOption; - private Button contextDiffOption; - private Button unifiedDiffOption; - private Button regularDiffOption; - private Button includeNewFilesOptions; - - /** - * Constructor for PatchFileCreationOptionsPage. - */ - protected OptionsPage(String pageName) { - super(pageName); - } - - /** - * Constructor for PatchFileCreationOptionsPage. - */ - protected OptionsPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - - /* - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - composite.setLayout(layout); - composite.setLayoutData(new GridData()); - setControl(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.PATCH_OPTIONS_PAGE); - - recurseOption = new Button(composite, SWT.CHECK); - recurseOption.setText(Policy.bind("Do_not_recurse_into_sub-folders_10")); //$NON-NLS-1$ - recurseOption.setSelection(true); - - includeNewFilesOptions = new Button(composite, SWT.CHECK); - includeNewFilesOptions.setText(Policy.bind("Do_not_include_new_files_in_patch_11")); //$NON-NLS-1$ - includeNewFilesOptions.setSelection(true); - - Group diffTypeGroup = new Group(composite, SWT.NONE); - layout = new GridLayout(); - layout.marginHeight = 0; - diffTypeGroup.setLayout(layout); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); - diffTypeGroup.setLayoutData(data); - diffTypeGroup.setText(Policy.bind("Diff_output_format_12")); //$NON-NLS-1$ - - unifiedDiffOption = new Button(diffTypeGroup, SWT.RADIO); - unifiedDiffOption.setText(Policy.bind("Unified_(format_required_by_Compare_With_Patch_feature)_13")); //$NON-NLS-1$ - unifiedDiffOption.setSelection(true); - contextDiffOption = new Button(diffTypeGroup, SWT.RADIO); - contextDiffOption.setText(Policy.bind("Context_14")); //$NON-NLS-1$ - regularDiffOption = new Button(diffTypeGroup, SWT.RADIO); - regularDiffOption.setText(Policy.bind("Standard_15")); //$NON-NLS-1$ - - Dialog.applyDialogFont(parent); - } - - /** - * Answers if the difference operation should be run recursively. - */ - public boolean isRecursive() { - return !recurseOption.getSelection(); - } - - /** - * Return the list of Diff command options configured on this page. - */ - public LocalOption[] getOptions() { - List options = new ArrayList(5); - if(includeNewFilesOptions.getSelection()) { - options.add(Diff.INCLUDE_NEWFILES); - } - if(!recurseOption.getSelection()) { - options.add(Command.DO_NOT_RECURSE); - } - if(unifiedDiffOption.getSelection()) { - options.add(Diff.UNIFIED_FORMAT); - } else if(contextDiffOption.getSelection()) { - options.add(Diff.CONTEXT_FORMAT); - } - return (LocalOption[]) options.toArray(new LocalOption[options.size()]); - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - recurseOption.setFocus(); - } - } - } - - /** - * Class to retrieve and store the default selected values. - */ - private final class DefaultValuesStore { - - private static final String PREF_LAST_SELECTION= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.selection"; //$NON-NLS-1$ - private static final String PREF_LAST_FS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.fs.path"; //$NON-NLS-1$ - private static final String PREF_LAST_WS_FILENAME= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.ws.filename"; //$NON-NLS-1$ - private static final String PREF_LAST_WS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.ws.path"; //$NON-NLS-1$ - - private final IDialogSettings dialogSettings; - - public DefaultValuesStore() { - dialogSettings= CVSUIPlugin.getPlugin().getDialogSettings(); - } - - public int getRadioSelection() { - int value= LocationPage.CLIPBOARD; - try { - value= dialogSettings.getInt(PREF_LAST_SELECTION); - } catch (NumberFormatException e) { - } - - switch (value) { - case LocationPage.FILESYSTEM: - case LocationPage.WORKSPACE: - case LocationPage.CLIPBOARD: - return value; - default: - return LocationPage.CLIPBOARD; - } - } - - public String getFilesystemPath() { - final String path= dialogSettings.get(PREF_LAST_FS_PATH); - return path != null ? path : ""; //$NON-NLS-1$ - } - - public String getWorkspaceFilename() { - final String filename= dialogSettings.get(PREF_LAST_WS_FILENAME); - return filename != null ? filename : ""; //$NON-NLS-1$ - } - - public IContainer getWorkspaceSelection() { - final String value= dialogSettings.get(PREF_LAST_WS_PATH); - if ( value != null ) { - final IPath path= new Path(value); - final IResource container= ResourcesPlugin.getWorkspace().getRoot().findMember(path); - if (container instanceof IContainer) { - return (IContainer)container; - } - } - return null; - } - - public void storeRadioSelection(int defaultSelection) { - dialogSettings.put(PREF_LAST_SELECTION, defaultSelection); - } - - public void storeFilesystemPath(String path) { - dialogSettings.put(PREF_LAST_FS_PATH, path); - } - - public void storeWorkspacePath(String path) { - dialogSettings.put(PREF_LAST_WS_PATH, path); - } - - public void storeWorkspaceFilename(String filename) { - dialogSettings.put(PREF_LAST_WS_FILENAME, filename); - } - } - - - private LocationPage locationPage; - private OptionsPage optionsPage; - - private final IResource resource; - private final DefaultValuesStore defaultValuesStore; - - - public GenerateDiffFileWizard(IResource resource) { - super(); - this.resource = resource; - setWindowTitle(Policy.bind("GenerateCVSDiff.title")); //$NON-NLS-1$ - initializeDefaultPageImageDescriptor(); - defaultValuesStore= new DefaultValuesStore(); - } - - public void addPages() { - String pageTitle = Policy.bind("GenerateCVSDiff.pageTitle"); //$NON-NLS-1$ - String pageDescription = Policy.bind("GenerateCVSDiff.pageDescription"); //$NON-NLS-1$ - locationPage = new LocationPage(pageTitle, pageTitle, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_DIFF), defaultValuesStore); - locationPage.setDescription(pageDescription); - addPage(locationPage); - - pageTitle = Policy.bind("Advanced_options_19"); //$NON-NLS-1$ - pageDescription = Policy.bind("Configure_the_options_used_for_the_CVS_diff_command_20"); //$NON-NLS-1$ - optionsPage = new OptionsPage(pageTitle, pageTitle, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_DIFF)); - optionsPage.setDescription(pageDescription); - addPage(optionsPage); - } - - /** - * Declares the wizard banner iamge descriptor - */ - protected void initializeDefaultPageImageDescriptor() { - final String iconPath= "icons/full/"; //$NON-NLS-1$ - try { - final URL installURL = CVSUIPlugin.getPlugin().getBundle().getEntry("/"); //$NON-NLS-1$ - final URL url = new URL(installURL, iconPath + "wizards/newconnect_wiz.gif"); //$NON-NLS-1$ - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - setDefaultPageImageDescriptor(desc); - } catch (MalformedURLException e) { - // Should not happen. Ignore. - } - } - - /* (Non-javadoc) - * Method declared on IWizard. - */ - public boolean needsProgressMonitor() { - return true; - } - - /** - * Completes processing of the wizard. If this method returns - * true, the wizard will close; otherwise, it will stay active. - */ - public boolean performFinish() { - - final int location= locationPage.getSelectedLocation(); - - final File file= location != LocationPage.CLIPBOARD? locationPage.getFile() : null; - - if (!(file == null || validateFile(file))) { - return false; - } - - /** - * Perform diff operation. - */ - try { - getContainer().run(true, true, new GenerateDiffFileOperation(resource, file, optionsPage.getOptions(), getShell())); - } catch (InterruptedException e1) { - return true; - } catch (InvocationTargetException e2) { - CVSUIPlugin.openError(getShell(), null, null, e2); - return false; - } - - /** - * Refresh workspace if necessary and save default selection. - */ - switch (location) { - - case LocationPage.WORKSPACE: - defaultValuesStore.storeRadioSelection(LocationPage.WORKSPACE); - final IResource workspaceResource= locationPage.getResource(); - defaultValuesStore.storeWorkspacePath(workspaceResource.getParent().getFullPath().toString()); - defaultValuesStore.storeWorkspaceFilename(workspaceResource.getName()); - try { - workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); - } catch(CoreException e) { - CVSUIPlugin.openError(getShell(), Policy.bind("GenerateCVSDiff.error"), null, e); //$NON-NLS-1$ - return false; - } - break; - - case LocationPage.FILESYSTEM: - defaultValuesStore.storeFilesystemPath(file.getPath()); - defaultValuesStore.storeRadioSelection(LocationPage.FILESYSTEM); - break; - - case LocationPage.CLIPBOARD: - defaultValuesStore.storeRadioSelection(LocationPage.CLIPBOARD); - break; - - default: - return false; - } - return true; - } - - public boolean validateFile(File file) { - - if (file == null) - return false; - - /** - * Consider file valid if it doesn't exist for now. - */ - if (!file.exists()) - return true; - - /** - * The file exists. - */ - if (!file.canWrite()) { - final String title= Policy.bind("GenerateCVSDiff.1"); //$NON-NLS-1$ - final String msg= Policy.bind("GenerateCVSDiff.2"); //$NON-NLS-1$ - final MessageDialog dialog= new MessageDialog(getShell(), title, null, msg, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); - dialog.open(); - return false; - } - - final String title = Policy.bind("GenerateCVSDiff.overwriteTitle"); //$NON-NLS-1$ - final String msg = Policy.bind("GenerateCVSDiff.overwriteMsg"); //$NON-NLS-1$ - final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); - dialog.open(); - if (dialog.getReturnCode() != 0) - return false; - - return true; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ICVSWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ICVSWizard.java deleted file mode 100644 index 77195124f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ICVSWizard.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on 16-Mar-2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardPage; - -/** - * Extended wizard interface that differentiates retrieving - * the next page for display vs. for determining it's state - */ -public interface ICVSWizard extends IWizard { - - /** - * Get the wizard page that follows the given page. If - * aboutToShow is true then the page will be shown. - * Otherwise, only its state will be queried. - * @param page a wizard page - * @param aboutToShow true iof the page returned will be shown - * @return the next wizard page - */ - public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow); -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizard.java deleted file mode 100644 index 6d455b898..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizard.java +++ /dev/null @@ -1,428 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -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.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * A wizard for changing the keyword substitution mode of files. - * - * 1. Ask the user select to select the desired keyword substitution mode. - * 2. Compute the set of possibly affected resources - * 3. If the affected resources include existing committed files, warn the user - * and provide an option to include them in the operation anyways. - * 4. If the affected resources include dirty files, warn the user and provide - * an option to include them in the operation anyways. - * 5. Perform the operation on Finish. - */ -public class KSubstWizard extends Wizard { - private KSubstOption defaultKSubst; - - private final IResource[] resources; - private final int depth; - private List changeList = null; - private KSubstOption changeOption = null; - - private KSubstWizardSelectionPage mainPage; - private KSubstWizardSummaryPage summaryPage; - private KSubstWizardSharedFilesPage sharedFilesPage; - private KSubstWizardDirtyFilesPage dirtyFilesPage; - - private Dialog parentDialog; - - private KSubstWizardCommitCommentPage commitCommentPage; - - public class KSubstChangeElement { - public static final int ADDED_FILE = 1; - public static final int CHANGED_FILE = 2; - public static final int UNCHANGED_FILE = 4; - - private IFile file; - private int classification; - private boolean excluded; - private KSubstOption fromKSubst; - private KSubstOption toKSubst; - - private KSubstChangeElement(IFile file, int classification, boolean excluded, KSubstOption fromKSubst, KSubstOption toKSubst) { - this.file = file; - this.classification = classification; - this.excluded = excluded; - this.fromKSubst = fromKSubst; - this.toKSubst = toKSubst; - } - public boolean matchesFilter(int filter) { - return (classification & filter) != 0; - } - public boolean isExcluded() { - return excluded; - } - public void setExcluded(boolean excluded) { - this.excluded = excluded; - } - public boolean isNewKSubstMode() { - return ! fromKSubst.equals(toKSubst); - } - public void setKSubst(KSubstOption toKSubst) { - this.toKSubst = toKSubst; - } - public KSubstOption getKSubst() { - return toKSubst; - } - public IFile getFile() { - return file; - } - } - - /** - * Creates a wizard to set the keyword substitution mode for the specified resources. - * - * @param resources the resources to alter - * @param depth the recursion depth - * @param defaultOption the keyword substitution option to select by default - */ - public KSubstWizard(IResource[] resources, int depth, KSubstOption defaultOption) { - super(); - this.defaultKSubst = defaultOption; - this.resources = resources; - this.depth = depth; - setWindowTitle(Policy.bind("KSubstWizard.title")); //$NON-NLS-1$ - } - - /** - * Returns the keyword substitution option that was selected at the time - * the Finish button was pressed. - */ - public KSubstOption getKSubstOption() { - return defaultKSubst; - } - - public void addPages() { - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_KEYWORD); - - // add main page - String pageTitle = Policy.bind("KSubstWizardSelectionPage.pageTitle"); //$NON-NLS-1$ - String pageDescription = Policy.bind("KSubstWizardSelectionPage.pageDescription"); //$NON-NLS-1$ - mainPage = new KSubstWizardSelectionPage(pageTitle, pageTitle, substImage, defaultKSubst); - mainPage.setDescription(pageDescription); - mainPage.setTitle(pageTitle); - addPage(mainPage); - - // add summary page - pageTitle = Policy.bind("KSubstWizardSummaryPage.pageTitle"); //$NON-NLS-1$ - pageDescription = Policy.bind("KSubstWizardSummaryPage.pageDescription"); //$NON-NLS-1$ - summaryPage = new KSubstWizardSummaryPage(pageTitle, pageTitle, substImage, false); - summaryPage.setDescription(pageDescription); - addPage(summaryPage); - - // add shared files warning page - pageTitle = Policy.bind("KSubstWizardSharedFilesPage.pageTitle"); //$NON-NLS-1$ - pageDescription = Policy.bind("KSubstWizardSharedFilesPage.pageDescription"); //$NON-NLS-1$ - sharedFilesPage = new KSubstWizardSharedFilesPage(pageTitle, pageTitle, substImage, false); - sharedFilesPage.setDescription(pageDescription); - addPage(sharedFilesPage); - - // add changed files warning page - pageTitle = Policy.bind("KSubstWizardDirtyFilesPage.pageTitle"); //$NON-NLS-1$ - pageDescription = Policy.bind("KSubstWizardDirtyFilesPage.pageDescription"); //$NON-NLS-1$ - dirtyFilesPage = new KSubstWizardDirtyFilesPage(pageTitle, pageTitle, substImage, false); - dirtyFilesPage.setDescription(pageDescription); - addPage(dirtyFilesPage); - - // add commit comment page - pageTitle = Policy.bind("KSubstWizardCommitCommentPage.pageTitle"); //$NON-NLS-1$ - pageDescription = Policy.bind("KSubstWizardCommitCommentPage.pageDescription"); //$NON-NLS-1$ - commitCommentPage = new KSubstWizardCommitCommentPage(parentDialog, pageTitle, pageTitle, substImage, pageDescription); - addPage(commitCommentPage); - } - - public IWizardPage getNextPage(IWizardPage page) { - if (page == mainPage) { - if (prepareSharedFilesPage()) return sharedFilesPage; - } else if (page == sharedFilesPage) { - if (sharedFilesPage.includeSharedFiles() && prepareDirtyFilesPage()) return dirtyFilesPage; - } else if (page == summaryPage) { - return null; - } - prepareSummaryPage(); - if (page != commitCommentPage) return commitCommentPage; - return summaryPage; - } - - public IWizardPage getPreviousPage(IWizardPage page) { - if (page == summaryPage) { - return commitCommentPage; - } else if (page == commitCommentPage) { - if (sharedFilesPage.includeSharedFiles() && prepareDirtyFilesPage()) return dirtyFilesPage; - if (prepareSharedFilesPage()) return sharedFilesPage; - return mainPage; - } else if (page == dirtyFilesPage) { - if (prepareSharedFilesPage()) return sharedFilesPage; - return mainPage; - } else if (page == sharedFilesPage) { - return mainPage; - } - return null; - } - - /* (Non-javadoc) - * Method declared on IWizard. - */ - public boolean needsProgressMonitor() { - return true; - } - - /* (Non-javadoc) - * Method declared on IWizard. - */ - public boolean needsPreviousAndNextButtons() { - return true; - } - - /* (Non-javadoc) - * Method declared on IWizard. - */ - public boolean performFinish() { - try { - if (sharedFilesPage.includeSharedFiles() - && !MessageDialog.openConfirm(getShell(), null, Policy.bind("KSubstWizardSharedFilesPage.contents"))) { //$NON-NLS-1$ - return false; - } - defaultKSubst = mainPage.getKSubstOption(); - final List messages = new ArrayList(); - getContainer().run(false /*fork*/, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask("", 10000); //$NON-NLS-1$ - monitor.setTaskName(Policy.bind("KSubstWizard.working")); //$NON-NLS-1$ - computeChangeList(mainPage.getKSubstOption()); - Map table = getProviderMapping(); - - int workPerProvider = 10000 / (table.size() + 1); - monitor.worked(workPerProvider); - for (Iterator it = table.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - CVSTeamProvider provider = (CVSTeamProvider) entry.getKey(); - Map providerFiles = (Map) entry.getValue(); - - String comment = commitCommentPage.getComment(); - IStatus status = provider.setKeywordSubstitution(providerFiles, comment, - Policy.subMonitorFor(monitor, workPerProvider)); - if (status.getCode() != CVSStatus.OK) { - messages.add(status); - } - } - // Broadcast a decorator change so all interested parties will update their labels. - // This is done in particular because the syncview will not see this change - // as a change in state for the resources involved - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - // Check for any status messages and display them - if ( ! messages.isEmpty()) { - boolean error = false; - MultiStatus combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, - Policy.bind("KSubstWizard.problemsMessage"), null); //$NON-NLS-1$ - for (int i = 0; i < messages.size(); i++) { - IStatus status = (IStatus)messages.get(i); - if (status.getSeverity() == IStatus.ERROR || status.getCode() == CVSStatus.SERVER_ERROR) { - error = true; - } - combinedStatus.merge(status); - } - String message = null; - IStatus statusToDisplay; - if (combinedStatus.getChildren().length == 1) { - message = combinedStatus.getMessage(); - statusToDisplay = combinedStatus.getChildren()[0]; - } else { - statusToDisplay = combinedStatus; - } - String title; - if (error) { - title = Policy.bind("KSubstWizard.errorTitle"); //$NON-NLS-1$ - } else { - title = Policy.bind("KSubstWizard.warningTitle"); //$NON-NLS-1$ - } - CVSUIPlugin.openError(getShell(), title, message, new CVSException(statusToDisplay)); - } - return true; - } catch (InterruptedException e1) { - return true; - } catch (InvocationTargetException e2) { - CVSUIPlugin.openError(getShell(), Policy.bind("KSubstWizard.problemsMessage"), null, e2); //$NON-NLS-1$ - return false; - } - } - - private boolean prepareDirtyFilesPage() { - BusyIndicator.showWhile(getContainer().getShell().getDisplay(), new Runnable() { - public void run() { - computeChangeList(mainPage.getKSubstOption()); - dirtyFilesPage.setChangeList(changeList); - } - }); - return ! dirtyFilesPage.isListEmpty(); - } - - private boolean prepareSharedFilesPage() { - BusyIndicator.showWhile(getContainer().getShell().getDisplay(), new Runnable() { - public void run() { - computeChangeList(mainPage.getKSubstOption()); - sharedFilesPage.setChangeList(changeList); - } - }); - return ! sharedFilesPage.isListEmpty(); - } - - private void prepareSummaryPage() { - BusyIndicator.showWhile(getContainer().getShell().getDisplay(), new Runnable() { - public void run() { - computeChangeList(mainPage.getKSubstOption()); - summaryPage.setChangeList(changeList, getFilters()); - } - }); - } - - /** - * @param ksubst the desired keyword substitution mode, if null chooses for each file: - * KSubstOption.fromPattern(fileName).isBinary() ? KSUBST_BINARY : KSUBST_TEXT - */ - private void computeChangeList(final KSubstOption ksubst) { - if (changeList != null) { - if (changeOption == ksubst) return; - changeList.clear(); - } else { - changeList = new ArrayList(); - } - changeOption = ksubst; - // recurse over all specified resources, considering each exactly once - final Set seen = new HashSet(); - for (int i = 0; i < resources.length; i++) { - final IResource currentResource = resources[i]; - try { - currentResource.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - try { - if (resource.getType() == IResource.FILE && resource.exists() && ! seen.contains(resource)) { - seen.add(resource); - IFile file = (IFile) resource; - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - if (cvsFile.isManaged()) { - ResourceSyncInfo info = cvsFile.getSyncInfo(); - // classify the change - final int classification; - if (info.isAdded()) { - classification = KSubstChangeElement.ADDED_FILE; - } else if (info.isDeleted()) { - return true; - } else if (cvsFile.isModified(null)) { - classification = KSubstChangeElement.CHANGED_FILE; - } else { - classification = KSubstChangeElement.UNCHANGED_FILE; - } - // determine the to/from substitution modes - KSubstOption fromKSubst = info.getKeywordMode(); - KSubstOption toKSubst = ksubst; - if (ksubst == null) { - toKSubst = KSubstOption.fromFile(file); - } - changeList.add(new KSubstChangeElement(file, classification, false, fromKSubst, toKSubst)); - } - } - } catch (TeamException e) { - throw new CoreException(e.getStatus()); - } - // always return true and let the depth determine if children are visited - return true; - } - }, depth, false); - } catch (CoreException e) { - CVSUIPlugin.openError(getShell(), Policy.bind("KSubstWizard.problemsMessage"), null, e); //$NON-NLS-1$ - } - } - } - - private int getFilters() { - return KSubstChangeElement.ADDED_FILE | - (sharedFilesPage.includeSharedFiles() ? KSubstChangeElement.UNCHANGED_FILE | - (dirtyFilesPage.includeDirtyFiles() ? KSubstChangeElement.CHANGED_FILE : 0) : 0); - } - - private Map getProviderMapping() { - Map table = new HashMap(); - int filter = getFilters(); - for (Iterator it = changeList.iterator(); it.hasNext();) { - KSubstChangeElement change = (KSubstChangeElement) it.next(); - if (! change.isExcluded() && change.isNewKSubstMode() && change.matchesFilter(filter)) { - // classify file according to its provider - IFile file = change.getFile(); - RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject(), CVSProviderPlugin.getTypeId()); - Map providerMap = (Map) table.get(provider); - if (providerMap == null) { - providerMap = new HashMap(); - table.put(provider, providerMap); - } - providerMap.put(file, change.toKSubst); - } - } - return table; - } - - /** - * Method setParentDialog. - * @param dialog - */ - public void setParentDialog(Dialog dialog) { - this.parentDialog = dialog; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java deleted file mode 100644 index d9bbe10e8..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.internal.ccvs.ui.CommitCommentArea; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.ui.help.WorkbenchHelp; - -public class KSubstWizardCommitCommentPage extends CVSWizardPage { - - private CommitCommentArea commitCommentArea; - - /** - * Constructor for KSubstWizardCommitCommentPage. - * @param pageName - * @param title - * @param titleImage - * @param description - */ - public KSubstWizardCommitCommentPage( - Dialog parentDialog, - String pageName, - String title, - ImageDescriptor titleImage, - String description) { - - super(pageName, title, titleImage, description); - commitCommentArea = new CommitCommentArea(); - } - - /** - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - setControl(top); - // set F1 help - WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_COMMIT_COMMENT_PAGE); - commitCommentArea.createArea(top); - Dialog.applyDialogFont(parent); - } - - /** - * Method getComment. - * @return String - */ - public String getComment() { - return commitCommentArea.getComment(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - commitCommentArea.setFocus(); - } - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardDirtyFilesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardDirtyFilesPage.java deleted file mode 100644 index 7df0ba1e6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardDirtyFilesPage.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.KSubstWizard.KSubstChangeElement; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Page to warn user about uncommitted outgoing changes. - */ -public class KSubstWizardDirtyFilesPage extends CVSWizardPage { - private boolean includeDirtyFiles; - private Button includeDirtyFilesButton; - private ListViewer listViewer; - - public KSubstWizardDirtyFilesPage(String pageName, String title, ImageDescriptor image, boolean includeDirtyFiles) { - super(pageName, title, image); - this.includeDirtyFiles = includeDirtyFiles; - } - - public void createControl(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - setControl(top); - - // set F1 help - WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_CHANGED_PAGE); - - createWrappingLabel(top, Policy.bind("KSubstWizardDirtyFilesPage.contents"), 0); //$NON-NLS-1$ - - includeDirtyFilesButton = new Button(top, SWT.CHECK); - includeDirtyFilesButton.setText(Policy.bind("KSubstWizardDirtyFilesPage.includeDirtyFiles")); //$NON-NLS-1$ - includeDirtyFilesButton.setSelection(includeDirtyFiles); - includeDirtyFilesButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - includeDirtyFiles = includeDirtyFilesButton.getSelection(); - } - }); - - createSeparator(top, SPACER_HEIGHT); - listViewer = createFileListViewer(top, - Policy.bind("KSubstWizardDirtyFilesPage.dirtyFilesViewer.title"), LIST_HEIGHT_HINT); //$NON-NLS-1$ - Dialog.applyDialogFont(parent); - } - - public boolean includeDirtyFiles() { - return includeDirtyFiles; - } - - public void setChangeList(List changes) { - List filteredFiles = new ArrayList(); - for (Iterator it = changes.iterator(); it.hasNext();) { - KSubstChangeElement change = (KSubstChangeElement) it.next(); - if (change.matchesFilter(KSubstChangeElement.CHANGED_FILE)) { - filteredFiles.add(change.getFile()); - } - } - listViewer.setInput(filteredFiles.toArray()); - } - - public boolean isListEmpty() { - // returns true iff the list is empty after filtering - return listViewer.getList().getItemCount() == 0; - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - includeDirtyFilesButton.setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSelectionPage.java deleted file mode 100644 index 4fec08d51..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSelectionPage.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Page to select keyword substitution mode. - */ -public class KSubstWizardSelectionPage extends CVSWizardPage { - private KSubstOption ksubst; - private List ksubstOptions; - private Button automaticRadioButton; - private Button binaryRadioButton; - private Button textRadioButton; - private Button ksubstRadioButton; - private Combo ksubstOptionCombo; - - public KSubstWizardSelectionPage(String pageName, String title, ImageDescriptor image, KSubstOption defaultKSubst) { - super(pageName, title, image); - this.ksubst = defaultKSubst; - - // sort the options by display text - KSubstOption[] options = KSubstOption.getAllKSubstOptions(); - this.ksubstOptions = new ArrayList(); - for (int i = 0; i < options.length; i++) { - KSubstOption option = options[i]; - if (! (Command.KSUBST_BINARY.equals(option) || - Command.KSUBST_TEXT.equals(option))) { - ksubstOptions.add(option); - } - } - Collections.sort(ksubstOptions, new Comparator() { - public int compare(Object a, Object b) { - String aKey = ((KSubstOption) a).getLongDisplayText(); - String bKey = ((KSubstOption) b).getLongDisplayText(); - return aKey.compareTo(bKey); - } - }); - } - - public void createControl(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - setControl(top); - - // set F1 help - WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_SELECTION_PAGE); - - Listener selectionListener = new Listener() { - public void handleEvent(Event event) { - updateEnablements(); - } - }; - - // Automatic - automaticRadioButton = createRadioButton(top, Policy.bind("KSubstWizardSelectionPage.automaticButton"), 1); //$NON-NLS-1$ - automaticRadioButton.addListener(SWT.Selection, selectionListener); - automaticRadioButton.setSelection(ksubst == null); - createWrappingLabel(top, Policy.bind("KSubstWizardSelectionPage.automaticLabel", //$NON-NLS-1$ - Command.KSUBST_BINARY.getLongDisplayText(), - CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption().getLongDisplayText()), - LABEL_INDENT_WIDTH); - - // Binary - binaryRadioButton = createRadioButton(top, Policy.bind("KSubstWizardSelectionPage.binaryButton"), 1); //$NON-NLS-1$ - binaryRadioButton.addListener(SWT.Selection, selectionListener); - binaryRadioButton.setSelection(Command.KSUBST_BINARY.equals(ksubst)); - createIndentedLabel(top, Policy.bind("KSubstWizardSelectionPage.binaryLabel"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - // Text without keyword substitution - textRadioButton = createRadioButton(top, Policy.bind("KSubstWizardSelectionPage.textButton"), 1); //$NON-NLS-1$ - textRadioButton.addListener(SWT.Selection, selectionListener); - textRadioButton.setSelection(Command.KSUBST_TEXT.equals(ksubst)); - createIndentedLabel(top, Policy.bind("KSubstWizardSelectionPage.textLabel"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - // Text with keyword substitution - ksubstRadioButton = createRadioButton(top, Policy.bind("KSubstWizardSelectionPage.textWithSubstitutionsButton"), 1); //$NON-NLS-1$ - ksubstRadioButton.addListener(SWT.Selection, selectionListener); - ksubstRadioButton.setSelection(false); - createIndentedLabel(top, Policy.bind("KSubstWizardSelectionPage.textWithSubstitutionsLabel"), LABEL_INDENT_WIDTH); //$NON-NLS-1$ - - ksubstOptionCombo = new Combo(top, SWT.READ_ONLY); - ksubstOptionCombo.addListener(SWT.Selection, selectionListener); - GridData data = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalIndent = LABEL_INDENT_WIDTH; - ksubstOptionCombo.setLayoutData(data); - - // populate the combo box and select the default option - for (int i = 0; i < ksubstOptions.size(); ++i) { - KSubstOption option = (KSubstOption) ksubstOptions.get(i); - ksubstOptionCombo.add(option.getLongDisplayText()); - if (option.equals(ksubst)) { - ksubstOptionCombo.select(i); - ksubstRadioButton.setSelection(true); - } else if (option.equals(Command.KSUBST_TEXT_EXPAND)) { - // if no expansion mode selected, show KSUBST_TEXT_EXPAND - // since it is the server default - if (! ksubstRadioButton.getSelection()) ksubstOptionCombo.select(i); - } - } - updateEnablements(); - Dialog.applyDialogFont(parent); - } - - /** - * Enable and disable controls based on the selected radio button. - */ - protected void updateEnablements() { - if (ksubstRadioButton.getSelection()) { - ksubstOptionCombo.setEnabled(true); - ksubst = (KSubstOption) ksubstOptions.get(ksubstOptionCombo.getSelectionIndex()); - } else { - ksubstOptionCombo.setEnabled(false); - if (automaticRadioButton.getSelection()) { - ksubst = null; - } else if (binaryRadioButton.getSelection()) { - ksubst = Command.KSUBST_BINARY; - } else if (textRadioButton.getSelection()) { - ksubst = Command.KSUBST_TEXT; - } - } - } - - public KSubstOption getKSubstOption() { - return ksubst; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSharedFilesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSharedFilesPage.java deleted file mode 100644 index de8f0e67a..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSharedFilesPage.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.KSubstWizard.KSubstChangeElement; -import org.eclipse.ui.help.WorkbenchHelp; - -/** - * Page to warn user about the side-effects of changing keyword - * substitution on already committed files. - */ -public class KSubstWizardSharedFilesPage extends CVSWizardPage { - private boolean includeSharedFiles; - private Button includeSharedFilesButton; - private ListViewer listViewer; - - public KSubstWizardSharedFilesPage(String pageName, String title, ImageDescriptor image, boolean includeSharedFiles) { - super(pageName, title, image); - this.includeSharedFiles = includeSharedFiles; - } - - public void createControl(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - setControl(top); - createWrappingLabel(top, Policy.bind("KSubstWizardSharedFilesPage.contents"), 0); //$NON-NLS-1$ - - // set F1 help - WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_SHARED_PAGE); - - includeSharedFilesButton = new Button(top, SWT.CHECK); - includeSharedFilesButton.setText(Policy.bind("KSubstWizardSharedFilesPage.includeSharedFiles")); //$NON-NLS-1$ - includeSharedFilesButton.setSelection(includeSharedFiles); - includeSharedFilesButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - includeSharedFiles = includeSharedFilesButton.getSelection(); - } - }); - - createSeparator(top, SPACER_HEIGHT); - listViewer = createFileListViewer(top, - Policy.bind("KSubstWizardSharedFilesPage.sharedFilesViewer.title"), LIST_HEIGHT_HINT); //$NON-NLS-1$ - Dialog.applyDialogFont(parent); - } - - public boolean includeSharedFiles() { - return includeSharedFiles; - } - - public void setChangeList(List changes) { - List filteredFiles = new ArrayList(); - for (Iterator it = changes.iterator(); it.hasNext();) { - KSubstChangeElement change = (KSubstChangeElement) it.next(); - if (change.matchesFilter(KSubstChangeElement.CHANGED_FILE | KSubstChangeElement.UNCHANGED_FILE)) { - filteredFiles.add(change.getFile()); - } - } - listViewer.setInput(filteredFiles.toArray()); - } - - public boolean isListEmpty() { - // returns true iff the list is empty after filtering - return listViewer.getList().getItemCount() == 0; - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - includeSharedFilesButton.setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSummaryPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSummaryPage.java deleted file mode 100644 index 7322eaaf1..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardSummaryPage.java +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.custom.TableEditor; -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.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.wizards.KSubstWizard.KSubstChangeElement; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchViewerSorter; - -public class KSubstWizardSummaryPage extends CVSWizardPage { - private CheckboxTableViewer tableViewer = null; - private KSubstOption[] ksubstOptions; - private String[] ksubstOptionsDisplayText; - private int filterType; - - private Button showUnaffectedFilesButton; - private boolean showUnaffectedFiles; - - public KSubstWizardSummaryPage(String pageName, String title, ImageDescriptor image, boolean showUnaffectedFiles) { - super(pageName, title, image); - this.showUnaffectedFiles = showUnaffectedFiles; - - // sort the options by display text - ksubstOptions = KSubstOption.getAllKSubstOptions(); - ksubstOptionsDisplayText = new String[ksubstOptions.length]; - Arrays.sort(ksubstOptions, new Comparator() { - public int compare(Object a, Object b) { - String aKey = getModeDisplayText((KSubstOption) a); - String bKey = getModeDisplayText((KSubstOption) b); - return aKey.compareTo(bKey); - } - }); - for (int i = 0; i < ksubstOptions.length; i++) { - ksubstOptionsDisplayText[i] = getModeDisplayText(ksubstOptions[i]); - } - } - - public void createControl(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - setControl(top); - createWrappingLabel(top, Policy.bind("KSubstWizardSummaryPage.contents"), 0); //$NON-NLS-1$ - - // set F1 help - WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_SUMMARY_PAGE); - - createSeparator(top, 0); - - showUnaffectedFilesButton = new Button(top, SWT.CHECK); - showUnaffectedFilesButton.setText(Policy.bind("KSubstWizardSummaryPage.showUnaffectedFiles")); //$NON-NLS-1$ - showUnaffectedFilesButton.setSelection(showUnaffectedFiles); - showUnaffectedFilesButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - BusyIndicator.showWhile(getContainer().getShell().getDisplay(), new Runnable() { - public void run() { - showUnaffectedFiles = showUnaffectedFilesButton.getSelection(); - refresh(false); - } - }); - } - }); - - tableViewer = createFileTableViewer(top, - Policy.bind("KSubstWizardSummaryPage.summaryViewer.title"), //$NON-NLS-1$ - Policy.bind("KSubstWizardSummaryPage.summaryViewer.fileHeader"), //$NON-NLS-1$ - Policy.bind("KSubstWizardSummaryPage.summaryViewer.ksubstHeader"), //$NON-NLS-1$ - LIST_HEIGHT_HINT); - Dialog.applyDialogFont(parent); - } - - /** - * Creates a TableViewer whose input is a Map from IFile to KSubstOption. - * - * @param parent the parent of the viewer - * @param title the text for the title label - * @param heightHint the nominal height of the list - * @return the created list viewer - */ - public CheckboxTableViewer createFileTableViewer(Composite parent, String title, - String fileHeader, String ksubstHeader, int heightHint) { - createLabel(parent, title); - // create a table - Table table = new Table(parent, SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = heightHint; - table.setLayoutData(data); - table.setLinesVisible(true); - table.setHeaderVisible(true); - - // add the columns - TableColumn column = new TableColumn(table, SWT.LEFT); - column.setText(fileHeader); - column = new TableColumn(table, SWT.LEFT); - column.setText(ksubstHeader); - TableLayout tableLayout = new TableLayout(); - table.setLayout(tableLayout); - tableLayout.addColumnData(new ColumnWeightData(1, true)); - tableLayout.addColumnData(new ColumnWeightData(1, true)); - - // create a viewer for the table - final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table); - tableViewer.setContentProvider(new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - return (Object[]) inputElement; - } - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - }); - - // show file name and keyword substitution mode - tableViewer.setLabelProvider(new ITableLabelProvider() { - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - public String getColumnText(Object element, int columnIndex) { - KSubstChangeElement change = (KSubstChangeElement) element; - if (columnIndex == 0) { - return change.getFile().getFullPath().toString(); - } else if (columnIndex == 1) { - return getModeDisplayText(change.getKSubst()); - } - return null; - } - public void addListener(ILabelProviderListener listener) { - } - public void dispose() { - } - public boolean isLabelProperty(Object element, String property) { - return false; - } - public void removeListener(ILabelProviderListener listener) { - } - }); - - // sort by file name - tableViewer.setSorter(new WorkbenchViewerSorter() { - public int compare(Viewer viewer, Object e1, Object e2) { - IFile file1 = ((KSubstChangeElement) e1).getFile(); - IFile file2 = ((KSubstChangeElement) e2).getFile(); - return super.compare(viewer, file1, file2); - } - }); - - // filter - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, Object element) { - KSubstChangeElement change = (KSubstChangeElement) element; - return ( showUnaffectedFiles || change.isNewKSubstMode()) && change.matchesFilter(filterType); - } - }); - - // add a check state listener - tableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - KSubstChangeElement change = (KSubstChangeElement) event.getElement(); - if (tableViewer.getGrayed(change)) { - // if it's grayed then give it the appearance of being disabled - updateCheckStatus(change); - } else { - // otherwise record the change - change.setExcluded(! event.getChecked()); - } - } - }); - - // add a cell editor in the Keyword Substitution Mode column - new TableEditor(table); - CellEditor cellEditor = new ComboBoxCellEditor(table, ksubstOptionsDisplayText); - tableViewer.setCellEditors(new CellEditor[] { null, cellEditor }); - tableViewer.setColumnProperties(new String[] { "file", "mode" }); //$NON-NLS-1$ //$NON-NLS-2$ - tableViewer.setCellModifier(new ICellModifier() { - public Object getValue(Object element, String property) { - KSubstChangeElement change = (KSubstChangeElement) element; - KSubstOption option = change.getKSubst(); - for (int i = 0; i < ksubstOptions.length; ++i) { - if (ksubstOptions[i].equals(option)) return new Integer(i); - } - // XXX need to handle this better - return null; - } - public boolean canModify(Object element, String property) { - return true; - } - public void modify(Object element, String property, Object value) { - // XXX The runtime type of 'element' seems to be a TableItem instead of the - // actual element data as with the other methods. As a workaround, use - // the table's selection mechanism instead. - IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); - element = selection.getFirstElement(); - int index = ((Integer) value).intValue(); - // selection will be -1 if some arbitrary text was entered since the combo box is not read only - if (index != -1) { - KSubstChangeElement change = (KSubstChangeElement) element; - KSubstOption newOption = ksubstOptions[index]; - if (! newOption.equals(change.getKSubst())) { - // the option has been changed, include it by default now if it wasn't before - // since the user has shown interest in it - change.setKSubst(newOption); - change.setExcluded(false); - tableViewer.refresh(change, true /*updateLabels*/); - updateCheckStatus(change); - } - } - } - }); - return tableViewer; - } - - public void setChangeList(List changes, int filterType) { - this.filterType = filterType; - tableViewer.setInput(changes.toArray()); - refresh(true); - } - - private void refresh(boolean updateLabels) { - tableViewer.refresh(updateLabels); - Object[] elements = (Object[]) tableViewer.getInput(); - for (int i = 0; i < elements.length; i++) { - KSubstChangeElement change = (KSubstChangeElement) elements[i]; - updateCheckStatus(change); - } - } - - private void updateCheckStatus(KSubstChangeElement change) { - if (change.isNewKSubstMode()) { - // if the mode differs, the checkbox indicates the inclusion/exclusion status - tableViewer.setGrayed(change, false); - tableViewer.setChecked(change, ! change.isExcluded()); - } else { - // otherwise, the checkbox is meaningless except to indicate that the file will not be changed - tableViewer.setGrayed(change, true); - tableViewer.setChecked(change, false); - } - } - - private String getModeDisplayText(KSubstOption option) { - return option.getLongDisplayText(); - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - showUnaffectedFilesButton.setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java deleted file mode 100644 index e7e527a57..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; -import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.ui.IWorkbenchPart; - -public class MergeWizard extends Wizard { - MergeWizardPage page; - IResource[] resources; - private final IWorkbenchPart part; - - public MergeWizard(IWorkbenchPart part, IResource[] resources) { - this.part = part; - this.resources = resources; - } - - public void addPages() { - setNeedsProgressMonitor(true); - TagSource tagSource = TagSource.create(resources); - setWindowTitle(Policy.bind("MergeWizard.title")); //$NON-NLS-1$ - ImageDescriptor mergeImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE); - page = new MergeWizardPage("mergePage", Policy.bind("MergeWizard.0"), mergeImage, Policy.bind("MergeWizard.1"), tagSource); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - addPage(page); - } - - /* - * @see IWizard#performFinish() - */ - public boolean performFinish() { - - CVSTag startTag = page.getStartTag(); - CVSTag endTag = page.getEndTag(); - - if (startTag == null || !page.isPreview()) { - // Perform the update (merge) in the background - UpdateOperation op = new UpdateOperation(getPart(), resources, getLocalOptions(startTag, endTag), null); - try { - op.run(); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - } catch (InterruptedException e) { - // Ignore - } - } else { - // First check if there is an existing matching participant, if so then re-use it - MergeSynchronizeParticipant participant = MergeSynchronizeParticipant.getMatchingParticipant(resources, startTag, endTag); - if(participant == null) { - CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag); - participant = new MergeSynchronizeParticipant(s); - TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); - } - participant.refresh(resources, null, null, null); - } - return true; - } - - private Command.LocalOption[] getLocalOptions(CVSTag startTag, CVSTag endTag) { - List options = new ArrayList(); - if (startTag != null) { - options.add(Command.makeArgumentOption(Update.JOIN, startTag.getName())); - } - options.add(Command.makeArgumentOption(Update.JOIN, endTag.getName())); - return (Command.LocalOption[]) options.toArray(new Command.LocalOption[options.size()]); - } - - private IWorkbenchPart getPart() { - return part; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java deleted file mode 100644 index c10125b69..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.tags.*; - -public class MergeWizardPage extends CVSWizardPage { - - private Text endTagField; - private Button endTagBrowseButton; - private TagSource tagSource; - private Text startTagField; - private Button startTagBrowseButton; - private TagRefreshButtonArea tagRefreshArea; - private CVSTag startTag; - private CVSTag endTag; - private Button previewButton; - private Button noPreviewButton; - protected boolean preview = true; - - public MergeWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, TagSource tagSource) { - super(pageName, title, titleImage, description); - this.tagSource = tagSource; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1, true); - - Composite mainArea = createComposite(composite, 2, true); - createEndTagArea(mainArea); - createStartTagArea(mainArea); - createPreviewOptionArea(mainArea); - - createTagRefreshArea(composite); - - Dialog.applyDialogFont(composite); - setControl(composite); - } - - private void createPreviewOptionArea(Composite mainArea) { - previewButton = createRadioButton(mainArea, Policy.bind("MergeWizardPage.0"), 2); //$NON-NLS-1$ - noPreviewButton = createRadioButton(mainArea, Policy.bind("MergeWizardPage.1"), 2); //$NON-NLS-1$ - SelectionAdapter selectionAdapter = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - preview = previewButton.getSelection(); - updateEnablements(); - } - }; - previewButton.setSelection(preview); - noPreviewButton.setSelection(!preview); - previewButton.addSelectionListener(selectionAdapter); - noPreviewButton.addSelectionListener(selectionAdapter); - } - - private void createTagRefreshArea(Composite parent) { - tagRefreshArea = new TagRefreshButtonArea(getShell(), getTagSource()); - tagRefreshArea.setRunnableContext(getContainer()); - tagRefreshArea.createArea(parent); - } - - private void createEndTagArea(Composite parent) { - createWrappingLabel(parent, Policy.bind("MergeWizardPage.2"), 0, 2); //$NON-NLS-1$ - endTagField = createTextField(parent); - endTagField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateEndTag(endTagField.getText()); - } - }); - final int endTagIncludeFlags = TagSelectionArea.INCLUDE_VERSIONS | TagSelectionArea.INCLUDE_BRANCHES | TagSelectionArea.INCLUDE_HEAD_TAG; - TagContentAssistProcessor.createContentAssistant(endTagField, tagSource, endTagIncludeFlags); - endTagBrowseButton = createPushButton(parent, Policy.bind("MergeWizardPage.3")); //$NON-NLS-1$ - endTagBrowseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), - Policy.bind("MergeWizardPage.4"), //$NON-NLS-1$ - Policy.bind("MergeWizardPage.5"), //$NON-NLS-1$ - endTagIncludeFlags, - false, IHelpContextIds.MERGE_END_PAGE); - if (dialog.open() == Dialog.OK) { - CVSTag selectedTag = dialog.getResult(); - setEndTag(selectedTag); - } - } - }); - } - - private void createStartTagArea(Composite parent) { - createWrappingLabel(parent, Policy.bind("MergeWizardPage.6"), 0, 2); //$NON-NLS-1$ - startTagField = createTextField(parent); - startTagField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateStartTag(startTagField.getText()); - } - }); - TagContentAssistProcessor.createContentAssistant(startTagField, tagSource, TagSelectionArea.INCLUDE_VERSIONS); - startTagBrowseButton = createPushButton(parent, Policy.bind("MergeWizardPage.7")); //$NON-NLS-1$ - startTagBrowseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), - Policy.bind("MergeWizardPage.8"), //$NON-NLS-1$ - Policy.bind("MergeWizardPage.9"), //$NON-NLS-1$ - TagSelectionDialog.INCLUDE_VERSIONS, - false, IHelpContextIds.MERGE_START_PAGE); - if (dialog.open() == Dialog.OK) { - CVSTag selectedTag = dialog.getResult(); - setStartTag(selectedTag); - } - } - }); - } - - protected void updateEndTag(String text) { - if (endTag == null || !endTag.getName().equals(text)) { - CVSTag tag = getTagFor(text, false); - setEndTag(tag); - } - updateEnablements(); - } - - protected void updateStartTag(String text) { - if (startTag == null || !startTag.getName().equals(text)) { - CVSTag tag = getTagFor(text, true); - setStartTag(tag); - } - updateEnablements(); - } - - private CVSTag getTagFor(String text, boolean versionsOnly) { - if (text.equals(CVSTag.DEFAULT.getName())) { - if (versionsOnly) return null; - return CVSTag.DEFAULT; - } - if (text.equals(CVSTag.BASE.getName())) { - if (versionsOnly) return null; - return CVSTag.BASE; - } - CVSTag[] tags; - if (versionsOnly) { - tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.DATE }); - } else { - tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }); - } - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (tag.getName().equals(text)) { - return tag; - } - } - return null; - } - - protected void setEndTag(CVSTag selectedTag) { - if (selectedTag == null || endTag == null || !endTag.equals(selectedTag)) { - endTag = selectedTag; - if (endTagField != null) { - String name = endTagField.getText(); - if (endTag != null) - name = endTag.getName(); - if (!endTagField.getText().equals(name)) - endTagField.setText(name); - if (startTag == null && endTag != null && endTag.getType() == CVSTag.BRANCH) { - CVSTag tag = findCommonBaseTag(endTag); - if (tag != null) { - setStartTag(tag); - } - } - } - updateEnablements(); - } - } - - protected void setStartTag(CVSTag selectedTag) { - if (selectedTag == null || startTag != null || !endTag.equals(selectedTag)) { - startTag = selectedTag; - if (startTagField != null) { - String name = startTagField.getText(); - if (startTag != null) - name = startTag.getName(); - if (!startTagField.getText().equals(name)) - startTagField.setText(name); - } - updateEnablements(); - } - } - - private CVSTag findCommonBaseTag(CVSTag tag) { - CVSTag[] tags = tagSource.getTags(CVSTag.VERSION); - for (int i = 0; i < tags.length; i++) { - CVSTag potentialMatch = tags[i]; - if (potentialMatch.getName().indexOf(tag.getName()) != -1) { - return potentialMatch; - } - } - return null; - } - - private void updateEnablements() { - if (endTag == null && endTagField.getText().length() > 0) { - setErrorMessage(Policy.bind("MergeWizardPage.10")); //$NON-NLS-1$ - } else if (startTag == null && startTagField.getText().length() > 0) { - setErrorMessage(Policy.bind("MergeWizardPage.11")); //$NON-NLS-1$ - } else if (endTag != null && startTag != null && startTag.equals(endTag)) { - setErrorMessage(Policy.bind("MergeWizardPage.12")); //$NON-NLS-1$ - } else if (startTag == null && endTag != null && preview) { - setErrorMessage(Policy.bind("MergeWizardPage.13")); //$NON-NLS-1$ - } else { - setErrorMessage(null); - } - setPageComplete((startTag != null || !preview) && endTag != null && (startTag == null || !startTag.equals(endTag))); - } - - protected TagSource getTagSource() { - return tagSource; - } - - private Button createPushButton(Composite parent, String label) { - Button b = new Button(parent, SWT.PUSH); - b.setText(label); - b.setLayoutData(new GridData(GridData.END | GridData.HORIZONTAL_ALIGN_FILL)); - return b; - } - - public CVSTag getStartTag() { - return startTag; - } - - public CVSTag getEndTag() { - return endTag; - } - - public boolean isPreview() { - return preview; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java deleted file mode 100644 index 7df778ff7..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider; -import org.eclipse.team.internal.ccvs.ui.repo.RepositorySorter; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -public class ModuleSelectionPage extends CVSWizardPage { - Button useProjectNameButton; - Button useSpecifiedNameButton; - private Button selectModuleButton; - Text text; - TreeViewer moduleList; - - String moduleName; - - // The project being associated with the remote module (or null) - private IProject project; - private ICVSRepositoryLocation location; - private boolean badLocation = false; - private String helpContextId; - private boolean supportsMultiSelection; - - private boolean isFetchingModules = false; - private Object fetchingModulesLock = new Object(); - - public ModuleSelectionPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - - public void setHelpContxtId(String helpContextId) { - this.helpContextId = helpContextId; - } - - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 2, false); - - if (helpContextId != null) - WorkbenchHelp.setHelp(composite, helpContextId); - - Listener listener = new Listener() { - public void handleEvent(Event event) { - updateEnablements(false); - } - }; - - if (project != null) { - useProjectNameButton = createRadioButton(composite, Policy.bind("ModuleSelectionPage.moduleIsProject"), 2); //$NON-NLS-1$ - useProjectNameButton.addListener(SWT.Selection, listener); - } - useSpecifiedNameButton = createRadioButton(composite, Policy.bind("ModuleSelectionPage.specifyModule"), 1); //$NON-NLS-1$ - useSpecifiedNameButton.addListener(SWT.Selection, listener); - - text = createTextField(composite); - text.addListener(SWT.Modify, listener); - - selectModuleButton = createRadioButton(composite, Policy.bind("ModuleSelectionPage.2"), 2); //$NON-NLS-1$ - selectModuleButton.addListener(SWT.Selection, listener); - moduleList = createModuleTree(composite, 2); - - // Set the initial enablement - if (useProjectNameButton != null) { - useProjectNameButton.setSelection(true); - useSpecifiedNameButton.setSelection(false); - } else { - useSpecifiedNameButton.setSelection(true); - } - selectModuleButton.setSelection(false); - updateEnablements(false); - setControl(composite); - Dialog.applyDialogFont(parent); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - if (useProjectNameButton != null && useProjectNameButton.getSelection()) { - useProjectNameButton.setFocus(); - } else if (useSpecifiedNameButton.getSelection()) { - text.setFocus(); - } else { - moduleList.getControl().setFocus(); - } - } - } - - protected void updateEnablements(boolean updateModulesList) { - if (useProjectNameButton != null && useProjectNameButton.getSelection()) { - text.setEnabled(false); - moduleList.getControl().setEnabled(false); - moduleName = null; - setPageComplete(true); - } else if (useSpecifiedNameButton.getSelection()) { - text.setEnabled(true); - moduleList.getControl().setEnabled(false); - moduleName = text.getText(); - if (moduleName.length() == 0) { - moduleName = null; - setPageComplete(false); - } else { - setPageComplete(true); - } - } else if (!badLocation){ - text.setEnabled(false); - moduleList.getControl().setEnabled(true); - moduleName = null; - if (moduleList.getInput() == null || updateModulesList) { - boolean fetchModules = false; - // The input is set after the page is shown to avoid - // fetching if the user wants to specify the name manually - try { - // This can be called from different events in the event loop. - // Ensure that we only fetch the input once - synchronized (fetchingModulesLock) { - if (!isFetchingModules) { - // This the first thread in so fetch the modules - fetchModules = true; - isFetchingModules = true; - } - } - if (fetchModules) { - // Validate the location first since the module fecthing is - // done in a deferred fashion - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - location.validateConnection(monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }); - setModuleListInput(); - } - } catch (InvocationTargetException e) { - if (!badLocation) { - badLocation = true; - CVSUIPlugin.openError(getShell(), null, null, e); - // This will null the module list input - setModuleListInput(); - } - } catch (InterruptedException e) { - // Canceled by the user - } finally { - synchronized (fetchingModulesLock) { - if (fetchModules) { - isFetchingModules = false; - } - } - } - } - setPageComplete(internalGetSelectedModules().length > 0); - } - } - - private ICVSRemoteFolder[] internalGetSelectedModules() { - if (moduleList != null && moduleList.getControl().isEnabled()) { - ISelection selection = moduleList.getSelection(); - if (!selection.isEmpty() && selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; - ArrayList result = new ArrayList(); - for (Iterator iter = ss.iterator(); iter.hasNext();) { - Object element = iter.next(); - if (element instanceof ICVSRemoteFolder) { - result.add(element); - } - - } - return (ICVSRemoteFolder[]) result.toArray(new ICVSRemoteFolder[result.size()]); - } - } else { - ICVSRemoteFolder folder = null; - if (moduleName != null) { - folder = internalCreateModuleHandle(moduleName); - } else { - if (project != null) { - folder = internalCreateModuleHandle(project.getName()); - } - } - if (folder != null) { - return new ICVSRemoteFolder[] { folder }; - } - } - return new ICVSRemoteFolder[0]; - } - - private ICVSRemoteFolder internalCreateModuleHandle(String name) { - ICVSRepositoryLocation location = getLocation(); - if (location == null) return null; - return location.getRemoteFolder(name, CVSTag.DEFAULT); - } - - /** - * Return the selected existing remote folder. If this - * method returns null, then getModuleName() - * can be used to get the name entered manually by the use. - * @return the selected exisiting remote module - */ - public ICVSRemoteFolder getSelectedModule() { - ICVSRemoteFolder[] selectedModules = getSelectedModules(); - if (selectedModules.length > 0) { - return selectedModules[0]; - } else { - return null; - } - } - - public ICVSRemoteFolder[] getSelectedModules() { - final ICVSRemoteFolder[][] folder = new ICVSRemoteFolder[][] { null }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - folder[0] = internalGetSelectedModules(); - } - }); - return folder[0]; - } - - private TreeViewer createModuleTree(Composite composite, int horizontalSpan) { - Tree tree = new Tree(composite, (supportsMultiSelection ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = horizontalSpan; - tree.setLayoutData(data); - TreeViewer result = new TreeViewer(tree) { - /* - * Fix to allow filtering to be used without triggering fetching - * of the contents of all children (see bug 62268) - */ - public boolean isExpandable(Object element) { - ITreeContentProvider cp = (ITreeContentProvider) getContentProvider(); - if(cp == null) - return false; - - return cp.hasChildren(element); - } - }; - result.setContentProvider(new RemoteContentProvider()); - result.setLabelProvider(new WorkbenchLabelProvider()); - result.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, Object element) { - return !(element instanceof ICVSRemoteFile); - } - }); - result.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateEnablements(false); - ICVSRemoteFolder[] modules = internalGetSelectedModules(); - if (modules.length == 1) { - // There is at 1 module selected - ICVSRemoteFolder selectedModule = modules[0]; - String repositoryRelativePath = selectedModule.getRepositoryRelativePath(); - if (!repositoryRelativePath.equals(FolderSyncInfo.VIRTUAL_DIRECTORY)) { - text.setText(repositoryRelativePath); - } - } else { - text.setText(""); //$NON-NLS-1$ - } - } - }); - result.getTree().addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (getSelectedModule() != null) { - ModuleSelectionPage.this.getContainer().showPage(getNextPage()); - } - } - }); - result.setSorter(new RepositorySorter()); - return result; - } - - private void setModuleListInput() { - ICVSRepositoryLocation location = getLocation(); - if (location == null || badLocation) return; - moduleList.setInput(location.getRemoteFolder(ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, CVSTag.DEFAULT)); - } - - private ICVSRepositoryLocation getLocation() { - return location; - } - - public void setLocation(ICVSRepositoryLocation location) { - boolean refresh = location != null && !location.equals(this.location); - this.location = location; - badLocation = false; - if (moduleList != null) { - updateEnablements(refresh); - } - } - - public void setProject(IProject project) { - this.project = project; - } - public void setSupportsMultiSelection(boolean supportsMultiSelection) { - this.supportsMultiSelection = supportsMultiSelection; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java deleted file mode 100644 index b45b81f40..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.lang.reflect.InvocationTargetException; -import java.util.Properties; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; - -public class NewLocationWizard extends Wizard { - private ConfigurationWizardMainPage mainPage; - - private Properties properties = null; - - /** - * Return the settings used for all location pages - */ - public static IDialogSettings getLocationDialogSettings() { - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - IDialogSettings section = workbenchSettings.getSection("NewLocationWizard");//$NON-NLS-1$ - if (section == null) { - section = workbenchSettings.addNewSection("NewLocationWizard");//$NON-NLS-1$ - } - return section; - } - - public NewLocationWizard() { - IDialogSettings section = getLocationDialogSettings(); - setDialogSettings(section); - setWindowTitle(Policy.bind("NewLocationWizard.title")); //$NON-NLS-1$ - } - - - public NewLocationWizard(Properties initialProperties) { - this(); - this.properties = initialProperties; - } - - /** - * Creates the wizard pages - */ - public void addPages() { - mainPage = new ConfigurationWizardMainPage("repositoryPage1", Policy.bind("NewLocationWizard.heading"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); //$NON-NLS-1$ //$NON-NLS-2$ - if (properties != null) { - mainPage.setProperties(properties); - } - mainPage.setShowValidate(true); - mainPage.setDescription(Policy.bind("NewLocationWizard.description")); //$NON-NLS-1$ - mainPage.setDialogSettings(getDialogSettings()); - addPage(mainPage); - } - /* - * @see IWizard#performFinish - */ - public boolean performFinish() { - final ICVSRepositoryLocation[] location = new ICVSRepositoryLocation[] { null }; - boolean keepLocation = false; - try { - // Create a handle to a repository location - location[0] = mainPage.getLocation(); - // Add the location quitely so we can validate - location[0] = KnownRepositories.getInstance().addRepository(location[0], false /* don't tell anybody */); - - if (mainPage.getValidate()) { - try { - new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - location[0].validateConnection(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - keepLocation = true; - } catch (InterruptedException e) { - // Cancelled by user. Fall through to dispose of location - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (t instanceof TeamException) { - throw (TeamException)t; - } else if (t instanceof Exception) { - throw CVSException.wrapException((Exception)t); - } else { - throw CVSException.wrapException(e); - } - } - } else { - keepLocation = true; - } - } catch (TeamException e) { - if (location[0] == null) { - // Exception creating the root, we cannot continue - CVSUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.exception"), null, e); //$NON-NLS-1$ - return false; - } else { - // Exception validating. We can continue if the user wishes. - IStatus error = e.getStatus(); - if (error.isMultiStatus() && error.getChildren().length == 1) { - error = error.getChildren()[0]; - } - - if (error.isMultiStatus()) { - CVSUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.validationFailedTitle"), null, e); //$NON-NLS-1$ - } else { - keepLocation = MessageDialog.openQuestion(getContainer().getShell(), - Policy.bind("NewLocationWizard.validationFailedTitle"), //$NON-NLS-1$ - Policy.bind("NewLocationWizard.validationFailedText", new Object[] {error.getMessage()})); //$NON-NLS-1$ - } - } - } - if (keepLocation) { - KnownRepositories.getInstance().addRepository(location[0], true /* let the world know */); - } else { - KnownRepositories.getInstance().disposeRepository(location[0]); - } - return keepLocation; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java deleted file mode 100644 index 4d02c7d57..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.*; - -/** - * First wizard page for importing a project into a CVS repository. - * This page prompts the user to select an existing repo or create a new one. - * If the user selected an existing repo, then getLocation() will return it. - */ -public class RepositorySelectionPage extends CVSWizardPage { - private TableViewer table; - private Button useExistingRepo; - private Button useNewRepo; - - private ICVSRepositoryLocation result; - - String extendedDescription; - - /** - * RepositorySelectionPage constructor. - * - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page - */ - public RepositorySelectionPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - protected TableViewer createTable(Composite parent, int span) { - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); - GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = span; - data.widthHint = 200; - table.setLayoutData(data); - TableLayout layout = new TableLayout(); - layout.addColumnData(new ColumnWeightData(100, true)); - table.setLayout(layout); - TableColumn col = new TableColumn(table, SWT.NONE); - col.setResizable(true); - - return new TableViewer(table); - } - /** - * Creates the UI part of the page. - * - * @param parent the parent of the created widgets - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1, false); - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARING_SELECT_REPOSITORY_PAGE); - if (extendedDescription == null) { - extendedDescription = Policy.bind("RepositorySelectionPage.description"); //$NON-NLS-1$ - } - createWrappingLabel(composite, extendedDescription, 0 /* indent */, 1 /* columns */); - - useNewRepo = createRadioButton(composite, Policy.bind("RepositorySelectionPage.useNew"), 1); //$NON-NLS-1$ - - useExistingRepo = createRadioButton(composite, Policy.bind("RepositorySelectionPage.useExisting"), 1); //$NON-NLS-1$ - table = createTable(composite, 1); - table.setContentProvider(new WorkbenchContentProvider()); - table.setLabelProvider(new WorkbenchLabelProvider()); - table.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - result = (ICVSRepositoryLocation)((IStructuredSelection)table.getSelection()).getFirstElement(); - setPageComplete(true); - } - }); - table.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - getContainer().showPage(getNextPage()); - } - }); - - useExistingRepo.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - if (useNewRepo.getSelection()) { - table.getTable().setEnabled(false); - result = null; - } else { - table.getTable().setEnabled(true); - result = (ICVSRepositoryLocation)((IStructuredSelection)table.getSelection()).getFirstElement(); - } - setPageComplete(true); - } - }); - - setControl(composite); - - initializeValues(); - Dialog.applyDialogFont(parent); - } - /** - * Initializes states of the controls. - */ - private void initializeValues() { - ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(); - AdaptableList input = new AdaptableList(locations); - table.setInput(input); - if (locations.length == 0) { - useNewRepo.setSelection(true); - } else { - useExistingRepo.setSelection(true); - table.setSelection(new StructuredSelection(locations[0])); - } - } - - public ICVSRepositoryLocation getLocation() { - return result; - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - useExistingRepo.setFocus(); - } - } - - public void setExtendedDescription(String extendedDescription) { - this.extendedDescription = extendedDescription; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java deleted file mode 100644 index 1133bf716..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java +++ /dev/null @@ -1,558 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import java.io.BufferedInputStream; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import org.eclipse.compare.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.ResourceSorter; - -/** - * Select the files to restore - */ -public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { - private TreeViewer fileTree; - private CompareViewerPane fileSelectionPane; - private CompareViewerPane revisionSelectionPane; - private CheckboxTableViewer revisionsTable; - private CompareViewerSwitchingPane fileContentPane; - - private HistoryTableProvider historyTableProvider; - private AdaptableHierarchicalResourceList treeInput = new AdaptableHierarchicalResourceList(ResourcesPlugin.getWorkspace().getRoot(), new IResource[0]); - - private IContainer folder; - private IFile selectedFile; - private ILogEntry selectedRevision; - private Map entriesCache = new HashMap(); - private Map filesToRestore = new HashMap(); - - private static final int WIZARD_WIDTH = 550; - - class HistoryInput implements ITypedElement, IEncodedStreamContentAccessor, IModificationDate { - IFile file; - ILogEntry logEntry; - - HistoryInput(IFile file, ILogEntry logEntry) { - this.file= file; - this.logEntry = logEntry; - } - public InputStream getContents() throws CoreException { - IStorage s = getStorageFromLogEntry(logEntry); - if (s == null) return null; - return new BufferedInputStream(s.getContents()); - } - public String getName() { - return file.getName(); - } - public String getType() { - return file.getFileExtension(); - } - public Image getImage() { - return CompareUI.getImage(file); - } - public long getModificationDate() { - return logEntry.getDate().getTime(); - } - public String getCharset() throws CoreException { - IStorage s = getStorageFromLogEntry(logEntry); - if (s instanceof IEncodedStorage) { - return ((IEncodedStorage)s).getCharset(); - } - return null; - } - } - - /** - * Constructor for RestoreFromRepositoryFileSelectionPage. - * @param pageName - * @param title - * @param titleImage - * @param description - */ - public RestoreFromRepositoryFileSelectionPage( - String pageName, - String title, - ImageDescriptor titleImage, - String description) { - super(pageName, title, titleImage, description); - } - - /** - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite= createComposite(parent, 1, false); - setControl(composite); - - WorkbenchHelp.setHelp(composite, IHelpContextIds.RESTORE_FROM_REPOSITORY_FILE_SELECTION_PAGE); - - // Top and bottom panes: top is the two selection panes, bottom is the file content viewer - Splitter vsplitter= new Splitter(composite, SWT.VERTICAL); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL - | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); - // Set the width to be extra wide to accomodate the two selection lists - data.widthHint = WIZARD_WIDTH; - vsplitter.setLayoutData(data); - - // Top left and top right panes: the left for the files, the right for the log entries - Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL); - - // Top left: file selection pane - fileSelectionPane = new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - fileSelectionPane.setLayoutData(data); - fileTree = createFileSelectionTree(fileSelectionPane); - - // Top right: Revision selection pane - revisionSelectionPane = new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - revisionSelectionPane.setLayoutData(data); - historyTableProvider = new HistoryTableProvider(); - revisionsTable = createRevisionSelectionTable(revisionSelectionPane, historyTableProvider); - revisionSelectionPane.setText(Policy.bind("RestoreFromRepositoryFileSelectionPage.emptyRevisionPane")); //$NON-NLS-1$ - - // Bottom: File content viewer - fileContentPane = new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - return CompareUI.findContentViewer(oldViewer, input, this, null); - } - }; - - initializeValues(); - updateWidgetEnablements(); - Dialog.applyDialogFont(parent); - } - - protected CheckboxTableViewer createRevisionSelectionTable(CompareViewerPane composite, HistoryTableProvider tableProvider) { - CheckboxTableViewer table = tableProvider.createCheckBoxTable(composite); - table.setContentProvider(new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - ILogEntry[] entries = getSelectedEntries(); - if (entries != null) return entries; - return new Object[0]; - } - public void dispose() { - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - }); - table.setInput(this); - table.getTable().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - // Handle check selection in the check state listener - if (e.detail == SWT.CHECK) return; - handleRevisionSelection(e.item); - } - } - ); - table.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - handleRevisionChecked(event); - } - }); - composite.setContent(table.getControl()); - return table; - } - - protected TreeViewer createFileSelectionTree(CompareViewerPane composite) { - TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - tree.setUseHashlookup(true); - tree.setContentProvider(treeInput.getTreeContentProvider()); - tree.setLabelProvider( - new DecoratingLabelProvider( - new WorkbenchLabelProvider() { - protected String decorateText(String input, Object element) { - String text; - if (element instanceof IFolder && element.equals(folder)) { - text = super.decorateText(folder.getProjectRelativePath().toString(), element); - } else { - ILogEntry entry = (ILogEntry)filesToRestore.get(element); - text = super.decorateText(input, element); - if (entry != null) { - text = Policy.bind("RestoreFromRepositoryFileSelectionPage.fileToRestore", text, entry.getRevision()); //$NON-NLS-1$ - } - } - return text; - } - }, - CVSUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator())); - tree.setSorter(new ResourceSorter(ResourceSorter.NAME)); - tree.setInput(treeInput); - - GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); - tree.getTree().setLayoutData(data); - tree.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - handleFileSelection(event); - } - }); - composite.setContent(tree.getControl()); - return tree; - } - - /** - * Method updateWidgetEnablements. - */ - private void updateWidgetEnablements() { - - if (filesToRestore.isEmpty()) { - setPageComplete(false); - setErrorMessage(null); - return; - } - - for (Iterator iter = filesToRestore.keySet().iterator(); iter.hasNext();) { - IFile file = (IFile) iter.next(); - if (file.exists()) { - setPageComplete(false); - setErrorMessage(Policy.bind("RestoreFromRepositoryFileSelectionPage.fileExists", file.getName())); //$NON-NLS-1$ - return; - } - - ILogEntry entry = (ILogEntry) filesToRestore.get(file); - if (entry.isDeletion()) { - setPageComplete(false); - setErrorMessage(Policy.bind("RestoreFromRepositoryFileSelectionPage.revisionIsDeletion", entry.getRevision(), file.getName())); //$NON-NLS-1$ - return; - } - } - setPageComplete(true); - setErrorMessage(null); - } - - /** - * Method initializeValues. - */ - private void initializeValues() { - refresh(); - } - - /** - * Sets the folder. - * @param folder The folder to set - */ - public void setInput(IContainer folder, ICVSFile[] files) { - if (folder.equals(this.folder)) return; - this.folder = folder; - setTreeInput(folder, files); - initializeValues(); - updateWidgetEnablements(); - } - - /* - * Set the resource tree input to the files that were deleted - */ - private void setTreeInput(IContainer folder, ICVSFile[] cvsFiles) { - reset(); - IResource[] files = new IResource[cvsFiles.length]; - for (int i = 0; i < cvsFiles.length; i++) { - try { - files[i] = cvsFiles[i].getIResource(); - } catch (CVSException e) { - // In practive, this error shold not occur. - // It may if there is an existing folder with a name that matches the file - // but this is bad in general when using CVS - CVSUIPlugin.log(e); - } - } - treeInput.setResources(files); - // kludge to avoid auto-selection of first element - // set the root to the folder's parent so the folder appears in the tree - treeInput.setRoot(folder.getParent()); - refresh(); - } - - private void reset() { - this.selectedFile = null; - this.selectedRevision = null; - treeInput.setResources(null); - filesToRestore = new HashMap(); - if (fileContentPane != null && !fileContentPane.isDisposed()) { - fileContentPane.setInput(null); - } - updateWidgetEnablements(); - } - - /** - * Method refresh. - */ - private void refresh() { - if (folder == null) return; - - if (fileSelectionPane != null && !fileSelectionPane.isDisposed()) { - fileSelectionPane.setText(Policy.bind("RestoreFromRepositoryFileSelectionPage.fileSelectionPaneTitle", folder.getProject().getName())); //$NON-NLS-1$ - fileSelectionPane.setImage(CompareUI.getImage(folder.getProject())); - } - - if (revisionSelectionPane != null && !revisionSelectionPane.isDisposed()) { - if (selectedFile == null) { - revisionSelectionPane.setText(Policy.bind("RestoreFromRepositoryFileSelectionPage.emptyRevisionPane")); //$NON-NLS-1$ - revisionSelectionPane.setImage(null); - } - } - - // Empty the file content viewer - if (fileContentPane != null && !fileContentPane.isDisposed()) { - fileContentPane.setInput(null); - } - - // refresh the tree - if (fileTree != null) { - // If the parent folder is in the tree, make sure it is expanded - fileTree.setExpandedState(folder, true); - fileTree.refresh(); - } - if (revisionsTable != null) - revisionsTable.refresh(); - } - - /* - * Set the log entry table input to the fetched entries in response to a file selection - */ - private void setLogEntryTableInput(ILogEntry[] entries) { - this.selectedRevision = null; - // Refresh the table so it picks up the selected entries through its content provider - revisionsTable.refresh(); - // Check the previously checked entry if one exists - ILogEntry selectedEntry = (ILogEntry)filesToRestore.get(selectedFile); - if (selectedEntry != null) { - revisionsTable.setChecked(selectedEntry, true); - } - // Disable entries that represent deletions since they can't be loaded - for (int i = 0; i < entries.length; i++) { - ILogEntry entry = entries[i]; - if (entry.isDeletion()) { - revisionsTable.setGrayed(entry, true); - } - } - // Set the titlebar text for the revisions table - revisionSelectionPane.setText(Policy.bind("RestoreFromRepositoryFileSelectionPage.revisionSelectionPaneTitle", selectedFile.getName())); //$NON-NLS-1$ - revisionSelectionPane.setImage(CompareUI.getImage(selectedFile)); - // Clear the file content pane - fileContentPane.setInput(null); - } - - private void handleFileSelection(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (selection == null || selection.isEmpty()) { - clearSelection(); - } else { - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - IResource resource = (IResource)structuredSelection.getFirstElement(); - if (resource instanceof IFile) { - handleFileSelection((IFile) resource); - } else { - clearSelection(); - } - } - } - } - - /** - * Method handleFileSelection. - * @param file - */ - private void handleFileSelection(IFile file) { - if (this.selectedFile == file) return; - this.selectedFile = file; - if (entriesCache.get(file) == null) { - try { - - // First, we need to create a remote file handle so we can get the log entries - ICVSFolder parent = CVSWorkspaceRoot.getCVSFolderFor(file.getParent()); - FolderSyncInfo info = parent.getFolderSyncInfo(); - ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); - final ICVSRemoteFile remoteFile = location.getRemoteFile(new Path(null, info.getRepository()).append(file.getName()).toString(), CVSTag.DEFAULT); - - // Then we need to fetch the log entries - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - // fetch the entries - ILogEntry[] entries = remoteFile.getLogEntries(monitor); - // cache the entries with the selected file - entriesCache.put(selectedFile, entries); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (CVSException e) { - setErrorMessage( - CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC) - .getMessage()); - return; - } catch (InvocationTargetException e) { - setErrorMessage( - CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC) - .getMessage()); - return; - } catch (InterruptedException e) { - return; - } - } - - // Set the log table to display the entries for the selected file - setLogEntryTableInput(getSelectedEntries()); - } - - private ILogEntry[] getSelectedEntries() { - return (ILogEntry[])entriesCache.get(selectedFile); - } - - private IStorage getStorageFromLogEntry(final ILogEntry logEntry) { - final IStorage[] s = new IStorage[] { null }; - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSRemoteFile remoteFile = logEntry.getRemoteFile(); - s[0] = ((IResourceVariant)remoteFile).getStorage(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } catch (InvocationTargetException e) { - setErrorMessage( - CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC) - .getMessage()); - return null; - } catch (InterruptedException e) { - return null; - } - return s[0]; - } - - private void handleRevisionChecked(CheckStateChangedEvent event) { - if (event.getChecked()) { - revisionsTable.setCheckedElements(new Object[] {event.getElement()}); - filesToRestore.put(selectedFile, event.getElement()); - } - if (revisionsTable.getCheckedElements().length == 0) { - filesToRestore.remove(selectedFile); - } - fileTree.refresh(); - updateWidgetEnablements(); - } - - /* - * A revision in the revision table has been selected. - * Populate the file contents pane with the selected log entry. - */ - private void handleRevisionSelection(Widget w) { - if (fileContentPane != null && !fileContentPane.isDisposed()) { - Object o= w.getData(); - if (o instanceof ILogEntry) { - ILogEntry selected = (ILogEntry) o; - if (this.selectedRevision == selected) return; - this.selectedRevision = selected; - if (selected.isDeletion()) { - fileContentPane.setInput(null); - } else { - fileContentPane.setInput(new HistoryInput(selectedFile, selected)); - fileContentPane.setText(getEditionLabel(selectedFile, selected)); - fileContentPane.setImage(CompareUI.getImage(selectedFile)); - } - } else { - fileContentPane.setInput(null); - } - } - } - /** - * Method getEditionLabel. - * @param selectedFile - * @param selected - * @return String - */ - private String getEditionLabel(IFile selectedFile, ILogEntry selected) { - return Policy.bind("RestoreFromRepositoryFileSelectionPage.fileContentPaneTitle", //$NON-NLS-1$ - new Object[] { selectedFile.getName(), selected.getRevision(), selectedFile.getFullPath().makeRelative().removeLastSegments(1).toString() }); - } - - public boolean restoreSelectedFiles() { - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(null, 100 * filesToRestore.size()); - for (Iterator iter = filesToRestore.keySet().iterator();iter.hasNext();) { - IFile file = (IFile) iter.next(); - ILogEntry entry = (ILogEntry)filesToRestore.get(file); - ensureParentExists(file); - file.create(entry.getRemoteFile().getContents(Policy.subMonitorFor(monitor, 50)), false, Policy.subMonitorFor(monitor, 50)); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - } catch (InvocationTargetException e) { - setErrorMessage( - CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC) - .getMessage()); - return false; - } catch (InterruptedException e) { - return false; - } - return true; - } - - /** - * Method ensureParentExists. - * @param file - */ - private void ensureParentExists(IResource resource) throws CoreException { - IContainer parent = resource.getParent(); - if (!parent.exists() && parent.getType() == IResource.FOLDER) { - ensureParentExists(parent); - ((IFolder)parent).create(false, true, null); - } - } - - private void clearSelection() { - this.selectedFile = null; - this.selectedRevision = null; - refresh(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryWizard.java deleted file mode 100644 index 960671851..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryWizard.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; - -/** - * This wizard allows the user to show deleted resources in the history view - */ -public class RestoreFromRepositoryWizard extends Wizard { - - private RestoreFromRepositoryFileSelectionPage fileSelectionPage; - private IContainer parent; - private ICVSFile[] files; - - /** - * Constructor for RestoreFromRepositoryWizard. - */ - public RestoreFromRepositoryWizard(IContainer parent, ICVSFile[] files) { - this.parent = parent; - this.files = files; - setWindowTitle(Policy.bind("RestoreFromRepositoryWizard.fileSelectionPageTitle")); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - return fileSelectionPage.restoreSelectedFiles(); - } - - /** - * @see org.eclipse.jface.wizard.IWizard#addPages() - */ - public void addPages() { - setNeedsProgressMonitor(true); - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); - - fileSelectionPage = new RestoreFromRepositoryFileSelectionPage("FileSelectionPage", Policy.bind("RestoreFromRepositoryWizard.fileSelectionPageTitle"), substImage, Policy.bind("RestoreFromRepositoryWizard.fileSelectionPageDescription")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - fileSelectionPage.setInput(parent, files); - addPage(fileSelectionPage); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java deleted file mode 100644 index 9b3651bcc..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java +++ /dev/null @@ -1,548 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.*; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; -import org.eclipse.team.internal.ccvs.ui.tags.*; -import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; -import org.eclipse.team.ui.IConfigurationWizard; -import org.eclipse.ui.IWorkbench; - -/** - * This wizard helps the user to import a new project in their workspace - * into a CVS repository for the first time. - */ -public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSWizard { - // The project to configure - private IProject project; - - // The autoconnect page is used if CVS/ directories already exist. - private ConfigurationWizardAutoconnectPage autoconnectPage; - - // The import page is used if CVS/ directories do not exist. - private RepositorySelectionPage locationPage; - - // The page that prompts the user for connection information. - private ConfigurationWizardMainPage createLocationPage; - - // The page that prompts the user for module name. - private ModuleSelectionPage modulePage; - - // The page that lets the user pick a branch to share against - private TagSelectionWizardPage tagPage; - - // The page that allows the user to commit or update resources - private SharingWizardSyncPage syncPage; - - // Keep track of location state so we know what to do at the end - private ICVSRepositoryLocation location; - private boolean isNewLocation; - - // Keep track of the folder that existed the last time we checked - private ICVSRemoteFolder existingRemote; - - public SharingWizard() { - IDialogSettings cvsSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - IDialogSettings section = cvsSettings.getSection("SharingWizard");//$NON-NLS-1$ - if (section == null) { - section = cvsSettings.addNewSection("SharingWizard");//$NON-NLS-1$ - } - setDialogSettings(section); - setNeedsProgressMonitor(true); - setWindowTitle(Policy.bind("SharingWizard.title")); //$NON-NLS-1$ - } - - public void addPages() { - ImageDescriptor sharingImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_SHARE); - if (doesCVSDirectoryExist()) { - autoconnectPage = new ConfigurationWizardAutoconnectPage("autoconnectPage", Policy.bind("SharingWizard.autoConnectTitle"), sharingImage); //$NON-NLS-1$ //$NON-NLS-2$ - autoconnectPage.setProject(project); - autoconnectPage.setDescription(Policy.bind("SharingWizard.autoConnectTitleDescription")); //$NON-NLS-1$ - addPage(autoconnectPage); - } else { - ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(); - if (locations.length > 0) { - locationPage = new RepositorySelectionPage("importPage", Policy.bind("SharingWizard.importTitle"), sharingImage); //$NON-NLS-1$ //$NON-NLS-2$ - locationPage.setDescription(Policy.bind("SharingWizard.importTitleDescription")); //$NON-NLS-1$ - addPage(locationPage); - } - createLocationPage = new ConfigurationWizardMainPage("createLocationPage", Policy.bind("SharingWizard.enterInformation"), sharingImage); //$NON-NLS-1$ //$NON-NLS-2$ - createLocationPage.setDescription(Policy.bind("SharingWizard.enterInformationDescription")); //$NON-NLS-1$ - createLocationPage.setCVSWizard(this); - createLocationPage.setDialogSettings(NewLocationWizard.getLocationDialogSettings()); - addPage(createLocationPage); - modulePage = new ModuleSelectionPage("modulePage", Policy.bind("SharingWizard.enterModuleName"), sharingImage); //$NON-NLS-1$ //$NON-NLS-2$ - modulePage.setDescription(Policy.bind("SharingWizard.enterModuleNameDescription")); //$NON-NLS-1$ - modulePage.setCVSWizard(this); - modulePage.setProject(project); - modulePage.setHelpContxtId(IHelpContextIds.SHARING_MODULE_PAGE); - addPage(modulePage); - - addTagPage(sharingImage); - addSyncPage(sharingImage); - } - } - - private void addTagPage(ImageDescriptor sharingImage) { - tagPage = new TagSelectionWizardPage("tagPage", //$NON-NLS-1$ - Policy.bind("SharingWizard.selectTagTitle"), //$NON-NLS-1$ - sharingImage, - Policy.bind("SharingWizard.selectTag"), //$NON-NLS-1$ - TagSource.EMPTY, // start with an empty tag source - TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG | TagSourceWorkbenchAdapter.INCLUDE_BRANCHES); //$NON-NLS-1$ - tagPage.setCVSWizard(this); - tagPage.setHelpContxtId(IHelpContextIds.SHARING_TAG_SELETION_PAGE); - addPage(tagPage); - } - - private void addSyncPage(ImageDescriptor sharingImage) { - syncPage = new SharingWizardSyncPage("syncPagePage", //$NON-NLS-1$ - Policy.bind("SharingWizard.23"), //$NON-NLS-1$ - sharingImage, - Policy.bind("SharingWizard.24")); //$NON-NLS-1$ - syncPage.setProject(project); - syncPage.setCVSWizard(this); - addPage(syncPage); - } - - public boolean canFinish() { - IWizardPage page = getContainer().getCurrentPage(); - return (page == autoconnectPage || page == syncPage); - } - - protected String getMainPageDescription() { - return Policy.bind("SharingWizard.description"); //$NON-NLS-1$ - } - - protected String getMainPageTitle() { - return Policy.bind("SharingWizard.heading"); //$NON-NLS-1$ - } - - public IWizardPage getNextPage(IWizardPage page) { - // Assume the page is about to be shown when this method is - // invoked - return getNextPage(page, true /* about to show*/); - } - - public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow) { - if (page == autoconnectPage) return null; - if (page == locationPage) { - if (locationPage.getLocation() == null) { - return createLocationPage; - } else { - if (aboutToShow) { - try { - modulePage.setLocation(getLocation()); - } catch (TeamException e1) { - CVSUIPlugin.log(e1); - } - } - return modulePage; - } - } - if (page == createLocationPage) { - if (aboutToShow) { - try { - modulePage.setLocation(getLocation()); - } catch (TeamException e1) { - CVSUIPlugin.log(e1); - } - } - return modulePage; - } - try { - if (page == modulePage) { - if (aboutToShow) { - ICVSRemoteFolder remoteFolder = getRemoteFolder(); - if (exists(remoteFolder)) { - prepareTagPage(remoteFolder); - return tagPage; - } else { - try { - populateSyncPage(false /* remote exists */); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - if (!RepositoryProvider.isShared(project)) { - // Only stay on the current page if the sharing was a total failure - return null; - } - } - return syncPage; - } - } else { - return syncPage; - } - } - if (page == tagPage) { - if (aboutToShow) { - populateSyncPage(true /* remote exists */); - } - return syncPage; - } - } catch (InvocationTargetException e) { - // Show the error and fall through to return null as the next page - CVSUIPlugin.openError(getShell(), null, null, e); - } catch (InterruptedException e) { - // The user cancelled. Falll through and return null as the next page. - } - return null; - } - - /* - * @see IWizard#performFinish - */ - public boolean performFinish() { - final boolean[] result = new boolean[] { true }; - if (isAutoconnect()) { - try { - getContainer().run(true /* fork */, true /* cancel */, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - result[0] = autoconnectCVSProject(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - } catch (InterruptedException e) { - return true; - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getContainer().getShell(), null, null, e); - result[0] = false; - } - } - // Add the location to the provider if it is new - if (result[0] && isNewLocation) { - KnownRepositories.getInstance().addRepository(location, true /* broadcast */); - } - if (getContainer().getCurrentPage() == syncPage) { - syncPage.saveSettings(); - syncPage.promptToCommit(); - } - return result[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#performCancel() - */ - public boolean performCancel() { - boolean disposeLocation = isNewLocation; - ICVSRepositoryLocation location; - try { - location = getLocation(); - } catch (TeamException e) { - CVSUIPlugin.log(e); - return true; - } - if (location == null) return true; - // If on the last page, offer to disconnect - if (getContainer().getCurrentPage() == syncPage - && RepositoryProvider.getProvider(project) != null) { - // Prompt to see if we should undo out work - if (promptToKeepMapping()) { - // If we didn't disconnect, don't dispose the repo - disposeLocation = false; - // Add the location to the provider if it is new - if (isNewLocation) { - KnownRepositories.getInstance().addRepository(location, true /* broadcast */); - } - } else { - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - new DisconnectOperation(null, new IProject[] { project }, true) - .run(monitor); - } - }); - } catch (InvocationTargetException e) { - CVSUIPlugin.log(IStatus.ERROR, e.getMessage(), e.getTargetException()); - } catch (InterruptedException e) { - // Ignore - } - } - } - // Dispose of the location if appropriate - if (disposeLocation) { - KnownRepositories.getInstance().disposeRepository(location); - } - return super.performCancel(); - } - - private boolean promptToKeepMapping() { - return (MessageDialog.openQuestion(getShell(), Policy.bind("SharingWizard.26"), Policy.bind("SharingWizard.27", project.getName()))); //$NON-NLS-1$ //$NON-NLS-2$ - } - - private void reconcileProject(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - new ReconcileProjectOperation(getShell(), project, getRemoteFolder()).run(monitor); - } - - /** - * Return an ICVSRepositoryLocation - */ - private ICVSRepositoryLocation getLocation() throws TeamException { - // If there is an autoconnect page then it has the location - if (autoconnectPage != null) { - return recordLocation(autoconnectPage.getLocation()); - } - - // If the location page has a location, use it. - if (locationPage != null) { - ICVSRepositoryLocation newLocation = locationPage.getLocation(); - if (newLocation != null) { - return recordLocation(newLocation); - } - } - - // Otherwise, get the location from the create location page - final ICVSRepositoryLocation[] locations = new ICVSRepositoryLocation[] { null }; - final CVSException[] exception = new CVSException[] { null }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - try { - locations[0] = createLocationPage.getLocation(); - } catch (CVSException e) { - exception[0] = e; - } - } - }); - if (exception[0] != null) { - throw exception[0]; - } - return recordLocation(locations[0]); - } - - private ICVSRepositoryLocation recordLocation(ICVSRepositoryLocation newLocation) { - if (newLocation == null) return location; - if (location == null || !newLocation.equals(location)) { - if (location != null && isNewLocation) { - // Dispose of the previous location - KnownRepositories.getInstance().disposeRepository(location); - } - location = newLocation; - isNewLocation = !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation()); - if (isNewLocation) { - // Add the location silently so we can work with it - location = KnownRepositories.getInstance().addRepository(location, false /* silently */); - } - } - return location; - } - - /* - * @see IConfigurationWizard#init(IWorkbench, IProject) - */ - public void init(IWorkbench workbench, IProject project) { - this.project = project; - } - - private boolean doesCVSDirectoryExist() { - // Determine if there is an existing CVS/ directory from which configuration - // information can be retrieved. - Shell shell = null; - if (getContainer() != null) { - shell = getContainer().getShell(); - } - final boolean[] isCVSFolder = new boolean[] { false }; - try { - CVSUIPlugin.runWithRefresh(shell, new IResource[] { project }, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); - FolderSyncInfo info = folder.getFolderSyncInfo(); - isCVSFolder[0] = info != null; - } catch (final TeamException e) { - throw new InvocationTargetException(e); - } - } - }, null); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(shell, null, null, e); - } catch (InterruptedException e) { - // Cancelled. Just fall through - } - return isCVSFolder[0]; - } - - /* - * Shoudl the project be auto-connected - */ - /* private*/ boolean isAutoconnect() { - return autoconnectPage != null && doesCVSDirectoryExist(); - } - - /* - * Auto-connect to the repository using CVS/ directories - */ - /*private */ boolean autoconnectCVSProject(IProgressMonitor monitor) throws TeamException { - try { - monitor.beginTask(null, 100); - - FolderSyncInfo info = autoconnectPage.getFolderSyncInfo(); - if (info == null) { - // Error! - return false; - } - - // Get the repository location (the get will add the locatin to the provider) - ICVSRepositoryLocation location = getLocation(); - - // Validate the connection if the user wants to - boolean validate = autoconnectPage.getValidate(); - if (validate) { - // Do the validation - try { - location.validateConnection(Policy.subMonitorFor(monitor, 50)); - } catch (final TeamException e) { - // Exception validating. We can continue if the user wishes. - final boolean[] keep = new boolean[] { false }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - keep[0] = MessageDialog.openQuestion(getContainer().getShell(), - Policy.bind("SharingWizard.validationFailedTitle"), //$NON-NLS-1$ - Policy.bind("SharingWizard.validationFailedText", new Object[] {e.getStatus().getMessage()})); //$NON-NLS-1$ - } - }); - if (!keep[0]) { - return false; - } - // They want to keep the connection anyway. Fall through. - } - } - - // Set the sharing - CVSWorkspaceRoot.setSharing(project, info, Policy.subMonitorFor(monitor, 50)); - return true; - } finally { - monitor.done(); - } - } - - private boolean shareProject(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(null, 100); - ICVSRepositoryLocation location = null; - try { - location = getLocation(); - location.validateConnection(Policy.subMonitorFor(monitor, 50)); - } catch (TeamException e) { - CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC); - if (isNewLocation && location != null) location.flushUserInfo(); - return false; - } - - // Create the remote module for the project - ShareProjectOperation op = new ShareProjectOperation(null, location, project, getRemoteFolder().getRepositoryRelativePath()); - op.setShell(getShell()); - op.run(Policy.subMonitorFor(monitor, 50)); - return true; - } - - private CVSTag getTag() { - if (tagPage == null || tagPage.getSelectedTag() == null) { - return CVSTag.DEFAULT; - } - return tagPage.getSelectedTag(); - } - - private ICVSRemoteFolder getRemoteFolder() { - ICVSRemoteFolder folder = modulePage.getSelectedModule(); - return (ICVSRemoteFolder)folder.forTag(getTag()); - } - - private boolean exists(ICVSRemoteFolder folder, IProgressMonitor monitor) throws TeamException { - if (existingRemote != null && existingRemote.equals(folder)) return true; - if (folder.exists(monitor)) { - existingRemote = folder; - return true; - } else { - existingRemote = null; - return false; - } - } - - private boolean exists(final ICVSRemoteFolder folder) throws InvocationTargetException, InterruptedException { - final boolean[] result = new boolean[] { false }; - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - result[0] = exists(folder, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - return result[0]; - } - - private void populateSyncPage(final boolean exists) throws InvocationTargetException, InterruptedException { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(null, 100); - if (exists) { - reconcileProject(Policy.subMonitorFor(monitor, 50)); - } else { - shareProject(Policy.subMonitorFor(monitor, 50)); - } - getParticipant().refreshNow(new IResource[] {project}, Policy.bind("ShareProjectOperation.1"), Policy.subMonitorFor(monitor, 50)); //$NON-NLS-1$ - if (monitor.isCanceled()) { - throw new InterruptedException(); - } - monitor.done(); - } - }); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getPreviousPage(IWizardPage page) { - if (page == syncPage) { - // There's no going back from the sync page - return null; - } - return super.getPreviousPage(page); - } - - private void prepareTagPage(ICVSRemoteFolder remote) { - tagPage.setTagSource(TagSource.create(remote)); - tagPage.setDescription(Policy.bind("SharingWizard.25", remote.getRepositoryRelativePath())); //$NON-NLS-1$ - } - - private WorkspaceSynchronizeParticipant getParticipant() { - return syncPage.getParticipant(); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java deleted file mode 100644 index 8cf1f8848..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.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.team.internal.ccvs.ui.wizards; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction; -import org.eclipse.team.internal.ccvs.ui.subscriber.CVSActionDelegateWrapper; -import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantAction; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceCommitOperation; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelAction; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; -import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; - -/** - * Adviser used to add toolbar buttons to the last page of the sharing wizard. - */ -public class SharingWizardPageActionGroup extends SynchronizePageActionGroup { - - public static final String ACTION_GROUP = "cvs_sharing_page_actions"; //$NON-NLS-1$ - - private SharingCommitAction commitAction; - - /** - * Custom commit that includes outgoing and conflicting. - */ - class SharingCommitAction extends CVSParticipantAction { - public SharingCommitAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider) { - super(configuration, provider, "SharingCommitAction."); //$NON-NLS-1$ - } - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}); - } - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new WorkspaceCommitOperation(configuration, elements, true /* override */); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SynchronizeViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) - */ - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP); - - commitAction = new SharingCommitAction( - configuration, - getVisibleRootsSelectionProvider()); - appendToGroup( - ISynchronizePageConfiguration.P_TOOLBAR_MENU, - ACTION_GROUP, - commitAction); - - appendToGroup( - ISynchronizePageConfiguration.P_TOOLBAR_MENU, - ACTION_GROUP, - new CVSActionDelegateWrapper(new IgnoreAction(), configuration){ - protected String getBundleKeyPrefix() { - return "SharingWizardIgnore."; //$NON-NLS-1$ - } - }); - } - /** - * @return Returns the commitAction. - */ - public SynchronizeModelAction getCommitAction() { - return commitAction; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java deleted file mode 100644 index eb2339d0f..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java +++ /dev/null @@ -1,279 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.TeamStatus; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.part.PageBook; - -/** - * Page that displays the compare input for sharing - */ -public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSetChangeListener { - - // Constant keys used to store last size for this page - private static final String PAGE_HEIGHT = "SyncPageHeight"; //$NON-NLS-1$ - private static final String PAGE_WIDTH = "SyncPageWidth"; //$NON-NLS-1$ - - private ParticipantPageSaveablePart input; - private ISynchronizePageConfiguration configuration; - private SyncInfoSet infos; - private IProject project; - - PageBook pageBook; - private Control syncPage; - private Control noChangesPage; - private Control errorPage; - - private int width; - private int height; - private SharingWizardPageActionGroup sharingWizardPageActionGroup; - - public SharingWizardSyncPage(String pageName, String title, ImageDescriptor titleImage, String description) { - super(pageName, title, titleImage, description); - } - - public void setProject(IProject project) { - this.project = project; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1, false); - setControl(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARING_SYNC_PAGE); - - pageBook = new PageBook(composite, SWT.NONE); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - pageBook.setLayoutData(data); - - input = createCompareInput(); - input.createPartControl(pageBook); - syncPage = input.getControl(); - infos = configuration.getSyncInfoSet(); - infos.addSyncSetChangedListener(this); - - noChangesPage = createNoChangesPage(pageBook); - noChangesPage.setLayoutData(new GridData(GridData.FILL_BOTH)); - - errorPage = createErrorPage(pageBook); - errorPage.setLayoutData(new GridData(GridData.FILL_BOTH)); - - updatePage(); - - Dialog.applyDialogFont(parent); - } - - private Control createNoChangesPage(PageBook pageBook) { - Composite composite = createComposite(pageBook, 1, false); - createWrappingLabel(composite, Policy.bind("SharingWizardSyncPage.3", project.getName()), 0); //$NON-NLS-1$ - return composite; - } - - private Control createErrorPage(PageBook pageBook) { - Composite composite = new Composite(pageBook, SWT.NONE); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - - createWrappingLabel(composite, Policy.bind("SharingWizardSyncPage.4"), 0); //$NON-NLS-1$ - - Button showErrors = new Button(composite, SWT.PUSH); - showErrors.setText(Policy.bind("SharingWizardSyncPage.5")); //$NON-NLS-1$ - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - showErrors.setLayoutData(data); - showErrors.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - showErrors(); - } - }); - - return composite; - } - - /* private */ void showErrors() { - ITeamStatus[] status = infos.getErrors(); - String title = Policy.bind("SharingWizardSyncPage.8"); //$NON-NLS-1$ - if (status.length == 1) { - IStatus s = status[0]; - if (s.getException() instanceof CoreException) { - s = ((CoreException)s.getException()).getStatus(); - } - ErrorDialog.openError(getShell(), title, null, s); - } else { - MultiStatus multi = new MultiStatus(CVSUIPlugin.ID, 0, status, Policy.bind("SharingWizardSyncPage.9"), null); //$NON-NLS-1$ - ErrorDialog.openError(getShell(), title, null, multi); - } - } - - private ParticipantPageSaveablePart createCompareInput() { - WorkspaceSynchronizeParticipant participant = new WorkspaceSynchronizeParticipant(new ResourceScope(new IResource[] { project })); - configuration = participant.createPageConfiguration(); - configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ISynchronizePageConfiguration.LAYOUT_GROUP, SharingWizardPageActionGroup.ACTION_GROUP}); - sharingWizardPageActionGroup = new SharingWizardPageActionGroup(); - configuration.addActionContribution(sharingWizardPageActionGroup); - configuration.setRunnableContext(getContainer()); - - CompareConfiguration cc = new CompareConfiguration(); - cc.setLeftEditable(false); - cc.setRightEditable(false); - ParticipantPageSaveablePart part = new ParticipantPageSaveablePart(getShell(), cc, configuration, participant); - part.setShowContentPanes(false); - return part; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - public void dispose() { - if (input != null) { - input.getParticipant().dispose(); - input.dispose(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.WizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public void setPreviousPage(IWizardPage page) { - // There's no going back from this page - super.setPreviousPage(null); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - updatePage(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoChanged(org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - updatePage(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetErrors(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - updatePage(); - } - - private void updatePage() { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (pageBook.isDisposed()) return; - if (infos.getErrors().length > 0) { - pageBook.showPage(errorPage); - } else if (infos.isEmpty()) { - pageBook.showPage(noChangesPage); - } else { - pageBook.showPage(syncPage); - } - } - }); - } - - public void showError(TeamStatus status) { - infos.addError(status); - } - - public WorkspaceSynchronizeParticipant getParticipant() { - return (WorkspaceSynchronizeParticipant)configuration.getParticipant(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - if (syncPage.isVisible()) { - initializeSize(); - getShell().setSize(Math.max(width, 300), Math.max(height, 300)); - if(input != null) { - Viewer viewer = input.getPageConfiguration().getPage().getViewer(); - if(viewer instanceof AbstractTreeViewer) { - ((AbstractTreeViewer)viewer).expandToLevel(2); - } - } - } - } - - private void initializeSize() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - try { - width = settings.getInt(PAGE_WIDTH); - height = settings.getInt(PAGE_HEIGHT); - } catch (NumberFormatException e) { - // Ignore and go on; - } - } - if (width == 0) width = 640; - if (height == 0) height = 480; - } - - /** - * Save the size of the page so it can be opened with the same size next time - */ - public void saveSettings() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - Point size = getShell().getSize(); - settings.put(PAGE_WIDTH, size.x); - settings.put(PAGE_HEIGHT, size.y); - } - } - - /** - * Prompt to commit any leftovers - */ - public void promptToCommit() { - if (sharingWizardPageActionGroup != null) { - if (sharingWizardPageActionGroup.getCommitAction().isEnabled()) { - if (MessageDialog.openQuestion(getShell(), Policy.bind("SharingWizardSyncPage.10"), Policy.bind("SharingWizardSyncPage.11"))) { //$NON-NLS-1$ //$NON-NLS-2$ - // Null the context so the commit will run in the background - configuration.setRunnableContext(null); - sharingWizardPageActionGroup.getCommitAction().run(); - } - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java deleted file mode 100644 index 8a09ef5c0..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; -import org.eclipse.team.internal.ccvs.ui.tags.*; -import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter; -import org.eclipse.team.internal.ccvs.ui.tags.TagSource; -import org.eclipse.ui.IWorkbenchPart; - -public class UpdateWizard extends Wizard { - - private IResource[] resources; - private final IWorkbenchPart part; - private TagSelectionWizardPage tagSelectionPage; - - public UpdateWizard(IWorkbenchPart part, IResource[] resources) { - this.part = part; - this.resources = resources; - setWindowTitle(Policy.bind("UpdateWizard.title")); //$NON-NLS-1$ - } - - public void addPages() { - ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); - tagSelectionPage = new TagSelectionWizardPage("tagPage", Policy.bind("UpdateWizard.0"), substImage, Policy.bind("UpdateWizard.1"), TagSource.create(resources), TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - tagSelectionPage.setAllowNoTag(true); - tagSelectionPage.setHelpContxtId(IHelpContextIds.UPDATE_TAG_SELETION_PAGE); - ICVSFolder[] folders = getCVSFolders(); - if (folders.length > 0) { - try { - CVSTag selectedTag = folders[0].getFolderSyncInfo().getTag(); - tagSelectionPage.setSelection(selectedTag); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } - addPage(tagSelectionPage); - } - - private ICVSFolder[] getCVSFolders() { - Set projects = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - projects.add(resource.getProject()); - } - ICVSFolder[] folders = new ICVSFolder[projects.size()]; - int i = 0; - for (Iterator iter = projects.iterator(); iter.hasNext();) { - IProject project = (IProject) iter.next(); - folders[i++] = CVSWorkspaceRoot.getCVSFolderFor(project); - } - return folders; - } - - /* - * @see IWizard#performFinish() - */ - public boolean performFinish() { - try { - new UpdateOperation(part, resources, Command.NO_LOCAL_OPTIONS, tagSelectionPage.getSelectedTag()).run(); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - return false; - } catch (InterruptedException e) { - return false; - } - return true; - } -} -- cgit v1.2.3