Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.compare.examples.xml/.classpath8
-rw-r--r--examples/org.eclipse.compare.examples.xml/.cvsignore1
-rw-r--r--examples/org.eclipse.compare.examples.xml/.project25
-rw-r--r--examples/org.eclipse.compare.examples.xml/.settings/org.eclipse.jdt.core.prefs70
-rw-r--r--examples/org.eclipse.compare.examples.xml/IdMaps/ant_test.xml7
-rw-r--r--examples/org.eclipse.compare.examples.xml/IdMaps/idmap.dtd8
-rw-r--r--examples/org.eclipse.compare.examples.xml/about.html30
-rw-r--r--examples/org.eclipse.compare.examples.xml/build.properties20
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/CreateNewIDMapButton.gifbin13851 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/EditCopy.gifbin49868 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMapContextMenu.gifbin5245 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_GeneralMatching.gifbin2816 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_MyPlugin.gifbin3525 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewIDMapScheme.gifbin5743 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_ContextMenu.gifbin3024 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_PreferencePage.gifbin7095 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/IDMap_SelectMyPlugin.gifbin4043 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/Ordered_MyANT.gifbin3184 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewIDMapScheme.gifbin5450 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_ContextMenu.gifbin2928 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_PreferencePage.gifbin5501 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/Ordered_UnorderedScheme.gifbin2821 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/PreferencePage.gifbin20791 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/addidmap.gifbin317 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/hglegal.htm14
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/idMapping.html103
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/ngibmcpy.gifbin1101 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/smartmode_co.gifbin553 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/tutorial_and_examples.html244
-rw-r--r--examples/org.eclipse.compare.examples.xml/doc-html/ui_xmlcompare_ex.html85
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/addidmap.gifbin317 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/attribute_obj.gifbin167 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_obj.gifbin353 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_ordered_obj.gifbin372 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/smartmode_co.gifbin553 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/icons/full/obj16/text_obj.gifbin556 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples.xml/plugin.properties21
-rw-r--r--examples/org.eclipse.compare.examples.xml/plugin.xml102
-rw-r--r--examples/org.eclipse.compare.examples.xml/schema/idMapping.exsd210
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java313
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AttributesImpl.java331
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java99
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/CreateNewIdMapAction.java63
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/IdMap.java142
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java91
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java218
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SWTUtil.java149
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java31
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java29
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java141
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java116
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java215
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java149
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java33
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java839
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java170
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java398
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java807
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java600
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewerCreator.java31
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java142
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusDialog.java164
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusInfo.java171
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java1
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/xmlcompare.properties109
-rw-r--r--examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/AllXMLCompareTests.java30
-rw-r--r--examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/TestXMLStructureCreator.java208
-rw-r--r--examples/org.eclipse.compare.examples/.classpath7
-rw-r--r--examples/org.eclipse.compare.examples/.cvsignore1
-rw-r--r--examples/org.eclipse.compare.examples/.project22
-rw-r--r--examples/org.eclipse.compare.examples/.settings/org.eclipse.jdt.core.prefs70
-rw-r--r--examples/org.eclipse.compare.examples/about.html30
-rw-r--r--examples/org.eclipse.compare.examples/build.properties19
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/hglegal.htm14
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gifbin1101 -> 0 bytes
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html84
-rw-r--r--examples/org.eclipse.compare.examples/plugin.properties15
-rw-r--r--examples/org.eclipse.compare.examples/plugin.xml40
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties16
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java156
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java31
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java80
-rw-r--r--examples/org.eclipse.team.examples.filesystem/.classpath7
-rw-r--r--examples/org.eclipse.team.examples.filesystem/.cvsignore1
-rw-r--r--examples/org.eclipse.team.examples.filesystem/.project40
-rw-r--r--examples/org.eclipse.team.examples.filesystem/about.html30
-rw-r--r--examples/org.eclipse.team.examples.filesystem/build.properties14
-rw-r--r--examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm14
-rw-r--r--examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gifbin1045 -> 0 bytes
-rw-r--r--examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html47
-rw-r--r--examples/org.eclipse.team.examples.filesystem/doc-html/team_localhistory_ex.html32
-rw-r--r--examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gifbin173 -> 0 bytes
-rw-r--r--examples/org.eclipse.team.examples.filesystem/icons/full/wizards/synced.gifbin160 -> 0 bytes
-rw-r--r--examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gifbin2615 -> 0 bytes
-rw-r--r--examples/org.eclipse.team.examples.filesystem/plugin.properties34
-rw-r--r--examples/org.eclipse.team.examples.filesystem/plugin.xml398
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java87
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java383
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java115
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java207
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java29
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java93
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java58
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties41
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java53
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java150
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java126
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSyncInfo.java54
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java88
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java46
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java61
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java301
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java77
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeOperation.java103
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java139
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java63
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeAction.java42
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeOperation.java82
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java123
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java65
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeAction.java42
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeOperation.java82
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java25
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeAction.java40
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeWizard.java68
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java87
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java83
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java31
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySynchronizeWizard.java63
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariant.java52
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariantComparator.java29
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java60
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IPessimisticFilesystemConstants.java64
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IResourceStateListener.java22
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java710
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java152
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java331
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java294
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java72
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java83
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/BlankPage.java38
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckInAction.java45
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckOutAction.java43
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/ConfigurationWizard.java54
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java90
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java130
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticPreferencesPage.java366
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java231
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java81
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java71
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/UncheckOutAction.java25
151 files changed, 0 insertions, 14090 deletions
diff --git a/examples/org.eclipse.compare.examples.xml/.classpath b/examples/org.eclipse.compare.examples.xml/.classpath
deleted file mode 100644
index ef70f953e..000000000
--- a/examples/org.eclipse.compare.examples.xml/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="tests"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/examples/org.eclipse.compare.examples.xml/.cvsignore b/examples/org.eclipse.compare.examples.xml/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/examples/org.eclipse.compare.examples.xml/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/examples/org.eclipse.compare.examples.xml/.project b/examples/org.eclipse.compare.examples.xml/.project
deleted file mode 100644
index 37bcfbdf7..000000000
--- a/examples/org.eclipse.compare.examples.xml/.project
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.compare.examples.xml</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.compare</project>
- <project>org.eclipse.compare.xml</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.swt</project>
- <project>org.eclipse.ui</project>
- <project>org.junit</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/examples/org.eclipse.compare.examples.xml/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.compare.examples.xml/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 6eb6ae3b2..000000000
--- a/examples/org.eclipse.compare.examples.xml/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,70 +0,0 @@
-#Tue Nov 30 15:50:49 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/examples/org.eclipse.compare.examples.xml/IdMaps/ant_test.xml b/examples/org.eclipse.compare.examples.xml/IdMaps/ant_test.xml
deleted file mode 100644
index 5587170bc..000000000
--- a/examples/org.eclipse.compare.examples.xml/IdMaps/ant_test.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE idmap SYSTEM "idmap.dtd">
-
-<idmap name="ANT">
- <element signature="root.project." id="name"/>
- <element signature="root.project.target." id="name"/>
-</idmap>
diff --git a/examples/org.eclipse.compare.examples.xml/IdMaps/idmap.dtd b/examples/org.eclipse.compare.examples.xml/IdMaps/idmap.dtd
deleted file mode 100644
index b60a2faae..000000000
--- a/examples/org.eclipse.compare.examples.xml/IdMaps/idmap.dtd
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!ELEMENT idmap (element)*>
-<!ATTLIST idmat
- name CDATA #REQUIRED>
-<!ELEMENT element EMPTY>
-<!ATTLIST element
- signature ID #REQUIRED
- id_attr CDATA #REQUIRED>
diff --git a/examples/org.eclipse.compare.examples.xml/about.html b/examples/org.eclipse.compare.examples.xml/about.html
deleted file mode 100644
index 9db411aab..000000000
--- a/examples/org.eclipse.compare.examples.xml/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
-other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/build.properties b/examples/org.eclipse.compare.examples.xml/build.properties
deleted file mode 100644
index 952ea1f3c..000000000
--- a/examples/org.eclipse.compare.examples.xml/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.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.xmlcompareexamples.jar = src/
-
-bin.includes = doc-html/,\
- about.html,\
- plugin.properties,\
- plugin.xml,\
- icons/,\
- xmlcompareexamples.jar
-
-src.includes = about.html
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/CreateNewIDMapButton.gif b/examples/org.eclipse.compare.examples.xml/doc-html/CreateNewIDMapButton.gif
deleted file mode 100644
index 907a80bfc..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/CreateNewIDMapButton.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/EditCopy.gif b/examples/org.eclipse.compare.examples.xml/doc-html/EditCopy.gif
deleted file mode 100644
index 6e7eb1da8..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/EditCopy.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMapContextMenu.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMapContextMenu.gif
deleted file mode 100644
index e7f2052c3..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMapContextMenu.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_GeneralMatching.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_GeneralMatching.gif
deleted file mode 100644
index 9ff706298..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_GeneralMatching.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_MyPlugin.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_MyPlugin.gif
deleted file mode 100644
index 1ddf17172..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_MyPlugin.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewIDMapScheme.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewIDMapScheme.gif
deleted file mode 100644
index 7c1d274c5..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewIDMapScheme.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_ContextMenu.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_ContextMenu.gif
deleted file mode 100644
index 93d1dc829..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_ContextMenu.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_PreferencePage.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_PreferencePage.gif
deleted file mode 100644
index 6d6e02b82..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_NewMapping_PreferencePage.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_SelectMyPlugin.gif b/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_SelectMyPlugin.gif
deleted file mode 100644
index 3b16c755d..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/IDMap_SelectMyPlugin.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_MyANT.gif b/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_MyANT.gif
deleted file mode 100644
index d4278fec0..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_MyANT.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewIDMapScheme.gif b/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewIDMapScheme.gif
deleted file mode 100644
index b9ac0da98..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewIDMapScheme.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_ContextMenu.gif b/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_ContextMenu.gif
deleted file mode 100644
index 8c882981b..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_ContextMenu.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_PreferencePage.gif b/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_PreferencePage.gif
deleted file mode 100644
index 0485d3ca8..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_NewOrderedEntry_PreferencePage.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_UnorderedScheme.gif b/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_UnorderedScheme.gif
deleted file mode 100644
index c58e5671b..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/Ordered_UnorderedScheme.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/PreferencePage.gif b/examples/org.eclipse.compare.examples.xml/doc-html/PreferencePage.gif
deleted file mode 100644
index ba7912b9d..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/PreferencePage.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/addidmap.gif b/examples/org.eclipse.compare.examples.xml/doc-html/addidmap.gif
deleted file mode 100644
index 62dad8be9..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/addidmap.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/hglegal.htm b/examples/org.eclipse.compare.examples.xml/doc-html/hglegal.htm
deleted file mode 100644
index f5871b79e..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <LINK REL="stylesheet" HREF="../../../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/idMapping.html b/examples/org.eclipse.compare.examples.xml/doc-html/idMapping.html
deleted file mode 100644
index 38de5539c..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/idMapping.html
+++ /dev/null
@@ -1,103 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>XML Compare Extension Points: idMapping</title>
-</head>
-<body link="#0000FF" vlink="#800080">
-
-<center>
-<h1>
-idMapping</h1></center>
-<b><i>Identifier: </i></b>org.eclipse.compare.examples.xml.idMapping
-<p><b><i>Description: </i></b>This extension point allows to define internal XML ID Mapping
-schemes using the <i>mapping</i> element. These schemes can then be used when performing an XML compare to uniquely identify XML elements by the value of an
-attribute or the text in a child element.
-<br>Additionally, <i>ordered</i> elements can be used to specify that the direct children of an element should be compared in ordered fashion instead of the
-default unordered way.
-<p><b><i>Configuration Markup:</i></b>
-<p><tt>&nbsp;&nbsp; &lt;!ELEMENT idmap (mapping*)></tt>
-<br><tt>&nbsp;&nbsp; &lt;!ATTLIST idmap</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-CDATA #REQUIRED</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extension&nbsp;
-CDATA</tt>
-<br><tt>&nbsp;&nbsp; ></tt>
-<ul>
-<li>
-<b>name</b> - the name of the ID Mapping scheme. Should be unique.</li>
-<li>
-<b>extension</b> - (optional) a file extension associated with this ID Mapping Scheme.
-When comparing files with this extension, the current ID Mapping Scheme will automatically be used.
-<br>If an extension is specified, then the extension should also be added in the plugin.xml file of the XML Compare Plugin.
-For example, if we create an ID Mapping Scheme with extension cd, the plugin.xml of the XML Compare Plugin is updated as follows
-(update shown in bold):
-<tt>
-<p>&lt;extension
-<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point="org.eclipse.compare.structureMergeViewers">
-<br>&nbsp;&nbsp;&nbsp;&lt;structureMergeViewer
-<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extensions="xml,classpath,<b>cd</b>"
-<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class="org.eclipse.compare.xml.XMLStructureViewerCreator">
-<br>&nbsp;&nbsp;&nbsp;&lt;/structureMergeViewer>
-</tt>
-<p><b>Warning: </b>If an extension is associated more than once, only the first association will be considered.
-Also, internal ID Mapping schemes have priority over user ID Mapping schemes when duplicate extensions are defined.
-<p><b>Warning: </b>When an internal ID Mapping scheme with extension association is removed (from a <tt>plugin.xml</tt>), the XML Compare plugin has to be reloaded to disassociate itself from the extension.
-If not, on the first compare of files with this extension, the XML Compare plugin will be used with the default <em>Unordered</em> algorithm.
-(However, at this point the extension will have been disassociated from the XML Plugin, as the plugin has been loaded.)
-</ul>
-<br>
-<p><tt>&nbsp;&nbsp; &lt;!ELEMENT mapping EMPTY></tt>
-<br><tt>&nbsp;&nbsp; &lt;!ATTLIST mapping</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signature&nbsp;
-CDATA #REQUIRED</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-CDATA #REQUIRED</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id-source &nbsp;CDATA</tt>
-<br><tt>&nbsp;&nbsp; ></tt>
-<ul>
-<li>
-<b>signature</b> - the XML path from the root to the current element (see examples below).</li>
-
-<li>
-<b>id</b> - the attribute that identifies this element or the name of the child element
-whose text identifies this element.</li>
-
-<li>
-<b>id-source</b> - (optional) if <em>id</em> is the name of a child element, then this attribute must have
-the value <em>body</em>. If <em>id-source</em> is left out, it is assumed that <em>id</em> is an attribute.</li>
-</ul>
-<br>
-<p><tt>&nbsp;&nbsp; &lt;!ELEMENT ordered EMPTY></tt>
-<br><tt>&nbsp;&nbsp; &lt;!ATTLIST ordered</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signature&nbsp;
-CDATA #REQUIRED</tt>
-<br><tt>&nbsp;&nbsp; ></tt>
-<ul>
-<li>
-<b>signature</b> - the XML path from the root to the element whose direct children will be compared in ordered fashion instead of the default unordered way.</li>
-</li>
-</ul>
-<b><i>Examples:</i></b>
-<br>The following is an example ID Mappings Scheme for ANT files.
-<br><i>project</i> elements are identified by an attribute <i>name</i>. <i>target</i> elements (which are children of <i>project</i>) are also identified by an attribute <i>name</i>.
-Also, the children of <i>target</i> will be compared in the order in which they appear in the document.
-<tt>
-<p>&lt;idmap name="ANT">
-<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;mapping signature="project" id="name"/>
-<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;mapping signature="project>target" id="name"/>
-<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;ordered signature="project>target"/>
-<br>&lt;idmap>
-</tt>
-<p>The following example illustrates a case where the text of a child element is used as id:
-<tt>
-<p>&lt;idmap name="Book Catalog" extension="book">
-<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;mapping signature="catalog>book" id="isbn" id-source="body"/>
-<br>&lt;idmap>
-</tt>
-<p><b><i>Supplied Implementation:</i></b>
-<br>The XML Compare plugin defines an ID Mapping scheme for Eclipse <tt>plugin.xml</tt> files, one for <tt>.classpath</tt> files and one for ANT files.
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corporation and others 2000, 2003. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/ngibmcpy.gif b/examples/org.eclipse.compare.examples.xml/doc-html/ngibmcpy.gif
deleted file mode 100644
index c786e43e1..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/ngibmcpy.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/smartmode_co.gif b/examples/org.eclipse.compare.examples.xml/doc-html/smartmode_co.gif
deleted file mode 100644
index 542dddca3..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/smartmode_co.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/tutorial_and_examples.html b/examples/org.eclipse.compare.examples.xml/doc-html/tutorial_and_examples.html
deleted file mode 100644
index ae1baff9f..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/tutorial_and_examples.html
+++ /dev/null
@@ -1,244 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Tutorial and Examples</title>
-</head>
-<body link="#0000FF" vlink="#800080">
-<h1>Tutorial and Examples</h1>
-<h2><a id="id_mapping" name="id_mapping">
-General Matching vs. ID Mapping Schemes:<br>How to create an ID Mapping Scheme to improve compare results
-</a></h2>
-Consider an example XML file in two slightly different versions, left and right. Assume that the element <tt>extension-point</tt> is uniquely identified by the attribute <tt>id</tt>.
-The textual differences are shown in bold.
-<table>
-<tr>
-<td><tt>
-<br>
-<p>&lt;?xml version="1.0" encoding="UTF-8"?>
-<p>&lt;plugin
-<br>
-&nbsp;&nbsp;&nbsp;name="%Plugin.name"
-<br>
-&nbsp;&nbsp;&nbsp;id="org.eclipse.ui"
-<br>
-&nbsp;&nbsp;&nbsp;version="1.0"
-<br>
-&nbsp;&nbsp;&nbsp;provider-name="Object Technology International, Inc."
-<br>
-&nbsp;&nbsp;&nbsp;class="org.eclipse.ui.internal.WorkbenchPlugin">
-<br>
-<br>&lt;extension-point name="%ExtPoint.editorMenus " id="editorActions"/>
-<br>&lt;extension-point name="%ExtPoint.popupMenus " id="popupMenus"/>
-<br>&lt;extension-point name="%ExtPoint.<b>importWizards</b>" id="<b>importWizards</b>"/>
-<br>
-<p>&lt;/plugin>
-</tt>
-</td>
-<td>
-&nbsp;&nbsp;
-</td>
-<td><tt>
-<p>&lt;?xml version="1.0" encoding="UTF-8"?>
-<p>&lt;plugin
-<br>
-&nbsp;&nbsp;&nbsp;name="%Plugin.name"
-<br>
-&nbsp;&nbsp;&nbsp;id="org.eclipse.ui"
-<br>
-&nbsp;&nbsp;&nbsp;version="1.0"
-<br>
-&nbsp;&nbsp;&nbsp;provider-name="Object Technology International, Inc."
-<br>
-&nbsp;&nbsp;&nbsp;class="org.eclipse.ui.internal.WorkbenchPlugin">
-<br>
-<br>&lt;extension-point name="%ExtPoint.editorMenus " id="editorActions"/>
-<br>&lt;extension-point name="%ExtPoint.popupMenus " id="popupMenus"/>
-<br>&lt;extension-point name="%ExtPoint.<b>exportWizards</b>" id="<b>exportWizards</b>"/>
-<br>
-<p>&lt;/plugin>
-</tt>
-</td>
-</tr>
-</table>
-<br>
-Assume that the order of the elements should be ignored. The structural difference between the two documents consists in the <tt>extension-point</tt> element on the left with <tt>id="importWizards"</tt> being replaced on the right with a new <tt>extension-point</tt> with <tt>id="exportWizards"</tt>.
-Using the general matching algorithm called <em>Unordered</em>, because it ignores the order in which the XML elements appear in the document, we obtain the following tree of differences.
-<br>
-<br>
-<img src="IDMap_GeneralMatching.gif" alt="Difference Tree using General Matching Algorithm">
-<br>
-<br>
-The first two <tt>extension-point</tt> elements are identical and are therefore matched and are not shown in the difference tree. There remains the third <tt>extension-point</tt> element on both sides which, having the same element name, are also matched.
-The difference tree then shows the differences between the third <tt>extension-point</tt> element left and the third <tt>extension-point</tt> element right.
-These differences consist in the values of the attributes <tt>id</tt> and <tt>name</tt>.
-<br>
-However, this is not what we would like to see. We would like the difference tree to show us that an <tt>extension-point</tt> element was removed from the left side and a new <tt>extension-point</tt> element was added on the right side.
-<br>
-To achieve this, we create a new ID Mapping Scheme. We can do this by using the appropriate button on toolbar.
-<br><br>
-<img src="IDMap_NewIDMapScheme.gif" alt="Creating a new ID Mapping Scheme">
-<br><br>
-Assume we call the ID Mapping Scheme <em>MyPlugin</em>. We now select the ID Mapping Scheme MyPlugin from the drop-down list in the Toolbar
-<br><br>
-<img src="IDMap_SelectMyPlugin.gif" alt="Select MyPlugin ID Map Scheme">
-<br><br>
-and add to it the following Mapping:
-<br><br>
-<table>
-<tr>
-<td>
-<img src="IDMap_NewMapping_PreferencePage.gif" alt="Creating a new mapping from the preference page">
-</td>
-<td>
-&nbsp;&nbsp;&nbsp;
-</td>
-<td>
-<img src="IDMap_NewMapping_ContextMenu.gif" alt="Creating a new mapping using the context menu">
-</td>
-</tr>
-</table>
-<br>
-This can be done from the preference page (left) or from the context menu in the structure view (right).
-<br>
-The difference tree now becomes:
-<br>
-(To refresh the structure view, click on the <img src="smartmode_co.gif" alt="Button for updating view"> button of the drop-down list in the toolbar.)
-<br><br>
-<img src="IDMap_MyPlugin.gif" alt="Difference Tree using MyPlugin ID Mapping Scheme">
-<br><br>
-This is the compare result that we wanted and that we achieved by created an ID Mapping Scheme.
-<br>
-<br>
-The XML Compare Plugin already comes with a ID Mapping Scheme for Plugin files, which can be customized for particular Plugin files.
-<br><br>
-<b>Warning:</b>
-<br>
-If an ID Mapping is created, it is assumed that the id is unique, i.e. there are no two XML elements with the same name and path that have the same id.
-Should this not be the case, the ID Mapping Scheme may not deliver a sensible difference tree.
-<br>
-When an id can appear more than once, one should rely on the general algorithm.
-<br>
-<br>
-Also, when an ID Mapping Scheme is used and there are elements with no id mapping specified, the <em>Unordered</em> compare method will be used, i.e. elements are matched by their similarity and not by the order in which they appear in the document.
-To specify that the children of an element should be compared in order of appearance. See the next section on Ordered entries.
-
-<h2>Adding Ordered entries</h2>
-Ordered entries are used to specify that the direct children (excluding attributes) of an xml element - identified by its path - should be compared in ordered way instead of the default unordered method.
-<br> As an example consider the following ANT file in two slightly different versions:
-<table>
-<tr>
-<td>
-<tt>
-<p>&lt;?xml version="1.0" encoding="UTF-8"?>
-<p>&lt;project name="org.junit.wizards" default="export" basedir="..">
-<br>
-&nbsp;&nbsp;&nbsp;&lt;target name="export" depends="build">
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mkdir dir="${destdir}" />
-<br>
-<b>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;delete dir="${dest}" />
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mkdir dir="${dest}" />
-<br>
-</b>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;jar
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jarfile="${dest}/JUnitWizard.jar"
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;basedir="bin"
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/>
-<br>&lt;/project>
-</tt>
-</td>
-<td>
-&nbsp;&nbsp;
-</td>
-<td>
-<tt>
-<p>&lt;?xml version="1.0" encoding="UTF-8"?>
-<p>&lt;project name="org.junit.wizards" default="export" basedir="..">
-<br>
-&nbsp;&nbsp;&nbsp;&lt;target name="export" depends="build">
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mkdir dir="${destdir}"/>
-<br>
-<b>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mkdir dir="${dest}"/>
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;delete dir="${dest}"/>
-<br>
-</b>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;jar
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jarfile="${dest}/JUnitWizard.jar"
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;basedir="bin"
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/>
-<br>
-<b>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;copy file="plugin.xml" todir="${dest}"/>
-</b>
-<br>&lt;/project>
-</tt>
-</td>
-</tr>
-</table>
-<br>
-The differences between the two documents are shown in bold. Two elements have been swapped (<tt>&lt;mkdir dir="${dest}"/></tt> and <tt>&lt;delete dir="${dest}"/></tt>) and a new element (<tt>&lt;copy .../></tt>) has been appended to the target element.
-<br>
-Performing an unordered compare will result in the following tree of differences:
-<br>
-<br>
-<img src="Ordered_UnorderedScheme.gif" alt="Difference Tree using Unordered Matching">
-<br>
-<br>
-The fact that two elements have been swapped is not shown since the order of elements is ignored.
-<br>
-However, from an ANT point of view, the two documents cause very different behaviour, because the order of the elements inside a <tt>target</tt> is important.
-We therefore want to create an <i>ordered entry</i> for target to instruct the compare engine to compare the direct children of target in ordered fashion.
-<br>
-We do so by first creating a new ID Mapping Scheme. This can be done using the appropriate button in the toolbar.
-<br><br>
-<img src="Ordered_NewIDMapScheme.gif" alt="Creating a new ID Mapping Scheme">
-<br><br>
-Assume we call the ID Mapping Scheme <em>MyANT</em>.
-<br>We now select the ID Mapping Scheme MyANT from the drop-down list in the Toolbar and add to it the following Ordered Entry:
-<br><br>
-<table>
-<tr>
-<td>
-<img src="Ordered_NewOrderedEntry_PreferencePage.gif" alt="Creating a new orderered entry from the preference page">
-</td>
-<td>
-&nbsp;&nbsp;&nbsp;
-</td>
-<td>
-<img src="Ordered_NewOrderedEntry_ContextMenu.gif" alt="Creating a new ordered entry using the context menu">
-</td>
-</tr>
-</table>
-<br>
-This can be done from the preference page (left) or from the context menu in the structure view (right).
-<br>
-The difference tree now becomes:
-<br>
-(To refresh the structure view, click on the <img src="smartmode_co.gif" alt="Button for updating view"> button of the drop-down list in the toolbar.)
-<br><br>
-<img src="Ordered_MyANT.gif" alt="Difference Tree using MyANT ID Mapping Scheme">
-<br><br>
-This is the compare result that we wanted and that we achieved by creating an Ordered Entry.
-<br>
-<br>
-Additionally, Id Mappings (see <a href="#id_mapping">previous section</a>) can be used to uniquely identify ordered children. Especially when there are many changes, this will improve compare results.
-<br>
-<br>
-The XML Compare Plugin already comes with a ID Mapping Scheme for ANT files, which can be customized for particular ANT files.
-<br><br>
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corporation and others 2000, 2003. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples.xml/doc-html/ui_xmlcompare_ex.html b/examples/org.eclipse.compare.examples.xml/doc-html/ui_xmlcompare_ex.html
deleted file mode 100644
index 4c9e1ad89..000000000
--- a/examples/org.eclipse.compare.examples.xml/doc-html/ui_xmlcompare_ex.html
+++ /dev/null
@@ -1,85 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>XML Compare Plugin</title>
-</head>
-<body link="#0000FF" vlink="#800080">
-
-<center><h1>Eclipse Platform XML Compare</h1></center>
-The XML Compare plugin allows you to perform a structural compare of two XML documents. It returns
-a difference tree which indicates which XML elements have been added or removed and - for modified XML elements -
-what differences there are with respect to attributes or body text.
-<h2>Installing the plugin</h2>
-<ul>
-<li>Copy the folder <tt>org.eclipse.compare.examples.xml</tt> to the <tt>plugins</tt> subfolder of Eclipse.
-</ul>
-<h2>Using the plugin</h2>
-The plugin is automatically used when comparing files with the extension .xml.
-<br>
-By default, the XML compare uses the <em>Unordered</em> compare method, which ignores the order in which the XML elements appear in the document and matches them so that elements which are most similar are matched.
-There is also an <em>Ordered</em> compare method, which simply compares the XML elements exactly in the order in which they appear in the document. In most cases, this compare method will not be of much use.
-<br>
-The compare method can be changed from a drop-down list in the toolbar of the structure view.
-<br>
-<br>
-When an XML document
-contains elements that can uniquely be identified by an attribute or the text of a child element,
-it is recommended that an ID Mapping Scheme be created for this type of XML document.
-<br>
-<br>
-See <a href="tutorial_and_examples.html">Tutorial and Examples</a> for more information on using the plugin.
-<br>
-<h3>ID Mapping Schemes</h3>
-An ID Mapping Scheme specifies for XML elements an attribute or the text of a child element that
-uniquely identifies this element. This assures that - in the compare process - the right elements will be
-matched and therefore compared with each other. If for an XML element no ID Mapping is specified, a general matching algorithm
-is be used. However, this general matching algorithm does not always return the desired result.
-The reason for this is that the general matching algorithm looks for a matching of the nodes of the two parsed trees
-to compare that minimizes the differences. The effect is that often two XML elements are matched with are
-structurally similar but represent two completely different entities of information.
-<br>
-<h3>Ordered entries</h3>
-When using the default Unordered compare (with or without id mappings) it is sometimes desired to specify that the children of certain elements be compared in ordered fashion intead of the usual unordered method.
-For example, when comparing ANT files the order of appearance of the children of <tt>target</tt> elements is important.
-<br>In such cases one can create an <i>Ordered entry</i>. An Ordered entry specifies that the direct children of an xml element, identified by its path, will be compared in ordered fashion (attributes however are still compared in unordered way).
-The children of these children will continue to be compared in unordered way, unless otherwise specified.
-<h3>Defining ID Mapping Schemes and Ordered entries</h3>
-ID Mapping Schemes can be created in three different ways:
-<ol>
-<li>By extending the extension point <a href="idMapping.html"><em>idMapping</em></a></li>
-<li>Using the <a href="PreferencePage.gif">XML Compare Preference page</a>.</li>
-<li>Using the <a href="CreateNewIDMapButton.gif">Create new Id Map Scheme button</a> in the toolbar and the <a href="IDMapContextMenu.gif">context menu</a>
-</ol>
-Method 1 creates a so-called <em>internal</em> mapping scheme. An internal ID Mapping Scheme
-cannot be edited at runtime. However, using the <a href="EditCopy.gif"><em>Edit Copy</em></a> button in the Preference Page, an editable copy of the
-internal ID Mapping Scheme can be created.
-<br>
-Methods 2 and 3 create so-called <em>user</em> mapping schemes. These are created by the user at runtime and
-can be modified anytime in the Preference Page.
-<p>Internal and user mapping schemes can be associated with a file extension. As a result, when comparing two XML files with this file extension, the particular ID Mapping scheme with this extension
-is automatically used.
-<br>
-<br>
-When creating or editing the ID mapping for a particular XML element, four items must be specified (see <a href="IDMap_NewMapping_PreferencePage.gif">example</a>):
-<ol>
-<li>The element name.</li>
-<li>The element path. This is the path of the element from the root of the XML document to the element's parent.</li>
-<li>The name of the id which will identify the element</li>
-<li>Whether the id name in point 3 is the name of an attribute of the element or the name of one of its children (in which case the text of this child element
-will be used as id).</li>
-</ol>
-<br>
-<hr WIDTH="100%">
-<h1>
-Extension Points</h1>
-Only one extension point is available in the XML Compare plugin. It is used to create
-internal ID Mapping Schemes:
-<ul>
-<li>
-<a href="idMapping.html">org.eclipse.compare.examples.xml.idMapping</a></li>
-</ul>
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corporation and others 2000, 2003. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/addidmap.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/addidmap.gif
deleted file mode 100644
index 62dad8be9..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/addidmap.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/attribute_obj.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/attribute_obj.gif
deleted file mode 100644
index 00bb7b475..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/attribute_obj.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_obj.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_obj.gif
deleted file mode 100644
index 01f488986..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_obj.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_ordered_obj.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_ordered_obj.gif
deleted file mode 100644
index e9adf7d94..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/element_ordered_obj.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/smartmode_co.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/smartmode_co.gif
deleted file mode 100644
index 542dddca3..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/smartmode_co.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/text_obj.gif b/examples/org.eclipse.compare.examples.xml/icons/full/obj16/text_obj.gif
deleted file mode 100644
index 2a2b4b6f4..000000000
--- a/examples/org.eclipse.compare.examples.xml/icons/full/obj16/text_obj.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples.xml/plugin.properties b/examples/org.eclipse.compare.examples.xml/plugin.properties
deleted file mode 100644
index 795569936..000000000
--- a/examples/org.eclipse.compare.examples.xml/plugin.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-#
-# Resource strings for XML Compare Examples plugin.xml file
-#
-pluginName= XML Compare Support
-providerName= Eclipse.org
-pluginNamePreferencePage= XML Compare
-idMapping= ID Mapping
-
-antMap=ANT
-eclipsePluginMap=Eclipse Plugin
-classpathMap=Eclipse ClassPath
diff --git a/examples/org.eclipse.compare.examples.xml/plugin.xml b/examples/org.eclipse.compare.examples.xml/plugin.xml
deleted file mode 100644
index 095fab4c3..000000000
--- a/examples/org.eclipse.compare.examples.xml/plugin.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.compare.examples.xml"
- name="%pluginName"
- version="3.1.0"
- provider-name="%providerName"
- class="org.eclipse.compare.examples.xml.XMLPlugin">
-
- <runtime>
- <library name="xmlcompareexamples.jar">
- <export name="*"/>
- </library>
- </runtime>
-
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.compare"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.junit"/>
- </requires>
-
-
- <extension-point id="idMapping" name="%idMapping" schema="schema/idMapping.exsd"/>
-
- <extension
- point="org.eclipse.compare.examples.xml.idMapping">
- <idmap
- name="%antMap"
- id="antMap">
- <mapping
- signature="project"
- id="name">
- </mapping>
- <mapping
- signature="project&gt;target"
- id="name">
- </mapping>
- <ordered
- signature="project&gt;target">
- </ordered>
- </idmap>
- <idmap
- name="%eclipsePluginMap"
- id="eclipsePluginMap">
- <mapping
- signature="plugin"
- id="id">
- </mapping>
- <mapping
- signature="plugin&gt;requires&gt;import"
- id="plugin">
- </mapping>
- <mapping
- signature="plugin&gt;runtime&gt;library"
- id="name">
- </mapping>
- <mapping
- signature="plugin&gt;runtime&gt;library&gt;export"
- id="name">
- </mapping>
- <mapping
- signature="plugin&gt;extension-point"
- id="id">
- </mapping>
- <mapping
- signature="plugin&gt;extension"
- id="point">
- </mapping>
- </idmap>
- <idmap
- name="%classpathMap"
- extension="CLASSPATH"
- id="classpathMap">
- <mapping
- signature="classpath&gt;classpathentry"
- id="path">
- </mapping>
- </idmap>
- </extension>
-
- <extension
- point="org.eclipse.compare.structureMergeViewers">
- <viewer
- extensions="xml,classpath"
- class="org.eclipse.compare.examples.xml.XMLStructureViewerCreator">
- </viewer>
- </extension>
-
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- name="%pluginNamePreferencePage"
- category="org.eclipse.ui.preferencePages.Workbench"
- class="org.eclipse.compare.examples.xml.XMLComparePreferencePage"
- id="org.eclipse.compare.examples.xml.XMLComparePreferencePage">
- </page>
- </extension>
-
-</plugin>
diff --git a/examples/org.eclipse.compare.examples.xml/schema/idMapping.exsd b/examples/org.eclipse.compare.examples.xml/schema/idMapping.exsd
deleted file mode 100644
index 9632e1602..000000000
--- a/examples/org.eclipse.compare.examples.xml/schema/idMapping.exsd
+++ /dev/null
@@ -1,210 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.compare.examples.xml">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.compare.examples.xml" id="idMapping" name="XML Id Mapping"/>
- </appInfo>
- <documentation>
- This extension point allows to define internal XML ID Mapping schemes using the &lt;i&gt;mapping&lt;/i&gt; element.
-These schemes can then be used when performing an XML compare to uniquely identify XML elements by the
-value of an attribute or the text in a child element.
-Additionally, &lt;i&gt;ordered&lt;/i&gt; elements can be used to specify that the direct children of an element
-should be compared in an ordered fashion instead of the default unordered way.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="idMap" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="idMap">
- <complexType>
- <sequence>
- <element ref="mapping"/>
- <element ref="ordered"/>
- </sequence>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- the name of the ID Mapping scheme. Should be unique.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="extension" type="string">
- <annotation>
- <documentation>
- a file extension associated with this ID Mapping Scheme.
-When comparing files with this extension, the current ID Mapping
-Scheme will automatically be used.
-If an extension is specified, then the extension should also be added
-in the plugin.xml file of the XML Compare Plugin. For example, if we
-create an ID Mapping Scheme with extension cd, the plugin.xml of the
-XML Compare Plugin is updated as follows (update shown in bold):
-&lt;p&gt;
-&lt;pre&gt;
-&lt;extension
-      point=&quot;org.eclipse.compare.structureMergeViewers&quot;&gt;
- &lt;structureMergeViewer
-         extensions=&quot;xml,classpath,cd&quot;
-         class=&quot;org.eclipse.compare.xml.XMLStructureViewerCreator&quot;
- /&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
-&lt;p&gt;
-Warning: If an extension is associated more than once, only the first
-association will be considered. Also, internal ID Mapping schemes have
-priority over user ID Mapping schemes when duplicate extensions are defined.
-&lt;/p&gt;
-&lt;p&gt;
-Warning: When an internal ID Mapping scheme with extension association is
-removed (from a plugin.xml ), the XML Compare plugin has to be reloaded
-to disassociate itself from the extension. If not, on the first compare
-of files with this extension, the XML Compare plugin will be used with
-the default Unordered algorithm. (However, at this point the extension
-will have been disassociated from the XML Plugin, as the plugin has been loaded.)
-&lt;/p&gt;
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="mapping">
- <complexType>
- <attribute name="signature" type="string" use="required">
- <annotation>
- <documentation>
- the XML path from the root to the current element (see examples below).
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- the attribute that identifies this element or the name of the child element whose text identifies this element.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id-source" type="string">
- <annotation>
- <documentation>
- if id is the name of a child element, then this attribute must have the value body.
-If id-source is left out, it is assumed that id is an attribute.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="ordered">
- <complexType>
- <attribute name="signature" type="string" use="required">
- <annotation>
- <documentation>
- the XML path from the root to the element whose direct children will be
-compared in ordered fashion instead of the default unordered way.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example ID Mappings Scheme for ANT files.
-&lt;i&gt;project&lt;/i&gt; elements are identified by an &lt;i&gt;attribute name&lt;/i&gt;. &lt;i&gt;target&lt;/i&gt; elements (which are children of &lt;i&gt;project&lt;/i&gt;) are also identified by an attribute &lt;i&gt;name&lt;/i&gt;. Also, the children of &lt;i&gt;target&lt;/i&gt; will be compared in the order in which they appear in the document.
-&lt;p&gt;
-&lt;pre&gt;
-&lt;extension point = &quot;org.eclipse.compare.examples.xml.idMapping&quot;&gt;
- &lt;idmap name=&quot;ANT&quot;&gt;
- &lt;mapping signature=&quot;project&quot; id=&quot;name&quot;/&gt;
- &lt;mapping signature=&quot;project&gt;target&quot; id=&quot;name&quot;/&gt;
- &lt;ordered signature=&quot;project&gt;target&quot;/&gt;
- &lt;idmap&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
-The following example illustrates a case where the text of a child element is used as the id:
-&lt;p&gt;
-&lt;pre&gt;
-&lt;extension point = &quot;org.eclipse.compare.examples.xml.idMapping&quot;&gt;
- &lt;idmap name=&quot;Book Catalog&quot; extension=&quot;book&quot;&gt;
- &lt;mapping signature=&quot;catalog&gt;book&quot; id=&quot;isbn&quot; id-source=&quot;body&quot;/&gt;
- &lt;idmap&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The XML Compare plugin defines an ID Mapping scheme for Eclipse &lt;samp&gt;plugin.xml&lt;/samp&gt; files, one for &lt;samp&gt;.classpath&lt;/samp&gt; files and one for Ant files.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- &lt;p&gt;
-&lt;a href=&quot;hglegal.htm&quot;&gt;
- &lt;img SRC=&quot;ngibmcpy.gif&quot; ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot; BORDER=0 height=14 width=324&gt;
-&lt;/a&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java
deleted file mode 100644
index ccf15a5b6..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import java.util.ArrayList;
-import java.util.Vector;
-
-import org.eclipse.compare.rangedifferencer.IRangeComparator;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.compare.rangedifferencer.RangeDifferencer;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AbstractMatching {
-
- protected static final int NO_ENTRY = -1;//value with which fDT elements are initialized
- protected static final String SIGN_ELEMENT= XMLStructureCreator.SIGN_ELEMENT;
- int[][] fDT;//Distance Table; 1st index from fNLeft, 2nd index from fNRight
- ArrayList[][] fDT_Matchings;//Mathing entries of children for a match. 1st index from fNLeft, 2nd index from fNRight
- Vector fNLeft;
- Vector fNRight;
- Vector fMatches;
-
- /* methods used for match */
-
- /* finds all the leaves of a tree and puts them in a vector */
- protected void findLeaves(XMLNode root, ArrayList leaves) {
- if (isLeaf(root)) {
- leaves.add(root);
- } else {
- Object[] children = root.getChildren();
- for (int i=0; i<children.length; i++)
- findLeaves((XMLNode) children[i], leaves);
- }
- }
-
- /* true if x is a leaf */
- protected boolean isLeaf(XMLNode x) {
- if (x == null) return true;
- return x.getChildren() == null || x.getChildren().length <= 0;
- }
-
- /* Numbers all nodes of tree. The number of x is its index in the vector numbering */
- protected void numberNodes(XMLNode root, Vector numbering) {
- if (root != null) {
- numbering.add(root);
- Object[] children = root.getChildren();
- if (children != null) {
- for (int i=0; i<children.length; i++)
- numberNodes((XMLNode) children[i], numbering);
- }
- }
- }
-
- /* counts # of nodes in tree including root */
- protected int countNodes(XMLNode root) {
- if (root == null) return 0;
- int count = 1;
- if (isLeaf(root)) return count;
- Object[] children = root.getChildren();
- for (int i=0; i<children.length; i++)
- count+=countNodes((XMLNode) children[i]);
- return count;
- }
-
- /* returns index of node x in fNLeft */
- protected int indexOfLN (XMLNode x) {
- int i= 0;
- while ((i<fNLeft.size()) && (fNLeft.elementAt(i) != x))
- i++;
- return i;
- }
-
- /* returns index of node y in fNRight */
- protected int indexOfRN (XMLNode y) {
- int j= 0;
- while ((j<fNRight.size()) && (fNRight.elementAt(j) != y))
- j++;
- return j;
- }
-
-/* for testing */
- public Vector getMatches() {
- return fMatches;
- }
-
- protected class XMLComparator implements IRangeComparator {
-
- private Object[] fXML_elements;
-
- public XMLComparator(Object[] xml_elements) {
- fXML_elements= xml_elements;
- }
-
- /*
- * @see IRangeComparator#getRangeCount()
- */
- public int getRangeCount() {
- return fXML_elements.length;
- }
-
- /*
- * @see IRangeComparator#rangesEqual(int, IRangeComparator, int)
- */
- public boolean rangesEqual(
- int thisIndex,
- IRangeComparator other_irc,
- int otherIndex) {
-
- if (other_irc instanceof XMLComparator) {
- XMLComparator other= (XMLComparator) other_irc;
- //return ((XMLNode)fXML_elements[thisIndex]).subtreeEquals(other.getXML_elements()[otherIndex]);
-
- //ordered compare of subtrees
- //boolean result= ((XMLNode)fXML_elements[thisIndex]).subtreeEquals(other.getXML_elements()[otherIndex]);
-
- //taking ids into account
- boolean sameId= false;
- XMLNode thisNode= (XMLNode)fXML_elements[thisIndex];
- XMLNode otherNode= (XMLNode)other.getXML_elements()[otherIndex];
- if ( thisNode.usesIDMAP() && otherNode.usesIDMAP() ) {
- if ( otherNode.getOrigId().equals(thisNode.getOrigId()) ) {
- sameId= true;
- }
- }
-
- //unordered compare of subtrees
- int distance= dist((XMLNode)other.getXML_elements()[otherIndex] , (XMLNode)fXML_elements[thisIndex]);
- return sameId || distance == 0;
- }
- return false;
- }
-
- /*
- * @see IRangeComparator#skipRangeComparison(int, int, IRangeComparator)
- */
- public boolean skipRangeComparison(
- int length,
- int maxLength,
- IRangeComparator other) {
- return false;
- }
-
- public Object[] getXML_elements() {
- return fXML_elements;
- }
-
- }
-
- /* represents a matching between a node in the Left tree and a node in the Right tree */
- class Match {
- public XMLNode fx;
- public XMLNode fy;
-
- Match(XMLNode x, XMLNode y) {
- fx = x;
- fy = y;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof Match) {
- Match m = (Match) obj;
- if (m != null)
- return fx == m.fx && fy == m.fy;
- }
- return false;
- }
- }
-
- protected int handleRangeDifferencer(Object[] xc_elements, Object[] yc_elements, ArrayList DTMatching, int distance) {
- RangeDifference[] differences= RangeDifferencer.findDifferences(new XMLComparator(xc_elements), new XMLComparator(yc_elements));
-
- int cur_pos_left= 0;
- int cur_pos_right= 0;
- for (int i= 0; i < differences.length; i++) {
- RangeDifference rd= differences[i];
- int equal_length= rd.leftStart();
- //handle elements before current range which are unchanged
- while (cur_pos_left < equal_length) {
- //assuming XMLComparator has already filled fDT and fDT_Matchings for subtrees
- //rooted at xc_elements[cur_pos_left] and yc_elements[cur_pos_right]
-// if ( fDT[indexOfLN( (XMLNode)xc_elements[cur_pos_left])][indexOfRN( (XMLNode)yc_elements[cur_pos_right])] != 0)
-// System.out.println("distance not 0");
-// distance += fDT[indexOfLN( (XMLNode)xc_elements[cur_pos_left])][indexOfRN( (XMLNode)yc_elements[cur_pos_right])];
- //DTMatching.addAll(fDT_Matchings[index_left][index_right]);
- DTMatching.add(new Match( (XMLNode)xc_elements[cur_pos_left], (XMLNode)yc_elements[cur_pos_right]));
- cur_pos_left++;
- cur_pos_right++;
- }
- //now handle RangeDifference rd[i]
- int smaller_length, greater_length;
- boolean leftGreater= rd.leftLength() > rd.rightLength();
- if (leftGreater) {
- smaller_length= rd.rightLength();
- greater_length= rd.leftLength();
- } else {
- smaller_length= rd.leftLength();
- greater_length= rd.rightLength();
- }
-
- //handle elements elements in range
- for (int j=0; j < smaller_length; j++) {
- distance += dist((XMLNode) xc_elements[cur_pos_left], (XMLNode) yc_elements[cur_pos_right]);
- DTMatching.add(new Match( (XMLNode)xc_elements[cur_pos_left], (XMLNode)yc_elements[cur_pos_right]));
- cur_pos_left++;
- cur_pos_right++;
- }
- //int cur_pos_greater= (leftGreater)?cur_pos_left:cur_pos_right;
- if (leftGreater) {
- for (int j=smaller_length; j < greater_length; j++) {
- distance += countNodes((XMLNode) xc_elements[cur_pos_left]);
- DTMatching.add(new Match( (XMLNode)xc_elements[cur_pos_left], null));
- cur_pos_left++;
- }
- } else {
- for (int j=smaller_length; j < greater_length; j++) {
- distance += countNodes((XMLNode) yc_elements[cur_pos_right]);
- DTMatching.add(new Match( null, (XMLNode)yc_elements[cur_pos_right]));
- cur_pos_right++;
- }
- }
-// for (int j=smaller_length; j < greater_length; j++) {
-// distance += countNodes((XMLNode) xc_elements[cur_pos_greater]);
-// cur_pos_greater++;
-// }
-// if (leftGreater)
-// cur_pos_left= cur_pos_greater;
-// else
-// cur_pos_right= cur_pos_greater;
- }
-
- for (int i= cur_pos_left; i < xc_elements.length; i++) {
- //distance += fDT[indexOfLN( (XMLNode)xc_elements[cur_pos_left])][indexOfRN( (XMLNode)yc_elements[cur_pos_right])];
- //DTMatching.addAll(fDT_Matchings[index_left][index_right]);
- DTMatching.add(new Match( (XMLNode)xc_elements[cur_pos_left], (XMLNode)yc_elements[cur_pos_right]));
- cur_pos_left++;
- cur_pos_right++;
- }
-
- return distance;
- }
-
- abstract public void match(XMLNode LeftTree, XMLNode RightTree, boolean rightTreeIsAncestor, IProgressMonitor monitor) throws InterruptedException;
-
- protected int dist(XMLNode x, XMLNode y) {
- //System.out.println("dist( "+x.getSignature()+" , "+y.getSignature()+")");
- int ret= NO_ENTRY;
-
- int index_x= indexOfLN(x);
- int index_y= indexOfRN(y);
- if (fDT[index_x][index_y] != NO_ENTRY) return fDT[index_x][index_y];
-
- if (isLeaf(x) && isLeaf(y)) {
- if (x.getXMLType() == XMLStructureCreator.TYPE_ELEMENT) {
- if ( x.getSignature().equals(y.getSignature()) ) {
- ret= 0;
- fDT[index_x][index_y] = ret;
- } else {
- ret= 2;
- fDT[index_x][index_y] = ret;
- }
- return ret;
- } else if (x.getXMLType() == XMLStructureCreator.TYPE_ATTRIBUTE || x.getXMLType() == XMLStructureCreator.TYPE_TEXT) {
- if ( x.getSignature().equals(y.getSignature()) ) {
- if (x.getValue().equals(y.getValue())) {
- ret= 0;
- fDT[index_x][index_y] = ret;
- } else {
- ret= 1;
- fDT[index_x][index_y] = ret;
- }
- } else {
- ret= 2;
- fDT[index_x][index_y] = ret;
- }
- return ret;
- }
- } else {//x or y are not leaves
- if ( !x.getSignature().equals(y.getSignature()) ) {
- ret= countNodes(x) + countNodes(y);
- fDT[index_x][index_y] = ret;
- return ret;
- }
- //x.getSignature().equals(y.getSignature())
- if (isLeaf(x)) {
- ret= countNodes(y)-1;
- fDT[index_x][index_y] = ret;
- return ret;
- }
- if (isLeaf(y)) {
- ret= countNodes(x)-1;
- fDT[index_x][index_y] = ret;
- return ret;
- }
- //both x and y have children
- return handleXandYnotLeaves(x,y);
- }
- return ret;
- }
-
- abstract int handleXandYnotLeaves(XMLNode x, XMLNode y);
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AttributesImpl.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AttributesImpl.java
deleted file mode 100644
index 8963a8fb0..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AttributesImpl.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import org.xml.sax.Attributes;
-
-/**
- * An Attributes implementation that can perform more operations
- * than the attribute list helper supplied with the standard SAX2
- * distribution.
- */
-public class AttributesImpl implements Attributes {
-
- /** Head node. */
- private ListNode fHead;
-
- /** Tail node. */
- private ListNode fTail;
-
- /** Length. */
- private int fLength;
-
-
- /* Returns the number of attributes. */
- public int getLength() {
- return fLength;
- }
-
- /* Returns the index of the specified attribute. */
- public int getIndex(String raw) {
- ListNode place= fHead;
- int index= 0;
- while (place != null) {
- if (place.raw.equals(raw)) {
- return index;
- }
- index++;
- place= place.next;
- }
- return -1;
- }
-
- /* Returns the index of the specified attribute. */
- public int getIndex(String uri, String local) {
- ListNode place= fHead;
- int index= 0;
- while (place != null) {
- if (place.uri.equals(uri) && place.local.equals(local)) {
- return index;
- }
- index++;
- place= place.next;
- }
- return -1;
- }
-
- /* Returns the attribute URI by index. */
- public String getURI(int index) {
-
- ListNode node= getListNodeAt(index);
- return node != null ? node.uri : null;
- }
-
- /* Returns the attribute local name by index. */
- public String getLocalName(int index) {
-
- ListNode node= getListNodeAt(index);
- return node != null ? node.local : null;
- }
-
- /* Returns the attribute raw name by index. */
- public String getQName(int index) {
-
- ListNode node= getListNodeAt(index);
- return node != null ? node.raw : null;
-
- }
-
- /* Returns the attribute type by index. */
- public String getType(int index) {
-
- ListNode node= getListNodeAt(index);
- return (node != null) ? node.type : null;
- }
-
- /* Returns the attribute type by uri and local. */
- public String getType(String uri, String local) {
-
- ListNode node= getListNode(uri, local);
- return (node != null) ? node.type : null;
-
- }
-
- /* Returns the attribute type by raw name. */
- public String getType(String raw) {
-
- ListNode node= getListNode(raw);
- return (node != null) ? node.type : null;
- }
-
- /* Returns the attribute value by index. */
- public String getValue(int index) {
-
- ListNode node= getListNodeAt(index);
- return (node != null) ? node.value : null;
- }
-
- /* Returns the attribute value by uri and local. */
- public String getValue(String uri, String local) {
-
- ListNode node= getListNode(uri, local);
- return (node != null) ? node.value : null;
- }
-
- /* Returns the attribute value by raw name. */
- public String getValue(String raw) {
-
- ListNode node= getListNode(raw);
- return (node != null) ? node.value : null;
- }
-
- /* Adds an attribute. */
- public void addAttribute(String raw, String type, String value) {
- addAttribute(null, null, raw, type, value);
- }
-
- /* Adds an attribute. */
- public void addAttribute(
- String uri,
- String local,
- String raw,
- String type,
- String value) {
-
- ListNode node= new ListNode(uri, local, raw, type, value);
- if (fLength == 0) {
- fHead= node;
- } else {
- fTail.next= node;
- }
- fTail= node;
- fLength++;
- }
-
- /* Inserts an attribute. */
- public void insertAttributeAt(
- int index,
- String raw,
- String type,
- String value) {
- insertAttributeAt(index, null, null, raw, type, value);
- }
-
- /* Inserts an attribute. */
- public void insertAttributeAt(
- int index,
- String uri,
- String local,
- String raw,
- String type,
- String value) {
-
- // if list is empty, add attribute
- if (fLength == 0 || index >= fLength) {
- addAttribute(uri, local, raw, type, value);
- return;
- }
-
- // insert at beginning of list
- ListNode node= new ListNode(uri, local, raw, type, value);
- if (index < 1) {
- node.next= fHead;
- fHead= node;
- } else {
- ListNode prev= getListNodeAt(index - 1);
- node.next= prev.next;
- prev.next= node;
- }
- fLength++;
- }
-
- /* Removes an attribute. */
- public void removeAttributeAt(int index) {
-
- if (fLength == 0)
- return;
-
- if (index == 0) {
- fHead= fHead.next;
- if (fHead == null) {
- fTail= null;
- }
- fLength--;
- } else {
- ListNode prev= getListNodeAt(index - 1);
- ListNode node= getListNodeAt(index);
- if (node != null) {
- prev.next= node.next;
- if (node == fTail) {
- fTail= prev;
- }
- fLength--;
- }
- }
- }
-
- /* Removes the specified attribute. */
- public void removeAttribute(String raw) {
- removeAttributeAt(getIndex(raw));
- }
-
- /* Removes the specified attribute. */
- public void removeAttribute(String uri, String local) {
- removeAttributeAt(getIndex(uri, local));
- }
-
- /* Returns the node at the specified index. */
- private ListNode getListNodeAt(int i) {
-
- for (ListNode place= fHead; place != null; place= place.next) {
- if (--i == -1) {
- return place;
- }
- }
- return null;
- }
-
- /* Returns the first node with the specified uri and local. */
- public ListNode getListNode(String uri, String local) {
-
- if (uri != null && local != null) {
- ListNode place= fHead;
- while (place != null) {
- if (place.uri != null
- && place.local != null
- && place.uri.equals(uri)
- && place.local.equals(local)) {
- return place;
- }
- place= place.next;
- }
- }
- return null;
- }
-
- /* Returns the first node with the specified raw name. */
- private ListNode getListNode(String raw) {
-
- if (raw != null) {
- for (ListNode place= fHead; place != null; place= place.next) {
- if (place.raw != null && place.raw.equals(raw)) {
- return place;
- }
- }
- }
-
- return null;
- }
-
- /* Returns a string representation of this object. */
- public String toString() {
- StringBuffer str= new StringBuffer();
-
- str.append('[');
- str.append("len="); //$NON-NLS-1$
- str.append(fLength);
- str.append(", {"); //$NON-NLS-1$
- for (ListNode place= fHead; place != null; place= place.next) {
- str.append(place.toString());
- if (place.next != null) {
- str.append(", "); //$NON-NLS-1$
- }
- }
- str.append("}]"); //$NON-NLS-1$
-
- return str.toString();
- }
-
- /*
- * An attribute node.
- */
- static class ListNode {
-
- /** Attribute uri. */
- public String uri;
-
- /** Attribute local. */
- public String local;
-
- /** Attribute raw. */
- public String raw;
-
- /** Attribute type. */
- public String type;
-
- /** Attribute value. */
- public String value;
-
- /** Next node. */
- public ListNode next;
-
- /* Constructs a list node. */
- public ListNode(
- String uri0,
- String local0,
- String raw0,
- String type0,
- String value0) {
-
- this.uri= uri0;
- this.local= local0;
- this.raw= raw0;
- this.type= type0;
- this.value= value0;
-
- }
-
- /* Returns string representation of this object. */
- public String toString() {
- return raw != null ? raw : local;
- }
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java
deleted file mode 100644
index edcbcb104..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import java.util.*;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.jface.action.*;
-
-
-/**
- * Drop down menu to select a particular id mapping scheme
- */
-class ChooseMatcherDropDownAction extends Action implements IMenuCreator {
-
- private XMLStructureViewer fViewer;
-
- public ChooseMatcherDropDownAction(XMLStructureViewer viewer) {
- fViewer = viewer;
- setText(XMLCompareMessages.getString("ChooseMatcherDropDownAction.text")); //$NON-NLS-1$
- setImageDescriptor(XMLPlugin.getDefault().getImageDescriptor("obj16/smartmode_co.gif")); //$NON-NLS-1$
- setToolTipText(XMLCompareMessages.getString("ChooseMatcherDropDownAction.tooltip")); //$NON-NLS-1$
- setMenuCreator(this);
- }
-
- public void dispose() {
- // nothing to do
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- XMLPlugin plugin= XMLPlugin.getDefault();
- Menu menu= new Menu(parent);
- addActionToMenu(menu, new SelectMatcherAction(XMLStructureCreator.USE_UNORDERED, fViewer));
- addActionToMenu(menu, new SelectMatcherAction(XMLStructureCreator.USE_ORDERED, fViewer));
- new MenuItem(menu, SWT.SEPARATOR);
- HashMap IdMaps = plugin.getIdMaps();
- HashMap IdMapsInternal = plugin.getIdMapsInternal();
-
- Set keySetIdMaps = IdMaps.keySet();
- Set keySetIdMapsInternal = IdMapsInternal.keySet();
- ArrayList internalIdMapsAL= new ArrayList();
- for (Iterator iter_internal = keySetIdMapsInternal.iterator(); iter_internal.hasNext(); ) {
- String idmap_name = (String)iter_internal.next();
- internalIdMapsAL.add(idmap_name);
- }
- Object[] internalIdMapsA= internalIdMapsAL.toArray();
- Arrays.sort(internalIdMapsA);
- for (int i= 0; i < internalIdMapsA.length; i++) {
- addActionToMenu(menu, new SelectMatcherAction((String)internalIdMapsA[i], fViewer));
- }
- new MenuItem(menu, SWT.SEPARATOR);
-
- ArrayList userIdMapsAL= new ArrayList();
- for (Iterator iter_idmaps = keySetIdMaps.iterator(); iter_idmaps.hasNext(); ) {
- String idmap_name = (String)iter_idmaps.next();
- userIdMapsAL.add(idmap_name);
- }
-
- HashMap OrderedElements= plugin.getOrderedElements();
- Set keySetOrdered= OrderedElements.keySet();
- for (Iterator iter_orderedElements= keySetOrdered.iterator(); iter_orderedElements.hasNext();) {
- String idmap_name= (String) iter_orderedElements.next();
- if (!keySetIdMaps.contains(idmap_name)) {
- userIdMapsAL.add(idmap_name);
- }
- }
-
- Object[] userIdMapsA= userIdMapsAL.toArray();
- Arrays.sort(userIdMapsA);
- for (int i= 0; i < userIdMapsA.length; i++) {
- addActionToMenu(menu, new SelectMatcherAction((String)userIdMapsA[i], fViewer));
- }
-
- return menu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- fViewer.contentChanged();
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/CreateNewIdMapAction.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/CreateNewIdMapAction.java
deleted file mode 100644
index 34a4a3daa..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/CreateNewIdMapAction.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.compare.examples.xml;
-
-import java.util.*;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.window.Window;
-
-/**
- * Button to create a new id mapping scheme
- */
-public class CreateNewIdMapAction extends Action {
-
- private HashMap fIdMaps;// HashMap ( idname -> HashMap (signature -> id) )
- private HashMap fIdMapsInternal;
- private HashMap fIdExtensionToName;
-
- public CreateNewIdMapAction(XMLStructureViewer viewer) {
- setImageDescriptor(XMLPlugin.getDefault().getImageDescriptor("obj16/addidmap.gif")); //$NON-NLS-1$
- setToolTipText(XMLCompareMessages.getString("XMLStructureViewer.newtask")); //$NON-NLS-1$
- }
-
- public void run() {
- XMLPlugin plugin= XMLPlugin.getDefault();
- fIdMapsInternal= plugin.getIdMapsInternal();//fIdMapsInternal is only read, not modified
-
- fIdMaps = new HashMap();
- HashMap PluginIdMaps = plugin.getIdMaps();
- Set keySet = PluginIdMaps.keySet();
- for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
- fIdMaps.put(key, ((HashMap)PluginIdMaps.get(key)).clone());
- }
-
- fIdExtensionToName= new HashMap();
- HashMap PluginIdExtensionToName= plugin.getIdExtensionToName();
- keySet= PluginIdExtensionToName.keySet();
- for (Iterator iter= keySet.iterator(); iter.hasNext(); ) {
- String key= (String) iter.next();
- fIdExtensionToName.put(key, PluginIdExtensionToName.get(key));
- }
-
- IdMap idmap = new IdMap(false);
- XMLCompareAddIdMapDialog dialog= new XMLCompareAddIdMapDialog(XMLPlugin.getActiveWorkbenchShell(),idmap,fIdMaps,fIdMapsInternal,fIdExtensionToName,false);
- if (dialog.open() == Window.OK) {
- if (!fIdMaps.containsKey(idmap.getName())) {
- fIdMaps.put(idmap.getName(),new HashMap());
- if (!idmap.getExtension().equals("")) //$NON-NLS-1$
- fIdExtensionToName.put(idmap.getExtension(),idmap.getName());
- XMLPlugin.getDefault().setIdMaps(fIdMaps,fIdExtensionToName,null,false);
- }
- }
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/IdMap.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/IdMap.java
deleted file mode 100644
index a2292131f..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/IdMap.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.examples.xml;
-
-import java.util.ArrayList;
-import java.util.Vector;
-
-/** This class is used to represent a id mapping scheme in the XML Compare preference page
- */
-public class IdMap {
-
- private String fName;
- private boolean fInternal;
- private Vector fMappings;
- private String fExtension;
- private ArrayList fOrdered;//contains Mapping elements for list of ordered entries (the children of these elements will be compared in ordered fashion)
-
- /**
- * Creates an IdMap which represents an Id Mapping Scheme
- * @param internal true if the IdMap is internal
- */
- public IdMap(boolean internal) {
- this("", internal); //$NON-NLS-1$
- }
-
- /**
- * Creates an IdMap which represents an Id Mapping Scheme
- * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps
- * @param internal true if the IdMap is internal
- */
- public IdMap(String name, boolean internal) {
- this(name, internal, new Vector());
- }
-
- /**
- * Creates an IdMap which represents an Id Mapping Scheme
- * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps
- * @param internal true if the IdMap is internal
- * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme
- */
- public IdMap(String name, boolean internal, Vector mappings) {
- this(name, internal, mappings, ""); //$NON-NLS-1$
- }
-
- /**
- * Creates an IdMap which represents an Id Mapping Scheme.
- * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps.
- * @param internal true if the IdMap is internal.
- * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme.
- * @param extension Optional extension to be associated with this id mapping scheme.
- */
- public IdMap(String name, boolean internal, Vector mappings, String extension) {
- this(name, internal, mappings, extension, null);
- }
-
- /**
- * Creates an IdMap which represents an Id Mapping Scheme.
- * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps.
- * @param internal true if the IdMap is internal.
- * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme.
- * @param extension Optional extension to be associated with this id mapping scheme.
- * @param ordered Optional ArrayList of Mapping elements representing ordered entries.
- */
- public IdMap(String name, boolean internal, Vector mappings, String extension, ArrayList ordered) {
- fName = name;
- fInternal = internal;
- fMappings = mappings;
- fExtension= extension.toLowerCase();
- fOrdered= ordered;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
- if (!(object instanceof IdMap))
- return false;
-
- IdMap idmap= (IdMap) object;
-
- if (idmap == this)
- return true;
-
- return
- idmap.getName().equals(fName) &&
- idmap.getMappings().equals(fMappings);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return fName.hashCode() ^ fMappings.hashCode();
- }
-
- public void setName(String name) {
- fName = name;
- }
-
- public String getName() {
- return fName;
- }
-
- public void setMappings(Vector mappings) {
- fMappings = mappings;
- }
-
- public Vector getMappings() {
- return fMappings;
- }
-
- public void setInternal(boolean bool) {
- fInternal = bool;
- }
-
- public boolean isInternal() {
- return fInternal;
- }
-
- public void setExtension(String extension) {
- fExtension= extension;
- }
-
- public String getExtension() {
- return fExtension;
- }
- public void setOrdered(ArrayList ordered) {
- fOrdered= ordered;
- }
- public ArrayList getOrdered() {
- return fOrdered;
- }
-
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java
deleted file mode 100644
index 7bf6be61c..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.examples.xml;
-
-/**
- * This class is used to represent a particular id mapping or ordered entry in the XML Compare preference page
- */
-public class Mapping {
-
- private String fElement;
- private String fSignature;
- private String fIdAttribute;
-
- public Mapping() {
- this("", "", ""); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- }
-
- public Mapping(String element, String signature) {
- this(element, signature, ""); //$NON-NLS-1$
- }
-
- public Mapping(String element, String signature, String idattribute) {
- fElement = element;
- fSignature = signature;
- fIdAttribute = idattribute;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
- if (!(object instanceof Mapping))
- return false;
-
- Mapping mapping= (Mapping) object;
-
- if (mapping == this)
- return true;
-
- return
- mapping.fElement.equals(fElement) &&
- mapping.fSignature.equals(fSignature) &&
- mapping.fIdAttribute.equals(fIdAttribute);
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return fElement.hashCode() ^ fSignature.hashCode();
- }
-
- public void setElement(String element) {
- fElement = element;
- }
- public String getElement() {
- return fElement;
- }
-
- public void setSignature(String signature) {
- fSignature = signature;
- }
- public String getSignature() {
- return fSignature;
- }
-
- public void setIdAttribute(String idattribute) {
- fIdAttribute = idattribute;
- }
- public String getIdAttribute() {
- return fIdAttribute;
- }
-
- public String getKey() {
- return getKey(fSignature, fElement);
- }
-
- public static String getKey(String signature, String element) {
- if (signature == "") //$NON-NLS-1$
- return XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + element + XMLStructureCreator.SIGN_SEPARATOR;
- return XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + signature + XMLStructureCreator.SIGN_SEPARATOR + element + XMLStructureCreator.SIGN_SEPARATOR;
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java
deleted file mode 100644
index ddcfc3ea4..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.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.compare.examples.xml;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class OrderedMatching extends AbstractMatching {
-
- public OrderedMatching() {
- super();
- }
-
- protected int orderedMath(XMLNode x, XMLNode y) {
- //assumes x and y have children
- Object[] xc= x.getChildren();
- Object[] yc= y.getChildren();
-
- ArrayList xc_elementsAL= new ArrayList();
- ArrayList xc_attrsAL= new ArrayList();
-
- ArrayList yc_elementsAL= new ArrayList();
- ArrayList yc_attrsAL= new ArrayList();
-
- //find attributes and elements and put them in xc_elementsAL and xc_attrsAL, respectively
- for (int i= 0; i < xc.length; i++) {
- XMLNode x_i= (XMLNode) xc[i];
- if (x_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) {
- xc_elementsAL.add(x_i);
- } else if (
- x_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
- xc_attrsAL.add(x_i);
- }
- }
-
- //do the same for yc
- for (int i= 0; i < yc.length; i++) {
- XMLNode y_i= (XMLNode) yc[i];
- if (y_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) {
- yc_elementsAL.add(y_i);
- } else if (
- y_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
- yc_attrsAL.add(y_i);
- }
- }
-
- Object[] xc_elements= xc_elementsAL.toArray();
- Object[] yc_elements= yc_elementsAL.toArray();
-
- ArrayList DTMatching= new ArrayList();
- // Matching to be added to Entry in fDT_Matchings
- int distance= 0; //distance to be added to entry in fDT
-
- // perform unordered matching on attributes
- // this updates fDT and fDT_Matchings
- if (xc_attrsAL.size() > 0 || yc_attrsAL.size() > 0) {
- if (xc_attrsAL.size() == 0)
- distance += yc_attrsAL.size();
- else if (yc_attrsAL.size() == 0)
- distance += xc_attrsAL.size();
- else {
- //unorderedMatch(x, y, xc_attrs, yc_attrs);
- // distance += fDT[indexOfLN(x)][indexOfRN(y)];
- // DTMatching= fDT_Matchings[indexOfLN(x)][indexOfRN(y)];
- distance= handleAttributes(xc_attrsAL, yc_attrsAL, DTMatching);
- }
- }
-
- //perform ordered matching on element children, i.e. number them in order of appearance
-
- /* start new */
- distance=
- handleRangeDifferencer(
- xc_elements,
- yc_elements,
- DTMatching,
- distance);
- /* end new */
-
- /* start: Naive ordered compare /*
- // int minlength= (xc_elements.length > yc_elements.length)?yc_elements.length:xc_elements.length;
- // for (int i= 0; i < minlength; i++) {
- // distance += dist((XMLNode) xc_elements[i], (XMLNode) yc_elements[i]);
- // DTMatching.add(new Match( (XMLNode)xc_elements[i], (XMLNode)yc_elements[i]));
- // }
- // if (xc_elements.length > yc_elements.length) {
- // for (int i= minlength; i < xc_elements.length; i++) {
- // distance += countNodes((XMLNode) xc_elements[i]);
- // }
- // } else if (xc_elements.length < yc_elements.length) {
- // for (int i= minlength; i < yc_elements.length; i++) {
- // distance += countNodes((XMLNode) yc_elements[i]);
- // }
- // }
- /* end: Naive ordered compare */
-
- fDT[indexOfLN(x)][indexOfRN(y)]= distance;
- fDT_Matchings[indexOfLN(x)][indexOfRN(y)]= DTMatching;
- return distance;
-
- }
-
- /* matches two trees according to paper "X-Diff", p. 16 */
- public void match(
- XMLNode LeftTree,
- XMLNode RightTree,
- boolean rightTreeIsAncestor,
- IProgressMonitor monitor)
- throws InterruptedException {
-
- fNLeft= new Vector();
- //numbering LeftTree: Mapping nodes in LeftTree to numbers to be used as array indexes
- fNRight= new Vector();
- //numbering RightTree: Mapping nodes in RightTree to numbers to be used as array indexes
- numberNodes(LeftTree, fNLeft);
- numberNodes(RightTree, fNRight);
- fDT= new int[fNLeft.size()][fNRight.size()];
- fDT_Matchings= new ArrayList[fNLeft.size()][fNRight.size()];
- for (int i= 0; i < fDT.length; i++) {
- fDT[i]= new int[fNRight.size()];
- for (int j= 0; j < fDT[0].length; j++) {
- fDT[i][j]= NO_ENTRY;
- }
- }
-
- dist(LeftTree, RightTree);
- // /* mark matchings on LeftTree and RightTree */
- fMatches= new Vector();
- if (!LeftTree.getSignature().equals(RightTree.getSignature())) {
- //matching is empty
- } else {
- fMatches.add(new Match(LeftTree, RightTree));
- for (int i_M= 0; i_M < fMatches.size(); i_M++) {
- Match m= (Match) fMatches.elementAt(i_M);
- if (!isLeaf(m.fx) && !isLeaf(m.fy)) {
- // if (fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ] == null)
- // System.out.println("Error: ID not unique for " + m.fx.getId());
- // else
- // fMatches.addAll(fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ]);
- if (fDT_Matchings[indexOfLN(m.fx)][indexOfRN(m.fy)]
- != null)
- fMatches.addAll(
- fDT_Matchings[indexOfLN(m.fx)][indexOfRN(m.fy)]);
- }
- }
- }
- //end of Step2
- /* Renumber Id of Nodes to follow Matches. Or for ancestor, copy over Id to ancestor */
- if (rightTreeIsAncestor) {
- for (ListIterator it_M= fMatches.listIterator(); it_M.hasNext();) {
- Match m= (Match) it_M.next();
- if (m.fx != null && m.fy != null)
- m.fy.setId(m.fx.getId());
- }
- } else {
- int newId= 0;
- for (ListIterator it_M= fMatches.listIterator();
- it_M.hasNext();
- newId++) {
- Match m= (Match) it_M.next();
- if (m.fx != null)
- m.fx.setId(Integer.toString(newId));
- if (m.fy != null)
- m.fy.setId(Integer.toString(newId));
- // System.out.println("Matching: "+ ((m.fx != null)?m.fx.getOrigId():"null")+" -> "+((m.fx != null)?m.fx.getId():"null")+" , "+((m.fy != null)?m.fy.getOrigId():"null")+" -> "+((m.fy != null)?m.fy.getId():"null")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- }
- //if (monitor != null) monitor.done();
- }
-
- public int handleAttributes(
- ArrayList xc_attrs,
- ArrayList yc_attrs,
- ArrayList DTMatching) {
- int distance= 0;
- x_for : for (
- Iterator iter_xc= xc_attrs.iterator(); iter_xc.hasNext();) {
- XMLNode x_attr= (XMLNode) iter_xc.next();
- String x_attr_name= x_attr.getName();
- for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext();) {
- XMLNode y_attr= (XMLNode) iter_yc.next();
- if (y_attr.getName().equals(x_attr_name)) {
- if (!y_attr.getValue().equals(x_attr.getValue()))
- distance += 1;
- DTMatching.add(new Match(x_attr, y_attr));
- yc_attrs.remove(y_attr);
- continue x_for;
- }
- }
- DTMatching.add(new Match(x_attr, null));
- distance += 1;
- }
-
- for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext();) {
- DTMatching.add(new Match(null, (XMLNode) iter_yc.next()));
- distance += 1;
- }
-
- return distance;
- }
-
- protected int handleXandYnotLeaves(XMLNode x, XMLNode y) {
- /* handle entries as ordered*/
- return orderedMath(x, y);
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SWTUtil.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SWTUtil.java
deleted file mode 100644
index b5c425d2f..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SWTUtil.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.compare.examples.xml;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Caret;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.util.Assert;
-
-/**
- * Utility class to simplify access to some SWT resources.
- */
-public class SWTUtil {
-
- /*
- * Returns the standard display to be used. The method first checks, if
- * the thread calling this method has an associated disaply. If so, this
- * display is returned. Otherwise the method returns the default display.
- */
- public static Display getStandardDisplay() {
- Display display;
- display= Display.getCurrent();
- if (display == null)
- display= Display.getDefault();
- return display;
- }
-
- /*
- * Returns the shell for the given widget. If the widget doesn't represent
- * a SWT object that manage a shell, <code>null</code> is returned.
- *
- * @return the shell for the given widget
- */
- public static Shell getShell(Widget widget) {
- if (widget instanceof Control)
- return ((Control)widget).getShell();
- if (widget instanceof Caret)
- return ((Caret)widget).getParent().getShell();
- if (widget instanceof DragSource)
- return ((DragSource)widget).getControl().getShell();
- if (widget instanceof DropTarget)
- return ((DropTarget)widget).getControl().getShell();
- if (widget instanceof Menu)
- return ((Menu)widget).getParent().getShell();
- if (widget instanceof ScrollBar)
- return ((ScrollBar)widget).getParent().getShell();
- return null;
- }
-
- private static double getVerticalDialogUnitSize(Control control) {
- GC gc= new GC(control);
- try {
- int height = gc.getFontMetrics().getHeight();
- return height * 0.125;
- } finally {
- gc.dispose();
- }
- }
-
- private static double getHorizontalDialogUnitSize(Control control) {
- GC gc= new GC(control);
- try {
- int averageWidth= gc.getFontMetrics().getAverageCharWidth();
- return averageWidth * 0.25;
- } finally {
- gc.dispose();
- }
- }
-
- /*
- * @see DialogPage#convertHeightInCharsToPixels
- */
- public static int convertHeightInCharsToPixels(int chars, Control control) {
- return convertVerticalDLUsToPixels(chars * 8, control);
- }
-
- /*
- * @see DialogPage#convertHorizontalDLUsToPixels
- */
- public static int convertHorizontalDLUsToPixels(int dlus, Control control) {
- return (int)Math.round(dlus * getHorizontalDialogUnitSize(control));
- }
-
- /*
- * @see DialogPage#convertVerticalDLUsToPixels
- */
- public static int convertVerticalDLUsToPixels(int dlus, Control control) {
- return (int)Math.round(dlus * getVerticalDialogUnitSize(control));
- }
-
- /*
- * @see DialogPage#convertWidthInCharsToPixels
- */
- public static int convertWidthInCharsToPixels(int chars, Control control) {
- return convertHorizontalDLUsToPixels(chars * 4, control);
- }
-
- /*
- * Returns a width hint for a button control.
- */
- public static int getButtonWidthHint(Button button) {
- int widthHint= convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH, button);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- }
-
- /*
- * Returns a height hint for a button control.
- */
-// public static int getButtonHeigthHint(Button button) {
-// return convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT, button);
-// }
-
- /*
- * Sets width and height hint for the button control.
- * <b>Note:</b> This is a NOP if the button's layout data is not
- * an instance of <code>GridData</code>.
- *
- * @param the button for which to set the dimension hint
- */
- public static void setButtonDimensionHint(Button button) {
- Assert.isNotNull(button);
- Object gd= button.getLayoutData();
- if (gd instanceof GridData) {
- //((GridData)gd).heightHint= getButtonHeigthHint(button);
- ((GridData)gd).widthHint= getButtonWidthHint(button);
- }
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java
deleted file mode 100644
index 79c03772f..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.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.examples.xml;
-
-import org.eclipse.jface.action.Action;
-
-class SelectMatcherAction extends Action {
-
- private XMLStructureViewer fViewer;
- private String fDesc;
-
- public SelectMatcherAction(String desc, XMLStructureViewer viewer) {
- fViewer= viewer;
- fDesc= desc;
- setText(fDesc);
- setToolTipText(fDesc);
- }
-
- public void run() {
- ((XMLStructureCreator) fViewer.getStructureCreator()).setIdMap(fDesc);
- fViewer.contentChanged();
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java
deleted file mode 100644
index 2c50c97fe..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.examples.xml;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.IDocument;
-
-/** XMLNode that has children elements */
-public class XMLChildren extends XMLNode {
-
- public int children; // counts the number of children
- public HashMap childElements; // maps the name of XML child elements to their # of occurence
-
- public XMLChildren(String XMLType, String id, String value, String signature, IDocument doc, int start, int length) {
- super(XMLType, id, value, signature, doc, start, length);
- children= 0;
- childElements = new HashMap();
- }
-}
-
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java
deleted file mode 100644
index 5f17aeb43..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.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.compare.examples.xml;
-
-import java.text.MessageFormat;
-import java.util.*;
-
-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.*;
-
-import org.eclipse.compare.examples.xml.ui.StatusDialog;
-import org.eclipse.compare.examples.xml.ui.StatusInfo;
-
-/**
- * This class is used to add or edit an ID Mapping Scheme
- */
-public class XMLCompareAddIdMapDialog extends StatusDialog {
-
- private IdMap fIdMap;
- private HashMap fIdMaps;
- private HashMap fIdMapsInternal;
- private HashMap fIdExtensionToName;
- private boolean fEdit;
-
- private Text fIdMapText;
- private Text fIdMapExtText;
-
- public XMLCompareAddIdMapDialog(Shell parent, IdMap idmap, HashMap idmaps, HashMap idmapsInternal, HashMap idextensiontoname, boolean edit) {
- super(parent);
-
- fEdit= edit;
- if (fEdit)
- setTitle(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.editTitle")); //$NON-NLS-1$
- else
- setTitle(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.newTitle")); //$NON-NLS-1$
-
- fIdMap= idmap;
- fIdMaps= idmaps;
- fIdMapsInternal= idmapsInternal;
- fIdExtensionToName= idextensiontoname;
- }
-
- /**
- * Creates and returns the contents of the upper part
- * of the dialog (above the button bar).
- *
- * Subclasses should override.
- *
- * @param ancestor the parent composite to contain the dialog area
- * @return the dialog area control
- */
- protected Control createDialogArea(Composite ancestor) {
- Composite composite= (Composite) super.createDialogArea(ancestor);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- inner.setLayout(layout);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.label")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fIdMapText= new Text(inner, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = convertWidthInCharsToPixels(30);
- fIdMapText.setLayoutData(data);
- fIdMapText.setText(fIdMap.getName());
- fIdMapText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.extlabel")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fIdMapExtText= new Text(inner, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = convertWidthInCharsToPixels(30);
- fIdMapExtText.setLayoutData(data);
- fIdMapExtText.setText(fIdMap.getExtension());
- fIdMapExtText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
-
- fIdMapText.setFocus();
-
- return composite;
- }
-
- /**
- * Validate user input
- */
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fIdMapText.getText();
- if (newText.length() == 0)
- status.setError(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.error.noname")); //$NON-NLS-1$
- else if (XMLComparePreferencePage.containsInvalidCharacters(newText))
- status.setError(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.error.invalidname")); //$NON-NLS-1$
- else if ( (!fEdit && (fIdMaps.containsKey(newText) || fIdMapsInternal.containsKey(newText)) )
- || (fEdit && !newText.equals(fIdMap.getName()) && (fIdMaps.containsKey(newText) || fIdMapsInternal.containsKey(newText)) )
- )
- status.setError(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.error.idmapExists")); //$NON-NLS-1$
- newText= fIdMapExtText.getText().toLowerCase();
- if (newText.length() > 0) {
- if (newText.indexOf(".") > -1) //$NON-NLS-1$
- status.setError(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.error.extfullstop")); //$NON-NLS-1$
- else if (fIdExtensionToName.containsKey(newText) && !fIdExtensionToName.get(newText).equals(fIdMap.getName()))
- status.setError(MessageFormat.format("{0} {1}",new String[] {XMLCompareMessages.getString("XMLCompareAddIdMapDialog.error.extExists"),(String)fIdExtensionToName.get(newText)})); //$NON-NLS-2$ //$NON-NLS-1$
- }
- updateStatus(status);
- }
-
- /**
- * Notifies that the ok button of this dialog has been pressed.
- */
- protected void okPressed() {
- fIdMap.setName(fIdMapText.getText());
- fIdMap.setExtension(fIdMapExtText.getText().toLowerCase());
- super.okPressed();
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java
deleted file mode 100644
index 5e31919ec..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.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.compare.examples.xml;
-
-import java.util.HashMap;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.compare.examples.xml.ui.StatusDialog;
-import org.eclipse.compare.examples.xml.ui.StatusInfo;
-
-/**
- * This class is used to create an editable ID Mapping Scheme from an internal ID Mappping Scheme
- */
-public class XMLCompareEditCopyIdMapDialog extends StatusDialog {
-
- private HashMap fIdMaps;
- private HashMap fIdMapsInternal;
-
- private Text fIdMapText;
- private String fResult;
-
- /*
- * Constructs a new edit copy mapping dialog.
- */
- public XMLCompareEditCopyIdMapDialog(Shell parent, IdMap idmap, HashMap idmaps, HashMap idmapsInternal) {
- super(parent);
-
- setTitle(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.title")); //$NON-NLS-1$
-
- fIdMaps= idmaps;
- fIdMapsInternal= idmapsInternal;
- }
-
- public String getResult() {
- return fResult;
- }
-
- /**
- * Creates and returns the contents of the upper part
- * of the dialog (above the button bar).
- *
- * Subclasses should override.
- *
- * @param ancestor the parent composite to contain the dialog area
- * @return the dialog area control
- */
- protected Control createDialogArea(Composite ancestor) {
- Composite composite= (Composite) super.createDialogArea(ancestor);
-
- Label comment= new Label(composite, SWT.NONE);
- comment.setText(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.comment")); //$NON-NLS-1$
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.verticalAlignment= GridData.BEGINNING;
- comment.setLayoutData(data);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- inner.setLayout(layout);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.label")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fIdMapText= new Text(inner, SWT.BORDER);
- fIdMapText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fIdMapText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- fIdMapText.setFocus();
-
- return composite;
- }
-
- /**
- * Validate user input
- */
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newText= fIdMapText.getText();
- if (newText.length() == 0)
- status.setError(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.error.noname")); //$NON-NLS-1$
- else if (XMLComparePreferencePage.containsInvalidCharacters(newText))
- status.setError(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.error.invalidname")); //$NON-NLS-1$
- else if (fIdMaps.containsKey(newText) || fIdMapsInternal.containsKey(newText))
- status.setError(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.error.nameExists")); //$NON-NLS-1$
- updateStatus(status);
- }
-
- /**
- * Notifies that the ok button of this dialog has been pressed.
- */
- protected void okPressed() {
- fResult= fIdMapText.getText();
- super.okPressed();
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java
deleted file mode 100644
index 434d47182..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.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.examples.xml;
-
-import java.util.HashMap;
-
-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.compare.examples.xml.ui.StatusDialog;
-import org.eclipse.compare.examples.xml.ui.StatusInfo;
-
-/**
- * This class is used to add or edit a particular ID Mapping
- */
-public class XMLCompareEditMappingDialog extends StatusDialog {
-
- private Mapping fMapping;
- private HashMap fIdmapHM;
- private boolean fEdit;
-
- private Text fElementText;
- private Text fSignatureText;
- private Text fIdAttributeText;
-
- private Button fIdTypeAttributeButton;
- private Button fIdTypeChildBodyButton;
-
- /*
- * Constructs a new edit mapping dialog.
- */
- public XMLCompareEditMappingDialog(Shell parent, Mapping mapping, HashMap idmapHM, boolean edit) {
- super(parent);
-
- int shellStyle= getShellStyle();
- setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
-
-
- fEdit= edit;
- if (fEdit)
- setTitle(XMLCompareMessages.getString("XMLCompareEditMappingDialog.editTitle")); //$NON-NLS-1$
- else
- setTitle(XMLCompareMessages.getString("XMLCompareEditMappingDialog.newTitle")); //$NON-NLS-1$
-
- fMapping= mapping;
- fIdmapHM= idmapHM;
- }
-
- /**
- * Creates and returns the contents of the upper part
- * of the dialog (above the button bar).
- *
- * Subclasses should override.
- *
- * @param ancestor the parent composite to contain the dialog area
- * @return the dialog area control
- */
- protected Control createDialogArea(Composite ancestor) {
- Composite composite= (Composite) super.createDialogArea(ancestor);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- inner.setLayout(layout);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- //Element
- Label label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.element")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fElementText= new Text(inner, SWT.BORDER);
- fElementText.setText(fMapping.getElement());
- fElementText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fElementText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- //Signature
- label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.signature")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fSignatureText= new Text(inner, SWT.BORDER);
- fSignatureText.setText(fMapping.getSignature());
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= convertWidthInCharsToPixels(50);
- fSignatureText.setLayoutData(data);
- fSignatureText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- //Id Attribute
- label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idattribute")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fIdAttributeText= new Text(inner, SWT.BORDER);
-
- fIdAttributeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fIdAttributeText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- //Id Source
- createIdSourceGroup(inner);
-
- fElementText.setFocus();
-
- return composite;
- }
-
- /**
- * Validate user input
- */
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String text= fElementText.getText();
- String mappingKey= Mapping.getKey(fSignatureText.getText(), text);
- String errormsg= ""; //$NON-NLS-1$
- boolean isError= false;
- if (text.length() == 0) {
- errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$
- isError= true;
- } else if (XMLComparePreferencePage.containsInvalidCharacters(text)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- } else if (!fEdit && fIdmapHM != null && fIdmapHM.containsKey(mappingKey)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.mappingExists"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- }
- text= fSignatureText.getText();
- if (XMLComparePreferencePage.containsInvalidCharacters(text)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- }
- text= fIdAttributeText.getText();
- if (text.length() == 0)
- isError= true;
- else if (XMLComparePreferencePage.containsInvalidCharacters(text)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalididattribute"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- }
- if (isError) status.setError(errormsg);
- updateStatus(status);
- }
-
- /**
- * Notifies that the ok button of this dialog has been pressed.
- */
- protected void okPressed() {
- fMapping.setElement(fElementText.getText());
- fMapping.setSignature(fSignatureText.getText());
- String idtext= fIdAttributeText.getText();
- if (fIdTypeChildBodyButton.getSelection()) {
- idtext= new Character(XMLStructureCreator.ID_TYPE_BODY) + idtext;
- }
- fMapping.setIdAttribute(idtext);
- super.okPressed();
- }
-
- private void createIdSourceGroup(Composite composite) {
- Label titleLabel= new Label(composite, SWT.NONE);
- titleLabel.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype")); //$NON-NLS-1$
- titleLabel.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.tooltip")); //$NON-NLS-1$
-
- Composite buttonComposite= new Composite(composite, SWT.LEFT);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- buttonComposite.setLayout(layout);
- composite.setData(new GridData());
-
- //attribute button
- fIdTypeAttributeButton= createRadioButton(buttonComposite, XMLCompareMessages.getString("XMLComparePreference.idtype.attribute")); //$NON-NLS-1$
- fIdTypeAttributeButton.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.attribute.tooltip")); //$NON-NLS-1$
-
- //child body button
- fIdTypeChildBodyButton= createRadioButton(buttonComposite, XMLCompareMessages.getString("XMLComparePreference.idtype.child_body")); //$NON-NLS-1$
- fIdTypeChildBodyButton.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.childbody.tooltip")); //$NON-NLS-1$
-
- String idtext= fMapping.getIdAttribute();
- if (fEdit && idtext.charAt(0) == XMLStructureCreator.ID_TYPE_BODY) {
- idtext= idtext.substring(1,idtext.length());
- fIdTypeChildBodyButton.setSelection(true);
- } else
- fIdTypeAttributeButton.setSelection(true);
- fIdAttributeText.setText(idtext);
-
- }
-
- private Button createRadioButton(Composite parent, String label) {
- Button button= new Button(parent, SWT.RADIO | SWT.LEFT);
- button.setText(label);
- GridData data= new GridData();
- button.setLayoutData(data);
- return button;
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java
deleted file mode 100644
index c4497aa09..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.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.compare.examples.xml;
-
-import java.util.ArrayList;
-
-import org.eclipse.compare.examples.xml.ui.StatusDialog;
-import org.eclipse.compare.examples.xml.ui.StatusInfo;
-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.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;
-
-/**
- * This class is used to add or edit a particular ID Mapping
- */
-public class XMLCompareEditOrderedDialog extends StatusDialog {
-
- private Mapping fMapping;
- private ArrayList fIdmapAL;
- private boolean fEdit;
-
- private Text fElementText;
- private Text fSignatureText;
-
- /*
- * Constructs a new edit mapping dialog.
- */
- public XMLCompareEditOrderedDialog(Shell parent, Mapping mapping, ArrayList idmapAL, boolean edit) {
- super(parent);
-
- int shellStyle= getShellStyle();
- setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
-
-
- fEdit= edit;
- if (fEdit)
- setTitle(XMLCompareMessages.getString("XMLCompareEditOrderedDialog.editTitle")); //$NON-NLS-1$
- else
- setTitle(XMLCompareMessages.getString("XMLCompareEditOrderedDialog.newTitle")); //$NON-NLS-1$
-
- fMapping= mapping;
- fIdmapAL= idmapAL;
- }
-
- /**
- * Creates and returns the contents of the upper part
- * of the dialog (above the button bar).
- *
- * Subclasses should override.
- *
- * @param ancestor the parent composite to contain the dialog area
- * @return the dialog area control
- */
- protected Control createDialogArea(Composite ancestor) {
- Composite composite= (Composite) super.createDialogArea(ancestor);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- inner.setLayout(layout);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- //Element
- Label label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.element")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fElementText= new Text(inner, SWT.BORDER);
- fElementText.setText(fMapping.getElement());
- fElementText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fElementText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- //Signature
- label= new Label(inner, SWT.NULL);
- label.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.signature")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- fSignatureText= new Text(inner, SWT.BORDER);
- fSignatureText.setText(fMapping.getSignature());
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= convertWidthInCharsToPixels(50);
- fSignatureText.setLayoutData(data);
- fSignatureText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e){
- doValidation();
- }
- });
-
- fElementText.setFocus();
-
- return composite;
- }
-
- /**
- * Validate user input
- */
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String text= fElementText.getText();
- String mappingKey= Mapping.getKey(fSignatureText.getText(), text);
- String errormsg= ""; //$NON-NLS-1$
- boolean isError= false;
- if (text.length() == 0) {
- errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$
- isError= true;
- } else if (XMLComparePreferencePage.containsInvalidCharacters(text)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- } else if (!fEdit && fIdmapAL.contains(mappingKey)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditOrderedDialog.error.orderedExists"); //$NON-NLS-1$ //$NON-NLS-2$
- isError= true;
- }
- text= fSignatureText.getText();
- if (XMLComparePreferencePage.containsInvalidCharacters(text)) {
- if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$
- isError= true;
- }
- if (isError) status.setError(errormsg);
- updateStatus(status);
- }
-
- /**
- * Notifies that the ok button of this dialog has been pressed.
- */
- protected void okPressed() {
- fMapping.setElement(fElementText.getText());
- fMapping.setSignature(fSignatureText.getText());
- super.okPressed();
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java
deleted file mode 100644
index 34de2561d..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.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.examples.xml;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class XMLCompareMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.compare.examples.xml.xmlcompare"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private XMLCompareMessages() {
- // nothing to do
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java
deleted file mode 100644
index b61efa81c..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java
+++ /dev/null
@@ -1,839 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import java.util.*;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.*;
-
-/**
- * The XMLComparePreferencePage is the page used to set ID Mappings for XML Compare
- */
-public class XMLComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener {
-
- private Table fIdMapsTable;
- private Button fAddIdMapButton;
- private Button fRenameIdMapButton;
- private Button fRemoveIdMapButton;
- private Button fEditIdMapButton;
-
- private Table fMappingsTable;
- private Button fNewMappingsButton;
- private Button fEditMappingsButton;
- private Button fRemoveMappingsButton;
-
- private Table fOrderedTable;
- private Button fNewOrderedButton;
- private Button fEditOrderedButton;
- private Button fRemoveOrderedButton;
-
- private HashMap fIdMapsInternal;
- private HashMap fIdMaps;// HashMap ( idname -> HashMap (signature -> id) )
- private HashMap fIdExtensionToName;
-
- //fOrderedElements contains signature of xml element whose children must be compared in ordered fashion
- private HashMap fOrderedElements;// HashMap ( idname -> ArrayList (signature) )
- private HashMap fOrderedElementsInternal;
-
- protected static char[] invalidCharacters;
- protected static final char SIGN_SEPARATOR = XMLStructureCreator.SIGN_SEPARATOR;
-
- public static String IDTYPE_ATTRIBUTE= XMLCompareMessages.getString("XMLComparePreference.idtype.attribute"); //$NON-NLS-1$
- public static String IDTYPE_CHILDBODY= XMLCompareMessages.getString("XMLComparePreference.idtype.child_body"); //$NON-NLS-1$
-
-
- static {
- invalidCharacters = new char[] {XMLPlugin.IDMAP_SEPARATOR,XMLPlugin.IDMAP_FIELDS_SEPARATOR,XMLStructureCreator.SIGN_ENCLOSING};
- }
-
-
- public XMLComparePreferencePage() {
- super();
-
- fIdMaps = new HashMap();
- XMLPlugin plugin= XMLPlugin.getDefault();
- HashMap PluginIdMaps = plugin.getIdMaps();
- Set keySet = PluginIdMaps.keySet();
- for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
- fIdMaps.put(key, ((HashMap)PluginIdMaps.get(key)).clone() );
- }
- fIdMapsInternal = plugin.getIdMapsInternal();
-
- fIdExtensionToName= new HashMap();
- HashMap PluginIdExtensionToName= plugin.getIdExtensionToName();
- keySet= PluginIdExtensionToName.keySet();
- for (Iterator iter= keySet.iterator(); iter.hasNext(); ) {
- String key= (String) iter.next();
- fIdExtensionToName.put(key, PluginIdExtensionToName.get(key));
- }
-
- fOrderedElements= new HashMap();
- HashMap PluginOrderedElements= plugin.getOrderedElements();
- keySet= PluginOrderedElements.keySet();
- for (Iterator iter= keySet.iterator(); iter.hasNext();) {
- String key= (String) iter.next();
- fOrderedElements.put(key, ((ArrayList)PluginOrderedElements.get(key)).clone());
- }
-
- fOrderedElementsInternal= plugin.getOrderedElementsInternal();
- }
-
- /**
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite ancestor) {
- Composite parent= new Composite(ancestor, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- parent.setLayout(layout);
-
- //layout the top table & its buttons
- Label label = new Label(parent, SWT.LEFT);
- label.setText(XMLCompareMessages.getString("XMLComparePreference.topTableLabel")); //$NON-NLS-1$
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- fIdMapsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
- fIdMapsTable.setHeaderVisible(true);
- data = new GridData(GridData.FILL_BOTH);
- data.heightHint = fIdMapsTable.getItemHeight()*4;
- fIdMapsTable.setLayoutData(data);
- fIdMapsTable.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- selectionChanged();
- }
- });
-
- String column2Text= XMLCompareMessages.getString("XMLComparePreference.topTableColumn2"); //$NON-NLS-1$
- String column3Text= XMLCompareMessages.getString("XMLComparePreference.topTableColumn3"); //$NON-NLS-1$
- ColumnLayoutData columnLayouts[]= {
- new ColumnWeightData(1),
- new ColumnPixelData(convertWidthInCharsToPixels(column2Text.length()+2), true),
- new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length()+5), true)};
- TableLayout tablelayout = new TableLayout();
- fIdMapsTable.setLayout(tablelayout);
- for (int i=0; i<3; i++)
- tablelayout.addColumnData(columnLayouts[i]);
- TableColumn column = new TableColumn(fIdMapsTable, SWT.NONE);
- column.setText(XMLCompareMessages.getString("XMLComparePreference.topTableColumn1")); //$NON-NLS-1$
- column = new TableColumn(fIdMapsTable, SWT.NONE);
- column.setText(column2Text); //$NON-NLS-1$
- column = new TableColumn(fIdMapsTable, SWT.NONE);
- column.setText(column3Text); //$NON-NLS-1$
-
- fillIdMapsTable();
-
- Composite buttons= new Composite(parent, SWT.NULL);
- buttons.setLayout(new GridLayout());
- data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- buttons.setLayoutData(data);
-
- fAddIdMapButton = new Button(buttons, SWT.PUSH);
- fAddIdMapButton.setText(XMLCompareMessages.getString("XMLComparePreference.topAdd")); //$NON-NLS-1$
- fAddIdMapButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addIdMap(fAddIdMapButton.getShell());
- }
- });
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- //data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- fAddIdMapButton.setLayoutData(data);
-
- fRenameIdMapButton = new Button(buttons, SWT.PUSH);
- fRenameIdMapButton.setText(XMLCompareMessages.getString("XMLComparePreference.topRename")); //$NON-NLS-1$
- fRenameIdMapButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- renameIdMap(fRenameIdMapButton.getShell());
- }
- });
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- //data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- fRenameIdMapButton.setLayoutData(data);
-
- fRemoveIdMapButton = new Button(buttons, SWT.PUSH);
- fRemoveIdMapButton.setText(XMLCompareMessages.getString("XMLComparePreference.topRemove")); //$NON-NLS-1$
- fRemoveIdMapButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeIdMap(fRemoveIdMapButton.getShell());
- }
- });
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- //data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, fRemoveIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- fRemoveIdMapButton.setLayoutData(data);
-
- createSpacer(buttons);
-
- fEditIdMapButton = new Button(buttons, SWT.PUSH);
- fEditIdMapButton.setText(XMLCompareMessages.getString("XMLComparePreference.topEdit")); //$NON-NLS-1$
- fEditIdMapButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- editIdMap(fEditIdMapButton.getShell());
- }
- });
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- //data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, fEditIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- fEditIdMapButton.setLayoutData(data);
-
- //Spacer
- label = new Label(parent, SWT.LEFT);
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- //layout the middle table & its buttons
- label = new Label(parent, SWT.LEFT);
- label.setText(XMLCompareMessages.getString("XMLComparePreference.middleTableLabel")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- fMappingsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
- fMappingsTable.setHeaderVisible(true);
- data = new GridData(GridData.FILL_BOTH);
- data.heightHint = fMappingsTable.getItemHeight()*4;
- data.widthHint= convertWidthInCharsToPixels(70);
- fMappingsTable.setLayoutData(data);
-
- column3Text= XMLCompareMessages.getString("XMLComparePreference.middleTableColumn3"); //$NON-NLS-1$
- String column4Text= XMLCompareMessages.getString("XMLComparePreference.middleTableColumn4"); //$NON-NLS-1$
- columnLayouts= new ColumnLayoutData[] {
- new ColumnWeightData(10),
- new ColumnWeightData(18),
- new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length()+1), true),
- new ColumnPixelData(convertWidthInCharsToPixels(column4Text.length()+3), true)};
- tablelayout = new TableLayout();
- fMappingsTable.setLayout(tablelayout);
- for (int i=0; i<4; i++)
- tablelayout.addColumnData(columnLayouts[i]);
- column = new TableColumn(fMappingsTable, SWT.NONE);
- column.setText(XMLCompareMessages.getString("XMLComparePreference.middleTableColumn1")); //$NON-NLS-1$
- column = new TableColumn(fMappingsTable, SWT.NONE);
- column.setText(XMLCompareMessages.getString("XMLComparePreference.middleTableColumn2")); //$NON-NLS-1$
- column = new TableColumn(fMappingsTable, SWT.NONE);
- column.setText(column3Text); //$NON-NLS-1$
- column = new TableColumn(fMappingsTable, SWT.NONE);
- column.setText(column4Text); //$NON-NLS-1$
-
- 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);
-
- fNewMappingsButton= new Button(buttons, SWT.PUSH);
- fNewMappingsButton.setLayoutData(getButtonGridData(fNewMappingsButton));
- fNewMappingsButton.setText(XMLCompareMessages.getString("XMLComparePreference.middleNew")); //$NON-NLS-1$
- fNewMappingsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addMapping(fAddIdMapButton.getShell());
- }
- });
-
- fEditMappingsButton= new Button(buttons, SWT.PUSH);
- fEditMappingsButton.setLayoutData(getButtonGridData(fEditMappingsButton));
- fEditMappingsButton.setText(XMLCompareMessages.getString("XMLComparePreference.middleEdit")); //$NON-NLS-1$
- fEditMappingsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- editMapping(fEditMappingsButton.getShell());
- }
- });
-
- fRemoveMappingsButton= new Button(buttons, SWT.PUSH);
- fRemoveMappingsButton.setLayoutData(getButtonGridData(fRemoveMappingsButton));
- fRemoveMappingsButton.setText(XMLCompareMessages.getString("XMLComparePreference.middleRemove")); //$NON-NLS-1$
- fRemoveMappingsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeMapping(fRemoveMappingsButton.getShell());
- }
- });
-
- createSpacer(buttons);
-
- //layout the botton table & its buttons
- label = new Label(parent, SWT.LEFT);
- label.setText(XMLCompareMessages.getString("XMLComparePreference.bottomTableLabel")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- fOrderedTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
- fOrderedTable.setHeaderVisible(true);
- data = new GridData(GridData.FILL_BOTH);
- data.heightHint = fOrderedTable.getItemHeight()*2;
- data.widthHint= convertWidthInCharsToPixels(70);
- fOrderedTable.setLayoutData(data);
-
- columnLayouts= new ColumnLayoutData[] {
- new ColumnWeightData(1),
- new ColumnWeightData(1)};
- tablelayout = new TableLayout();
- fOrderedTable.setLayout(tablelayout);
- for (int i=0; i<2; i++)
- tablelayout.addColumnData(columnLayouts[i]);
- column = new TableColumn(fOrderedTable, SWT.NONE);
- column.setText(XMLCompareMessages.getString("XMLComparePreference.bottomTableColumn1")); //$NON-NLS-1$
- column = new TableColumn(fOrderedTable, SWT.NONE);
- column.setText(XMLCompareMessages.getString("XMLComparePreference.bottomTableColumn2")); //$NON-NLS-1$
-
- 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);
-
- fNewOrderedButton= new Button(buttons, SWT.PUSH);
- fNewOrderedButton.setLayoutData(getButtonGridData(fNewOrderedButton));
- fNewOrderedButton.setText(XMLCompareMessages.getString("XMLComparePreference.bottomNew")); //$NON-NLS-1$
- fNewOrderedButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addOrdered(fNewOrderedButton.getShell());
- }
- });
-
- fEditOrderedButton= new Button(buttons, SWT.PUSH);
- fEditOrderedButton.setLayoutData(getButtonGridData(fEditOrderedButton));
- fEditOrderedButton.setText(XMLCompareMessages.getString("XMLComparePreference.bottomEdit")); //$NON-NLS-1$
- fEditOrderedButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- editOrdered(fEditOrderedButton.getShell());
- }
- });
-
- fRemoveOrderedButton= new Button(buttons, SWT.PUSH);
- fRemoveOrderedButton.setLayoutData(getButtonGridData(fRemoveOrderedButton));
- fRemoveOrderedButton.setText(XMLCompareMessages.getString("XMLComparePreference.bottomRemove")); //$NON-NLS-1$
- fRemoveOrderedButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeOrdered(fRemoveOrderedButton.getShell());
- }
- });
-
- createSpacer(buttons);
-
-
-
- fIdMapsTable.setSelection(0);
- fIdMapsTable.setFocus();
- selectionChanged();
-
- return parent;
- }
-
- protected void createSpacer(Composite parent) {
- Label spacer= new Label(parent, SWT.NONE);
- GridData data= new GridData();
- data.horizontalAlignment= GridData.FILL;
- data.verticalAlignment= GridData.BEGINNING;
- data.heightHint= 4;
- spacer.setLayoutData(data);
- }
-
- private static GridData getButtonGridData(Button button) {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= SWTUtil.getButtonWidthHint(button);
- //data.heightHint= SWTUtil.getButtonHeigthHint(button);
- return data;
- }
-
- public void init(IWorkbench workbench) {
- noDefaultAndApplyButton();
- }
-
- public void handleEvent(Event event) {
- // empty implementation
- }
-
- private void addIdMap(Shell shell) {
- IdMap idmap = new IdMap(false);
- XMLCompareAddIdMapDialog dialog= new XMLCompareAddIdMapDialog(shell,idmap,fIdMaps,fIdMapsInternal,fIdExtensionToName,false);
- if (dialog.open() == Window.OK) {
- if (!fIdMaps.containsKey(idmap.getName())) {
- fIdMaps.put(idmap.getName(),new HashMap());
- if (!idmap.getExtension().equals("")) //$NON-NLS-1$
- fIdExtensionToName.put(idmap.getExtension(),idmap.getName());
- newIdMapsTableItem(idmap,true);
- }
- }
- }
-
- private void renameIdMap(Shell shell) {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- if (itemsIdMaps.length > 0) {
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- String old_name = idmap.getName();
- String old_extension= idmap.getExtension();
- HashMap idmapHS = (HashMap) fIdMaps.get(old_name);
- XMLCompareAddIdMapDialog dialog= new XMLCompareAddIdMapDialog(shell,idmap,fIdMaps,fIdMapsInternal,fIdExtensionToName,true);
- if (dialog.open() == Window.OK) {
- fIdMaps.remove(old_name);
- fIdExtensionToName.remove(old_extension);
- fIdMaps.put(idmap.getName(),idmapHS);
- if (!idmap.getExtension().equals("")) //$NON-NLS-1$
- fIdExtensionToName.put(idmap.getExtension(),idmap.getName());
- fIdMapsTable.remove(fIdMapsTable.indexOf(itemsIdMaps[0]));
- newIdMapsTableItem(idmap,true);
- }
- }
- }
-
- private void removeIdMap(Shell shell) {
- TableItem[] itemsIdMap = fIdMapsTable.getSelection();
- if (itemsIdMap.length > 0) {
-// fIdMaps.remove(itemsIdMap[0].getText());
- String IdMapName= ((IdMap)itemsIdMap[0].getData()).getName();
- fIdMaps.remove( IdMapName );
- fOrderedElements.remove( IdMapName );
- //All the corresponding ID Mappings must be removed as well
- TableItem[] itemsMappings = fMappingsTable.getItems();
- for (int i=0; i<itemsMappings.length; i++) {
- itemsMappings[i].dispose();
- }
- //All the corresponding Ordered entries must be removed as well
- TableItem[] itemsOrdered= fOrderedTable.getItems();
- for (int i= 0; i < itemsOrdered.length; i++) {
- itemsOrdered[i].dispose();
- }
- //Remove extension
- if (!itemsIdMap[0].getText(2).equals("")) { //$NON-NLS-1$
- fIdExtensionToName.remove(itemsIdMap[0].getText(2));
- }
- itemsIdMap[0].dispose(); //Table is single selection
- }
- }
-
- private void editIdMap(Shell shell) {
- TableItem[] items = fIdMapsTable.getSelection();
- if (items.length > 0) {
- IdMap idmap = (IdMap) items[0].getData();
- XMLCompareEditCopyIdMapDialog dialog= new XMLCompareEditCopyIdMapDialog(shell,idmap,fIdMaps,fIdMapsInternal);
- if (dialog.open() == Window.OK) {
- String new_idmapName = dialog.getResult();
- if (!fIdMaps.containsKey(new_idmapName)) {
- //copy over id mappings
- Vector newMappings = new Vector();
- IdMap newIdMap = new IdMap(new_idmapName, false, newMappings);
- HashMap newIdmapHM = new HashMap();
- fIdMaps.put(newIdMap.getName(),newIdmapHM);
- Vector Mappings = idmap.getMappings();
- for (Enumeration enumeration= Mappings.elements(); enumeration.hasMoreElements(); ) {
- Mapping mapping = (Mapping) enumeration.nextElement();
- Mapping newMapping = new Mapping(mapping.getElement(), mapping.getSignature(), mapping.getIdAttribute());
- newMappings.add(newMapping);
- newIdmapHM.put(newMapping.getKey(), newMapping.getIdAttribute());
- }
- //copy over ordered entries
- ArrayList orderedAL= idmap.getOrdered();
- if (orderedAL != null && orderedAL.size() > 0) {
- ArrayList newOrderedAL= new ArrayList();
- newIdMap.setOrdered(newOrderedAL);
- ArrayList idmapOrdered= new ArrayList();
- fOrderedElements.put(newIdMap.getName(),idmapOrdered);
- for (Iterator iter= orderedAL.iterator(); iter.hasNext();) {
- Mapping ordered= (Mapping) iter.next();
- Mapping newOrdered= new Mapping(ordered.getElement(), ordered.getSignature());
- newOrderedAL.add(newOrdered);
- idmapOrdered.add(newOrdered.getKey());
- }
- }
-
- newIdMapsTableItem(newIdMap,true);
- selectionChanged();
- }
- }
- }
- }
-
- private void addMapping(Shell shell) {
- TableItem[] items = fIdMapsTable.getSelection();
- if (items.length > 0) {
- IdMap idmap = (IdMap) items[0].getData();
- Mapping mapping = new Mapping();
- HashMap idmapHM = (HashMap) fIdMaps.get(idmap.getName());
- XMLCompareEditMappingDialog dialog= new XMLCompareEditMappingDialog(shell,mapping,idmapHM,false);
- if (dialog.open() == Window.OK) {
- String idmapHMKey = mapping.getKey();
- if (idmapHM == null)
- idmapHM= new HashMap();
- if (!idmapHM.containsKey(idmapHMKey)) {
- idmapHM.put(idmapHMKey, mapping.getIdAttribute());
- newMappingsTableItem(mapping, true);
- Vector mappings = idmap.getMappings();
- mappings.add(mapping);
- }
- }
- }
- }
-
- private void editMapping(Shell shell) {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- TableItem[] itemsMappings = fMappingsTable.getSelection();
- if (itemsMappings.length > 0) {
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- HashMap idmapHM = (HashMap) fIdMaps.get(idmap.getName());
- Mapping mapping = (Mapping)itemsMappings[0].getData();
- String idmapHMKey = mapping.getKey();
- idmapHM.remove(idmapHMKey);
- XMLCompareEditMappingDialog dialog= new XMLCompareEditMappingDialog(shell,mapping,null,true);
- if (dialog.open() == Window.OK) {
- idmapHMKey = mapping.getKey();
- idmapHM.put(idmapHMKey, mapping.getIdAttribute());
- fMappingsTable.remove(fMappingsTable.indexOf(itemsMappings[0]));
- newMappingsTableItem(mapping, true);
- }
- }
- }
-
- private void removeMapping(Shell shell) {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- TableItem[] itemsMappings = fMappingsTable.getSelection();
-
- if (itemsMappings.length > 0 && itemsIdMaps.length > 0) {
- Mapping mapping = (Mapping)itemsMappings[0].getData();
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- HashMap idmapHS = (HashMap) fIdMaps.get( idmap.getName() );
- idmapHS.remove(mapping.getKey());
- Vector mappings= idmap.getMappings();
- mappings.remove(mapping);
- itemsMappings[0].dispose(); //Table is single selection
- }
- }
-
- private void addOrdered(Shell shell) {
- TableItem[] items = fIdMapsTable.getSelection();
- if (items.length > 0) {
-// Set orderedSet= fOrderedElements.keySet();
-// for (Iterator iter= orderedSet.iterator(); iter.hasNext(); ) {
-// String IdMapName= (String) iter.next();
-// ArrayList ordered= (ArrayList) fOrderedElements.get(IdMapName);
-// for (Iterator iter2= ordered.iterator(); iter2.hasNext(); ) {
-// System.out.println(IdMapName + ": " + iter2.next()); //$NON-NLS-1$
-// }
-// }
- IdMap idmap = (IdMap) items[0].getData();
- Mapping mapping = new Mapping();
- ArrayList idmapAL= (ArrayList) fOrderedElements.get(idmap.getName());
- if (idmapAL == null)
- idmapAL= new ArrayList();
- XMLCompareEditOrderedDialog dialog= new XMLCompareEditOrderedDialog(shell,mapping,idmapAL,false);
- if (dialog.open() == Window.OK) {
- String idmapALKey = mapping.getKey();
- if (!idmapAL.contains(idmapALKey)) {
- idmapAL.add(idmapALKey);
- newOrderedTableItem(mapping, true);
- ArrayList ordered= idmap.getOrdered();
- if (ordered == null) {
- ordered= new ArrayList();
- ordered.add(mapping);
- idmap.setOrdered(ordered);
- } else {
- ordered.add(mapping);
- }
- if (!fOrderedElements.containsKey(idmap.getName()))
- fOrderedElements.put(idmap.getName(), idmapAL);
- }
- }
- }
- }
-
- private void editOrdered(Shell shell) {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- TableItem[] itemsOrdered = fOrderedTable.getSelection();
- if (itemsOrdered.length > 0) {
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- ArrayList idmapAL = (ArrayList) fOrderedElements.get(idmap.getName());
- Mapping mapping = (Mapping)itemsOrdered[0].getData();
- String idmapALKey = mapping.getKey();
- idmapAL.remove(idmapALKey);
- XMLCompareEditOrderedDialog dialog= new XMLCompareEditOrderedDialog(shell,mapping,null,true);
- if (dialog.open() == Window.OK) {
- idmapALKey = mapping.getKey();
- idmapAL.add(idmapALKey);
- fOrderedTable.remove(fOrderedTable.indexOf(itemsOrdered[0]));
- newOrderedTableItem(mapping, true);
- }
- }
-
- }
-
- private void removeOrdered(Shell shell) {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- TableItem[] itemsOrdered = fOrderedTable.getSelection();
- if (itemsOrdered.length > 0 && itemsIdMaps.length > 0) {
- Mapping mapping = (Mapping)itemsOrdered[0].getData();
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- ArrayList idmapAL = (ArrayList) fOrderedElements.get( idmap.getName() );
- idmapAL.remove(mapping.getKey());
- if (idmapAL.size() <= 0)
- fOrderedElements.remove(idmap.getName());
- ArrayList ordered= idmap.getOrdered();
- ordered.remove(mapping);
- if (ordered.size() <= 0)
- idmap.setOrdered(null);
- itemsOrdered[0].dispose(); //Table is single selection
- }
- }
-
- protected TableItem newIdMapsTableItem(IdMap idmap, boolean selected) {
- //find index where to insert table entry
- TableItem[] items = fIdMapsTable.getItems();
- int i= 0;
- while (i<items.length && idmap.getName().compareToIgnoreCase(items[i].getText(0)) > 0)
- i++;
- TableItem item = new TableItem(fIdMapsTable, SWT.NULL, i);
- String[] values = new String[] {idmap.getName(), (idmap.isInternal())?XMLCompareMessages.getString("XMLComparePreference.topTableColumn2internal"):XMLCompareMessages.getString("XMLComparePreference.topTableColumn2user"),idmap.getExtension()}; //$NON-NLS-2$ //$NON-NLS-1$
- item.setText(values);
- item.setData(idmap);
- if (selected) {
- fIdMapsTable.setSelection(i);
- fIdMapsTable.setFocus();
- selectionChanged();
- }
- return item;
- }
-
- protected TableItem newMappingsTableItem(Mapping mapping, boolean selected) {
- TableItem[] items = fMappingsTable.getItems();
- int i= 0;
- while (i<items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0)
- i++;
- TableItem item = new TableItem(fMappingsTable, SWT.NULL, i);
- String idtext = mapping.getIdAttribute();
- String idtype;
- if (idtext.charAt(0)==XMLStructureCreator.ID_TYPE_BODY) {
- idtext = idtext.substring(1,idtext.length());
- idtype = IDTYPE_CHILDBODY;
- } else
- idtype = IDTYPE_ATTRIBUTE;
-
- String[] values = new String[] {mapping.getElement(), mapping.getSignature(), idtext, idtype};
- item.setText(values);
- item.setData(mapping);
- if (selected)
- fMappingsTable.setSelection(i);
-
- return item;
- }
-
- protected TableItem newOrderedTableItem(Mapping mapping, boolean selected) {
- TableItem[] items = fOrderedTable.getItems();
- int i= 0;
- while (i<items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0)
- i++;
-
- TableItem item = new TableItem(fOrderedTable, SWT.NULL, i);
-
- String[] values = new String[] {mapping.getElement(), mapping.getSignature()};
- item.setText(values);
- item.setData(mapping);
- if (selected)
- fOrderedTable.setSelection(i);
-
- return item;
- }
-
-
- protected void fillIdMapsTable() {
- //fill user idmaps from plugin.xml
- fillIdMaps(true);
-
- //fill user idmaps from Preference Store
- fillIdMaps(false);
-
- //add user idmaps that have ordered entries but no id mappings
- //they do not appear in the preference store with name IDMAP_PREFERENCE_NAME
- Set OrderedKeys= fOrderedElements.keySet();
- Set IdMapKeys= fIdMaps.keySet();
- for (Iterator iter_orderedElements= OrderedKeys.iterator(); iter_orderedElements.hasNext();) {
- String IdMapName= (String) iter_orderedElements.next();
- if (!IdMapKeys.contains(IdMapName)) {
- IdMap idmap= new IdMap(IdMapName, false);
- ArrayList idmapOrdered= (ArrayList) fOrderedElements.get(IdMapName);
- setOrdered(idmap, idmapOrdered);
- newIdMapsTableItem(idmap, false);
- }
- }
- }
-
- private void fillIdMaps(boolean internal) {
- HashMap IdMaps= (internal)?fIdMapsInternal:fIdMaps;
- HashMap OrderedElements= (internal)?fOrderedElementsInternal:fOrderedElements;
- Set IdMapKeys = IdMaps.keySet();
- for (Iterator iter_internal = IdMapKeys.iterator(); iter_internal.hasNext(); ) {
- String IdMapName = (String) iter_internal.next();
- Vector Mappings = new Vector();
- IdMap idmap = new IdMap(IdMapName, internal, Mappings);
- //create mappings of internal idmaps
- HashMap idmapHM = (HashMap) IdMaps.get(IdMapName);
- Set idmapKeys = idmapHM.keySet();
- for (Iterator iter_idmap = idmapKeys.iterator(); iter_idmap.hasNext(); ) {
- Mapping mapping = new Mapping();
- String signature = (String) iter_idmap.next();
- int end_of_signature = signature.lastIndexOf(SIGN_SEPARATOR,signature.length()-2);
- if (end_of_signature < XMLStructureCreator.ROOT_ID.length() + 1)
- mapping.setSignature(""); //$NON-NLS-1$
- else
- mapping.setSignature(signature.substring(XMLStructureCreator.ROOT_ID.length() + 1,end_of_signature));
- mapping.setElement(signature.substring(end_of_signature+1,signature.length()-1));
- mapping.setIdAttribute((String)idmapHM.get(signature));
- Mappings.add(mapping);
- }
- //create ordered mappings
- ArrayList idmapOrdered= (ArrayList) OrderedElements.get(IdMapName);
- if (idmapOrdered != null) {
- setOrdered(idmap, idmapOrdered);
- }
- //set extension
- if (fIdExtensionToName.containsValue(IdMapName)) {
- Set keySet= fIdExtensionToName.keySet();
- String extension= new String();
- for (Iterator iter= keySet.iterator(); iter.hasNext(); ) {
- extension= (String)iter.next();
- if ( ((String)fIdExtensionToName.get(extension)).equals(IdMapName) )
- break;
- }
- idmap.setExtension(extension);
- }
- newIdMapsTableItem(idmap, false);
- }
- }
-
- protected static void setOrdered(IdMap idmap, ArrayList idmapOrdered) {
- ArrayList Ordered= new ArrayList();
- for (Iterator iter_ordered= idmapOrdered.iterator(); iter_ordered.hasNext();) {
- Mapping mapping= new Mapping();
- String signature= (String) iter_ordered.next();
- int end_of_signature = signature.lastIndexOf(SIGN_SEPARATOR,signature.length()-2);
- if (end_of_signature < XMLStructureCreator.ROOT_ID.length() + 1)
- mapping.setSignature(""); //$NON-NLS-1$
- else
- mapping.setSignature(signature.substring(XMLStructureCreator.ROOT_ID.length() + 1,end_of_signature));
- mapping.setElement(signature.substring(end_of_signature+1,signature.length()-1));
- Ordered.add(mapping);
- }
- idmap.setOrdered(Ordered);
- }
-
- /*
- * @see IWorkbenchPreferencePage#performDefaults
- */
- public boolean performOk() {
- XMLPlugin plugin= XMLPlugin.getDefault();
- if (!plugin.getIdMaps().equals(fIdMaps)
- || !plugin.getIdExtensionToName().equals(fIdExtensionToName)
- || !plugin.getOrderedElements().equals(fOrderedElements) )
- plugin.setIdMaps(fIdMaps,fIdExtensionToName,fOrderedElements,true);
- //XMLPlugin.getDefault().setIdMaps(fIdMaps,fIdExtensionToName,null);
- return super.performOk();
- }
-
- public boolean performCancel() {
- fIdMaps = (HashMap) XMLPlugin.getDefault().getIdMaps().clone();
- return super.performCancel();
- }
-
- protected void selectionChanged() {
- TableItem[] items = fIdMapsTable.getSelection();
- if (items.length > 0) {
- //Refresh Mappings Table
- fMappingsTable.removeAll();
- Vector Mappings = ((IdMap)items[0].getData()).getMappings();
- for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) {
- newMappingsTableItem((Mapping)enumeration.nextElement(), false);
- }
- //Refresh Ordered Table
- fOrderedTable.removeAll();
- ArrayList Ordered= ((IdMap)items[0].getData()).getOrdered();
- if (Ordered != null) {
- for (Iterator iter_ordered= Ordered.iterator(); iter_ordered.hasNext();) {
- newOrderedTableItem((Mapping)iter_ordered.next(), false);
- }
- }
- }
- updateEnabledState();
- }
-
- /**
- * Updates the state (enabled, not enabled) of the buttons
- */
- private void updateEnabledState() {
- TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
- if (itemsIdMaps.length > 0) {
- IdMap idmap = (IdMap) itemsIdMaps[0].getData();
- if (idmap.isInternal()) {
- fRenameIdMapButton.setEnabled(false);
- fRemoveIdMapButton.setEnabled(false);
- fEditIdMapButton.setEnabled(true);
-
- fNewMappingsButton.setEnabled(false);
- fEditMappingsButton.setEnabled(false);
- fRemoveMappingsButton.setEnabled(false);
-
- fNewOrderedButton.setEnabled(false);
- fEditOrderedButton.setEnabled(false);
- fRemoveOrderedButton.setEnabled(false);
- } else {
- fRenameIdMapButton.setEnabled(true);
- fRemoveIdMapButton.setEnabled(true);
- fEditIdMapButton.setEnabled(false);
-
- fNewMappingsButton.setEnabled(true);
- fEditMappingsButton.setEnabled(true);
- fRemoveMappingsButton.setEnabled(true);
-
- fNewOrderedButton.setEnabled(true);
- fEditOrderedButton.setEnabled(true);
- fRemoveOrderedButton.setEnabled(true);
- }
- }
- }
-
- static protected boolean containsInvalidCharacters(String text) {
- for (int i=0; i<invalidCharacters.length; i++) {
- if (text.indexOf(invalidCharacters[i]) > -1)
- return true;
- }
- return false;
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java
deleted file mode 100644
index 6d89166f5..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.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.compare.examples.xml;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Objects that make up the parse tree.
- */
-public class XMLNode extends DocumentRangeNode implements ITypedElement {
-
- private String fValue;
- private String fName;
- private String fSignature;
- private String fOrigId;
- private XMLNode parent;
- private String fXMLType;
- private boolean fUsesIDMAP;
- private boolean fOrderedChild;
-
- public int bodies; // counts the number of bodies
-
- public XMLNode(String XMLType, String id, String value, String signature, IDocument doc, int start, int length) {
- super(0, id, doc, start, length);
- fXMLType= XMLType;
- fValue= value;
- fSignature= signature;
- fOrigId= id;
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Created XMLNode with XMLType: " + XMLType + ", id: " + id + ", value: " + value + ", signature: " + fSignature); //$NON-NLS-1$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$
- bodies= 0;
- fUsesIDMAP= false;
- fOrderedChild= false;
- }
-
- void setValue(String value) {
- fValue= value;
- }
-
- String getValue() {
- return fValue;
- }
-
- /*
- * @see ITypedElement#getName
- */
- public String getName() {
- if (fName != null)
- return fName;
- return this.getId();
- }
-
- public void setName(String name) {
- fName= name;
- }
-
- /*
- * Every xml node is of type "txt" so that the builtin TextMergeViewer is used automatically.
- * @see ITypedElement#getType
- */
- public String getType() {
- return "txt"; //$NON-NLS-1$
- }
-
- public void setIsOrderedChild(boolean isOrderedChild) {
- fOrderedChild= isOrderedChild;
- }
-
- /*
- * @see ITypedElement#getImage
- */
- public Image getImage() {
- if (fOrderedChild)
- return CompareUI.getImage(XMLPlugin.IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_ELEMENT + XMLPlugin.IMAGE_TYPE_ORDERED_SUFFIX);
- return CompareUI.getImage(XMLPlugin.IMAGE_TYPE_PREFIX + getXMLType());
- }
-
- public void setParent(XMLNode parent0) {
- this.parent= parent0;
- }
-
- public XMLNode getParent() {
- return this.parent;
- }
-
- String getXMLType() {
- return fXMLType;
- }
-
- String getSignature() {
- return fSignature;
- }
-
- void setOrigId(String id) {
- fOrigId= id;
- }
-
- public String getOrigId() {
- return fOrigId;
- }
-
- public void setUsesIDMAP(boolean b) {
- fUsesIDMAP= b;
- }
-
- public boolean usesIDMAP() {
- return fUsesIDMAP;
- }
-
- //for tests
- public boolean testEquals(Object obj) {
- if (obj instanceof XMLNode) {
- XMLNode n= (XMLNode) obj;
- return fValue.equals(n.getValue())
- && fSignature.equals(n.getSignature())
- && fXMLType.equals(n.getXMLType())
- && fUsesIDMAP == n.usesIDMAP();
- }
- return false;
- }
-
- /*
- * Returns true if the subtree rooted at this node is equals to the subtree rooted at <code>obj</code>
- */
- public boolean subtreeEquals(Object obj) {
- if (!testEquals(obj))
- return false;
- if (obj instanceof XMLNode) {
- XMLNode n= (XMLNode) obj;
- if (getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)
- && n.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE))
- return true;
- Object[] children= getChildren();
- Object[] n_children= n.getChildren();
- //if both nodes have no children, return true;
- if ((children == null || children.length <= 0)
- && (n_children == null || n_children.length <= 0))
- return true;
- //now at least one of the two nodes has children;
- /* so if one of the two nodes has no children, or they don't have the same number of children,
- * return false;
- */
- if ((children == null || children.length <= 0)
- || (n_children == null || n_children.length <= 0)
- || (children.length != n_children.length))
- return false;
- //now both have children and the same number of children
- for (int i= 0; i < children.length; i++) {
- /* if the subtree rooted at children[i] is not equal to the subtree rooted at n_children[i],
- * return false
- */
- if (!((XMLNode) children[i]).subtreeEquals(n_children[i]))
- return false;
- }
- }
- return true;
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java
deleted file mode 100644
index e1b8d5b77..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.examples.xml;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.ListenerList;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.runtime.*;
-import org.osgi.framework.BundleContext;
-
-/**
- * This class is the plug-in runtime class for the
- * <code>"org.eclipse.compare.xml"</code> plug-in.
- * </p>
- */
-public final class XMLPlugin extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID= "org.eclipse.compare.examples.xml"; //$NON-NLS-1$
-
- private static final String ID_MAPPING_EXTENSION_POINT= "idMapping"; //$NON-NLS-1$
- private static final String MAPPING_ELEMENT_NAME= "mapping"; //$NON-NLS-1$
- private static final String IDMAP_NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String EXTENSION_NAME_ATTRIBUTE= "extension"; //$NON-NLS-1$
- private static final String MAPPING_SIGNATURE_ATTRIBUTE= "signature"; //$NON-NLS-1$
- private static final String MAPPING_ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private static final String MAPPING_ID_SOURCE= "id-source"; //$NON-NLS-1$
- private static final String MAPPING_ID_SOURCE_BODY= "body"; //$NON-NLS-1$
- private static final String ORDERED_ELEMENT_NAME= "ordered"; //$NON-NLS-1$
- private static final String ORDERED_SIGNATURE_ATTRIBUTE= "signature"; //$NON-NLS-1$
-
- public static final String DEFAULT_PREFIX = "XML"; //$NON-NLS-1$
- public static final String IMAGE_TYPE_PREFIX = "xml_"; //$NON-NLS-1$
- public static final String IMAGE_TYPE_ORDERED_SUFFIX = "_ordered"; //$NON-NLS-1$
- public static final String IDMAP_PREFERENCE_NAME = "idmap"; //$NON-NLS-1$
- public static final String IDMAP_PREFIX = "idmap"; //$NON-NLS-1$
- public static final char IDMAP_SEPARATOR = '*';
- public static final char IDMAP_FIELDS_SEPARATOR = '!';
-
- public static final String ORDERED_PREFERENCE_NAME = "ordered"; //$NON-NLS-1$
- public static final char ORDERED_FIELDS_SEPARATOR = IDMAP_FIELDS_SEPARATOR;
-
- private static XMLPlugin fgXMLPlugin;
- private IPreferenceStore fPrefStore;
-
- private HashMap fIdMapsInternal;
- private HashMap fIdMaps;
- private HashMap fIdExtensionToName;
- private HashMap fOrderedElementsInternal;
- private HashMap fOrderedElements;
-
- private ListenerList fViewers= new ListenerList();
-
-
- /**
- * Creates the <code>XMLPlugin</code> object and registers all
- * structure creators, content merge viewers, and structure merge viewers
- * contributed to this plug-in's extension points.
- * <p>
- * Note that instances of plug-in runtime classes are automatically created
- * by the platform in the course of plug-in activation.
- */
- public XMLPlugin() {
- super();
- Assert.isTrue(fgXMLPlugin == null);
- fgXMLPlugin= this;
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- CompareUI.removeAllStructureViewerAliases(DEFAULT_PREFIX);
- initPrefStore();
- CompareUI.registerImageDescriptor(IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_ELEMENT, getImageDescriptor("obj16/element_obj.gif")); //$NON-NLS-1$
- CompareUI.registerImageDescriptor(IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_ATTRIBUTE, getImageDescriptor("obj16/attribute_obj.gif")); //$NON-NLS-1$
- CompareUI.registerImageDescriptor(IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_TEXT, getImageDescriptor("obj16/text_obj.gif")); //$NON-NLS-1$
- CompareUI.registerImageDescriptor(IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_ELEMENT + IMAGE_TYPE_ORDERED_SUFFIX, getImageDescriptor("obj16/element_ordered_obj.gif")); //$NON-NLS-1$
- registerExtensions();
- }
-
- protected ImageDescriptor getImageDescriptor(String relativePath) {
-
- //URL installURL= getDescriptor().getInstallURL();
-
- URL installURL= fgXMLPlugin.getBundle().getEntry("/"); //$NON-NLS-1$
- if (installURL != null) {
- try {
- URL url= new URL(installURL, "icons/full/" + relativePath); //$NON-NLS-1$
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- Assert.isTrue(false);
- }
- }
- return null;
- }
-
- /**
- * Returns the singleton instance of this plug-in runtime class.
- *
- * @return the XMLPlugin instance
- */
- public static XMLPlugin getDefault() {
- return fgXMLPlugin;
- }
-
- /**
- * Reads the Preference Store associated with XMLPlugin and initializes ID Mappings.
- */
- public void initPrefStore() {
- fIdMaps = new HashMap();
- fIdExtensionToName= new HashMap();
- fPrefStore = getPreferenceStore();
- String IdMapPrefValue = fPrefStore.getString(IDMAP_PREFERENCE_NAME);
- int start = 0;
- int end = IdMapPrefValue.indexOf(IDMAP_SEPARATOR);
- while (end >= 0) {
- String CurrentIdMap = IdMapPrefValue.substring(start,end);
- int end_of_IdMapName = CurrentIdMap.indexOf(IDMAP_FIELDS_SEPARATOR);
- String IdMapName = CurrentIdMap.substring(0,end_of_IdMapName);
- int end_of_signature = CurrentIdMap.indexOf(IDMAP_FIELDS_SEPARATOR,end_of_IdMapName+1);
- String IdMapSignature = CurrentIdMap.substring(end_of_IdMapName+1,end_of_signature);
- int end_of_attribute= CurrentIdMap.indexOf(IDMAP_FIELDS_SEPARATOR,end_of_signature+1);
- String IdMapAttribute;
- if (end_of_attribute < 0) {//for backward compatibility
- IdMapAttribute = CurrentIdMap.substring(end_of_signature+1,CurrentIdMap.length());
- } else {//normal case
- IdMapAttribute = CurrentIdMap.substring(end_of_signature+1,end_of_attribute);
- String IdMapExtension= CurrentIdMap.substring(end_of_attribute+1,CurrentIdMap.length());
- //if extension already associated, do not associate with this idmap
- if (!IdMapExtension.equals("") && !fIdExtensionToName.containsKey(IdMapExtension)) { //$NON-NLS-1$
- fIdExtensionToName.put(IdMapExtension,IdMapName);
- CompareUI.addStructureViewerAlias(DEFAULT_PREFIX, IdMapExtension);
- }
- }
-
- if (fIdMaps.containsKey(IdMapName)) {
- HashMap Mappings = (HashMap) fIdMaps.get(IdMapName);
- Mappings.put(IdMapSignature,IdMapAttribute);
- } else {
- HashMap Mappings = new HashMap();
- Mappings.put(IdMapSignature,IdMapAttribute);
- fIdMaps.put(IdMapName,Mappings);
- }
- start = end+1;
- end = IdMapPrefValue.indexOf(IDMAP_SEPARATOR,end+1);
- }
-
- fOrderedElements= new HashMap();
- String OrderedPrefValue= fPrefStore.getString(ORDERED_PREFERENCE_NAME);
- StringTokenizer orderedTokens= new StringTokenizer(OrderedPrefValue, (new Character(ORDERED_FIELDS_SEPARATOR)).toString());
- while (orderedTokens.hasMoreTokens()) {
- String IdMapName= orderedTokens.nextToken();
- String signature= orderedTokens.nextToken();
- if (fOrderedElements.containsKey(IdMapName)) {
- ArrayList idmapAL= (ArrayList) fOrderedElements.get(IdMapName);
- idmapAL.add(signature);
- } else {
- ArrayList idmapAL= new ArrayList();
- idmapAL.add(signature);
- fOrderedElements.put(IdMapName, idmapAL);
- }
- }
-
- }
-
- /*
- * Updates the user Id Mappings, the IdExtensionToName mappings and refreshes the preference store.
- * @param IdMap the new Id Mappings
- * @param IdExtensionToName the new IdExtensionToName mappings
- * @param refresh whether all the open StructureViewers should be refreshed with the new IdMapping settings
- */
- public void setIdMaps(HashMap IdMap, HashMap IdExtensionToName, HashMap OrderedElements, boolean refresh) {
- fIdMaps = IdMap;
- if (IdExtensionToName != null && !IdExtensionToName.equals(fIdExtensionToName)) {
- CompareUI.removeAllStructureViewerAliases(DEFAULT_PREFIX);
- fIdExtensionToName= IdExtensionToName;
- Set newkeySet= fIdExtensionToName.keySet();
- for (Iterator iter= newkeySet.iterator(); iter.hasNext(); ) {
- String extension= (String)iter.next();
- CompareUI.addStructureViewerAlias(DEFAULT_PREFIX, extension);
- }
- }
- StringBuffer IdMapPrefValue = new StringBuffer();
- Set idmapKeys = fIdMaps.keySet();
- for (Iterator iter_idmap = idmapKeys.iterator(); iter_idmap.hasNext(); ) {
- String IdMapName = (String) iter_idmap.next();
- HashMap idmapHM = (HashMap) fIdMaps.get(IdMapName);
- Set mappingKeys = idmapHM.keySet();
- String extension= ""; //$NON-NLS-1$
- if (fIdExtensionToName.containsValue(IdMapName)) {
- Set keySet= fIdExtensionToName.keySet();
- for (Iterator iter= keySet.iterator(); iter.hasNext(); ) {
- extension= (String)iter.next();
- if ( ((String)fIdExtensionToName.get(extension)).equals(IdMapName) )
- break;
- }
- }
- for (Iterator iter_mapping = mappingKeys.iterator(); iter_mapping.hasNext(); ) {
- String signature = (String) iter_mapping.next();
- IdMapPrefValue.append(IdMapName+IDMAP_FIELDS_SEPARATOR+signature+IDMAP_FIELDS_SEPARATOR+idmapHM.get(signature)+IDMAP_FIELDS_SEPARATOR+extension+IDMAP_SEPARATOR);
- }
- }
- fPrefStore.setValue(IDMAP_PREFERENCE_NAME,IdMapPrefValue.toString());
- //fPrefStore.setValue(IDMAP_PREFERENCE_NAME,"");
-
- //stores OrderedElements
- if (OrderedElements != null) {
- fOrderedElements= OrderedElements;
- StringBuffer OrderedPrefValue= new StringBuffer();
- Set orderedKeys= fOrderedElements.keySet();
- for (Iterator iter_ordered= orderedKeys.iterator(); iter_ordered.hasNext();) {
- String IdMapName= (String) iter_ordered.next();
- ArrayList idmapAL= (ArrayList) fOrderedElements.get(IdMapName);
- for (Iterator iter_idmapAL= idmapAL.iterator(); iter_idmapAL.hasNext();) {
- String signature= (String) iter_idmapAL.next();
- OrderedPrefValue.append(IdMapName+ORDERED_FIELDS_SEPARATOR+signature+ORDERED_FIELDS_SEPARATOR);
- }
- }
- fPrefStore.setValue(ORDERED_PREFERENCE_NAME,OrderedPrefValue.toString());
- //fPrefStore.setValue(ORDERED_PREFERENCE_NAME,"");
- }
-
- if (refresh) {
- Object[] viewers = fViewers.getListeners();
- for (int i = 0; i < viewers.length; ++i) {
- XMLStructureViewer viewer = (XMLStructureViewer) viewers[i];
- viewer.updateIdMaps();
- viewer.contentChanged();
- }
- }
- }
-
- public HashMap getIdMaps() {
- return fIdMaps;
- }
-
- public HashMap getIdMapsInternal() {
- return fIdMapsInternal;
- }
-
- public HashMap getIdExtensionToName() {
- return fIdExtensionToName;
- }
-
- public HashMap getOrderedElements() {
- return fOrderedElements;
- }
-
- public HashMap getOrderedElementsInternal() {
- return fOrderedElementsInternal;
- }
-
- /**
- * Registers all internal Id Mapping schemes
- * that are found in plugin.xml files.
- */
- private void registerExtensions() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
-
- // collect all Id Mappings
- IConfigurationElement[] idmaps= registry.getConfigurationElementsFor(PLUGIN_ID, ID_MAPPING_EXTENSION_POINT);
- fIdMapsInternal = new HashMap();
- fOrderedElementsInternal= new HashMap();
- for (int i_idmap= 0; i_idmap < idmaps.length; i_idmap++) {
- final IConfigurationElement idmap= idmaps[i_idmap];
- //handle IDMAP_NAME_ATTRIBUTE
- String idmap_name= idmap.getAttribute(IDMAP_NAME_ATTRIBUTE);
- //ignores idmap if its name equals the reserved name for unordered matching or the the name for ordered matching
- if ( !idmap_name.equals(XMLStructureCreator.USE_UNORDERED) && !idmap_name.equals(XMLStructureCreator.USE_ORDERED) ) {
- //handle mappings
- HashMap idmapHM = new HashMap();
- fIdMapsInternal.put(idmap_name, idmapHM);
- IConfigurationElement[] mappings = idmap.getChildren(MAPPING_ELEMENT_NAME);
- for (int i_mapping= 0; i_mapping < mappings.length; i_mapping++) {
- IConfigurationElement mapping = mappings[i_mapping];
- //add SIGN_SEPARATOR at the end because not contained in signatures of plugin.xml
- //also add prefix at beginning
- String signature= mapping.getAttribute(MAPPING_SIGNATURE_ATTRIBUTE);
- String attribute= mapping.getAttribute(MAPPING_ID_ATTRIBUTE);
- String idsource= mapping.getAttribute(MAPPING_ID_SOURCE);
- String bodyid= ""; //$NON-NLS-1$
- if (signature != null && !signature.equals("") //$NON-NLS-1$
- && attribute != null && !attribute.equals("")) { //$NON-NLS-1$
- if (idsource != null && idsource.equals(MAPPING_ID_SOURCE_BODY))
- bodyid= (new Character(XMLStructureCreator.ID_TYPE_BODY)).toString();
- idmapHM.put(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR
- + signature + XMLStructureCreator.SIGN_SEPARATOR, bodyid + attribute);
- }
- }
- //handles ordered entries
- IConfigurationElement[] orderedEntries= idmap.getChildren(ORDERED_ELEMENT_NAME);
- if (orderedEntries.length > 0) {
- ArrayList orderedAL= new ArrayList();
- for (int i_ordered= 0; i_ordered < orderedEntries.length; i_ordered++) {
- IConfigurationElement ordered= orderedEntries[i_ordered];
- //add SIGN_SEPARATOR at the end because not contained in signatures of plugin.xml
- //also add prefix at beginning
- String signature= ordered.getAttribute(ORDERED_SIGNATURE_ATTRIBUTE);
- if (signature != null && !signature.equals("")) //$NON-NLS-1$
- orderedAL.add(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + signature + XMLStructureCreator.SIGN_SEPARATOR);
- }
- if (orderedAL.size() > 0)
- fOrderedElementsInternal.put(idmap_name, orderedAL);
- }
- //handle EXTENSION_NAME_ATTRIBUTE
- String ext_name= idmap.getAttribute(EXTENSION_NAME_ATTRIBUTE);
- if (ext_name != null && !fIdExtensionToName.containsKey(ext_name)) {
- ext_name= ext_name.toLowerCase();
- fIdExtensionToName.put(ext_name,idmap_name);
- CompareUI.addStructureViewerAlias(DEFAULT_PREFIX, ext_name);
- }
- }
- }
- }
-
- public ListenerList getViewers() {
- return fViewers;
- }
-
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window= getActiveWorkbenchWindow();
- if (window != null)
- return window.getShell();
- return null;
- }
-
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- IWorkbenchWindow window= fgXMLPlugin.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- final WindowRef windowRef= new WindowRef();
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- setActiveWorkbenchWindow(windowRef);
- }
- });
- return windowRef.window;
- }
- return window;
- }
-
- private static class WindowRef {
- public IWorkbenchWindow window;
- }
-
- private static void setActiveWorkbenchWindow(WindowRef windowRef) {
- windowRef.window= null;
- Display display= Display.getCurrent();
- if (display == null)
- return;
- Control shell= display.getActiveShell();
- while (shell != null) {
- Object data= shell.getData();
- if (data instanceof IWorkbenchWindow) {
- windowRef.window= (IWorkbenchWindow)data;
- return;
- }
- shell= shell.getParent();
- }
- Shell shells[]= display.getShells();
- for (int i= 0; i < shells.length; i++) {
- Object data= shells[i].getData();
- if (data instanceof IWorkbenchWindow) {
- windowRef.window= (IWorkbenchWindow)data;
- return;
- }
- }
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, "Internal Error", e)); //$NON-NLS-1$
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static String getPluginId() {
- return getDefault().getBundle().getSymbolicName();
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java
deleted file mode 100644
index c6771752e..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java
+++ /dev/null
@@ -1,807 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import java.text.MessageFormat;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.helpers.LocatorImpl;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.compare.IEditableContent;
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
-
-/**
- * This structure analyzer builds a parse tree of an XML document found in a
- * <code>IByteContentAccessor</code> input by calling getStructure(Object)
- */
-public class XMLStructureCreator implements IStructureCreator {
-
- protected static final boolean DEBUG_MODE= false;
-
- public static final String DEFAULT_NAME= XMLCompareMessages.getString("XMLStructureCreator.pluginname"); //$NON-NLS-1$
-
- public static final String USE_UNORDERED= XMLCompareMessages.getString("XMLStructureCreator.unordered"); //$NON-NLS-1$
- public static final String USE_ORDERED= XMLCompareMessages.getString("XMLStructureCreator.ordered"); //$NON-NLS-1$
- public static final String DEFAULT_IDMAP= USE_ORDERED;
-
- public static final String TYPE_ELEMENT= "element"; //$NON-NLS-1$
- public static final String TYPE_TEXT= "text"; //$NON-NLS-1$
- public static final String TYPE_ATTRIBUTE= "attribute"; //$NON-NLS-1$
-
- // for signatures
- public static final String ROOT_ID= "root"; //$NON-NLS-1$
- public static final char SIGN_SEPARATOR= '>';//'.'
- public static final char SIGN_ENCLOSING= '$';
- public static final String SIGN_ELEMENT= SIGN_ENCLOSING + TYPE_ELEMENT + SIGN_ENCLOSING;
- public static final String SIGN_TEXT= SIGN_ENCLOSING + TYPE_TEXT + SIGN_ENCLOSING;
- public static final String SIGN_ATTRIBUTE= SIGN_ENCLOSING + TYPE_ATTRIBUTE + SIGN_ENCLOSING;
-
- public static final String IDMAP_UNORDERED= XMLCompareMessages.getString("XMLStructureCreator.idmap_unordered"); //$NON-NLS-1$
- public static final char ID_SEPARATOR= '<';
- public static final char ID_TYPE_BODY= '<';
-
- private XMLNode fcurrentParent;
- private String fsignature;
- private Document fdoc;
- private boolean ignoreBodies= false;
- private HashMap fIdMapsInternal;
- private HashMap fIdMaps;
- private HashMap fIdExtensionToName;
- private HashMap fOrderedElementsInternal;
- private HashMap fOrderedElements;
- private HashMap idMap;
- private ArrayList fOrdered;
- private String fIdMapToUse;
- private boolean fUseIdMap;
- private String fFileExt;
- private boolean fFirstCall= true;
- private boolean fRemoveWhiteSpace;
-
- protected class XMLHandler extends DefaultHandler {
-
- protected Locator prevlocator; //previous locator
- protected Locator locator; //current locator
-
- public void setDocumentLocator(Locator locator0) {
- this.locator= locator0;
- }
-
- // DocumentHandler methods
-
- /* Processing instruction. */
- public void processingInstruction(String target, String data) {
-
- // System.out.println("target: " + target);
- // System.out.println("data: " + data);
- // System.out.print("<?");
- // System.out.print(target);
- // if (data != null && data.length() > 0) {
- // System.out.print(' ');
- // System.out.print(data);
- // }
- // System.out.print("?>");
- // System.out.flush();
- prevlocator= new LocatorImpl(locator);
- }
-
- /** Start document. */
- public void startDocument() {
- prevlocator= new LocatorImpl(locator);
- }
-
- /* Start element. */
- public void startElement(String uri, String local, String raw, Attributes attrs) {
- XMLNode currentElement;
-
- /* add root node for this element */
-
- if (XMLStructureCreator.DEBUG_MODE) {
- if (locator != null && prevlocator != null) {
- System.out.println("prevlocator: line " + prevlocator.getLineNumber() + " column " + prevlocator.getColumnNumber() + " id " + prevlocator.getPublicId()); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- System.out.println("locator: line " + locator.getLineNumber() + " column " + locator.getColumnNumber() + " id " + locator.getPublicId()); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- try {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Node where children field accessed: " + fcurrentParent.getId()); //$NON-NLS-1$
- XMLChildren currentParent= (XMLChildren) fcurrentParent;
- currentParent.children++;
- String elementId;
- String elementName;
- IRegion r= fdoc.getLineInformation(prevlocator.getLineNumber() - 1);
-
- String parentSig= fsignature;
- fsignature= fsignature + raw + SIGN_SEPARATOR;
-
- if (isUseIdMap() && idMap.containsKey(fsignature)) {
- String attrName= (String) idMap.get(fsignature);
- elementId= raw + new Character(ID_SEPARATOR) + attrs.getValue(attrName);
- elementName= raw + " [" + attrName + "=" + attrs.getValue(attrName) + "]"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- } else {
- if (!currentParent.childElements.containsKey(raw)) {
- currentParent.childElements.put(raw, new Integer(1));
- } else {
- currentParent.childElements.put(raw, new Integer(((Integer) currentParent.childElements.get(raw)).intValue() + 1));
- }
- elementId= raw + new Character(ID_SEPARATOR) + "[" + currentParent.childElements.get(raw) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
- elementName= MessageFormat.format("{0} [{1}]", new String[] { raw, currentParent.childElements.get(raw).toString()}); //$NON-NLS-2$ //$NON-NLS-1$
- }
- int start= r.getOffset() + prevlocator.getColumnNumber() - 1;
- if (start < 0)
- start= 0;
- currentElement= new XMLChildren(TYPE_ELEMENT, elementId, elementId, (fsignature + SIGN_ELEMENT), fdoc, start, 0);
- currentElement.setName(elementName);
- if (isUseIdMap() && idMap.containsKey(fsignature))
- currentElement.setUsesIDMAP(true);
- if (fOrdered != null && fOrdered.contains(parentSig))
- currentElement.setIsOrderedChild(true);
-
- fcurrentParent.addChild(currentElement);
- currentElement.setParent(fcurrentParent);
- fcurrentParent= currentElement;
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("\nAdded Element " + raw + " with offset " + r.getOffset()); //$NON-NLS-2$ //$NON-NLS-1$
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("fcurrentParent1: " + fcurrentParent.getId()); //$NON-NLS-1$
-
- if (attrs != null) {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("attrs != null, fcurrentParent is " + fcurrentParent.getId()); //$NON-NLS-1$
- //attrs = sortAttributes(attrs);
- int len= attrs.getLength();
- int element_lines_length_size;
- int[] element_lines_length;
- int column_offset;
- String element_string;
- if (fcurrentParent.getParent().getId().equals(ROOT_ID)) {
- element_lines_length_size= locator.getLineNumber() - prevlocator.getLineNumber();
- element_lines_length= new int[element_lines_length_size];
- column_offset= 0;
- element_string= ""; //$NON-NLS-1$
- for (int i_ell= 0; i_ell < element_lines_length.length; i_ell++) {
- IRegion attr_r= fdoc.getLineInformation(i_ell + prevlocator.getLineNumber());
- element_lines_length[i_ell]= fdoc.get(attr_r.getOffset(), attr_r.getLength()).length() + 1;
- element_string= element_string + fdoc.get(attr_r.getOffset(), attr_r.getLength()) + " "; //$NON-NLS-1$
- }
- } else {
- element_lines_length_size= locator.getLineNumber() - prevlocator.getLineNumber() + 1;
- //if (element_lines_length_size < 1)
- // element_lines_length_size = 1;
- element_lines_length= new int[element_lines_length_size];
- IRegion first_line= fdoc.getLineInformation(prevlocator.getLineNumber() - 1);
- column_offset= prevlocator.getColumnNumber() - 1;
- int first_line_relevant_offset= first_line.getOffset() + column_offset;
- int first_line_relevant_length= first_line.getLength() - column_offset;
- element_string= fdoc.get(first_line_relevant_offset, first_line_relevant_length) + " "; //$NON-NLS-1$
- element_lines_length[0]= element_string.length();
- for (int i_ell= 1; i_ell < element_lines_length.length; i_ell++) {
- IRegion attr_r= fdoc.getLineInformation(i_ell + prevlocator.getLineNumber() - 1);
- element_lines_length[i_ell]= fdoc.get(attr_r.getOffset(), attr_r.getLength()).length() + 1;
- element_string= element_string + fdoc.get(attr_r.getOffset(), attr_r.getLength()) + " "; //$NON-NLS-1$
- }
- }
-
- for (int i_attr= 0; i_attr < len; i_attr++) {
- String attr_name= attrs.getQName(i_attr);
- String attr_value= attrs.getValue(i_attr);
-
- /*
- * find range of attribute in doc; manually parses the
- * line
- */
- boolean found= false;
- int first_quotes= -1;
- int second_quotes= -1;
- int id_index= -1;
- while (!found) {
- first_quotes= element_string.indexOf("\"", second_quotes + 1); //$NON-NLS-1$
- second_quotes= element_string.indexOf("\"", first_quotes + 1); //$NON-NLS-1$
- String value;
- try {
- value= element_string.substring(first_quotes + 1, second_quotes);
- } catch (Exception e) {
- value= ""; //$NON-NLS-1$
- }
- if (value.equals("")) //$NON-NLS-1$
- found= true;
- else if (value.equals(attr_value)) {
- id_index= element_string.lastIndexOf(attr_name, first_quotes - 1);
- boolean wrong= false;
- boolean found_equal= false;
- for (int i_char= id_index + attr_name.length(); i_char < first_quotes && !wrong; i_char++) {
- if (element_string.charAt(i_char) == '=')
- if (!found_equal)
- found_equal= true;
- else
- wrong= true;
- else if (!Character.isWhitespace(element_string.charAt(i_char)))
- wrong= true;
- }
- if (!wrong)
- found= true;
- }
- }
- //id_index has one char missing for every line (the
- // final cr)
- int line_of_index= 0;
- for (line_of_index= 0; id_index > element_lines_length[line_of_index] - 1; line_of_index++)
- id_index-= (element_lines_length[line_of_index]);
- if (line_of_index == 0)
- id_index+= column_offset;
- if (fcurrentParent.getParent().getId().equals(ROOT_ID))
- line_of_index+= prevlocator.getLineNumber();
- else
- line_of_index+= prevlocator.getLineNumber() - 1;
- //index at line line_of_index, line offset id_index
- int line_of_end_of_value= 0;
- int end_of_value_index= second_quotes;
- for (line_of_end_of_value= 0; end_of_value_index > element_lines_length[line_of_end_of_value] - 1; line_of_end_of_value++)
- end_of_value_index-= (element_lines_length[line_of_end_of_value]);
- if (line_of_end_of_value == 0)
- end_of_value_index+= column_offset;
- if (fcurrentParent.getParent().getId().equals(ROOT_ID))
- line_of_end_of_value+= prevlocator.getLineNumber();
- else
- line_of_end_of_value+= prevlocator.getLineNumber() - 1;
- //end of value at line line_of_end_of_value, line
- // offset end_of_value_index
-
- int attr_start_doc_offset= fdoc.getLineInformation(line_of_index).getOffset() + id_index;
- //int attr_length_doc_offset =
- // fdoc.getLineInformation(line_of_value).getOffset()+value_index+attr_value.length()+1+(line_of_end_of_value-line_of_index)
- // - attr_start_doc_offset;
- int attr_length_doc_offset= fdoc.getLineInformation(line_of_end_of_value).getOffset() + end_of_value_index + 1 - attr_start_doc_offset;
- currentElement= new XMLNode(TYPE_ATTRIBUTE, attr_name, attr_value, (fsignature + attr_name + SIGN_SEPARATOR + SIGN_ATTRIBUTE), fdoc, attr_start_doc_offset, attr_length_doc_offset);
- currentElement.setName(attr_name);
- fcurrentParent.addChild(currentElement);
- currentElement.setParent(fcurrentParent);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("added attribute " + currentElement.getId() + " with value >" + currentElement.getValue() + "<" + " to element " + fcurrentParent.getId() + " which has parent " + fcurrentParent.getParent().getId()); //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- } catch (BadLocationException ex) {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("BadLocationException in startElement(...) " + ex); //$NON-NLS-1$
- currentElement= new XMLChildren(TYPE_ELEMENT, raw + "_(" + ((XMLChildren) fcurrentParent).children + ")", raw + "_(" + ((XMLChildren) fcurrentParent).children + ")", (fsignature + SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- }
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("At the end of startElement(...), fcurrentParent is " + fcurrentParent.getId()); //$NON-NLS-1$
- prevlocator= new LocatorImpl(locator);
- }
-
- /* Characters. */
- public void characters(char ch[], int start, int length) {
- if (!ignoreBodies) {
- // String chars = (new String(ch, start, length)).trim();
- String chars= new String(ch, start, length);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("characters: >" + chars + "<"); //$NON-NLS-2$ //$NON-NLS-1$
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Body Location: line " + locator.getLineNumber() + " column " + locator.getColumnNumber()); //$NON-NLS-2$ //$NON-NLS-1$
-
- //if text contains only white space, it will be ignored.
- if (!trimWhiteSpace(chars).equals("")) { //$NON-NLS-1$
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Adding body"); //$NON-NLS-1$
- try {
- IRegion r= fdoc.getLineInformation(locator.getLineNumber() - 1);
- //location returns the END of the characters
- //offset of BEGINNING of characters:
- int offset= r.getOffset() + locator.getColumnNumber() - 1 - length;
- fcurrentParent.bodies++;
- String body_value= new String(ch, start, length);
- if (fRemoveWhiteSpace) {
- body_value= removeWhiteSpace(body_value);
- }
- XMLNode bodynode= new XMLNode(TYPE_TEXT, "body_(" + fcurrentParent.bodies + ")", body_value, (fsignature + SIGN_TEXT), fdoc, offset, length); //$NON-NLS-2$ //$NON-NLS-1$
- bodynode.setName(MessageFormat.format("{0} ({1})", new String[] { XMLCompareMessages.getString("XMLStructureCreator.body"), Integer.toString(fcurrentParent.bodies)})); //$NON-NLS-2$ //$NON-NLS-1$
- fcurrentParent.addChild(bodynode);
- bodynode.setParent(fcurrentParent);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Created body " + fcurrentParent.bodies //$NON-NLS-1$
- + " with offset " + offset + " and length " + length //$NON-NLS-2$ //$NON-NLS-1$
- + " with parent " + bodynode.getParent().getId()); //$NON-NLS-1$
- //bodies as id attributes
- String popsig= fcurrentParent.getParent().getSignature(); //signature of parent of
- // parent
- popsig= popsig.substring(0, popsig.lastIndexOf(SIGN_ELEMENT));
- if (isUseIdMap() && fcurrentParent.bodies == 1 && idMap.containsKey(popsig)) {
- String pid= fcurrentParent.getId();//id of parent
- String pelementname= pid.substring(0, pid.indexOf("<")); //name of parent element //$NON-NLS-1$
- if (((String) idMap.get(popsig)).equals(ID_TYPE_BODY + pelementname)) {
- XMLNode pop= fcurrentParent.getParent();
- String popid= pop.getId();
- String popelementname= popid.substring(0, popid.indexOf("<")); //$NON-NLS-1$
- pop.setId(popelementname + "<" + body_value); //$NON-NLS-1$
- pop.setOrigId(popelementname + "<" + body_value); //$NON-NLS-1$
- pop.setName(MessageFormat.format("{0} [{1}={2}]", new String[] { popelementname, pelementname, body_value})); //$NON-NLS-1$
- pop.setUsesIDMAP(true);
- }
- }
- } catch (BadLocationException ex) {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("BadLocationException in characters(...) " + ex); //$NON-NLS-1$
- fcurrentParent.addChild(new XMLNode(TYPE_TEXT, "body_(" + fcurrentParent.bodies + ")", new String(ch, start, length), (fsignature + SIGN_TEXT), fdoc, 0, 0)); //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- }
- prevlocator= new LocatorImpl(locator);
- }
-
- /* Ignorable whitespace. */
- public void ignorableWhitespace(char ch[], int start, int length) {
- //
- //// characters(ch, start, length);
- //// System.out.flush();
- //
- prevlocator= new LocatorImpl(locator);
- }
-
- /* End element. */
- public void endElement(String uri, String local, String raw) {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("\nExiting element " + fcurrentParent.getId()); //$NON-NLS-1$
-
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("prevlocator: line " + prevlocator.getLineNumber() + " column " + prevlocator.getColumnNumber() + " id " + prevlocator.getPublicId()); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("locator: line " + locator.getLineNumber() + " column " + locator.getColumnNumber() + " id " + locator.getPublicId()); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- if (fcurrentParent.getParent() != null) {
- try {
- IRegion r2= fdoc.getLineInformation(locator.getLineNumber() - 1);
- Position pos= fcurrentParent.getRange();
-
- int elem_length= r2.getOffset() + locator.getColumnNumber() - 1 - pos.getOffset();//length of element from
- // start tag to end tag
- fcurrentParent.setLength(elem_length);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("pos.getOffset: " + pos.getOffset() + " elem_length: " + elem_length); //$NON-NLS-2$ //$NON-NLS-1$
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("fdoc.get(pos.getOffset()+elem_length-5,4): >" + fdoc.get(pos.getOffset() + elem_length - 5, 4) + "<"); //$NON-NLS-2$ //$NON-NLS-1$
- //if (fdoc.get(pos.getOffset()+elem_length-2,1) != ">")
- // elem_length-=1;
- try {
- fcurrentParent.setValue(fdoc.get(pos.getOffset(), elem_length));
- } catch (BadLocationException ex) {
- try {
- fcurrentParent.setValue(fdoc.get(pos.getOffset(), elem_length - 1));
- } catch (BadLocationException ex2) {
- if (XMLStructureCreator.DEBUG_MODE) {
- System.out.println("BadLocationException in endElement(...) while attempting fcurrentParent.setValue(...): " + ex); //$NON-NLS-1$
- System.out.println("Attempt to correct BadLocationException failed: " + ex2); //$NON-NLS-1$
- }
- }
- }
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Value of " + fcurrentParent.getId() + " is >" + fcurrentParent.getValue() + "<"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
-
- //going from ending element to parent element
- fcurrentParent= fcurrentParent.getParent();
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("fcurrentParent = fcurrentParent.getParent();"); //$NON-NLS-1$
- } catch (BadLocationException ex) {
- if (XMLStructureCreator.DEBUG_MODE) {
- System.out.println("BadLocationException in endElement(...): " + ex); //$NON-NLS-1$
- System.out.println("fcurrentParent.getId(): " + fcurrentParent.getId()); //$NON-NLS-1$
- }
- }
- } else {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Error: Cannot reach Parent of Parent"); //$NON-NLS-1$
- }
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("fcurrentParent is now " + fcurrentParent.getId()); //$NON-NLS-1$
-
- prevlocator= new LocatorImpl(locator);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Signature before cutting: " + fsignature); //$NON-NLS-1$
- int ssi= fsignature.lastIndexOf(SIGN_SEPARATOR);//fsignature
- // separator index
- ssi= fsignature.lastIndexOf(SIGN_SEPARATOR, ssi - 1);//second-last
- // ".", e.g. in
- // root.a.b. to
- // obtain
- // root.a.
- fsignature= fsignature.substring(0, ssi + 1);
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Signature after cutting: " + fsignature); //$NON-NLS-1$
- }
-
- //
- // ErrorHandler methods
- //
-
- /* Warning. */
- public void warning(SAXParseException ex) {
- System.err.println("[Warning] " + //$NON-NLS-1$
- getLocationString(ex) + ": " + //$NON-NLS-1$
- ex.getMessage());
- }
-
- /* Error. */
- public void error(SAXParseException ex) {
- System.err.println("[Error] " + //$NON-NLS-1$
- getLocationString(ex) + ": " + //$NON-NLS-1$
- ex.getMessage());
- }
-
- /* Fatal error. */
- public void fatalError(SAXParseException ex) throws SAXException {
- System.err.println("[Fatal Error] " + //$NON-NLS-1$
- getLocationString(ex) + ": " + //$NON-NLS-1$
- ex.getMessage());
- //System.out.println(ex);
- //throw ex;
- }
-
- /* Returns a string of the location. */
- private String getLocationString(SAXParseException ex) {
- StringBuffer str= new StringBuffer();
-
- String systemId= ex.getSystemId();
- if (systemId != null) {
- int index= systemId.lastIndexOf('/');
- if (index != -1)
- systemId= systemId.substring(index + 1);
- str.append(systemId);
- }
- str.append(':');
- str.append(ex.getLineNumber());
- str.append(':');
- str.append(ex.getColumnNumber());
-
- return str.toString();
-
- }
- }
-
- public XMLStructureCreator() {
- //set default idmap
- fIdMapToUse= DEFAULT_IDMAP;
- fUseIdMap= false;
- XMLPlugin plugin= XMLPlugin.getDefault();
- //if statement required for tests
- if (plugin != null) {
- fIdMaps= plugin.getIdMaps();
- fIdMapsInternal= plugin.getIdMapsInternal();
- fIdExtensionToName= plugin.getIdExtensionToName();
- fOrderedElements= plugin.getOrderedElements();
- fOrderedElementsInternal= plugin.getOrderedElementsInternal();
- }
- fRemoveWhiteSpace= false;
- }
-
- /*
- * This title will be shown in the title bar of the structure compare pane.
- */
- public String getName() {
- return DEFAULT_NAME;
- }
-
- /*
- * Set File extension of the parsed file. This extension will be used to choose an Id Map scheme.
- */
- public void setFileExtension(String ext) {
- fFileExt= ext;
- }
-
- /**
- * Initialize the Id Mappings for the Id Mapping Scheme and the Ordered Elements
- * This method must be called before getStructure(Object) is called on the two/three inputs of the compare
- */
- public void initIdMaps() {
- if (fFirstCall && fFileExt != null) {
- fFirstCall= false;
- String fileExtLower= fFileExt.toLowerCase();
- if (fIdExtensionToName.containsKey(fileExtLower))
- setIdMap((String) fIdExtensionToName.get(fileExtLower));
- }
-
- setUseIdMap();
- fOrdered= null;
- if (!isUseIdMap())
- idMap= null;
- else if (fIdMaps.containsKey(fIdMapToUse)) {
- idMap= (HashMap) fIdMaps.get(fIdMapToUse);
- } else if (fIdMapsInternal.containsKey(fIdMapToUse)) {
- idMap= (HashMap) fIdMapsInternal.get(fIdMapToUse);
- }
-
- if (fOrderedElements != null)
- fOrdered= (ArrayList) fOrderedElements.get(fIdMapToUse);
- if (fOrdered == null && fOrderedElementsInternal != null)
- fOrdered= (ArrayList) fOrderedElementsInternal.get(fIdMapToUse);
- }
-
- /*
- * Returns the XML parse tree of the input.
- */
- public IStructureComparator getStructure(Object input) {
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("Starting parse"); //$NON-NLS-1$
-
- if (!(input instanceof IStreamContentAccessor))
- return null;
-
- IStreamContentAccessor sca= (IStreamContentAccessor) input;
-
- try {
- // Input parsed with parser.parse(new InputSource(sca.getContents));
-
- String contents= readString(sca);
- if (contents == null)
- contents= ""; //$NON-NLS-1$
- fdoc= new Document(contents);
-
- fsignature= ROOT_ID + SIGN_SEPARATOR;
- XMLChildren root= new XMLChildren(TYPE_ELEMENT, ROOT_ID, "", (fsignature + SIGN_ELEMENT), fdoc, 0, fdoc.getLength()); //$NON-NLS-1$
- fcurrentParent= root;
-
- XMLHandler handler= new XMLHandler();
-
- try {
- // /* original xerces code
- // SAXParser parser = (SAXParser)Class.forName(parserName).newInstance();
- // */
- // XMLReader parser = XMLReaderFactory.createXMLReader(parserName);
- //
- // parser.setFeature( "http://xml.org/sax/features/validation", setValidation); //$NON-NLS-1$
- // parser.setFeature( "http://xml.org/sax/features/namespaces", setNameSpaces ); //$NON-NLS-1$
- // /*
- // parser.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$
- // parser.setFeature( "http://apache.org/xml/features/validation/schema", setSchemaSupport ); //$NON-NLS-1$
- // parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", setSchemaFullSupport); //$NON-NLS-1$
- // */
- // parser.setContentHandler(handler);
- // parser.setErrorHandler(handler);
- //
- // parser.parse(new InputSource(sca.getContents()));
-
- SAXParserFactory factory= SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- SAXParser parser= factory.newSAXParser();
- parser.parse(new InputSource(new StringReader(contents)), handler);
-
- if (XMLStructureCreator.DEBUG_MODE)
- System.out.println("End of parse"); //$NON-NLS-1$
- } catch (SAXParseException e) {
- XMLPlugin.log(e);
- return null;
- } catch (Exception e) {
- // MessageDialog.openError(XMLPlugin.getActiveWorkbenchShell(),"Error in XML parser","An error occured in the XML parser.\nNo structured compare can be shown");
- XMLPlugin.log(e);
- return null;
- }
- return root;
- } catch (CoreException ex) {
- XMLPlugin.log(ex);
- }
- return null;
- }
-
- public boolean canSave() {
- return true;
- }
-
- public boolean canRewriteTree() {
- return false;
- }
-
- public void rewriteTree(Differencer differencer, IDiffContainer root) {
- // nothing to do
- }
-
- public void save(IStructureComparator structure, Object input) {
- if (input instanceof IEditableContent && structure instanceof XMLNode) {
- IDocument document= ((XMLNode) structure).getDocument();
- IEditableContent bca= (IEditableContent) input;
- String contents= document.get();
- String encoding= null;
- if (input instanceof IEncodedStreamContentAccessor) {
- try {
- encoding= ((IEncodedStreamContentAccessor)input).getCharset();
- } catch (CoreException e1) {
- // ignore
- }
- }
- if (encoding == null)
- encoding= "UTF-8"; //$NON-NLS-1$
- try {
- bca.setContent(contents.getBytes(encoding));
- } catch (UnsupportedEncodingException e) {
- bca.setContent(contents.getBytes());
- }
- }
- }
-
- public String getContents(Object node, boolean ignoreWhitespace) {
- if (node instanceof XMLNode) {
- String s= ((XMLNode) node).getValue();
- if (ignoreWhitespace)
- s= s.trim();
- return s;
- }
- return null;
- }
-
- public IStructureComparator locate(Object path, Object source) {
- return null;
- }
-
- 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= "UTF-8"; //$NON-NLS-1$
- return readString(is, encoding);
- }
-
- /*
- * Returns null if an error occurred.
- */
- private 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;
- }
-
- /* Returns a sorted list of attributes.
- */
- protected Attributes sortAttributes(Attributes attrs) {
-
- AttributesImpl attributes= new AttributesImpl();
- int len= (attrs != null) ? attrs.getLength() : 0;
- for (int i= 0; i < len; i++) {
- String name= attrs.getQName(i);
- int count= attributes.getLength();
- int j= 0;
- while (j < count) {
- if (name.compareTo(attributes.getQName(j)) < 0)
- break;
- j++;
- }
- attributes.insertAttributeAt(j, name, attrs.getType(i), attrs.getValue(i));
- }
-
- return attributes;
-
- }
-
- public void setIdMap(String idmap_name) {
- fIdMapToUse= idmap_name;
- }
-
- /*
- * Returns the name of the IdMap Scheme that will be used to set ids.
- */
- public String getIdMap() {
- return fIdMapToUse;
- }
-
- public void setUseIdMap() {
- if (fIdMaps != null && fIdMapsInternal != null)
- fUseIdMap= fIdMaps.containsKey(fIdMapToUse) || fIdMapsInternal.containsKey(fIdMapToUse);
- }
-
- public boolean isUseIdMap() {
- return fUseIdMap;
- }
-
- public void updateIdMaps() {
- fIdMaps= XMLPlugin.getDefault().getIdMaps();
- fOrderedElements= XMLPlugin.getDefault().getOrderedElements();
- }
-
- protected boolean isWhiteSpace(char c) {
- return c == '\t' || c == '\n' || c == '\r' || c == ' ';
- }
-
- protected String removeWhiteSpace(String str) {
- str= trimWhiteSpace(str);
- StringBuffer retStr= new StringBuffer();
- int start= 0, end= 0;
- outer_while: while (true) {
- while (end < str.length() && !isWhiteSpace(str.charAt(end))) {
- end++;
- }
- if (end > str.length())
- break outer_while;
- if (start != 0)
- retStr.append(' ');
- retStr.append(str.substring(start, end));
- end++;
- while (end < str.length() && isWhiteSpace(str.charAt(end))) {
- end++;
- }
- start= end;
- }
- return retStr.toString();
- }
-
- protected String trimWhiteSpace(String str) {
- int start= 0, end= str.length() - 1;
- while (start < str.length() && isWhiteSpace(str.charAt(start))) {
- start++;
- }
- if (start == str.length())
- return ""; //$NON-NLS-1$
- while (end >= 0 && isWhiteSpace(str.charAt(end))) {
- end--;
- }
- return str.substring(start, end + 1);
- }
-
- public void setRemoveWhiteSpace(boolean removeWhiteSpace) {
- fRemoveWhiteSpace= removeWhiteSpace;
- }
-
- public boolean getRemoveWhiteSpace() {
- return fRemoveWhiteSpace;
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java
deleted file mode 100644
index d81a533a4..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml;
-
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * An XML diff tree viewer that can be configured with a <code>IStructureCreator</code>
- * to retrieve a hierarchical structure from the input object (an <code>ICompareInput</code>)
- * and perform a two-way or three-way compare on it.
- * <p>
- * This class may be instantiated; it is not intended to be subclassed outside
- * this package.
- * </p>
- *
- * @see ICompareInput
- */
-public class XMLStructureViewer extends StructureDiffViewer {
-
- private CompareViewerSwitchingPane fParent;
-
- private HashMap fIdMapsInternal;
- private HashMap fIdMaps;
- private HashMap fOrderedElementsInternal;
- private HashMap fOrderedElements;
-
- protected static final char SIGN_SEPARATOR=
- XMLStructureCreator.SIGN_SEPARATOR;
-
- class XMLSorter extends ViewerSorter {
-
- ArrayList fOrdered;
- boolean fAlwaysOrderSort;
-
- public XMLSorter() {
- super();
- fAlwaysOrderSort= false;
- }
-
- public void setOrdered(ArrayList ordered) {
- fOrdered= ordered;
- }
-
- public void setAlwaysOrderSort(boolean alwaysOrderSort) {
- fAlwaysOrderSort= alwaysOrderSort;
- }
-
- public int category(Object node) {
- if (node instanceof DiffNode) {
- Object o= ((DiffNode) node).getId();
- if (o instanceof XMLNode) {
- String xmlType= ((XMLNode) o).getXMLType();
- if (xmlType.equals(XMLStructureCreator.TYPE_ATTRIBUTE))
- return 1;
- if (xmlType.equals(XMLStructureCreator.TYPE_ELEMENT))
- return 2;
- if (xmlType.equals(XMLStructureCreator.TYPE_TEXT))
- return 2;
- }
- }
- return 0;
- }
-
- public void sort(final Viewer viewer, Object[] elements) {
- if ((fOrdered != null || fAlwaysOrderSort)
- && elements != null
- && elements.length > 0
- && elements[0] instanceof DiffNode) {
- Object o= ((DiffNode) elements[0]).getId();
- if (o instanceof XMLNode) {
- XMLNode parent= ((XMLNode) o).getParent();
- String sig= parent.getSignature();
- if (sig.endsWith(XMLStructureCreator.SIGN_ELEMENT)) {
- String newSig=
- sig.substring(
- 0,
- sig.length()
- - XMLStructureCreator.SIGN_ELEMENT.length());
- if (fAlwaysOrderSort || fOrdered.contains(newSig)) {
- final ArrayList originalTree=
- new ArrayList(
- Arrays.asList(parent.getChildren()));
- Arrays.sort(elements, new Comparator() {
- public int compare(Object a, Object b) {
- return XMLSorter.this.compare(
- (DiffNode) a,
- (DiffNode) b,
- originalTree);
- }
- });
- return;
- }
- }
- }
- }
- super.sort(viewer, elements);
- }
-
- private int compare(DiffNode a, DiffNode b, ArrayList originalTree) {
-
- int index_a= originalTree.indexOf(a.getId());
- int index_b= originalTree.indexOf(b.getId());
- if (index_a < index_b)
- return -1;
- return 1;
- }
- }
-
- /**
- * 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 XMLStructureViewer(Tree tree, CompareConfiguration configuration) {
- super(tree, configuration);
- 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 XMLStructureViewer(
- Composite parent,
- CompareConfiguration configuration) {
- super(parent, configuration);
- if (parent instanceof CompareViewerSwitchingPane) {
- fParent= (CompareViewerSwitchingPane) parent;
- }
- initialize();
- }
-
- private void initialize() {
- setStructureCreator(new XMLStructureCreator());
- XMLPlugin plugin= XMLPlugin.getDefault();
-
- plugin.getViewers().add(this);
-
- fIdMaps= plugin.getIdMaps();
- fIdMapsInternal= plugin.getIdMapsInternal();
- fOrderedElements= plugin.getOrderedElements();
- fOrderedElementsInternal= plugin.getOrderedElementsInternal();
-
- XMLSorter sorter= new XMLSorter();
- setSorter(sorter);
-
- }
-
- protected XMLStructureCreator getXMLStructureCreator() {
- return (XMLStructureCreator) getStructureCreator();
- }
-
- /* (non Javadoc)
- * Overridden to unregister all listeners.
- */
- protected void handleDispose(DisposeEvent event) {
-
- XMLPlugin.getDefault().getViewers().remove(this);
-
- super.handleDispose(event);
- }
-
- /*
- * Recreates the comparable structures for the input sides.
- */
- protected void compareInputChanged(ICompareInput input) {
- if (input != null) {
- ITypedElement t= input.getLeft();
- if (t != null) {
- String fileExtension= t.getType();
- getXMLStructureCreator().setFileExtension(fileExtension);
- }
- }
-
- getXMLStructureCreator().initIdMaps();
- super.compareInputChanged(input);
-
- if (input != null && fParent.getTitleArgument() == null)
- appendToTitle(getXMLStructureCreator().getIdMap());
- }
-
- /**
- * Calls <code>diff</code> whenever the byte contents changes.
- */
- protected void contentChanged() {
- fIdMaps= XMLPlugin.getDefault().getIdMaps();
- fOrderedElements= XMLPlugin.getDefault().getOrderedElements();
- getXMLStructureCreator().updateIdMaps();
- if (isIdMapRemoved()) {
- getXMLStructureCreator().setIdMap(
- XMLStructureCreator.DEFAULT_IDMAP);
- }
-
- getXMLStructureCreator().initIdMaps();
-
- contentChanged(null);
-
- if (fParent.getTitleArgument() == null)
- appendToTitle(getXMLStructureCreator().getIdMap());
-
- }
-
- public IRunnableWithProgress getMatchingRunnable(
- final XMLNode left,
- final XMLNode right,
- final XMLNode ancestor) {
- return new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws
- InvocationTargetException,
- InterruptedException,
- OperationCanceledException {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- int totalWork;
- if (ancestor != null)
- totalWork= 1;
- else
- totalWork= 3;
- monitor.beginTask(XMLCompareMessages.getString("XMLStructureViewer.matching.beginTask"), totalWork); //$NON-NLS-1$
- ArrayList ordered= null;
- if (!getXMLStructureCreator()
- .getIdMap()
- .equals(XMLStructureCreator.USE_UNORDERED)
- && !getXMLStructureCreator().getIdMap().equals(
- XMLStructureCreator.USE_ORDERED)) {
- ordered=
- (ArrayList) fOrderedElements.get(
- getXMLStructureCreator().getIdMap());
- if (ordered == null)
- ordered=
- (ArrayList) fOrderedElementsInternal.get(
- getXMLStructureCreator().getIdMap());
- }
- if (getSorter() instanceof XMLSorter)
- ((XMLSorter) getSorter()).setOrdered(ordered);
- AbstractMatching m= null;
- if (getXMLStructureCreator()
- .getIdMap()
- .equals(XMLStructureCreator.USE_ORDERED)) {
- m= new OrderedMatching();
- if (getSorter() instanceof XMLSorter)
- ((XMLSorter) getSorter()).setAlwaysOrderSort(true);
- }
- try {
- if (m != null) {
- m.match(left, right, false, monitor);
- if (ancestor != null) {
- m.match(
- left,
- ancestor,
- true,
- new SubProgressMonitor(monitor, 1));
- m.match(
- right,
- ancestor,
- true,
- new SubProgressMonitor(monitor, 1));
- }
- // } catch (InterruptedException e) {
- // System.out.println("in run");
- // e.printStackTrace();
- }
- } finally {
- monitor.done();
- }
- }
- };
- }
-
- protected void preDiffHook(
- IStructureComparator ancestor,
- IStructureComparator left,
- IStructureComparator right) {
- // if (!xsc.getIdMap().equals(XMLStructureCreator.USE_ORDERED)) {
- //TimeoutContext.run(true, TIMEOUT, getControl().getShell(), runnable);
- if (left != null && right != null) {
- try {
- PlatformUI.getWorkbench().getProgressService().run(true, true,
- //TimeoutContext.run(true, 500, XMLPlugin.getActiveWorkbenchShell(),
- getMatchingRunnable(
- (XMLNode) left,
- (XMLNode) right,
- (XMLNode) ancestor));
- } catch (Exception e) {
- XMLPlugin.log(e);
- }
- }
- }
-
- /**
- * Overriden to create buttons in the viewer's pane control bar.
- * <p>
- *
- * @param toolBarManager the toolbar manager for which to add the buttons
- */
- protected void createToolItems(ToolBarManager toolBarManager) {
- super.createToolItems(toolBarManager);
- toolBarManager.appendToGroup("modes", new ChooseMatcherDropDownAction(this)); //$NON-NLS-1$
- toolBarManager.appendToGroup("modes", new CreateNewIdMapAction(this)); //$NON-NLS-1$
- }
-
- /**
- * Overriden to create a context menu.
- * <p>
- *
- * @param manager the menu manager for which to add menu items
- */
- protected void fillContextMenu(IMenuManager manager) {
- super.fillContextMenu(manager);
- ISelection s= getSelection();
- if (s instanceof StructuredSelection
- && ((StructuredSelection) s).getFirstElement() instanceof DiffNode
- && ((DiffNode) ((StructuredSelection) s).getFirstElement()).getId()
- instanceof XMLNode) {
- DiffNode diffnode=
- (DiffNode) ((StructuredSelection) s).getFirstElement();
- String diffnodeIdSig= ((XMLNode) diffnode.getId()).getSignature();
- fIdMaps= XMLPlugin.getDefault().getIdMaps();
- String idmap_name= getXMLStructureCreator().getIdMap();
- if (diffnodeIdSig.endsWith(XMLStructureCreator.SIGN_ATTRIBUTE) || (diffnodeIdSig.endsWith(XMLStructureCreator.SIGN_TEXT) && ((XMLNode) diffnode.getId()).getOrigId().endsWith("(1)"))) { //$NON-NLS-1$
- Action action= new SetAsIdAction(diffnode);
- if (!fIdMaps.containsKey(idmap_name)) {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.notUserIdMap")); //$NON-NLS-1$
- action.setEnabled(false);
- } else {
- HashMap idmapHM= (HashMap) fIdMaps.get(idmap_name);
- XMLNode idNode= (XMLNode) diffnode.getId();
- String signature= idNode.getSignature();
- String idname= ""; //$NON-NLS-1$
- if (idNode
- .getSignature()
- .endsWith(XMLStructureCreator.SIGN_ATTRIBUTE)) {
- signature=
- signature.substring(
- 0,
- signature.indexOf(
- XMLStructureCreator.SIGN_ATTRIBUTE));
- int end_of_signature=
- signature.lastIndexOf(
- SIGN_SEPARATOR,
- signature.length() - 2);
- idname=
- signature.substring(
- end_of_signature + 1,
- signature.length() - 1);
- signature= signature.substring(0, end_of_signature + 1);
- } else if (
- idNode.getSignature().endsWith(
- XMLStructureCreator.SIGN_TEXT)) {
- XMLNode textNode= (XMLNode) diffnode.getId();
- XMLNode idelem= textNode.getParent();
- XMLNode elem= idelem.getParent();
- signature=
- elem.getSignature().substring(
- 0,
- elem.getSignature().indexOf(
- XMLStructureCreator.SIGN_ELEMENT));
- idname= idelem.getOrigId();
- idname=
- idname.substring(
- 0,
- idname.indexOf(
- XMLStructureCreator.ID_SEPARATOR));
- idname=
- new Character(XMLStructureCreator.ID_TYPE_BODY)
- + idname;
- }
- if (idmapHM.containsKey(signature)) {
- if (idmapHM.get(signature).equals(idname)) {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.setId.text1")); //$NON-NLS-1$
- action.setEnabled(false);
- } else {
- String oldId= (String) idmapHM.get(signature);
- if (oldId
- .startsWith(
- (new Character(XMLStructureCreator
- .ID_TYPE_BODY))
- .toString()))
- oldId= oldId.substring(1);
- action.setText(MessageFormat.format("{0} {1}", new String[] { XMLCompareMessages.getString("XMLStructureViewer.action.setId.text2"), oldId })); //$NON-NLS-2$ //$NON-NLS-1$
- action.setEnabled(true);
- }
- } else {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.setId.text3")); //$NON-NLS-1$
- action.setEnabled(true);
- }
- }
- manager.add(action);
- } else if (
- diffnodeIdSig.endsWith(XMLStructureCreator.SIGN_ELEMENT)) {
- SetOrderedAction action= new SetOrderedAction(idmap_name);
- if (!fIdMaps.containsKey(idmap_name)) {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.notUserIdMap")); //$NON-NLS-1$
- action.setEnabled(false);
- } else {
- ArrayList idmapOrdered=
- (ArrayList) fOrderedElements.get(idmap_name);
- XMLNode idNode= (XMLNode) diffnode.getId();
- String signature= idNode.getSignature();
- // String idname= "";
- signature=
- signature.substring(
- 0,
- signature.indexOf(
- XMLStructureCreator.SIGN_ELEMENT));
- if (idmapOrdered != null
- && idmapOrdered.contains(signature)) {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.setOrdered.exists")); //$NON-NLS-1$
- action.setEnabled(false);
- } else {
- action.setText(XMLCompareMessages.getString("XMLStructureViewer.action.setOrdered")); //$NON-NLS-1$
- action.setSignature(signature);
- action.setEnabled(true);
- }
- }
-
- manager.add(action);
- }
- }
- }
-
- protected void appendToTitle(String idmap_name) {
- if (fParent != null) {
- getXMLStructureCreator().setIdMap(idmap_name);
- fParent.setTitleArgument(idmap_name);
- }
- }
-
- /*
- * Returns true if the current Id Map scheme has been removed.
- */
- private boolean isIdMapRemoved() {
- XMLStructureCreator xsc= getXMLStructureCreator();
- String IdMapName= xsc.getIdMap();
- return !IdMapName.equals(XMLStructureCreator.USE_UNORDERED)
- && !IdMapName.equals(XMLStructureCreator.USE_ORDERED)
- && !fIdMaps.containsKey(IdMapName)
- && !fIdMapsInternal.containsKey(IdMapName)
- && !fOrderedElements.containsKey(IdMapName);
- }
-
- protected class SetAsIdAction extends Action {
-
- DiffNode fDiffNode;
-
- public SetAsIdAction(DiffNode diffnode) {
- fDiffNode= diffnode;
- }
-
- public void run() {
- XMLStructureCreator sc= getXMLStructureCreator();
- // DiffNode diffnode = (DiffNode) ((StructuredSelection) getSelection()).getFirstElement();
- String idmap_name= sc.getIdMap();
- if (fIdMaps.containsKey(idmap_name)) {
- HashMap idmapHM= (HashMap) fIdMaps.get(idmap_name);
- if (((XMLNode) fDiffNode.getId())
- .getSignature()
- .endsWith(XMLStructureCreator.SIGN_ATTRIBUTE)) {
- XMLNode attrNode= (XMLNode) fDiffNode.getId();
- String signature= attrNode.getSignature();
- signature=
- signature.substring(
- 0,
- signature.indexOf(
- XMLStructureCreator.SIGN_ATTRIBUTE));
- int end_of_signature=
- signature.lastIndexOf(
- SIGN_SEPARATOR,
- signature.length() - 2);
- String idattr=
- signature.substring(
- end_of_signature + 1,
- signature.length() - 1);
- signature= signature.substring(0, end_of_signature + 1);
- idmapHM.put(signature, idattr);
- XMLPlugin.getDefault().setIdMaps(
- fIdMaps,
- null,
- null,
- false);
- //contentChanged();
- } else if (
- ((XMLNode) fDiffNode.getId()).getSignature().endsWith(
- XMLStructureCreator.SIGN_TEXT)) {
- XMLNode textNode= (XMLNode) fDiffNode.getId();
- XMLNode idelem= textNode.getParent();
- XMLNode elem= idelem.getParent();
- String signature=
- elem.getSignature().substring(
- 0,
- elem.getSignature().indexOf(
- XMLStructureCreator.SIGN_ELEMENT));
- String idname= idelem.getOrigId();
- idname=
- idname.substring(
- 0,
- idname.indexOf(XMLStructureCreator.ID_SEPARATOR));
- idname=
- new Character(XMLStructureCreator.ID_TYPE_BODY)
- + idname;
- idmapHM.put(signature, idname);
- XMLPlugin.getDefault().setIdMaps(
- fIdMaps,
- null,
- null,
- false);
- //contentChanged();
- }
- }
- }
- }
-
- protected class SetOrderedAction extends Action {
-
- String fIdMapName;
- String fSignature;
-
- public SetOrderedAction(String idmap_name) {
- fIdMapName= idmap_name;
- }
-
- public void run() {
- //String idmap_name= getXMLStructureCreator().getIdMap();
- if (fSignature != null) {
- ArrayList idmapOrdered=
- (ArrayList) fOrderedElements.get(fIdMapName);
- if (idmapOrdered == null) {
- idmapOrdered= new ArrayList();
- fOrderedElements.put(fIdMapName, idmapOrdered);
- }
- idmapOrdered.add(fSignature);
- }
- }
-
- public void setSignature(String signature) {
- fSignature= signature;
- }
- }
-
- protected void updateIdMaps() {
- getXMLStructureCreator().updateIdMaps();
- }
-
- /*
- * 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.
- */
- protected void propertyChange(PropertyChangeEvent event) {
- String key= event.getProperty();
- if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) {
- getXMLStructureCreator().setRemoveWhiteSpace(
- !getXMLStructureCreator().getRemoveWhiteSpace());
- contentChanged();
- }
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewerCreator.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewerCreator.java
deleted file mode 100644
index 0cdc9f4d3..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewerCreator.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.examples.xml;
-
-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 <code>TextMergeViewer</code>.
- * This indirection is necessary because only objects with a default
- * constructor can be created via an extension point
- * (this precludes Viewers).
- */
-public class XMLStructureViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new XMLStructureViewer(parent, mp);
- }
-}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java
deleted file mode 100644
index 6eb3af6f8..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.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.examples.xml.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A message line. It distinguishs between "normal" messages and errors.
- * Setting an error message hides a currently displayed message until
- * <code>clearErrorMessage</code> is called.
- */
-public class MessageLine extends CLabel {
-
- public static final RGB RED= new RGB(200, 0, 0);
- private static RGB fgDefaultErrorRGB= RED;
-
- private String fMessageText;
- private String fErrorText;
-
- private Color fDefaultColor;
- private RGB fErrorRGB;
- private Color fErrorColor;
-
- /*
- * Creates a new message line as a child of the given parent.
- * Error message will be shown in <code>RED</code>.
- */
- public MessageLine(Composite parent) {
- this(parent, SWT.LEFT);
- }
-
- /*
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown in <code>RED</code>.
- */
- public MessageLine(Composite parent, int style) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= fgDefaultErrorRGB;
- }
-
- /*
- * Creates a new message line as a child of the parent and with the given SWT stylebits.
- * Error message will be shown with in the given rgb color.
- */
- public MessageLine(Composite parent, int style, RGB errorRGB) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= errorRGB;
- }
-
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage() {
- setErrorMessage(null);
- }
-
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage() {
- setMessage(null);
- }
-
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage() {
- return fErrorText;
- }
-
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage() {
- return fMessageText;
- }
-
- /*
- * Sets the default error color used by all message lines.
- * Note: a call to this method only affects newly created MessageLines not existing ones.
- */
- public static void setDefaultErrorColor(RGB color) {
- fgDefaultErrorRGB= color;
- }
-
- /*
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message) {
- fErrorText= message;
-
- if (message == null) {
- setMessage(fMessageText);
- } else {
- if (fErrorColor == null) {
- fErrorColor= new Color(getDisplay(), fErrorRGB);
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fErrorColor.dispose();
- }
- });
- }
- setForeground(fErrorColor);
- setText(message);
- }
- }
-
- /*
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message) {
- fMessageText= message;
- if (message == null)
- message= ""; //$NON-NLS-1$
- if (fErrorText == null) {
- setForeground(fDefaultColor);
- setText(message);
- }
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusDialog.java
deleted file mode 100644
index 85bd90d3b..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusDialog.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.xml.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * An abstract base class for dialogs with a status bar and ok/cancel buttons.
- * The status message must be passed over as StatusInfo object and can be
- * an error, warning or ok. The OK button is enabled or disabled depending
- * on the status.
- */
-public abstract class StatusDialog extends Dialog {
-
- private Button fOkButton;
- private MessageLine fStatusLine;
- private IStatus fLastStatus;
- private String fTitle;
- private Image fImage;
-
- /*
- * Creates an instane of a status dialog.
- */
- public StatusDialog(Shell parent) {
- super(parent);
- }
-
- /*
- * Specifies whether status line appears to the left of the buttons (default)
- * or above them.
- *
- * @param aboveButtons if <code>true</code> status line is placed above buttons; if
- * <code>false</code> to the right
- */
- public void setStatusLineAboveButtons(boolean aboveButtons) {
- // empty default implementation
- }
-
- /*
- * Update the dialog's status line to reflect the given status.
- * It is save to call this method before the dialog has been opened.
- */
- protected void updateStatus(IStatus status) {
- fLastStatus= status;
- if (fStatusLine != null && !fStatusLine.isDisposed()) {
- updateButtonsEnableState(status);
- StatusUtil.applyToStatusLine(fStatusLine, status);
- }
- }
-
- /*
- * Returns the last status.
- */
- public IStatus getStatus() {
- return fLastStatus;
- }
-
- /**
- * Updates the status of the ok button to reflect the given status.
- * Subclasses may override this method to update additional buttons.
- * @param status the status.
- */
- protected void updateButtonsEnableState(IStatus status) {
- if (fOkButton != null && !fOkButton.isDisposed())
- fOkButton.setEnabled(!status.matches(IStatus.ERROR));
- }
-
- /*
- * @see Window#create(Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (fTitle != null)
- shell.setText(fTitle);
- }
-
- /*
- * @see Window#create()
- */
- public void create() {
- super.create();
- if (fLastStatus != null) {
- // policy: dialogs are not allowed to come up with an error message
- if (fLastStatus.matches(IStatus.ERROR)) {
- StatusInfo status= new StatusInfo();
- status.setError(""); //$NON-NLS-1$
- fLastStatus= status;
- }
- updateStatus(fLastStatus);
- }
- }
-
- /*
- * @see Dialog#createButtonsForButtonBar(Composite)
- */
- protected void createButtonsForButtonBar(Composite parent) {
- fOkButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- /*
- * @see Dialog#createButtonBar(Composite)
- */
- protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fStatusLine= new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fStatusLine.setMessage(""); //$NON-NLS-1$
-
- super.createButtonBar(composite);
- return composite;
- }
-
- /**
- * Sets the title for this dialog.
- * @param title the title.
- */
- public void setTitle(String title) {
- fTitle= title != null ? title : ""; //$NON-NLS-1$
- Shell shell= getShell();
- if ((shell != null) && !shell.isDisposed())
- shell.setText(fTitle);
- }
-
- /**
- * Sets the image for this dialog.
- * @param image the image.
- */
- public void setImage(Image image) {
- fImage= image;
- Shell shell= getShell();
- if ((shell != null) && !shell.isDisposed())
- shell.setImage(fImage);
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusInfo.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusInfo.java
deleted file mode 100644
index d49a55256..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusInfo.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.examples.xml.ui;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.util.Assert;
-
-/**
- * A settable IStatus.
- * Can be an error, warning, info or ok. For error, info and warning states,
- * a message describes the problem.
- */
-public class StatusInfo implements IStatus {
-
- private String fStatusMessage;
- private int fSeverity;
-
- /**
- * Creates a status set to OK (no message)
- */
- public StatusInfo() {
- this(OK, null);
- }
-
- /**
- * Creates a status .
- * @param severity The status severity: ERROR, WARNING, INFO and OK.
- * @param message The message of the status. Applies only for ERROR,
- * WARNING and INFO.
- */
- public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
-
- /*
- * Returns if the status' severity is OK.
- */
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
-
- /*
- * Returns if the status' severity is WARNING.
- */
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
-
- /*
- * Returns if the status' severity is INFO.
- */
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
-
- /*
- * Returns if the status' severity is ERROR.
- */
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
-
- /*
- * @see IStatus#getMessage
- */
- public String getMessage() {
- return fStatusMessage;
- }
-
- /*
- * Sets the status to ERROR.
- * @param The error message (can be empty, but not null)
- */
- public void setError(String errorMessage) {
- Assert.isNotNull(errorMessage);
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
-
- /*
- * Sets the status to WARNING.
- * @param The warning message (can be empty, but not null)
- */
- public void setWarning(String warningMessage) {
- Assert.isNotNull(warningMessage);
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
-
- /*
- * Sets the status to INFO.
- * @param The info message (can be empty, but not null)
- */
- public void setInfo(String infoMessage) {
- Assert.isNotNull(infoMessage);
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
-
- /*
- * Sets the status to OK.
- */
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
-
- /*
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
-
- /**
- * Returns always <code>false</code>.
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /*
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /*
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return "XMLPlugIn"; //$NON-NLS-1$
- }
-
- /**
- * Returns always <code>null</code>.
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
-
- /**
- * Returns always the error severity.
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
-
- /**
- * Returns always <code>null</code>.
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java
deleted file mode 100644
index 43facd7bc..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java
+++ /dev/null
@@ -1 +0,0 @@
-/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies 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.examples.xml.ui; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.core.runtime.IStatus; /** * A utility class to work with IStatus. */ public class StatusUtil { /* * Compares two instances of <code>IStatus</code>. The more severe is returned: * An error is more severe than a warning, and a warning is more severe * than ok. If the two stati have the same severity, the second is returned. */ public static IStatus getMoreSevere(IStatus s1, IStatus s2) { if (s1.getSeverity() > s2.getSeverity()) return s1; return s2; } /* * Finds the most severe status from a array of stati. * An error is more severe than a warning, and a warning is more severe * than ok. */ public static IStatus getMostSevere(IStatus[] status) { IStatus max= null; for (int i= 0; i < status.length; i++) { IStatus curr= status[i]; if (curr.matches(IStatus.ERROR)) { return curr; } if (max == null || curr.getSeverity() > max.getSeverity()) { max= curr; } } return max; } /* * Returns error-message / warning-message for a status. * @return Array of size 2. Index 0 is the error message or <null> * if not an error. Index 1 the warning message or <null> if not a warning. */ private static String[] getErrorMessages(IStatus status) { String message= status.getMessage(); if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$ return new String[] { message, null }; } else if (status.matches(IStatus.WARNING | IStatus.INFO)) { return new String[] { null, message }; } else { return new String[] { null, null }; } } /* * Applies the status to the status line of a dialog page. */ public static void applyToStatusLine(DialogPage page, IStatus status) { String[] messages= getErrorMessages(status); page.setErrorMessage(messages[0]); page.setMessage(messages[1]); } /* * Applies the status to a message line */ public static void applyToStatusLine(MessageLine messageLine, IStatus status) { String[] messages= getErrorMessages(status); messageLine.setErrorMessage(messages[0]); messageLine.setMessage(messages[1]); } } \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/xmlcompare.properties b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/xmlcompare.properties
deleted file mode 100644
index 2c1b2177f..000000000
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/xmlcompare.properties
+++ /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
-###############################################################################
-
-#
-# Structure Creator
-#
-XMLStructureCreator.pluginname= XML Compare
-XMLStructureCreator.unordered= Unordered
-XMLStructureCreator.ordered= Ordered
-XMLStructureCreator.idmap_unordered= Unordered
-XMLStructureCreator.id_map_scheme= Id Map Scheme:
-XMLStructureCreator.body= body
-
-
-#
-# Id Scheme Drop Down Menu
-#
-ChooseMatcherDropDownAction.text= Compare Mode
-ChooseMatcherDropDownAction.tooltip= Compare Mode
-
-#
-# Preference Page
-#
-XMLComparePreference.idtype.attribute= attribute
-XMLComparePreference.idtype.child_body= child text
-XMLComparePreference.topTableLabel= Id Mapping schemes:
-XMLComparePreference.topTableColumn1= Name
-XMLComparePreference.topTableColumn2= Internal/User
-XMLComparePreference.topTableColumn2internal= Internal
-XMLComparePreference.topTableColumn2user= User
-XMLComparePreference.topTableColumn3= Extension
-XMLComparePreference.topAdd= &Add...
-XMLComparePreference.topRename= &Edit...
-XMLComparePreference.topRemove= &Remove
-XMLComparePreference.topEdit= Edit &Copy...
-XMLComparePreference.middleTableColumn1= Element
-XMLComparePreference.middleTableColumn2= Path
-XMLComparePreference.middleTableColumn3= Id Attribute
-XMLComparePreference.middleTableColumn4= Id Source
-XMLComparePreference.middleNew= &New...
-XMLComparePreference.middleEdit= E&dit...
-XMLComparePreference.middleRemove= Re&move
-XMLComparePreference.middleTableLabel=Element mappings of selected Id Mapping Scheme:
-XMLComparePreference.bottomTableLabel=Elements whose children are compared in ordered fashion:
-XMLComparePreference.bottomTableColumn1=Element
-XMLComparePreference.bottomTableColumn2=Path
-XMLComparePreference.bottomNew=Ne&w...
-XMLComparePreference.bottomEdit=Edi&t...
-XMLComparePreference.bottomRemove=Remo&ve
-
-#
-# Dialogs
-#
-XMLCompareAddIdMapDialog.editTitle= Edit Id Mapping Scheme
-XMLCompareAddIdMapDialog.newTitle= New Id Mapping Scheme
-XMLCompareAddIdMapDialog.label= ID Map Name:
-XMLCompareAddIdMapDialog.extlabel= Extension (optional)
-XMLCompareAddIdMapDialog.error.noname= Enter Id Map Name.
-XMLCompareAddIdMapDialog.error.invalidname= Invalid Id Map Name.
-XMLCompareAddIdMapDialog.error.idmapExists= Id Map already exists.
-XMLCompareAddIdMapDialog.error.extfullstop= Extension cannot contain '.'
-XMLCompareAddIdMapDialog.error.extExists= Extension already set for
-
-XMLCompareEditCopyIdMapDialog.title= Create Editable Copy of Internal Scheme
-XMLCompareEditCopyIdMapDialog.comment= You cannon edit an internal Id Map Scheme.\nTherefore, a user copy of the Id Map Scheme will created for editing.\nThe extension associated with the internal Id Map Scheme will not be transferred.\n\nPlease Enter a new name for the Id Map Scheme copy.
-XMLCompareEditCopyIdMapDialog.label= ID Map Name of Copy:
-XMLCompareEditCopyIdMapDialog.error.noname= Enter Id Map Name.
-XMLCompareEditCopyIdMapDialog.error.invalidname= Invalid Id Map Name.
-XMLCompareEditCopyIdMapDialog.error.nameExists= Id Map Name already exists.
-
-XMLCompareEditMappingDialog.editTitle= Edit Mapping
-XMLCompareEditMappingDialog.newTitle= New Mapping
-XMLCompareEditMappingDialog.element= Element
-XMLCompareEditMappingDialog.signature= Path
-XMLCompareEditMappingDialog.idattribute= ID
-XMLCompareEditMappingDialog.idtype= ID Source
-XMLCompareEditMappingDialog.idtype.tooltip= Select whether the ID is an attribute of the element or the text of a child
-XMLCompareEditMappingDialog.idtype.attribute.tooltip= ID is an attribute of the element
-XMLCompareEditMappingDialog.idtype.childbody.tooltip= ID is the text of a child element
-XMLCompareEditMappingDialog.error.noname= Enter Element Name.
-XMLCompareEditMappingDialog.error.invalidname= Invalid Element Name.
-XMLCompareEditMappingDialog.error.mappingExists= Mapping already exists.
-XMLCompareEditMappingDialog.error.invalidsignature= Invalid Signature.
-XMLCompareEditMappingDialog.error.invalididattribute= Invalid ID Attribute.
-
-XMLCompareEditOrderedDialog.newTitle=New Ordered
-XMLCompareEditOrderedDialog.editTitle=Edit Ordered
-XMLCompareEditOrderedDialog.error.orderedExists=Ordered entry already exists
-
-#
-# XMLStructureViewer
-#
-XMLStructureViewer.newtask= Create new Id Map Scheme
-XMLStructureViewer.action.notUserIdMap= Please select a User Id Mapping Scheme
-XMLStructureViewer.action.setId.text1= Already set as Id
-XMLStructureViewer.action.setId.text2= Replace existing Id
-XMLStructureViewer.action.setId.text3= Set as Id
-XMLStructureViewer.action.setOrdered.exists= Ordered entry exists already
-XMLStructureViewer.action.setOrdered=Set children as ordered
-XMLStructureViewer.matching.beginTask=Running Matching algorithm...
-
diff --git a/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/AllXMLCompareTests.java b/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/AllXMLCompareTests.java
deleted file mode 100644
index e97c067f2..000000000
--- a/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/AllXMLCompareTests.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.examples.xml;
-
-import junit.framework.*;
-
-/**
- * TestSuite that runs all the XML Compare tests.
- */
-public class AllXMLCompareTests {
-
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite ( ) {
- TestSuite suite= new TestSuite("All XML Compare Tests"); //$NON-NLS-1$
- suite.addTest(TestXMLStructureCreator.suite());
- return suite;
- }
-}
-
diff --git a/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/TestXMLStructureCreator.java b/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/TestXMLStructureCreator.java
deleted file mode 100644
index f8fb50b8e..000000000
--- a/examples/org.eclipse.compare.examples.xml/tests/org/eclipse/compare/examples/xml/TestXMLStructureCreator.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.examples.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import junit.framework.*;
-
-import org.eclipse.jface.text.Document;
-
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.examples.xml.XMLChildren;
-import org.eclipse.compare.examples.xml.XMLNode;
-import org.eclipse.compare.examples.xml.XMLStructureCreator;
-import org.eclipse.core.runtime.CoreException;
-
-public class TestXMLStructureCreator extends TestCase {
-
- Document fdoc;
- XMLStructureCreator fsc;
-
- public class TestStream implements IEncodedStreamContentAccessor {
- String fString;
-
- public TestStream(String string) {
- fString= string;
- }
-
- public InputStream getContents() throws CoreException {
- try {
- return new ByteArrayInputStream(fString.getBytes("UTF-16")); //$NON-NLS-1$
- } catch (Exception e) {
- return new ByteArrayInputStream(fString.getBytes());
- }
- }
-
- public String getCharset() {
- return "UTF-16"; //$NON-NLS-1$
- }
- }
-
- public TestXMLStructureCreator(String name) {
- super(name);
- }
-
- protected void setUp() {
- System.out.println("TestXMLStructureCreator.name()==" + getName()); //$NON-NLS-1$
- fdoc = new Document();
- fsc = new XMLStructureCreator();
- }
-
- protected void tearDown() throws Exception {
- //remove set-up
- }
-
- public static Test suite() {
- return new TestSuite(TestXMLStructureCreator.class);
- }
-
- public void test0() {
- TestStream s= new TestStream("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<a attr1=\"&lt;b&gt;&lt;/b&gt;\"\nattr2=\"he\n ll\n o2\" attr3=\"hello3\"\nattr4=\"hello4\"><b attr=\n\"battr\" attr2=\"battr2\">\n<c/>\n</b>\n<b2/>\n</a>\n"); //$NON-NLS-1$
- XMLChildren Tree= (XMLChildren) fsc.getStructure(s);
-
- XMLChildren ExpectedTree = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,XMLStructureCreator.ROOT_ID, "",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$
- //create Expected Tree
- XMLChildren parent = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"a<[1]","<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<a attr1=\"&lt;b&gt;&lt;/b&gt;\"\nattr2=\"he\n ll\n o2\" attr3=\"hello3\"\nattr4=\"hello4\"><b attr=\n\"battr\" attr2=\"battr2\">\n<c/>\n</b>\n<b2/>\n</a>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- parent.setName("a [1]"); //$NON-NLS-1$
- ExpectedTree.addChild(parent);
- parent.setParent(ExpectedTree);
- XMLChildren current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr1","<b></b>",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "attr1" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("attr1"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr2","he ll o2",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "attr2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("attr2"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr3","hello3",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "attr3" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("attr3"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr4","hello4",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "attr4" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("attr4"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"b<[1]","<b attr=\n\"battr\" attr2=\"battr2\">\n<c/>\n</b>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR +"b" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("b [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = current;
- current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr","battr",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "attr" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("attr"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ATTRIBUTE,"attr2","battr2",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "attr2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ATTRIBUTE), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("attr2"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"c<[1]","<c/>",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("c [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = (XMLChildren) parent.getParent();
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"b2<[1]","<b2/>",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR +"b2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("b2 [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
-
- checkTrees(Tree,ExpectedTree);
- }
-
- public void test1() {
- TestStream s= new TestStream("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<a>body_a_1\n <b>body_b_1\n <c>body_c_1\n <d2>body_d2\n </d2>\nbody_c_2\n </c>\nbody_b_2\n </b>\nbody_a_2\n <b2>\n </b2>\nbody_a_3\n</a>"); //$NON-NLS-1$
- XMLChildren Tree= (XMLChildren) fsc.getStructure(s);
-
- XMLChildren ExpectedTree = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,XMLStructureCreator.ROOT_ID, "",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$
- //create Expected Tree
- XMLChildren parent = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"a<[1]","<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<a>body_a_1\n <b>body_b_1\n <c>body_c_1\n <d2>body_d2\n </d2>\nbody_c_2\n </c>\nbody_b_2\n </b>\nbody_a_2\n <b2>\n </b2>\nbody_a_3\n</a>",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- parent.setName("a [1]"); //$NON-NLS-1$
- ExpectedTree.addChild(parent);
- parent.setParent(ExpectedTree);
- XMLChildren current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(1)","body_a_1\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- current.setName("body (1)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"b<[1]","<b>body_b_1\n <c>body_c_1\n <d2>body_d2\n </d2>\nbody_c_2\n </c>\nbody_b_2\n </b>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("b [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = current;
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(1)","body_b_1\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("body (1)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"c<[1]","<c>body_c_1\n <d2>body_d2\n </d2>\nbody_c_2\n </c>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR +"a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("c [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = current;
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(1)","body_c_1\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("body (1)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"d2<[1]","<d2>body_d2\n </d2>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + "d2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- current.setName("d2 [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = current;
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(1)","body_d2\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + "d2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- current.setName("body (1)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = (XMLChildren) parent.getParent();
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(2)","\nbody_c_2\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + "c" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- current.setName("body (2)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = (XMLChildren) parent.getParent();
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(2)","\nbody_b_2\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("body (2)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- parent = (XMLChildren) parent.getParent();
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(2)","\nbody_a_2\n ",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- current.setName("body (2)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_ELEMENT,"b2<[1]","<b2>\n </b2>\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + "b2" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_ELEMENT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- current.setName("b2 [1]"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
- current = new XMLChildren(XMLStructureCreator.TYPE_TEXT,"body_(3)","\nbody_a_3\n",(XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + "a" + XMLStructureCreator.SIGN_SEPARATOR + XMLStructureCreator.SIGN_TEXT), fdoc, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- current.setName("body (2)"); //$NON-NLS-1$
- parent.addChild(current);
- current.setParent(parent);
-
- checkTrees(Tree,ExpectedTree);
- }
-
- protected void checkTrees(XMLNode left, XMLNode right) {
- if (left != null && right != null) {
- //System.out.println(left.getName() + ", " + right.getName());
- //System.out.println(">" + left.getValue() + "<\n>" + right.getValue() + "<");
- assertTrue(left.testEquals(right));
- Object[] leftChildren = left.getChildren();
- Object[] rightChildren = right.getChildren();
- if (leftChildren != null && rightChildren != null) {
- if (leftChildren.length == rightChildren.length) {
- for (int i=0; i<leftChildren.length; i++)
- checkTrees((XMLNode) leftChildren[i], (XMLNode) rightChildren[i]);
- } else
- assertTrue(false);
- }
- } else if ( ((left == null) && (right != null)) || ((left != null) && (right == null)) ) {
- assertTrue(false);
- }
- }
-}
-
diff --git a/examples/org.eclipse.compare.examples/.classpath b/examples/org.eclipse.compare.examples/.classpath
deleted file mode 100644
index 065ac06e1..000000000
--- a/examples/org.eclipse.compare.examples/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/examples/org.eclipse.compare.examples/.cvsignore b/examples/org.eclipse.compare.examples/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/examples/org.eclipse.compare.examples/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/examples/org.eclipse.compare.examples/.project b/examples/org.eclipse.compare.examples/.project
deleted file mode 100644
index 507ff7b71..000000000
--- a/examples/org.eclipse.compare.examples/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.compare.examples</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.compare</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.ui</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/examples/org.eclipse.compare.examples/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.compare.examples/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 380a449bf..000000000
--- a/examples/org.eclipse.compare.examples/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,70 +0,0 @@
-#Tue Nov 30 15:46:38 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=ignore
-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.4
-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/examples/org.eclipse.compare.examples/about.html b/examples/org.eclipse.compare.examples/about.html
deleted file mode 100644
index 9db411aab..000000000
--- a/examples/org.eclipse.compare.examples/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
-other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples/build.properties b/examples/org.eclipse.compare.examples/build.properties
deleted file mode 100644
index 24c663c5a..000000000
--- a/examples/org.eclipse.compare.examples/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.compareexamples.jar = src/
-
-bin.includes = doc-html/,\
- about.html,\
- plugin.properties,\
- plugin.xml,\
- compareexamples.jar
-
-src.includes = about.html
diff --git a/examples/org.eclipse.compare.examples/doc-html/hglegal.htm b/examples/org.eclipse.compare.examples/doc-html/hglegal.htm
deleted file mode 100644
index f5871b79e..000000000
--- a/examples/org.eclipse.compare.examples/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <LINK REL="stylesheet" HREF="../../../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif b/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif
deleted file mode 100644
index c786e43e1..000000000
--- a/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html b/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html
deleted file mode 100644
index 88596b47d..000000000
--- a/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html
+++ /dev/null
@@ -1,84 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Structural Compare for Key/Value Pairs</title>
-</head>
-<body>
-
-<h2>Compare Example - Structural Compare for Key/Value Pairs</h2>
-
-<h3>Introduction</h3>
-
-This example demonstrates how to support structural compare for
-files consisting of key/value pairs. It shows how to implement and register a
-custom structure creator that parses key/value pairs into a tree structure
-that is used as the input to the structural compare framework provided by the
-Compare plugin. In addition, it registers a standard text viewer for the individual
-key/value pairs.
-
-<p>
-
-This example is only for demonstration purposes. Structural compare support
-for Java property files (another key/value format) is provided by the Eclipse Java Tooling.
-
-<h3> Running the example</h3>
-
-<ol>
- <li>Create a project (not necessarily a Java project)</li>
-
- <li>Create a key/value pair file f1.kv</li>
-
- <li>Open <strong>Window</strong> &gt; <strong>Preferences</strong> &gt; <strong>Workbench</strong> &gt; <strong>File Association</strong>
- and associate the default text editor with the file extension "kv"</li>
-
- <li>Open f1.kv with the editor and enter this contents
- <pre>
-lastname=Doe
-firstname=John
-city=Chicago
-state=IL
-</pre></li>
-
- <li>Make a copy of this file and rename it f2.kv</li>
-
- <li>Open f2.kv and change the firstname "John" to "Mary"</li>
-
- <li>Add another key/value pair "country=US" to f2.kv</li>
-
- <li>Select both files f1.kv and f2.kv</li>
-
- <li>From the context menu select <strong>Compare With</strong> &gt; <strong>Each Other</strong></li>
-
- <li>A new compare editor opens that shows the structural differences of both files in its
- top pane. Selecting one of the properties "firstname" or "country" feeds the text of the
- corresponding key/value pair into the standard text compare viewer in the bottom pane.
- </li>
-
-</ol>
-
-<h3>Code organization of the example</h3>
-The example code is organized in a single package <tt>org.eclipse.compare.examples.structurecreator</tt>:
-
-<ul>
- <li><tt>KeyValuePairStructureCreator</tt><br>
- is the structure creator that parses the contents of a stream into a tree of
- <tt>IStructureComparator</tt>s.
- </li>
-
- <li><tt>TextMergeViewerCreator</tt><br>
- is a factory for TextMergeViewers. It is registered for the type "kvtxt" which is the
- type of an individual key/value pair.
- </li>
-
- <li><tt>Util</tt><br>
- provides utility methods for NLS support and for reading an InputStream as a String.
- </li>
-
-</ul>
-
-<p>&nbsp;</p>
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corporation and others 2000, 2003. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
-</body>
-</html>
diff --git a/examples/org.eclipse.compare.examples/plugin.properties b/examples/org.eclipse.compare.examples/plugin.properties
deleted file mode 100644
index c67e77dbe..000000000
--- a/examples/org.eclipse.compare.examples/plugin.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.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 Examples plugin.xml file
-#
-pluginName= Compare Example
-providerName= Eclipse.org
diff --git a/examples/org.eclipse.compare.examples/plugin.xml b/examples/org.eclipse.compare.examples/plugin.xml
deleted file mode 100644
index c46095143..000000000
--- a/examples/org.eclipse.compare.examples/plugin.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-
-<plugin
- id="org.eclipse.compare.examples"
- name="%pluginName"
- version="3.1.0"
- provider-name="%providerName">
-
- <runtime>
- <library name="compareexamples.jar">
- <export name="*"/>
- </library>
- </runtime>
-
- <requires>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.compare"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- </requires>
-
- <extension
- point="org.eclipse.compare.contentMergeViewers">
- <viewer
- extensions="kvtxt"
- class="org.eclipse.compare.examples.structurecreator.TextMergeViewerCreator">
- </viewer>
- </extension>
-
- <extension
- point="org.eclipse.compare.structureCreators">
- <structureCreator
- extensions="kv"
- class="org.eclipse.compare.examples.structurecreator.KeyValuePairStructureCreator">
- </structureCreator>
- </extension>
-
-</plugin>
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties
deleted file mode 100644
index d59e04685..000000000
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-#
-# Resource strings
-#
-KeyValuePairStructureCreator.title= Key/Value Pair Compare
-KeyValuePairStructureCreator.CoreException.message= CoreException
-KeyValuePairStructureCreator.BadLocationException.message= BadLocationException
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
deleted file mode 100644
index 675c1a5af..000000000
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.examples.structurecreator;
-
-import org.eclipse.swt.graphics.*;
-
-import org.eclipse.jface.text.*;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.compare.*;
-import org.eclipse.compare.structuremergeviewer.*;
-
-
-/**
- * This structure creator parses input containing key/value pairs
- * and returns the pairs as a tree of <code>IStructureComparator</code>s.
- * Each key/value pair must be on a separate line and keys are separated
- * from values by a '='.
- * <p>
- * Example:
- * <pre>
- * foo=bar
- * name=joe
- * </pre>
- */
-public class KeyValuePairStructureCreator implements IStructureCreator {
-
- static class KeyValueNode extends DocumentRangeNode implements ITypedElement {
-
- String fValue;
-
- public KeyValueNode(String id, String value, IDocument doc, int start, int length) {
- super(0, id, doc, start, length);
- fValue= value;
- }
-
- String getValue() {
- return fValue;
- }
-
- /*
- * @see ITypedElement#getName
- */
- public String getName() {
- return this.getId();
- }
-
- /*
- * Every key/value pair is of type "kvtxt". We register a TextMergeViewer for it.
- * @see ITypedElement#getType
- */
- public String getType() {
- return "kvtxt"; //$NON-NLS-1$
- }
-
- /*
- * @see ITypedElement#getImage
- */
- public Image getImage() {
- return CompareUI.getImage(getType());
- }
- }
-
-
- public KeyValuePairStructureCreator() {
- // nothing to do
- }
-
- /*
- * This title will be shown in the title bar of the structure compare pane.
- */
- public String getName() {
- return Util.getString("KeyValuePairStructureCreator.title"); //$NON-NLS-1$
- }
-
- /*
- * Returns a node.
- */
- public IStructureComparator getStructure(Object input) {
-
- if (!(input instanceof IStreamContentAccessor))
- return null;
-
- IStreamContentAccessor sca= (IStreamContentAccessor) input;
- try {
- String contents= Util.readString(sca);
- if (contents == null)
- contents= ""; //$NON-NLS-1$
- Document doc= new Document(contents);
-
- KeyValueNode root= new KeyValueNode("root", "", doc, 0, doc.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
-
- for (int i= 0; i < doc.getNumberOfLines(); i++) {
-
- IRegion r= doc.getLineInformation(i);
- String s= doc.get(r.getOffset(), r.getLength());
- int start= r.getOffset();
-
- String key= ""; //$NON-NLS-1$
- String value= ""; //$NON-NLS-1$
- int pos= s.indexOf('=');
- if (pos >= 0) {
- key= s.substring(0, pos);
- value= s.substring(pos+1);
- } else {
- key= s;
- }
- if (key.length() > 0)
- root.addChild(new KeyValueNode(key, value, doc, start, s.length()));
- }
- return root;
- } catch (CoreException ex) {
- String message= Util.getString("KeyValuePairStructureCreator.CoreException.message"); //$NON-NLS-1$
- CompareUI.getPlugin().getLog().log(new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 0, message, ex));
- } catch (BadLocationException ex) {
- String message= Util.getString("KeyValuePairStructureCreator.BadLocationException.message"); //$NON-NLS-1$
- CompareUI.getPlugin().getLog().log(new Status(IStatus.ERROR, CompareUI.PLUGIN_ID, 0, message, ex));
- }
-
- return null;
- }
-
- public void save(IStructureComparator structure, Object input) {
- if (input instanceof IEditableContent && structure instanceof KeyValueNode) {
- IDocument doc= ((KeyValueNode)structure).getDocument();
- IEditableContent bca= (IEditableContent) input;
- String c= doc.get();
- bca.setContent(c.getBytes());
- }
- }
-
- public String getContents(Object node, boolean ignoreWhitespace) {
- if (node instanceof KeyValueNode) {
- String s= ((KeyValueNode)node).getValue();
- if (ignoreWhitespace)
- s= s.trim();
- return s;
- }
- return null;
- }
-
- public IStructureComparator locate(Object path, Object source) {
- return null;
- }
-}
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java
deleted file mode 100644
index 3448ff02a..000000000
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.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.examples.structurecreator;
-
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.compare.*;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-
-/**
- * A factory object for the <code>TextMergeViewer</code>.
- * 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/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
deleted file mode 100644
index d048ac803..000000000
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies 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.examples.structurecreator;
-
-import java.io.*;
-import java.util.*;
-
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-
-
-public class Util {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.compare.examples.structurecreator.CompareExampleMessages"; //$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!"; //$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /*
- * Reads the contents of the given input stream into a string.
- * The function assumes that the input stream uses the platform's default encoding
- * (<code>ResourcesPlugin.getEncoding()</code>).
- * Returns null if an error occurred.
- */
- private 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) {
- // silently ignored
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ex) {
- // we don't log IOException when closing a file
- }
- }
- }
- return null;
- }
-
- 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 readString(is, encoding);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/.classpath b/examples/org.eclipse.team.examples.filesystem/.classpath
deleted file mode 100644
index 065ac06e1..000000000
--- a/examples/org.eclipse.team.examples.filesystem/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/examples/org.eclipse.team.examples.filesystem/.cvsignore b/examples/org.eclipse.team.examples.filesystem/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/examples/org.eclipse.team.examples.filesystem/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/examples/org.eclipse.team.examples.filesystem/.project b/examples/org.eclipse.team.examples.filesystem/.project
deleted file mode 100644
index 06b5b570f..000000000
--- a/examples/org.eclipse.team.examples.filesystem/.project
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.team.examples.filesystem</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.team.core</project>
- <project>org.eclipse.team.ui</project>
- <project>org.eclipse.ui</project>
- <project>org.eclipse.ui.editors</project>
- <project>org.eclipse.ui.ide</project>
- <project>org.eclipse.ui.views</project>
- <project>org.eclipse.ui.workbench.texteditor</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/examples/org.eclipse.team.examples.filesystem/about.html b/examples/org.eclipse.team.examples.filesystem/about.html
deleted file mode 100644
index 9db411aab..000000000
--- a/examples/org.eclipse.team.examples.filesystem/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
-other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/build.properties b/examples/org.eclipse.team.examples.filesystem/build.properties
deleted file mode 100644
index fa97e5430..000000000
--- a/examples/org.eclipse.team.examples.filesystem/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.teamfilesystem.jar=src/
-src.includes=about.html
-bin.includes=about.html,icons/,doc-html/,plugin.xml,plugin.properties,*.jar \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm b/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm
deleted file mode 100644
index cf2ced352..000000000
--- a/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.73 [en] (Win98; U) [Netscape]">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
-</body>
-</html>
diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif b/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif
deleted file mode 100644
index 61cef4852..000000000
--- a/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html b/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html
deleted file mode 100644
index 8fcab9972..000000000
--- a/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Team - File System Repository Provider Example</title>
-</head>
-<body>
-
-<h2>Team - File System Repository Provider Example</h2>
-
-<h3>Introduction</h3>
-<p>
-The File System and Pessimistic Repository Providers examples shows how to define your own repository provider. In particular you
-this example shows how to:
-<ul>
-<li>Extend the RepositoryProvider class and register a new repository provider.
-<li>Register a sharing wizard that will appear in the Team > Share... wizard.
-<li>Add resource actions to the Team menu.
-<li>Implement synchronization support that shows up the Synchronize View.
-<li>Use decorators to show the repository state of the local resources.
-<li>How to implement a file modification validator.
-<li>Adding a repository provider to a capability.
-</ul>
-The example includes two separate repository providers, the basic file system and the pessimistic file system. The basic provider illustrates
-the synchronization support whereas the pessimistic provider is more focused to allowing you to test the workbench behavior with pessimistic
-repository providers. There is a preference page for the pessimistic provider that allows configuring the behavior of the file modification
-validator.
-
-<h3>Running the example</h3>
-<p>
-To start using this example create a project and select <b>Team > Share Project...</b> from the project's popup menu. Click the show
-all wizards button. This will show both the file system provider and the pessimistic provider.
-<ul>
-<li><b>Basic file system provider</b>: you will have to enter the location in the local file system where you would like to connect the project
-to. The Get and Put operations in the Team menu will now transfer to and from the selected location. And if you open the Synchronize View
-you can browse the synchronization between the local workspace and the remote file system location the files are stored in. If you edit
-a file and then create a Synchronization you can browse changes between the local and the remote.
-<li><b>Pessimistic file system provider</b>: the sharing wizard next page doesn't actually require any user input. The pessimistic
-provider doesn't actually copy the local files anywhere, and instead simply simulates a check in/check out by flipping the
-read-only bit on files. Once a project is shared with the pessimistic provider you can add files to control and the check in and check out.
-</ul>
-<p>
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corp. 2000, 2004. All Rights Reserved." BORDER=0></a>
-</body>
-</html>
-
diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/team_localhistory_ex.html b/examples/org.eclipse.team.examples.filesystem/doc-html/team_localhistory_ex.html
deleted file mode 100644
index 0466ac6e1..000000000
--- a/examples/org.eclipse.team.examples.filesystem/doc-html/team_localhistory_ex.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Team - Local History Synchronize Participant Example</title>
-</head>
-<body>
-
-<h2>Team - Local History Synchronize Participant Example</h2>
-
-<h3>Introduction</h3>
-<p> The Local History Synchronize Participant example illustrates how to intergate
- a participant into the synchronize view. It covers such things as:
-<ul>
- <li>Creating a simple subscriber for accessing the local history
- <li>Creating a synchronize particpant
- <li>Adding a cusotm action to a particpant
- <li>Showing custom label decorations
- <li>Add a synchronize wizard
-</ul>
-<h3>Running the example</h3>
-<p> To start using this example, open the <strong>Team Synchronizing</strong>
- perspective, click on the global Synchronize toolbar action and choose <strong>Synchronize
- with Latest from Local History</strong>. A more detailed look at this example
- is available in the <a href="../../../guide/team_synchronize_localhistory_example.htm">Local
- History Synchronization Example</a> guide section.
-<p>
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corp. 2000, 2004. All Rights Reserved." BORDER=0></a>
-</body>
-</html>
-
diff --git a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif b/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif
deleted file mode 100644
index af038fa69..000000000
--- a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/synced.gif b/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/synced.gif
deleted file mode 100644
index 870934b69..000000000
--- a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/synced.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif b/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif
deleted file mode 100644
index 3038a23c0..000000000
--- a/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.properties b/examples/org.eclipse.team.examples.filesystem/plugin.properties
deleted file mode 100644
index 668b3c2f2..000000000
--- a/examples/org.eclipse.team.examples.filesystem/plugin.properties
+++ /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
-###############################################################################
-pluginName = Eclipse Team File System Example
-providerName=Eclipse.org
-
-Synchronize.name=Synchronize
-Synchronize.tooltip=Synchronize the selected resources
-Put.name=Put
-Put.tooltip=Copy resources to the shared file system location
-Get.name=Get
-Get.tooltip=Copy resources from the shared file system location to the workbench
-Unmanage.name=Disconnect
-Unmanage.tooltip=Disconnect the project from the shared file system locaton
-
-Replace.name=File System Contents
-Replace.tooltip=Overwrites the local copy of this resource with the one in the repository
-
-fspropertypage.name=FileSystem Provider
-fspropertypage.tooltip=An example repository provider that uses the filesystem to provide storage.
-fswizard.name=File System Example (Non-Versioning)
-fswizard.description=Associate a project with a file system location. This location can be used to shared resources with others.
-
-activity.team.examples.filesystem.name=Team File System Example
-activity.team.examples.filesystem.description=An example Team repository provider.
-activity.team.examples.pessimistic.name=Team Pessimistic Example
-activity.team.examples.pessimistic.description=An example Team repository provider that needs to checkout resources before they can be edited.
diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.xml b/examples/org.eclipse.team.examples.filesystem/plugin.xml
deleted file mode 100644
index 7faa829f4..000000000
--- a/examples/org.eclipse.team.examples.filesystem/plugin.xml
+++ /dev/null
@@ -1,398 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<!-- =================================================================================== -->
-<!-- Team Examples Plug-in Manifest -->
-<!-- =================================================================================== -->
-<plugin
- id="org.eclipse.team.examples.filesystem"
- name="%pluginName"
- version="3.1.0"
- provider-name="%providerName"
- class="org.eclipse.team.examples.filesystem.FileSystemPlugin">
-
-<!-- =================================================================================== -->
-<!-- Libraries -->
-<!-- =================================================================================== -->
-
-<runtime>
- <library name="teamfilesystem.jar">
- <export name="*"/>
- </library>
-</runtime>
-
-<!-- =================================================================================== -->
-<!-- Imports -->
-<!-- =================================================================================== -->
-
-<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.ui.ide" optional="true"/>
- <import plugin="org.eclipse.ui.views" optional="true"/>
- <import plugin="org.eclipse.jface.text" optional="true"/>
- <import plugin="org.eclipse.ui.workbench.texteditor" optional="true"/>
- <import plugin="org.eclipse.ui.editors" optional="true"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.team.core"/>
- <import plugin="org.eclipse.team.ui"/>
- <import plugin="org.eclipse.compare"/>
- <import plugin="org.eclipse.ui"/>
-</requires>
-
-<!-- =================================================================================== -->
-<!-- Repository Providers -->
-<!-- =================================================================================== -->
-
-<extension point="org.eclipse.team.core.repository">
- <repository
- class="org.eclipse.team.examples.filesystem.FileSystemProvider"
- id="org.eclipse.team.examples.filesystem.FileSystemProvider">
- </repository>
-</extension>
-
-<extension point="org.eclipse.team.core.repository">
- <repository
- class="org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider"
- id="org.eclipse.team.examples.pessimistic.pessimisticnature">
- </repository>
-</extension>
-
-<!-- =================================================================================== -->
-<!-- Synchronize Participants -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.team.ui.synchronizeParticipants">
- <participant
- persistent="false"
- class="org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeParticipant"
- icon="icons/full/wizards/fsicon_wiz.gif"
- name="File System Example"
- id="org.eclipse.team.examples.filesystem.participant"/>
- </extension>
-
- <extension
- point="org.eclipse.team.ui.synchronizeWizards">
- <wizard
- class="org.eclipse.team.examples.filesystem.ui.SynchronizeWizard"
- icon="icons/full/wizards/fsicon_wiz.gif"
- description="Synchronize files managed with the file system provider."
- name="Synchronize File System Provider"
- id="org.eclipse.team.examples.filesystem.synchronizeWizard"/>
- </extension>
-
- <extension
- point="org.eclipse.team.ui.synchronizeParticipants">
- <participant
- persistent="false"
- icon="icons/full/wizards/synced.gif"
- class="org.eclipse.team.examples.localhistory.LocalHistoryParticipant"
- name="Latest From Local History"
- id="org.eclipse.team.synchronize.example"/>
- </extension>
-
- <extension
- point="org.eclipse.team.ui.synchronizeWizards">
- <wizard
- class="org.eclipse.team.examples.localhistory.LocalHistorySynchronizeWizard"
- icon="icons/full/wizards/synced.gif"
- description="Synchronize resources with their previous contents in the local history"
- name="Synchronize with Latest From Local History"
- id="ExampleSynchronizeSupport.wizard1"/>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Menus for File System Example -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
- adaptable="true"
- id="org.eclipse.team.examples.filesystem.ResourceContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider">
- </filter>
- <action
- label="%Put.name"
- tooltip="%Put.tooltip"
- class="org.eclipse.team.examples.filesystem.ui.PutAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.filesystem.put">
- </action>
- <action
- label="%Get.name"
- tooltip="%Get.tooltip"
- class="org.eclipse.team.examples.filesystem.ui.GetAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.filesystem.get">
- </action>
- <action
- label="%Synchronize.name"
- tooltip="%Synchronize.tooltip"
- class="org.eclipse.team.examples.filesystem.ui.SynchronizeAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.filesystem.synchronize">
- </action>
- <action
- label="%Replace.name"
- tooltip="%ReplaceAction.tooltip"
- class="org.eclipse.team.examples.filesystem.ui.ReplaceAction"
- menubarPath="replaceWithMenu/replaceWithGroup"
- id="org.eclipse.team.examples.filesystem.replace">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true"
- id="org.eclipse.team.examples.filesystem.ProjectContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider">
- </filter>
- <action
- label="%Unmanage.name"
- tooltip="%Unmanage.tooltip"
- class="org.eclipse.team.examples.filesystem.ui.DisconnectAction"
- menubarPath="team.main/group2"
- id="org.eclipse.team.examples.filesystem.unmanage">
- </action>
- </objectContribution>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Sharing Wizards -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.team.ui.configurationWizards">
- <wizard
- name="%fswizard.name"
- icon="icons/full/wizards/fsicon_wiz.gif"
- class="org.eclipse.team.examples.filesystem.ui.ConfigurationWizard"
- id="org.eclipse.team.examples.filesystem.ui.ConfigurationWizard">
- </wizard>
- </extension>
-
- <extension
- point="org.eclipse.team.ui.configurationWizards">
- <wizard
- name="Pessimistic Simple Provider (Non-Versioning)"
- icon="icons/full/wizards/fsicon_wiz.gif"
- class="org.eclipse.team.examples.pessimistic.ui.ConfigurationWizard"
- id="org.eclipse.team.examples.pessimistic.ui.ConfigurationWizard">
- </wizard>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Property Pages -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.ui.propertyPages">
- <page
- objectClass="org.eclipse.core.resources.IResource"
- adaptable="true"
- name="%fspropertypage.name"
- class="org.eclipse.team.examples.filesystem.ui.FileSystemPropertiesPage"
- id="org.eclipse.team.examples.filesystem.ui.FileSystemPropertiesPage">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider">
- </filter>
- </page>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Preference Pages -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- name="Pessimistic Filesystem Provider"
- category="org.eclipse.team.ui.TeamPreferences"
- class="org.eclipse.team.examples.pessimistic.ui.PessimisticPreferencesPage"
- id="org.eclipse.team.examples.pessimistic.ui.PessimisticPreferences">
- </page>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Decorators -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.ui.decorators">
- <decorator
- objectClass="org.eclipse.core.resources.IResource"
- adaptable="true"
- label="Pessimistic Filesystem Provider Decorator"
- state="true"
- class="org.eclipse.team.examples.pessimistic.ui.PessimisticDecorator"
- id="org.eclipse.team.pessimistic.ui.decorator">
- <description>
- Provides simple checked-in, checked-out decorations on files.
- </description>
- </decorator>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Menus for Pessimistic Provider -->
-<!-- =================================================================================== -->
-
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
- adaptable="true"
- id="org.eclipse.team.cvs.ui.filesystem.ResourceContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.pessimistic.pessimisticnature">
- </filter>
- <action
- label="Checkout"
- tooltip="Check resources out of the repository"
- class="org.eclipse.team.examples.pessimistic.ui.CheckOutAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.pessimistic.checkout">
- </action>
- <action
- label="Checkin"
- tooltip="Check resources into the repository"
- class="org.eclipse.team.examples.pessimistic.ui.CheckInAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.pessimistic.checkin">
- </action>
- <action
- label="Uncheckout"
- tooltip="Revert checked out status of resources"
- class="org.eclipse.team.examples.pessimistic.ui.UncheckOutAction"
- menubarPath="team.main/group1"
- id="org.eclipse.team.examples.pessimistic.uncheckout">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- id="org.eclipse.team.cvs.ui.filesystem.ResourceContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.pessimistic.pessimisticnature">
- </filter>
- <action
- label="Add to control"
- class="org.eclipse.team.examples.pessimistic.ui.AddToControlAction"
- menubarPath="team.main/group2"
- id="org.eclipse.team.examples.pessimistic.addToControl">
- </action>
- <action
- label="Remove from control"
- class="org.eclipse.team.examples.pessimistic.ui.RemoveFromControlAction"
- menubarPath="team.main/group2"
- id="org.eclipse.team.examples.pessimistic.removeFromControl">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IFolder"
- adaptable="true"
- id="org.eclipse.team.cvs.ui.filesystem.ResourceContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.pessimistic.pessimisticnature">
- </filter>
- <action
- label="Add to control"
- class="org.eclipse.team.examples.pessimistic.ui.AddToControlAction"
- menubarPath="team.main/group2"
- id="org.eclipse.team.examples.pessimistic.addToControl">
- </action>
- <action
- label="Remove from control"
- class="org.eclipse.team.examples.pessimistic.ui.RemoveFromControlAction"
- menubarPath="team.main/group2"
- id="org.eclipse.team.examples.pessimistic.removeFromControl">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true"
- id="org.eclipse.team.cvs.ui.filesystem.ResourceContributions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.core.repository=org.eclipse.team.examples.pessimistic.pessimisticnature">
- </filter>
- <action
- label="Stop sharing"
- tooltip="Stop sharing the project using the pessimistic file provider"
- class="org.eclipse.team.examples.pessimistic.ui.DisconnectAction"
- menubarPath="team.main/projectGroup"
- id="org.eclipse.team.examples.pessimistic.disconnect">
- </action>
- </objectContribution>
- </extension>
-
-<!-- =================================================================================== -->
-<!-- Capability Support (a.k.a. Activities) -->
-<!-- Note: Uncomment the lines below to enable the capabilities. These can't be enabled in the -->
-<!-- examples because some products ship the examples with the product. -->
-<!-- =================================================================================== -->
-<!--
- <extension point="org.eclipse.ui.activities">
-
- <activity
- name="%activity.team.examples.filesystem.name"
- description="%activity.team.examples.filesystem.description"
- id="org.eclipse.team.examples.filesystem">
- </activity>
-
- <activityRequirementBinding
- activityId="org.eclipse.team.examples.filesystem"
- requiredActivityId="org.eclipse.team">
- </activityRequirementBinding>
-
- <activityPatternBinding
- activityId="org.eclipse.team.examples.filesystem"
- pattern="org\.eclipse\.team\.examples\.filesystem/.*filesystem\.ui.*">
- </activityPatternBinding>
-
- <activityPatternBinding
- activityId="org.eclipse.team.examples.filesystem"
- pattern="org\.eclipse\.team\.examples\.filesystem/.*FileSystemProvider">
- </activityPatternBinding>
-
- <categoryActivityBinding
- activityId="org.eclipse.team.examples.filesystem"
- categoryId="org.eclipse.categories.teamCategory">
- </categoryActivityBinding>
-
- <activity
- name="%activity.team.examples.pessimistic.name"
- description="%activity.team.examples.pessimistic.description"
- id="org.eclipse.team.examples.pessimistic">
- </activity>
-
- <activityRequirementBinding
- activityId="org.eclipse.team.examples.pessimistic"
- requiredActivityId="org.eclipse.team">
- </activityRequirementBinding>
-
- <activityPatternBinding
- activityId="org.eclipse.team.examples.pessimistic"
- pattern="org\.eclipse\.team\.examples\.filesystem/.*pessimistic\.ui.*">
- </activityPatternBinding>
-
- <activityPatternBinding
- activityId="org.eclipse.team.examples.pessimistic"
- pattern="org\.eclipse\.team\.examples\.filesystem/.*pessimisticnature">
- </activityPatternBinding>
-
- <categoryActivityBinding
- activityId="org.eclipse.team.examples.pessimistic"
- categoryId="org.eclipse.categories.teamCategory">
- </categoryActivityBinding>
-
- </extension>
--->
-</plugin>
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java
deleted file mode 100644
index 5e0821b2d..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFileModificationValidator;
-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;
-
-/**
- * This class models a sentry that verifies whether resources are available for editing or overwriting.
- * This has been made a separate clas for illustration purposes. It may have been more apporpriate
- * to have FileSystemProvider implement IFileModificationValidator itself since the interface
- * only has two methods and their implementation is straight forward.
- */
-public final class FileModificationValidator implements IFileModificationValidator {
-
- private FileSystemOperations operations;
-
- /**
- * Constructor for FileModificationValidator.
- */
- public FileModificationValidator(RepositoryProvider provider) {
- operations = ((FileSystemProvider)provider).getOperations();
- }
-
- /**
- * This method will convert any exceptions thrown by the SimpleAccessOperations.chechout() to a Status.
- * @param resources the resources that are to be checked out
- * @return IStatus a status indicator that reports whether the operation went smoothly or not.
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#chechout(IResource[] resources, int depth, IProgressMonitor progress)
- */
- private IStatus checkout(IResource[] resources) {
- try {
- operations.checkout(resources, IResource.DEPTH_INFINITE, null);
- } catch (TeamException e) {
- return new Status(IStatus.ERROR, FileSystemPlugin.ID, 0, e.getLocalizedMessage(), e);
- }
- return Status.OK_STATUS;
- }
-
- /**
- * This method will be called by the workbench/editor before it tries to edit one or more files.
- * The idea is to prevent anyone from accidentally working on a file that they won't be able to check in changes to.
- * @see org.eclipse.core.resources.IFileModificationValidator#validateEdit(IFile[], Object)
- */
- public IStatus validateEdit(IFile[] files, Object context) {
- Collection toBeCheckedOut = new ArrayList();
-
- //Make a list of all the files that need to be checked out:
- for (int i = 0; i < files.length; i++) {
- if (!operations.isCheckedOut(files[i])) {
- toBeCheckedOut.add(files[i]);
- }
- }
-
- return checkout((IResource[]) toBeCheckedOut.toArray(new IResource[toBeCheckedOut.size()]));
- }
-
- /**
- * This method will be called by the workbench before it tries to save a file.
- * It should not attempt to save any files that don't recieve an OK status here.
- * @see org.eclipse.core.resources.IFileModificationValidator#validateSave(IFile)
- */
- public IStatus validateSave(IFile file) {
- if (file.isReadOnly()) {
- return checkout(new IResource[] { file });
- } else {
- return Status.OK_STATUS;
- }
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
deleted file mode 100644
index 32133b3ec..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-import org.eclipse.team.core.variants.ThreeWaySynchronizer;
-import org.eclipse.team.examples.filesystem.subscriber.FileSystemResourceVariant;
-import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber;
-
-/**
- * The get and put operations for the file system provider.
- */
-public class FileSystemOperations {
-
- // A reference to the provider
- private FileSystemProvider provider;
-
- FileSystemOperations(FileSystemProvider provider) {
- this.provider = provider;
- }
-
- /**
- * Make the local state of the project match the remote state by getting any out-of-sync
- * resources. The overrideOutgoing flag is used to indicate whether locally modified
- * files should also be replaced or left alone.
- * @param resources the resources to get
- * @param depth the depth of the operation
- * @param overrideOutgoing whether locally modified resources should be replaced
- * @param progress a progress monitor
- * @throws TeamException
- */
- public void get(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
- try {
- // ensure the progress monitor is not null
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("GetAction.working"), 100); //$NON-NLS-1$
- // Refresh the subscriber so we have the latest remote state
- FileSystemSubscriber.getInstance().refresh(resources, depth, new SubProgressMonitor(progress, 30));
- internalGet(resources, depth, overrideOutgoing, new SubProgressMonitor(progress, 70));
- } finally {
- progress.done();
- }
- }
-
- /**
- * Checkout the given resources to the given depth by setting any files
- * to writtable (i.e set read-only to <coce>false</code>.
- * @param resources the resources to be checked out
- * @param depth the depth of the checkout
- * @param progress a progress monitor
- * @throws TeamException
- */
- public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- try {
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.1"), resources.length); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
- resources[i].accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- //TODO: lock the file on the 'server'.
- resource.setReadOnly(false);
- }
- return true;
- }
- }, depth, false /* include phantoms */);
- progress.worked(1);
- }
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- } finally {
- progress.done();
- }
- }
-
- /**
- * Checkin the given resources to the given depth by replacing the remote (i.e. file system)
- * contents with the local workspace contents.
- * @param resources the resources
- * @param depth the depth of the operation
- * @param overrideIncoming indicate whether incoming remote changes should be replaced
- * @param progress a progress monitor
- * @throws TeamException
- */
- public void checkin(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
- try {
- // ensure the progress monitor is not null
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("PutAction.working"), 100); //$NON-NLS-1$
- // Refresh the subscriber so we have the latest remote state
- FileSystemSubscriber.getInstance().refresh(resources, depth, new SubProgressMonitor(progress, 30));
- internalPut(resources, depth, overrideIncoming, new SubProgressMonitor(progress, 70));
- } finally {
- progress.done();
- }
- }
-
- /**
- * Return whether the local resource is checked out. A resource
- * is checked out if it is a file that is not read-only. Folders
- * are always checked out.
- * @param resource the resource
- * @return whether the resource is checked out and can be modified
- */
- public boolean isCheckedOut(IResource resource) {
- if (resource.getType() != IResource.FILE) return true;
- return !resource.isReadOnly();
- }
-
- /*
- * Get the resource variant for the given resource.
- */
- private FileSystemResourceVariant getResourceVariant(IResource resource) {
- return (FileSystemResourceVariant)provider.getResourceVariant(resource);
- }
-
- private void internalGet(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
- // Traverse the resources and get any that are out-of-sync
- progress.beginTask(Policy.bind("GetAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
- if (resources[i].getType() == IResource.FILE) {
- internalGet((IFile) resources[i], overrideOutgoing, progress);
- } else if (depth != IResource.DEPTH_ZERO) {
- internalGet((IContainer)resources[i], depth, overrideOutgoing, progress);
- }
- progress.worked(1);
- }
- }
-
- /*
- * Get the folder and its children to the depth specified.
- */
- private void internalGet(IContainer container, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
- try {
- ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
- // Make the local folder state match the remote folder state
- List toDelete = new ArrayList();
- if (container.getType() == IResource.FOLDER) {
- IFolder folder = (IFolder)container;
- FileSystemResourceVariant remote = getResourceVariant(container);
- if (!folder.exists() && remote != null) {
- // Create the local folder
- folder.create(false, true, progress);
- synchronizer.setBaseBytes(folder, remote.asBytes());
- } else if (folder.exists() && remote == null) {
- // Schedule the folder for removal but delay in
- // case the folder contains outgoing changes
- toDelete.add(folder);
- }
- }
-
- // Get the children
- IResource[] children = synchronizer.members(container);
- if (children.length > 0) {
- internalGet(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideOutgoing, progress);
- }
-
- // Remove any empty folders
- for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
- IFolder folder = (IFolder) iter.next();
- if (folder.members().length == 0) {
- folder.delete(false, true, progress);
- synchronizer.flush(folder, IResource.DEPTH_INFINITE);
- }
- }
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
-
- /*
- * Get the file if it is out-of-sync.
- */
- private void internalGet(IFile localFile, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
- ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
- IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
- FileSystemResourceVariant remote = getResourceVariant(localFile);
- byte[] baseBytes = synchronizer.getBaseBytes(localFile);
- IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
- if (!synchronizer.hasSyncBytes(localFile)
- || (synchronizer.isLocallyModified(localFile) && !overrideOutgoing)) {
- // Do not overwrite the local modification
- return;
- }
- if (base != null && remote == null) {
- // The remote no longer exists so remove the local
- try {
- localFile.delete(false, true, progress);
- synchronizer.flush(localFile, IResource.DEPTH_ZERO);
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
- if (!synchronizer.isLocallyModified(localFile) && comparator.compare(base, remote)) {
- // The base and remote are the same and there's no local changes
- // so nothing needs to be done
- }
- try {
- //Copy from the local file to the remote file:
- InputStream source = null;
- try {
- // Get the remote file content.
- source = remote.getContents();
- // Set the local file content to be the same as the remote file.
- if (localFile.exists())
- localFile.setContents(source, false, false, progress);
- else
- localFile.create(source, false, progress);
- } finally {
- if (source != null)
- source.close();
- }
- // Mark as read-only to force a checkout before editing
- localFile.setReadOnly(true);
- synchronizer.setBaseBytes(localFile, remote.asBytes());
- } catch (IOException e) {
- throw FileSystemPlugin.wrapException(e);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
-
- private void internalPut(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
- // ensure the progress monitor is not null
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("PutAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
- if (resources[i].getType() == IResource.FILE) {
- internalPut((IFile)resources[i], overrideIncoming, progress);
- } else if (depth > 0) { //Assume that resources are either files or containers.
- internalPut((IContainer)resources[i], depth, overrideIncoming, progress);
- }
- progress.worked(1);
- }
- progress.done();
- }
-
- /*
- * Get the file if it is out-of-sync.
- */
- private void internalPut(IFile localFile, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
- ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
- IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
- FileSystemResourceVariant remote = getResourceVariant(localFile);
- byte[] baseBytes = synchronizer.getBaseBytes(localFile);
- IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
-
- // Check whether we are overriding a remote change
- if (base == null && remote != null && !overrideIncoming) {
- // The remote is an incoming (or conflicting) addition.
- // Do not replace unless we are overriding
- return;
- } else if (base != null && remote == null) {
- // The remote is an incoming deletion
- if (!localFile.exists()) {
- // Conflicting deletion. Clear the synchronizer.
- synchronizer.flush(localFile, IResource.DEPTH_ZERO);
- } else if (!overrideIncoming) {
- // Do not override the incoming deletion
- return;
- }
- } else if (base != null && remote != null) {
- boolean same = comparator.compare(base, remote);
- if (!synchronizer.isLocallyModified(localFile) && same) {
- // The base and remote are the same and there's no local changes
- // so nothing needs to be done
- return;
- }
- if (!same && !overrideIncoming) {
- // The remote has changed. Only override if specified
- return;
- }
- }
-
- // Handle an outgoing deletion
- File diskFile = provider.getFile(localFile);
- if (!localFile.exists()) {
- diskFile.delete();
- synchronizer.flush(localFile, IResource.DEPTH_ZERO);
- } else {
- // Otherwise, upload the contents
- try {
- //Copy from the local file to the remote file:
- InputStream in = null;
- FileOutputStream out = null;
- try {
- if(! diskFile.getParentFile().exists()) {
- diskFile.getParentFile().mkdirs();
- }
- in = localFile.getContents();
- out = new FileOutputStream(diskFile);
- //Copy the contents of the local file to the remote file:
- StreamUtil.pipe(in, out, diskFile.length(), progress, diskFile.getName());
- // Mark the file as read-only to require another checkout
- localFile.setReadOnly(true);
- } finally {
- if (in != null)
- in.close();
- if (out != null)
- out.close();
- }
- // Update the synchronizer base bytes
- remote = getResourceVariant(localFile);
- synchronizer.setBaseBytes(localFile, remote.asBytes());
- } catch (IOException e) {
- throw FileSystemPlugin.wrapException(e);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- }
-
- /*
- * Get the folder and its children to the depth specified.
- */
- private void internalPut(IContainer container, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
- try {
- ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
- // Make the local folder state match the remote folder state
- List toDelete = new ArrayList();
- if (container.getType() == IResource.FOLDER) {
- IFolder folder = (IFolder)container;
- File diskFile = provider.getFile(container);
- FileSystemResourceVariant remote = getResourceVariant(container);
- if (!folder.exists() && remote != null) {
- // Schedule the folder for removal but delay in
- // case the folder contains incoming changes
- toDelete.add(diskFile);
- } else if (folder.exists() && remote == null) {
- // Create the remote directory and sync up the local
- diskFile.mkdir();
- synchronizer.setBaseBytes(folder, provider.getResourceVariant(folder).asBytes());
- }
- }
-
- // Get the children
- IResource[] children = synchronizer.members(container);
- if (children.length > 0) {
- internalPut(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideIncoming, progress);
- }
-
- // Remove any empty folders
- for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
- File diskFile = (File) iter.next();
- if (diskFile.listFiles().length == 0) {
- diskFile.delete();
- synchronizer.flush(container, IResource.DEPTH_INFINITE);
- }
- }
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java
deleted file mode 100644
index 9be45c067..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.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.examples.filesystem;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * This is the plugin class for the file system examples. It provides the following:
- *
- * <ol>
- * <li>public fields for the plugin and provider IDs as defined in the plugin.xml
- * <li>initialization on startup of Policy class that provides internationalization of strings
- * <li>helper methods for outputing IStatus objects to the log
- * <li>helper methods for converting CoreExceptions and IOExceptions to TeamExceptions
- * </ol>
- */
-public class FileSystemPlugin extends AbstractUIPlugin {
-
- /**
- * This is the ID of the plugin as defined in the plugin.xml
- */
- public static final String ID = "org.eclipse.team.examples.filesystem"; //$NON-NLS-1$
-
- /**
- * This is the provider ID of the plugin as defined in the plugin.xml
- */
- public static final String PROVIDER_ID = ID + ".FileSystemProvider"; //$NON-NLS-1$
-
- // This static field will hold the singleton instance of the plugin class
- private static FileSystemPlugin plugin;
-
- private PessimisticFilesystemProviderPlugin pessimisticPlugin;
-
- /**
- * Override the standard plugin constructor.
- *
- * @param descriptor the plugin descriptor
- */
- public FileSystemPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- // record this instance as the singleton
- plugin = this;
- pessimisticPlugin = new PessimisticFilesystemProviderPlugin(descriptor);
- }
-
- /**
- * This method will get invoked when the plugin is started.
- * Note that this is not necessarily at workbench startup.
- *
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void startup() throws CoreException {
- // localize the string bindings used by the plugins (in order to provide NLS support)
- Policy.localize("org.eclipse.team.examples.filesystem.messages"); //$NON-NLS-1$
- }
-
- /**
- * Return the singlton instance of the plugin class to allow other
- * classes in the plugin access to plugin instance methods such as
- * those for logging errors, etc.
- */
- public static FileSystemPlugin getPlugin() {
- return plugin;
- }
-
- /**
- * Helper method to convert a CoreException into a TeamException.
- * We do this to maintain the core status and code. This type of
- * mapping may not be appropriate in more complicated exception
- * handling situations.
- *
- * @param e the CoreException
- */
- public static TeamException wrapException(CoreException e) {
- return new TeamException(e.getStatus());
- }
-
- /**
- * Helper method to convert an IOException into a TeamException.
- * This type of mapping may not be appropriate in more complicated
- * exception handling situations.
- *
- * @param e the CoreException
- */
- public static TeamException wrapException(IOException e) {
- return new TeamException(new Status(IStatus.ERROR, FileSystemPlugin.ID,
- TeamException.IO_FAILED, e.getMessage(), e));
- }
-
- /**
- * Helper method to log an exception status.
- *
- * @param status the status to be logged
- */
- public static void log(IStatus status) {
- plugin.getLog().log(status);
- }
-}
-
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java
deleted file mode 100644
index 4d80d9fb7..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFileModificationValidator;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.examples.filesystem.subscriber.FileSystemResourceVariant;
-import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber;
-
-/**
- * This example illustrates how to create a concrete implementation of a <code>RepositoryProvider</code>
- * that uses the file system to act as the repository. See the plugin.xml file for the xml required
- * to register this provider with the Team extension point <code>org.eclipse.team.core.repository</code>.
- * The plugin.xml file also contains examples of how to filter menu items using a repsitory provider's
- * ID.
- *
- * <p>
- * This example provider illustrates the following:
- * <ol>
- * <li>simple working implementation of <code>RepositoyProvider</code>
- * <li>storage of a persistant property with the project (which provides the target location for the provider)
- * <li>access to an instance of <code>SimpleAccessOperations</code> for performing simple file operations
- * </ol>
- *
- * <p>
- * Additional functionality that will be illustrated in the future include:
- * <ol>
- * <li>Validate Save/Validat Edit
- * <li>Move/Delete Hook
- * <li>Project Sets
- * <li>Use of the workspace synchronizer (ISynchronizer)
- * <li>Use of decorators
- * <li>combining streams and progress monitors to get responsive UI
- * </ol>
- *
- */
-public class FileSystemProvider extends RepositoryProvider {
-
- // The location of the folder on file system where the repository is stored.
- private IPath root;
-
- // The QualifiedName that is used to persist the location accross workspace as a persistant property on a resource
- private static QualifiedName FILESYSTEM_REPO_LOC = new QualifiedName(FileSystemPlugin.ID, "disk_location"); //$NON-NLS-1$
-
- /**
- * Create a new FileSystemProvider.
- */
- public FileSystemProvider() {
- super();
- }
-
- /**
- * This method is invoked when the provider is mapped to a project.
- * Although we have access to the project at this point (using
- * <code>getProject()</code>, we don't know the root location so
- * there is nothing we can do yet.
- *
- * @see org.eclipse.team.core.RepositoryProvider#configureProject()
- */
- public void configureProject() throws CoreException {
- FileSystemSubscriber.getInstance().handleRootChanged(getProject(), true /* added */);
- }
-
- /**
- * This method is invoked when the provider is unmapped from its
- * project.
- *
- * @see org.eclipse.core.resources.IProjectNature#deconfigure()
- */
- public void deconfigure() throws CoreException {
- // Clear the persistant property containing the location
- getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, null);
- FileSystemSubscriber.getInstance().handleRootChanged(getProject(), false /* removed */);
- }
-
- /**
- * Return the provider ID as specified in the plugin.xml
- *
- * @see RepositoryProvider#getID()
- */
- public String getID() {
- return FileSystemPlugin.PROVIDER_ID;
- }
-
- /**
- * Set the file system location for the provider. This mist be invoked after
- * the provider is mapped and configured but before the provider is used to
- * perform any operations.
- *
- * @param location the path representing the location where the project contents will be stored.
- * @throws TeamException
- */
- public void setTargetLocation(String location) throws TeamException {
-
- // set the instance variable to the provided path
- root = new Path(location);
-
- // ensure that the location is a folder (if it exists)
- File file = new File(location);
- if (file.exists() && !file.isDirectory()) {
- throw new TeamException(Policy.bind("FileSystemProvider.mustBeFolder", location)); //$NON-NLS-1$
- }
-
- // record the location as a persistant property so it will be remembered across platform invokations
- try {
- getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, location);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
-
- /**
- * Returns the folder in the file system to which the provider is connected.
- * Return <code>null</code> if there is no location or there was a problem
- * determining it.
- *
- * @return IPath The path to the root of the repository.
- */
- public IPath getRoot() {
- if (root == null) {
- try {
- String location = getProject().getPersistentProperty(FILESYSTEM_REPO_LOC);
- if (location == null) {
- return null;
- }
- root = new Path(location);
- } catch (CoreException e) {
- // log the problem and carry on
- FileSystemPlugin.log(e.getStatus());
- return null;
- }
- }
- return root;
- }
-
- /**
- * Return an object that provides the operations for transfering data
- * to and from the provider's location.
- */
- public FileSystemOperations getOperations() {
- return new FileSystemOperations(this);
- }
- /**
- * @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator()
- */
- public IFileModificationValidator getFileModificationValidator() {
- return new FileModificationValidator(this);
- }
-
- /**
- * Return the resource variant for the local resource using the bytes to
- * identify the variant.
- * @param resource the resource
- * @param bytes the bytes that identify the resource variant
- * @return the resource variant handle
- */
- public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) {
- if (bytes == null) return null;
- File file = getFile(resource);
- if (file == null) return null;
- return new FileSystemResourceVariant(file, bytes);
- }
-
- /**
- * Return the resource variant for the local resource.
- * @param resource the resource
- * @return the resource variant
- */
- public IResourceVariant getResourceVariant(IResource resource) {
- File file = getFile(resource);
- if (file == null) return null;
- return new FileSystemResourceVariant(file);
- }
-
- /**
- * Return the <code>java.io.File</code> that the given resource maps to.
- * Return <code>null</code> if the resource is not a child of this provider's
- * project.
- * @param resource the resource
- * @return the file that the resource maps to.
- */
- public java.io.File getFile(IResource resource) {
- if (resource.getProject().equals(getProject())) {
- IPath rootdir = getRoot();
- return new File(rootdir.append(resource.getProjectRelativePath()).toOSString());
- }
- return null;
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java
deleted file mode 100644
index 97a9aff37..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProviderType.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem;
-
-import org.eclipse.team.core.ProjectSetCapability;
-import org.eclipse.team.core.RepositoryProviderType;
-
-/**
- * The file system repository provider types
- */
-public class FileSystemProviderType extends RepositoryProviderType {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()
- */
- public ProjectSetCapability getProjectSetCapability() {
- // Create an empty project set capability to test backwards compatibility
- return new ProjectSetCapability() {};
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java
deleted file mode 100644
index cfb2db53a..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.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.examples.filesystem;
-
-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;
-
-/**
- * This class is a clone of the Polciy classes many Eclipse plugin suse to
- * provide NLSing of strings and aid in proper progress monitoring.
- */
-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);
- }
-
- /**
- * 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;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java
deleted file mode 100644
index f39f21743..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.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.examples.filesystem;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class StreamUtil {
-
- protected final static byte[] COPY_BUFFER = new byte[4096];
-
- public static void pipe(
- InputStream in,
- OutputStream out,
- long sizeEstimate,
- IProgressMonitor progress,
- String title)
- throws IOException {
-
- // Only show progress for files larger than 25Kb.
- Long kilobytesEstimate = new Long(sizeEstimate / 1024);
- boolean showProgress = (progress != null) && (sizeEstimate > 25000);
- long bytesCopied = 0;
-
- synchronized (COPY_BUFFER) {
- // Read the initial chunk.
- int read = in.read(COPY_BUFFER, 0, COPY_BUFFER.length);
-
- while (read != -1) {
- out.write(COPY_BUFFER, 0, read);
-
- // Report progress
- if (showProgress) {
- bytesCopied = bytesCopied + read;
- progress.subTask(
- Policy.bind(
- "filetransfer.monitor", //$NON-NLS-1$
- new Object[] { title, new Long(bytesCopied / 1024), kilobytesEstimate }));
- }
-
- // Read the next chunk.
- read = in.read(COPY_BUFFER, 0, COPY_BUFFER.length);
- } // end while
- } // end synchronized
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties
deleted file mode 100644
index ccb68c1c3..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties
+++ /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
-###############################################################################
-fileSystem.propertyLocation=Location:
-
-FileSystemMainPage.location=Location:
-FileSystemMainPage.browseDir=&Browse...
-FileSystemMainPage.notValidLocation=Location must be an existing directory
-
-fsMainPage.name=Select a file system location
-fsMainPage.description=This location will be used to share resources with a team
-
-ConfigurationWizard.errorTitle=Error configuring the provider.
-ConfigurationWizard.error=File System provider could not be created
-
-ConfigurationWizard.name=File System Repository
-ConfigurationWizard.description=File System Repository Properties
-
-DisconnectAction.errorTitle=Error Disconnecting
-
-PutAction.working=Putting resources...
-PutAction.problemMessage=A problem occured putting the resources.
-
-GetAction.working=Getting resources...
-GetAction.problemMessage=A problem occured getting the resources.
-
-ReplaceAction.working=Replacing resources...
-ReplaceAction.problemMessage=A problem occured replacing the resources.
-
-FileSystemProvider.mustBeFolder=Target location ''{0}'' is a file and must be a folder.
-RemoteResource.mustBeFolder=Resource ''{0}'' is a file so it cannot have entries
-FileSystemRemoteResource.0=This resource is a container so it cannot have data.
-FileSystemSimpleAccessOperations.1=Checking resources out...
-FileSystemSimpleAccessOperations.3=Re-locking resources...
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java
deleted file mode 100644
index 891046ad3..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.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.examples.filesystem.subscriber;
-
-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.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.ThreeWayRemoteTree;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-
-/**
- * The file sytem three-way remote resource varant tree taht provides
- * the ability to traverse the file system for the creation of resource variants.
- */
-public class FileSystemRemoteTree extends ThreeWayRemoteTree {
-
- /**
- * Create the file syetm remote resource variant tree
- * @param subscriber the file system subscriber
- */
- public FileSystemRemoteTree(FileSystemSubscriber subscriber) {
- super(subscriber);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchMembers(org.eclipse.team.core.variants.IResourceVariant, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException {
- return ((FileSystemResourceVariant)variant).members();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchVariant(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID);
- if (provider != null) {
- return ((FileSystemProvider)provider).getResourceVariant(resource);
- }
- return null;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java
deleted file mode 100644
index 365846239..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.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.examples.filesystem.subscriber;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.CachedResourceVariant;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-
-/**
- * A file system resource variant. Although not strictly necessary, this
- * class extends <code>CachedResourceVariant</code> which will
- * cache the contents of the resource variant.
- */
-public class FileSystemResourceVariant extends CachedResourceVariant {
-
- private java.io.File ioFile;
- private byte[] bytes;
-
- /**
- * Create a resource variant for the given file. The bytes will
- * be calculated when they are accessed.
- * @param file the file
- */
- public FileSystemResourceVariant(java.io.File file) {
- this.ioFile = file;
- }
-
- /**
- * Create a resource variant for the given file and sync bytes.
- * @param file the file
- * @param bytes the timestamp bytes
- */
- public FileSystemResourceVariant(java.io.File file, byte[] bytes) {
- this.ioFile = file;
- this.bytes = bytes;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.CachedResourceVariant#fetchContents(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void fetchContents(IProgressMonitor monitor) throws TeamException {
- setContents(getContents(), monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.CachedResourceVariant#getCachePath()
- */
- protected String getCachePath() {
- // append the timestamp to the file path to give each variant a unique path
- return getFilePath() + " " + ioFile.lastModified(); //$NON-NLS-1$
- }
-
- private String getFilePath() {
- try {
- return ioFile.getCanonicalPath();
- } catch (IOException e) {
- // Failed for some reason. Try the absolute path.
- FileSystemPlugin.log(new Status(IStatus.ERROR, FileSystemPlugin.ID, 0,
- "Failed to obtain canonical path for " + ioFile.getAbsolutePath(), e)); //$NON-NLS-1$
- return ioFile.getAbsolutePath();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.CachedResourceVariant#getCacheId()
- */
- protected String getCacheId() {
- return FileSystemPlugin.ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariant#getName()
- */
- public String getName() {
- return ioFile.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariant#isContainer()
- */
- public boolean isContainer() {
- return ioFile.isDirectory();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariant#getContentIdentifier()
- */
- public String getContentIdentifier() {
- // Use the modification timestamp as the content identifier
- return new Date(ioFile.lastModified()).toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariant#asBytes()
- */
- public byte[] asBytes() {
- if (bytes == null) {
- // For simplicity, convert the timestamp to it's string representation.
- // A more optimal storage format would be the 8 bytes that make up the long.
- bytes = Long.toString(ioFile.lastModified()).getBytes();
- }
- return bytes;
- }
-
- /**
- * Return the files contained by the file of this resource variant.
- * @return the files contained by the file of this resource variant.
- */
- public FileSystemResourceVariant[] members() {
- if (isContainer()) {
- java.io.File[] members = ioFile.listFiles();
- FileSystemResourceVariant[] result = new FileSystemResourceVariant[members.length];
- for (int i = 0; i < members.length; i++) {
- result[i] = new FileSystemResourceVariant(members[i]);
- }
- return result;
- } else {
- return new FileSystemResourceVariant[0];
- }
- }
-
- /**
- * @return
- */
- public InputStream getContents() throws TeamException {
- try {
- return new BufferedInputStream(new FileInputStream(ioFile));
- } catch (FileNotFoundException e) {
- throw new TeamException("Failed to fetch contents for " + getFilePath(), e); //$NON-NLS-1$
- }
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java
deleted file mode 100644
index d8b94976e..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.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
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.subscriber;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.ThreeWayRemoteTree;
-import org.eclipse.team.core.variants.ThreeWaySubscriber;
-import org.eclipse.team.core.variants.ThreeWaySynchronizer;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-
-/**
- * This is an example file system subscriber that overrides
- * ThreeWaySubscriber. It uses a repository
- * provider (<code>FileSystemProvider</code>) to determine and
- * manage the roots and to create resource variants. It also makes
- * use of a file system specific remote tree (<code>FileSystemRemoteTree</code>)
- * for provided the remote tree access and refresh.
- *
- * @see ThreeWaySubscriber
- * @see ThreeWaySynchronizer
- * @see FileSystemProvider
- * @see FileSystemRemoteTree
- */
-public class FileSystemSubscriber extends ThreeWaySubscriber {
-
- private static FileSystemSubscriber instance;
-
- /**
- * Return the file system subscriber singleton.
- * @return the file system subscriber singleton.
- */
- public static synchronized FileSystemSubscriber getInstance() {
- if (instance == null) {
- instance = new FileSystemSubscriber();
- }
- return instance;
- }
-
- /**
- * Create the file system subscriber.
- */
- private FileSystemSubscriber() {
- super(new ThreeWaySynchronizer(new QualifiedName(FileSystemPlugin.ID, "workpsace-sync"))); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#getResourceVariant(org.eclipse.core.resources.IResource, byte[])
- */
- public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException {
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID);
- if (provider != null) {
- return ((FileSystemProvider)provider).getResourceVariant(resource, bytes);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#createRemoteTree()
- */
- protected ThreeWayRemoteTree createRemoteTree() {
- return new FileSystemRemoteTree(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#getName()
- */
- public String getName() {
- return "File System Example"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#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.isAccessible()) {
- RepositoryProvider provider = RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
- if(provider != null) {
- result.add(project);
- }
- }
- }
- return (IProject[]) result.toArray(new IProject[result.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#handleRootChanged(org.eclipse.core.resources.IResource, boolean)
- */
- public void handleRootChanged(IResource resource, boolean added) {
- // Override to allow FileSystemProvider to signal the addition and removal of roots
- super.handleRootChanged(resource, added);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, org.eclipse.team.core.variants.IResourceVariant)
- */
- protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
- // Override to use a custom sync info
- FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, this.getResourceComparator());
- info.init();
- return info;
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSyncInfo.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSyncInfo.java
deleted file mode 100644
index 6f9f52d69..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSyncInfo.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.examples.filesystem.subscriber;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-
-/**
- * Provide a custom sync info that will report files that exist both
- * locally and remotely as in-sync and will return a null base if there
- * is an incoming change.
- */
-public class FileSystemSyncInfo extends SyncInfo {
-
- public FileSystemSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) {
- super(local, base, remote, comparator);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.SyncInfo#calculateKind(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected int calculateKind() throws TeamException {
- if (getLocal().getType() != IResource.FILE) {
- if (getLocal().exists() && getRemote() != null) {
- return IN_SYNC;
- }
- }
- return super.calculateKind();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.synchronize.SyncInfo#getBase()
- */
- public IResourceVariant getBase() {
- // If the kind has been set and there is an incoming change
- // return null as the base since the server does not keep the
- // base contents
- if ((getKind() & INCOMING) > 0) {
- return null;
- }
- return super.getBase();
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java
deleted file mode 100644
index bab78242b..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.examples.filesystem.Policy;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * The file system configuration wizard used when associating a project
- * the the file system provider. It is registered as a Team configuration wizard
- * in the plugin.xml and is invoked when a user chooses to create a File System
- * Repository Provider. One invoked, this wizard makes use of the <code>FileSystemMainPage</code>
- * in order to obtain a target locaton on disk.
- */
-public class ConfigurationWizard extends Wizard implements IConfigurationWizard {
-
- IProject project;
-
- FileSystemMainPage mainPage;
-
- public ConfigurationWizard() {
- // retrieve the remembered dialog settings
- IDialogSettings workbenchSettings = FileSystemPlugin.getPlugin().getDialogSettings();
- IDialogSettings section = workbenchSettings.getSection("ProviderExamplesWizard"); //$NON-NLS-1$
- if (section == null) {
- section = workbenchSettings.addNewSection("ProviderExamplesWizard"); //$NON-NLS-1$
- }
- setDialogSettings(section);
- }
-
- /**
- * Remember the project so we can map it on finish
- *
- * @see org.eclipse.team.ui.IConfigurationWizard#init(IWorkbench, IProject)
- */
- public void init(IWorkbench workbench, IProject project) {
- this.project = project;
- }
-
- public void addPages() {
- mainPage = new FileSystemMainPage(
- "FileSystemMainPage", //$NON-NLS-1$
- Policy.bind("ConfigurationWizard.name"), //$NON-NLS-1$
- Policy.bind("ConfigurationWizard.description"), //$NON-NLS-1$
- null);
- addPage(mainPage);
- }
-
- /*
- * Using the information entered in the main page set the provider for
- * the given project.
- */
- public boolean performFinish() {
- mainPage.finish(null);
- try {
- // Map the provider and set the location
- RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID);
- FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project);
- provider.setTargetLocation(mainPage.getLocation());
- } catch (TeamException e) {
- ErrorDialog.openError(
- getShell(),
- Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$
- Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$
- e.getStatus());
- return false;
- }
- return true;
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java
deleted file mode 100644
index 6fc051cdd..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.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.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.filesystem.Policy;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-
-/**
- * Action for getting the contents of the selected resources
- */
-public class DisconnectAction extends TeamAction {
-
- /**
- * @see org.eclipse.ui.IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- IProject projects[] = getSelectedProjects();
- try {
- for (int i = 0; i < projects.length; i++) {
- RepositoryProvider.unmap(projects[i]);
- }
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), Policy.bind("DisconnectAction.errorTitle"), null, e.getStatus()); //$NON-NLS-1$
- }
- }
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() {
- return true;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java
deleted file mode 100644
index f129ab5d4..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.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.examples.filesystem.ui;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-
-/**
- * An abstract class that acts as a super class for FileSystemProvider actions.
- * It provides some general methods applicable to multipe actions.
- */
-public abstract class FileSystemAction extends TeamAction {
-
- /**
- * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
- */
- protected boolean isEnabled() {
- IResource[] resources = getSelectedResources();
- if (resources.length == 0)
- return false;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- // we only want to work on resources mapped to a file system provider
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID);
- if (provider == null)
- return false;
- }
- return true;
- }
-
- /**
- * Split the resources into sets associated with their project/provider
- */
- protected Map getRepositoryProviderMapping() {
- HashMap result = new HashMap();
- IResource[] resources = getSelectedResources();
- for (int i = 0; i < resources.length; i++) {
- RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject());
- List list = (List) result.get(provider);
- if (list == null) {
- list = new ArrayList();
- result.put(provider, list);
- }
- list.add(resources[i]);
- }
- return result;
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java
deleted file mode 100644
index 219ac80fc..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.ImageDescriptor;
-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.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.team.examples.filesystem.Policy;
-
-/**
- * This class provides the main page of the file system repository configuration wizard.
- * It allows the user to select a location on disk. Once the page is finished, the
- * location can be accessed using the <code>getLocation()</code> method.
- */
-public class FileSystemMainPage extends WizardPage {
-
- private static final int COMBO_HISTORY_LENGTH = 5;
-
- String location;
- Combo locationCombo;
-
- /*
- * WizardPage constructor comment.
- * @param pageName the name of the page
- * @param title the title of the page
- * @param description the description of the page
- * @param titleImage the image for the page
- */
-
- public FileSystemMainPage(String pageName, String title, String description, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- setDescription(description);
- setTitle(title);
- }
-
- /*
- * 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
- * @return the newly-created coposite
- */
- protected Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- // GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- // GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- 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) {
- 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;
- }
-
- /*
- * 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);
- 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;
- }
-
- /*
- * 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 <code>ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH</code>.
- *
- * @param history the current history
- * @param newEntry the entry to add to the history
- * @return the history with the new entry appended
- */
- protected 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;
- }
-
- /*
- * 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 <code>ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH</code>.
- *
- * @param history the current history
- * @param newEntry the entry to add to the history
- */
- protected 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);
- }
-
- /*
- * 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;
- }
-
- // Dialog store id constants
- private static final String STORE_LOCATION =
- "ExamplesFSWizardMainPage.STORE_LOCATION";//$NON-NLS-1$
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
- setControl(composite);
-
- Label label = new Label(composite, SWT.NULL);
- label.setText(Policy.bind("FileSystemMainPage.location")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
-
- locationCombo = createEditableCombo(composite);
- locationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- locationCombo.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e) {
- location = ((Combo)e.widget).getText();
- FileSystemMainPage.this.validateFields();
- }
- });
-
- locationCombo.setFocus();
-
- new Label(composite, SWT.NULL);
- Button browse = new Button(composite, SWT.NULL);
- browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- browse.setText(Policy.bind("FileSystemMainPage.browseDir")); //$NON-NLS-1$
- browse.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- DirectoryDialog d = new DirectoryDialog(getShell());
- String directory = d.open();
- if(directory!=null) {
- locationCombo.setText(directory);
- }
- }
- });
-
- initializeValues();
- validateFields();
- }
-
- public String getLocation() {
- return location;
- }
-
- public boolean finish(IProgressMonitor monitor) {
- saveWidgetValues();
- return true;
- }
- /**
- * Initializes states of the controls.
- */
- private void initializeValues() {
- IDialogSettings settings = getDialogSettings();
- if (settings != null) {
- String[] locations = settings.getArray(STORE_LOCATION);
- if (locations != null) {
- for (int i = 0; i < locations.length; i++) {
- locationCombo.add(locations[i]);
- }
- locationCombo.select(0);
- }
- }
- }
- /**
- * Saves the widget values
- */
- private void saveWidgetValues() {
- // Update history
- IDialogSettings settings = getDialogSettings();
- if (settings != null) {
- String[] locations = settings.getArray(STORE_LOCATION);
- if (locations == null) locations = new String[0];
- locations = addToHistory(locations, locationCombo.getText());
- settings.put(STORE_LOCATION, locations);
- }
- }
-
- /*
- * Validates the contents of the editable fields and set page completion
- * and error messages appropriately.
- */
- private void validateFields() {
- String location = locationCombo.getText();
- if (location.length() == 0) {
- setErrorMessage(null);
- setPageComplete(false);
- return;
- } else {
- File file = new File(location);
- if(!file.exists() || !file.isDirectory()) {
- setErrorMessage(Policy.bind("FileSystemMainPage.notValidLocation")); //$NON-NLS-1$
- setPageComplete(false);
- return;
- }
- }
- setErrorMessage(null);
- setPageComplete(true);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java
deleted file mode 100644
index 5db059449..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-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.dialogs.PropertyPage;
-/*
- * A property page which displays the file system specific properties
- * for the selected resource.
- */
-public class FileSystemPropertiesPage extends PropertyPage {
- // The resource to show properties for
- protected IResource resource;
-
- /*
- * 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;
- }
-
- /*
- * @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));
-
- return composite;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeOperation.java
deleted file mode 100644
index 2795419df..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeOperation.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
-
-/**
- * Override SynchronizeModelOperation in order to delegate the operation to each file system
- * provider instance (i.e. each project). Also, prompt to prune conflicts from the set of
- * selected resources.
- */
-public abstract class FileSystemSynchronizeOperation extends SynchronizeModelOperation {
-
- protected FileSystemSynchronizeOperation(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 {
- // First, ask the user if they want to include conflicts
- SyncInfoSet syncSet = getSyncInfoSet();
- if (!promptForConflictHandling(getShell(), syncSet)) return;
- // Divide the sync info by project
- final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
- 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
- FileSystemProvider provider = (FileSystemProvider)RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
- if (provider != null) {
- run(provider, (SyncInfoSet)projectSyncInfos.get(project), monitor);
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- monitor.done();
- }
-
- /**
- * Prompt the user to include conflicts. If the user choses not to include
- * conflicts, they will be removed from the passed set. If the user cancels,
- * <code>false</code> is returned.
- * @param shell a shell
- * @param syncSet the set of selected resources
- * @return whether the operation should proceed.
- */
- protected abstract boolean promptForConflictHandling(Shell shell, SyncInfoSet syncSet);
-
- /*
- * Divide the sync info for the operation by project
- */
- private Map getProjectSyncInfoSetMap(SyncInfoSet syncSet) {
- Map map = new HashMap();
- SyncInfo[] infos = syncSet.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;
- }
-
- /**
- * Run the operation on the sync info in the given set. The sync info will be all
- * from the same project.
- * @param provider
- * @param set the sync info set
- * @param monitor a progress monitor
- */
- protected abstract void run(FileSystemProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws TeamException;
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java
deleted file mode 100644
index 7ff7f3891..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-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.examples.filesystem.subscriber.FileSystemSubscriber;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
-
-
-/**
- * This is an example synchronize participant for the file system provider. It will allow
- * showing synchronization state for local resources mapped to a remote file system
- * location.
- *
- * @since 3.0
- */
-public class FileSystemSynchronizeParticipant extends SubscriberParticipant {
-
- /**
- * The particpant ID as defined in the plugin manifest
- */
- public static final String ID = "org.eclipse.team.examples.filesystem.participant"; //$NON-NLS-1$
-
- /**
- * Contxt menu action group for synchronize view actions
- */
- public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_1 = "context_group_1"; //$NON-NLS-1$
-
- /**
- * A custom label decorator that will show the remote mapped path for each
- * file.
- */
- private class FileSystemParticipantLabelDecorator extends LabelProvider implements ILabelDecorator {
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
- */
- public Image decorateImage(Image image, Object element) {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object)
- */
- public String decorateText(String text, Object element) {
- try {
- if (element instanceof ISynchronizeModelElement) {
- IResource resource = ((ISynchronizeModelElement) element).getResource();
- if (resource != null && resource.getType() == IResource.FILE) {
- SyncInfo info = FileSystemSubscriber.getInstance().getSyncInfo(resource);
- IResourceVariant variant = info.getRemote();
- if (variant != null) {
- return text + " (" + variant.getContentIdentifier() + ")";
- }
- }
- }
- } catch (TeamException e) {
- }
- return null;
- }
- }
-
- /**
- * Action group that contributes the get an put menus to the context menu
- * in the synchronize view
- */
- private class FileSystemParticipantActionGroup extends SynchronizePageActionGroup {
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
- */
- public void initialize(ISynchronizePageConfiguration configuration) {
- super.initialize(configuration);
- appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
- CONTEXT_MENU_CONTRIBUTION_GROUP_1,
- new GetSynchronizeAction("Get", configuration));
- appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
- CONTEXT_MENU_CONTRIBUTION_GROUP_1,
- new PutSynchronizeAction("Put", configuration));
- }
-
- }
-
- public FileSystemSynchronizeParticipant(ISynchronizeScope scope) {
- super(scope);
- setSubscriber(FileSystemSubscriber.getInstance());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber)
- */
- protected void setSubscriber(Subscriber subscriber) {
- super.setSubscriber(subscriber);
- try {
- ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(ID);
- setInitializationData(descriptor);
- setSecondaryId(Long.toString(System.currentTimeMillis()));
- } catch (CoreException e) {
- // ignore
- }
- }
-
- /* (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 FileSystemParticipantLabelDecorator();
- configuration.addLabelDecorator(labelDecorator);
-
- // Add support for showing mode buttons
- configuration.setSupportedModes(ISynchronizePageConfiguration.ALL_MODES);
- configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE);
-
- // Create the action group that contributes the get and put actions
- configuration.addActionContribution(new FileSystemParticipantActionGroup());
- // Add the get and put group to the context menu
- configuration.addMenuGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
- CONTEXT_MENU_CONTRIBUTION_GROUP_1);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java
deleted file mode 100644
index 06dc044d3..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.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.examples.filesystem.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.examples.filesystem.Policy;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * Action for getting the contents of the selected resources
- */
-public class GetAction extends FileSystemAction {
-
- public void run(IAction action) {
- run(new WorkspaceModifyOperation(null) {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- Map table = getRepositoryProviderMapping();
- monitor.beginTask(null, table.size() * 1000);
- monitor.setTaskName(Policy.bind("GetAction.working")); //$NON-NLS-1$
- for (Iterator iter = table.keySet().iterator(); iter.hasNext();) {
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
- FileSystemProvider provider = (FileSystemProvider) iter.next();
- List list = (List) table.get(provider);
- IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
- provider.getOperations().get(providerResources, IResource.DEPTH_INFINITE, isOverwriteOutgoing(), subMonitor);
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("GetAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
-
- /**
- * Indicate whether the action should overwrite outgoing changes.
- * By default, the get action does not override local modifications.
- * @return whether the action should overwrite outgoing changes.
- */
- protected boolean isOverwriteOutgoing() {
- return false;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeAction.java
deleted file mode 100644
index 307598713..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeAction.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.examples.filesystem.ui;
-
-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.*;
-
-/**
- * Get action that appears in the synchronize view. It's main purpose is
- * to filter the selection and delegate its execution to the get operation.
- */
-public class GetSynchronizeAction extends SynchronizeModelAction {
-
- protected GetSynchronizeAction(String text, ISynchronizePageConfiguration configuration) {
- super(text, configuration);
- }
-
- /* (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 GetSynchronizeOperation(configuration, elements);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter()
- */
- protected FastSyncInfoFilter getSyncInfoFilter() {
- return new SyncInfoDirectionFilter(new int[] {SyncInfo.INCOMING, SyncInfo.CONFLICTING});
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeOperation.java
deleted file mode 100644
index 067861739..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetSynchronizeOperation.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.examples.filesystem.ui;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-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.synchronize.SyncInfoSet;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-
-/**
- * Sync view operation for getting file system resources
- */
-public class GetSynchronizeOperation extends FileSystemSynchronizeOperation {
-
- protected GetSynchronizeOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
- super(configuration, elements);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#promptForConflictHandling(org.eclipse.swt.widgets.Shell, org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForConflictHandling(Shell shell, SyncInfoSet syncSet) {
- // If there is a conflict in the syncSet, we need to prompt the user before proceeding.
- if (syncSet.hasConflicts() || syncSet.hasOutgoingChanges()) {
- switch (promptForConflicts(shell, syncSet)) {
- case 0:
- // Yes, synchronize conflicts as well
- break;
- case 1:
- // No, remove outgoing
- syncSet.removeConflictingNodes();
- syncSet.removeOutgoingNodes();
- break;
- case 2:
- default:
- // Cancel
- return false;
- }
- }
- return true;
- }
-
- /**
- * 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
- */
- private int promptForConflicts(Shell shell, SyncInfoSet syncSet) {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
- String title = "Confirm Overwrite"; //$NON-NLS-1$
- String question = "You have changes that conflict with the server. Overwrite those changes?"; //$NON-NLS-1$
- final MessageDialog dialog = new MessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, 0);
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- return dialog.getReturnCode();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#run(org.eclipse.team.examples.filesystem.FileSystemProvider, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void run(FileSystemProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws TeamException {
- provider.getOperations().get(set.getResources(), IResource.DEPTH_INFINITE, true, monitor);
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
deleted file mode 100644
index 4d0316af8..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-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.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-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.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.examples.filesystem.Policy;
-import org.eclipse.team.internal.core.Assert;
-
-/**
- * This is an old-style (pre-3.0) project set serializer used to test backwards compatibility
- */
-public class ProjectSetSerializer implements IProjectSetSerializer {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.IProjectSetSerializer#asReference(org.eclipse.core.resources.IProject[], java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) throws TeamException {
- Assert.isTrue(context instanceof Shell);
- List refs = new ArrayList();
- for (int i = 0; i < providerProjects.length; i++) {
- IProject project = providerProjects[i];
- FileSystemProvider provider = (FileSystemProvider)RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
- if (provider != null) {
- refs.add(asReference(provider));
- }
- }
- return (String[]) refs.toArray(new String[refs.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.IProjectSetSerializer#addToWorkspace(java.lang.String[], java.lang.String, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) throws TeamException {
- Assert.isTrue(context instanceof Shell);
- List projects = new ArrayList();
- for (int i = 0; i < referenceStrings.length; i++) {
- String string = referenceStrings[i];
- String projectName = getProjectName(string);
- String path = getPath(string);
- if (projectName != null && path != null) {
- try {
- IProject project = createProject(projectName, monitor);
- RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID);
- FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project);
- provider.setTargetLocation(path);
- projects.add(project);
- } catch (CoreException e) {
- ErrorDialog.openError(
- (Shell)context,
- Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$
- Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$
- e.getStatus());
- }
- }
- }
- return (IProject[]) projects.toArray(new IProject[projects.size()]);
- }
-
- /**
- * @param provider
- * @return
- */
- private String asReference(FileSystemProvider provider) {
- return provider.getProject().getName() + "," + provider.getRoot().toString(); //$NON-NLS-1$
- }
-
- /**
- * @param string
- * @return
- */
- private String getProjectName(String string) {
- int i = string.indexOf(',');
- if (i == -1) return null;
- return string.substring(0, i);
- }
-
- /**
- * @param string
- * @return
- */
- private String getPath(String string) {
- int i = string.indexOf(',');
- if (i == -1) return null;
- return string.substring(i + 1);
- }
-
- /**
- * @param projectName
- * @return
- * @throws CoreException
- */
- private IProject createProject(String projectName, IProgressMonitor monitor) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (!project.exists()) {
- project.create(monitor);
- }
- if (!project.isOpen()) {
- project.open(monitor);
- }
- return project;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java
deleted file mode 100644
index 585391d8c..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.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.examples.filesystem.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.examples.filesystem.Policy;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * Action for checking in the selected resources
- */
-public class PutAction extends FileSystemAction {
-
- /*
- * Method declared on IActionDelegate.
- */
- public void run(IAction action) {
- run(new WorkspaceModifyOperation(null) {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- Map table = getRepositoryProviderMapping();
- monitor.beginTask(null, table.size() * 1000);
- monitor.setTaskName(Policy.bind("PutAction.working")); //$NON-NLS-1$
- for (Iterator iter = table.keySet().iterator(); iter.hasNext();) {
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
- FileSystemProvider provider = (FileSystemProvider) iter.next();
- List list = (List) table.get(provider);
- IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
- provider.getOperations().checkin(providerResources, IResource.DEPTH_INFINITE, isOverrideIncoming(), subMonitor);
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("PutAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
-
- /**
- * Indicate whether the put should override incoming changes.
- * @return whether the put should override incoming changes.
- */
- protected boolean isOverrideIncoming() {
- return false;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeAction.java
deleted file mode 100644
index d6234c606..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeAction.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.examples.filesystem.ui;
-
-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.*;
-
-/**
- * Put action that appears in the synchronize view. It's main purpose is
- * to filter the selection and delegate its execution to the put operation.
- */
-public class PutSynchronizeAction extends SynchronizeModelAction {
-
- public PutSynchronizeAction(String text, ISynchronizePageConfiguration configuration) {
- super(text, configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
- */
- protected FastSyncInfoFilter getSyncInfoFilter() {
- return new SyncInfoDirectionFilter(new int[] {SyncInfo.OUTGOING, SyncInfo.CONFLICTING});
- }
-
- /* (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 PutSynchronizeOperation(configuration, elements);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeOperation.java
deleted file mode 100644
index 91fdf4db1..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutSynchronizeOperation.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.examples.filesystem.ui;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-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.synchronize.SyncInfoSet;
-import org.eclipse.team.examples.filesystem.FileSystemProvider;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-
-/**
- * Sync view operation for putting file system resources
- */
-public class PutSynchronizeOperation extends FileSystemSynchronizeOperation {
-
- protected PutSynchronizeOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
- super(configuration, elements);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#promptForConflictHandling(org.eclipse.swt.widgets.Shell, org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForConflictHandling(Shell shell, SyncInfoSet syncSet) {
- // If there is a conflict in the syncSet, we need to prompt the user before proceeding.
- if (syncSet.hasConflicts() || syncSet.hasIncomingChanges()) {
- switch (promptForConflicts(shell, syncSet)) {
- case 0:
- // Yes, synchronize conflicts as well
- break;
- case 1:
- // No, stop here
- syncSet.removeConflictingNodes();
- syncSet.removeIncomingNodes();
- break;
- case 2:
- default:
- // Cancel
- return false;
- }
- }
- return true;
- }
-
- /**
- * 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
- */
- private int promptForConflicts(Shell shell, SyncInfoSet syncSet) {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
- String title = "Confirm Overwrite"; //$NON-NLS-1$
- String question = "You have changes that conflict with the server. Release those changes?"; //$NON-NLS-1$
- final MessageDialog dialog = new MessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, 0);
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- return dialog.getReturnCode();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#run(org.eclipse.team.examples.filesystem.FileSystemProvider, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void run(FileSystemProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws TeamException {
- provider.getOperations().checkin(set.getResources(), IResource.DEPTH_INFINITE, true, monitor);
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java
deleted file mode 100644
index 7c22b7ccb..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.filesystem.ui;
-
-
-/**
- * A replace is simply a get that overwrite local changes
- */
-public class ReplaceAction extends GetAction {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.filesystem.ui.GetAction#isOverwriteOutgoing()
- */
- protected boolean isOverwriteOutgoing() {
- return true;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeAction.java
deleted file mode 100644
index d60ffc021..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeAction.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.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
-
-/**
- * Action to synchronize the selected resources. This results
- * in a file-system participant being added to the synchronize view.
- */
-public class SynchronizeAction extends FileSystemAction {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- IResource[] resources = getSelectedResources();
- // First check if there is an existing matching participant
- FileSystemSynchronizeParticipant participant = (FileSystemSynchronizeParticipant)SubscriberParticipant.getMatchingParticipant(FileSystemSynchronizeParticipant.ID, resources);
- // If there isn't, create one and add to the manager
- if (participant == null) {
- participant = new FileSystemSynchronizeParticipant(new ResourceScope(resources));
- TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
- }
- participant.refresh(resources, null, null, getTargetPart().getSite());
-
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeWizard.java
deleted file mode 100644
index b79f651c9..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/SynchronizeWizard.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.examples.filesystem.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber;
-import org.eclipse.team.internal.ui.ITeamUIImages;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.synchronize.GlobalRefreshResourceSelectionPage;
-import org.eclipse.team.ui.TeamImages;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
-
-public class SynchronizeWizard extends Wizard {
- private GlobalRefreshResourceSelectionPage selectionPage;
- private IWizard importWizard;
-
- public SynchronizeWizard() {
- setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE));
- setNeedsProgressMonitor(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#getWindowTitle()
- */
- public String getWindowTitle() {
- return Policy.bind("GlobalRefreshSubscriberPage.0"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- public void addPages() {
- selectionPage = new GlobalRefreshResourceSelectionPage(FileSystemSubscriber.getInstance().roots());
- selectionPage.setTitle("Synchronize File System Example");
- selectionPage.setMessage("Synchronize File System Example");
- addPage(selectionPage);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- if (importWizard != null) {
- return importWizard.performFinish();
- } else {
- IResource[] resources = selectionPage.getRootResources();
- if (resources != null && resources.length > 0) {
- SubscriberParticipant participant = new FileSystemSynchronizeParticipant(selectionPage.getSynchronizeScope());
- TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant});
- // We don't know in which site to show progress because a participant could actually be shown in multiple sites.
- participant.run(null /* no site */);
- }
- return true;
- }
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java
deleted file mode 100644
index 12658fd09..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.localhistory;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
-
-public class LocalHistoryPartipant extends SubscriberParticipant {
-
- public static final String ID = "org.eclipse.team.synchronize.example"; //$NON-NLS-1$
- public static final String CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_1"; //$NON-NLS-1$
-
- private class LocalHistoryActionContribution extends SynchronizePageActionGroup {
- public void initialize(ISynchronizePageConfiguration configuration) {
- super.initialize(configuration);
- appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP,
- new SynchronizeModelAction("Revert to latest in local history", configuration) { //$NON-NLS-1$
- protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
- return new RevertAllOperation(configuration, elements);
- }
- });
- }
- }
-
- private class LocalHistoryDecorator extends LabelProvider implements ILabelDecorator {
- public String decorateText(String text, Object element) {
- if(element instanceof ISynchronizeModelElement) {
- ISynchronizeModelElement node = (ISynchronizeModelElement)element;
- if(node instanceof IAdaptable) {
- SyncInfo info = (SyncInfo)((IAdaptable)node).getAdapter(SyncInfo.class);
- if(info != null) {
- LocalHistoryVariant state = (LocalHistoryVariant)info.getRemote();
- return text+ " ("+ state.getContentIdentifier() + ")";
- }
- }
- }
- return text;
- }
-
- public Image decorateImage(Image image, Object element) {
- return null;
- }
- }
-
- public LocalHistoryPartipant() {
- setSubscriber(new LocalHistorySubscriber());
- }
-
- /* (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);
- try {
- ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(ID);
- setInitializationData(descriptor);
- setSecondaryId(Long.toString(System.currentTimeMillis()));
- } catch (CoreException e) {
- }
- }
-
- protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
- super.initializeConfiguration(configuration);
- configuration.addMenuGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
- CONTEXT_MENU_CONTRIBUTION_GROUP);
- configuration.addActionContribution(new LocalHistoryActionContribution());
- configuration.addLabelDecorator(new LocalHistoryDecorator());
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java
deleted file mode 100644
index 49a6b4c14..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.localhistory;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-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.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-
-public class LocalHistorySubscriber extends Subscriber {
-
- private LocalHistoryVariantComparator comparator;
-
- public LocalHistorySubscriber() {
- this.comparator = new LocalHistoryVariantComparator();
- }
-
- public String getName() {
- return "Local History Subscriber"; //$NON-NLS-1$
- }
-
- public boolean isSupervised(IResource resource) throws TeamException {
- // all resources in the workspace can potentially have resource history
- return true;
- }
-
- public IResource[] members(IResource resource) throws TeamException {
- try {
- if(resource.getType() == IResource.FILE)
- return new IResource[0];
- IContainer container = (IContainer)resource;
- List existingChildren = new ArrayList(Arrays.asList(container.members()));
- existingChildren.addAll(Arrays.asList(container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, null)));
- return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]);
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
-
- public IResource[] roots() {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
-
- public SyncInfo getSyncInfo(IResource resource) throws TeamException {
- try {
- IResourceVariant variant = null;
- if(resource.getType() == IResource.FILE) {
- IFile file = (IFile)resource;
- IFileState[] states = file.getHistory(null);
- if(states.length > 0) {
- // last state only
- variant = new LocalHistoryVariant(states[0]);
- }
- }
- SyncInfo info = new LocalHistorySyncInfo(resource, variant, comparator);
- info.init();
- return info;
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
-
- public IResourceVariantComparator getResourceComparator() {
- return comparator;
- }
-
- public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java
deleted file mode 100644
index fd0c38fdc..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.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.examples.localhistory;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-
-public class LocalHistorySyncInfo extends SyncInfo {
-
- public LocalHistorySyncInfo(IResource local, IResourceVariant remote, IResourceVariantComparator comparator) {
- super(local, null, remote, comparator);
- }
-
- protected int calculateKind() throws TeamException {
- if (getRemote() == null)
- return IN_SYNC;
- else
- return super.calculateKind();
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySynchronizeWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySynchronizeWizard.java
deleted file mode 100644
index ebbfb0d3f..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySynchronizeWizard.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.examples.localhistory;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-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.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.team.internal.ui.ITeamUIImages;
-import org.eclipse.team.ui.TeamImages;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
-import org.eclipse.team.ui.synchronize.ISynchronizeManager;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-
-
-public class LocalHistorySynchronizeWizard extends Wizard {
-
- private class MessagePage extends WizardPage {
- protected MessagePage(String pageName, String title, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- }
-
- public void createControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayout(new GridLayout());
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
- Label label = new Label(top, SWT.WRAP);
- label.setText("This will create a synchronization against the latest file state in local history."); //$NON-NLS-1$
- label.setLayoutData(new GridData(GridData.FILL_BOTH));
- setControl(top);
- }
- }
-
- public LocalHistorySynchronizeWizard() {
- super();
- }
-
- public void addPages() {
- addPage(new MessagePage("Local History", "Create a local history synchronization", TeamImages.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE))); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- public boolean performFinish() {
- LocalHistoryPartipant participant = new LocalHistoryPartipant();
- ISynchronizeManager manager = TeamUI.getSynchronizeManager();
- manager.addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
- ISynchronizeView view = manager.showSynchronizeViewInActivePage();
- view.display(participant);
- return true;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariant.java
deleted file mode 100644
index fcee62b20..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariant.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.examples.localhistory;
-
-import java.text.DateFormat;
-import java.util.Date;
-import org.eclipse.core.resources.IFileState;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.IResourceVariant;
-
-public class LocalHistoryVariant implements IResourceVariant {
-
- private final IFileState state;
-
- public LocalHistoryVariant(IFileState state) {
- this.state = state;
- }
-
- public String getName() {
- return state.getName();
- }
-
- public boolean isContainer() {
- return false;
- }
-
- public IStorage getStorage(IProgressMonitor monitor) throws TeamException {
- return state;
- }
-
- public String getContentIdentifier() {
- return DateFormat.getDateTimeInstance().format(new Date(state.getModificationTime()));
- }
-
- public byte[] asBytes() {
- return null;
- }
-
- public IFileState getFileState() {
- return state;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariantComparator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariantComparator.java
deleted file mode 100644
index ead29974d..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryVariantComparator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.examples.localhistory;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-
-public class LocalHistoryVariantComparator implements IResourceVariantComparator {
- public boolean compare(IResource local, IResourceVariant remote) {
- return false;
- }
-
- public boolean compare(IResourceVariant base, IResourceVariant remote) {
- return false;
- }
-
- public boolean isThreeWay() {
- return false;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java
deleted file mode 100644
index 93913befc..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.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.examples.localhistory;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-public class RevertAllOperation extends SynchronizeModelOperation {
-
- protected RevertAllOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
- super(configuration, elements);
- }
-
- protected boolean canRunAsJob() {
- return true;
- }
-
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- final SyncInfo infos[] = getSyncInfoSet().getSyncInfos();
- if(infos.length == 0) return;
-
- WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor pm) throws InvocationTargetException {
- try {
- pm.beginTask("Reverting from local history", 100 * infos.length); //$NON-NLS-1$
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
- LocalHistoryVariant state = (LocalHistoryVariant)info.getRemote();
- IFile file = (IFile)info.getLocal();
- if(file.exists()) {
- file.setContents(state.getFileState(), false, true, new SubProgressMonitor(pm, 100));
- } else {
- // TODO: have to pre-create parents if they dont exist
- file.create(state.getFileState().getContents(), false, new SubProgressMonitor(pm, 100));
- }
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
- };
- operation.run(monitor);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IPessimisticFilesystemConstants.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IPessimisticFilesystemConstants.java
deleted file mode 100644
index 7f8748631..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IPessimisticFilesystemConstants.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-/**
- * Preference constants for the <code>PessimisticFilesystemProvider</code>.
- */
-public interface IPessimisticFilesystemConstants {
- /**
- * Preference name's prefix
- */
- String PREFIX = "org.eclipse.team.examples.pessimistic.";
-
- /**
- * Preference name for when checked in files are saved.
- */
- String PREF_CHECKED_IN_FILES_SAVED = PREFIX + "WhenCheckedInFilesAreSaved";
- /**
- * Preference name for when checked in files are edited with a UI context.
- */
- String PREF_CHECKED_IN_FILES_EDITED = PREFIX + "WhenCheckedInFilesAreEdited";
- /**
- * Preference name for when checked in files are edited without a UI context.
- */
- String PREF_CHECKED_IN_FILES_EDITED_NOPROMPT = PREFIX + "WhenCheckedInFilesAreEditedNoPrompt";
- /**
- * Preference name for the option to always fail validate edit.
- */
- String PREF_FAIL_VALIDATE_EDIT= PREFIX + "FailValidateEdit";
- /**
- * Preference name for the option to touch files during validate edit calls
- */
- String PREF_TOUCH_DURING_VALIDATE_EDIT= PREFIX + "ChangeFileContents";
- /**
- * Preference name for the option to add files to the repository provider.
- */
- String PREF_ADD_TO_CONTROL= PREFIX + "AddToControl";
-
- /**
- * Preference option indicating that the user should be prompted.
- */
- int OPTION_PROMPT = 1;
- /**
- * Preference option indicating that the action should happen automatically.
- */
- int OPTION_AUTOMATIC = 2;
- /**
- * Preference option indicating that the action should not occur.
- */
- int OPTION_DO_NOTHING = 4;
-
- /**
- * Status flag indicating that resources are ready to be edited.
- */
- int STATUS_OK_TO_EDIT = 1;
- /**
- * Status flag indicating that resources need to be reloaded.
- */
- int STATUS_PROMPT_FOR_RELOAD = 2;
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IResourceStateListener.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IResourceStateListener.java
deleted file mode 100644
index d8dc6be75..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/IResourceStateListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * An <code>IResourceStateListener</code> recieves callbacks
- * when the repository state of resources change, i.e. a file gets checked
- * in, a folder gets checked out, a project is no longer shared, etc.
- */
-public interface IResourceStateListener {
- /**
- * Notifies this listener that the state of the resources has changed.
- * @param resources An array of resources with changed states or an empty array.
- */
- void stateChanged(IResource[] resources);
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
deleted file mode 100644
index 57b9463ab..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.team.core.RepositoryProvider;
-
-/**
- * The <code>PessimisticFilesystemProvider</code> is a repository provider.
- *
- * The provider manages a file named ".pessimistic" in each container it
- * controls. This is where it stores metadata on which files it controls
- * in that container. This file is considered to be controlled by the
- * provider and may be deleted.
- *
- * The provider provides very simple checkin/checkout facilities by marking
- * files read-only to check them in and read-write to check them out. It
- * also supports ignoring derived files.
- */
-public class PessimisticFilesystemProvider extends RepositoryProvider {
- /**
- * The name of the file used to store metadata on which
- * files are controlled by this provider.
- */
- private static final String CONTROL_FILE_NAME= ".pessimistic";
- /**
- * The file modification validator for this provider.
- */
- private IFileModificationValidator validator;
- /**
- * The cache of resources that are currently controlled.
- * The cache is a map of parent resource -> set of controlled children.
- */
- private Map fControlledResources;
-
- /**
- * Creates a new provider, required for team repository extension.
- */
- public PessimisticFilesystemProvider() {
- validator = new PessimisticModificationValidator(this);
- fControlledResources= new HashMap(1);
- }
-
- /**
- * Adds the resources to the control of this provider.
- */
- public void addToControl(final IResource[] resources, IProgressMonitor monitor) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Add to control:");
- if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
- }
- } else {
- System.out.println("null resources");
- }
- }
- if (resources == null || resources.length == 0) {
- return;
- }
- final Set toAdd= new HashSet(resources.length);
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (!isControlled(resource)) {
- toAdd.add(resource);
- }
- }
- Map byParent= sortByParent(toAdd);
-
- monitor.beginTask("Adding to control", 1000);
- for (Iterator i= byParent.keySet().iterator(); i.hasNext();) {
- IContainer parent= (IContainer) i.next();
- Set controlledResources= (Set)fControlledResources.get(parent);
- if (controlledResources == null) {
- controlledResources= new HashSet(1);
- fControlledResources.put(parent, controlledResources);
- }
- controlledResources.addAll((Set)byParent.get(parent));
- writeControlFile(parent, monitor);
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- fireStateChanged(toAdd, false);
- }
-
- /**
- * Removes the resources from the control of this provider.
- */
- public void removeFromControl(final IResource[] resources, IProgressMonitor monitor) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Remove from control:");
- if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
- }
- } else {
- System.out.println("null resources");
- }
- }
- if (resources == null || resources.length == 0) {
- return;
- }
- final Set toRemove= new HashSet(resources.length);
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isControlled(resource)) {
- toRemove.add(resource);
- }
- }
- Map byParent= sortByParent(toRemove);
-
- Set keys= byParent.keySet();
- monitor.beginTask("Removing from control", 1000);
- for (Iterator i= byParent.keySet().iterator(); i.hasNext();) {
- IContainer parent= (IContainer) i.next();
- Set controlledResources= (Set)fControlledResources.get(parent);
- if (controlledResources == null) {
- deleteControlFile(parent, monitor);
- } else {
- Set toRemove= (Set)byParent.get(parent);
- controlledResources.removeAll(toRemove);
- if (controlledResources.isEmpty()) {
- fControlledResources.remove(parent);
- deleteControlFile(parent, monitor);
- } else {
- writeControlFile(parent, monitor);
- }
- for (Iterator j= controlledResources.iterator(); j.hasNext();) {
- IResource resource= (IResource) j.next();
- if (!resource.exists()) {
- j.remove();
- }
- }
- }
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- fireStateChanged(toRemove, false);
- }
-
- /*
- * Returns a map of IContainer -> Set of IResource.
- */
- private Map sortByParent(Set resources) {
- Map byParent= new HashMap(1);
- for (Iterator i = resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
- IContainer parent= resource.getParent();
- Set set= (Set)byParent.get(parent);
- if (set == null) {
- set= new HashSet(1);
- byParent.put(parent, set);
- }
- set.add(resource);
- }
- return byParent;
- }
-
- /*
- * Deletes the control file for the given container.
- */
- private void deleteControlFile(final IContainer container, IProgressMonitor monitor) {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IFile controlFile= getControlFile(container, monitor);
- monitor.beginTask("Deleting control file " + controlFile, 1);
- if (controlFile.exists()) {
- controlFile.delete(true, false, monitor);
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- }
-
- /*
- * Answers the control file for the given container. If the control
- * file exists, but is a directory, it will be deleted!
- */
- private IFile getControlFile(IContainer container, IProgressMonitor monitor) throws CoreException {
- IResource child= container.findMember(CONTROL_FILE_NAME);
- if (child != null) {
- if (child.getType() == IResource.FILE) {
- return (IFile)child;
- } else {
- child.delete(true, monitor);
- }
- }
- IFile controlFile= container.getFile(new Path(CONTROL_FILE_NAME));
- monitor.beginTask("Creating control file " + controlFile, 2);
- controlFile.create(new ByteArrayInputStream(new byte[0]), true, monitor);
- controlFile.setDerived(true);
- controlFile.setTeamPrivateMember(true);
- monitor.done();
- return controlFile;
- }
-
- /*
- * Reads the contents of a control file, answering the set of
- * resources that was specified in the file.
- */
- private Set readControlFile(IFile controlFile) {
- Set controlledResources= new HashSet(1);
- if (controlFile.exists()) {
- InputStream in= null;
- try {
- try {
- in= ((IFile)controlFile).getContents(true);
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Could not open stream on control file: " + controlFile);
- }
- DataInputStream dIn= new DataInputStream(in);
- int count= 0;
- try {
- count= dIn.readInt();
- } catch (IOException e) {
- // could be empty
- }
- if (count > 0) {
- try {
- for(int i= 0; i < count; i++) {
- String name= dIn.readUTF();
- IResource resource= getProject().findMember(new Path(name));
- if (resource != null) {
- controlledResources.add(resource);
- }
- }
- } catch (IOException e) {
- // corrupt control file
- try {
- controlFile.delete(true, null);
- } catch (CoreException ce) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(ce, "Could not delete corrupt control file: " + controlFile);
- }
- }
- }
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems closing input stream on control file: " + controlFile);
- }
- }
- }
- }
- return controlledResources;
- }
-
- /*
- * Writes the currently controled resources to the control file for the container.
- */
- private void writeControlFile(IContainer container, IProgressMonitor monitor) throws CoreException {
- IFile controlFile= getControlFile(container, monitor);
- Set controlledResources= (Set)fControlledResources.get(container);
- InputStream contents= generateControlFileContents(controlledResources);
- monitor.beginTask("Writing control file " + controlFile, 1000);
- if (contents == null) {
- controlFile.delete(true, false, monitor);
- } else {
- controlFile.setContents(contents, true, false, monitor);
- }
- monitor.done();
- }
-
- /*
- * Generates an InputStream on a byte array which specifies
- * the resources given in controlledResources.
- */
- private InputStream generateControlFileContents(Set controlledResources) {
- if (controlledResources == null || controlledResources.isEmpty()) {
- return null;
- }
- ByteArrayOutputStream byteOut= new ByteArrayOutputStream();
- DataOutputStream out= new DataOutputStream(byteOut);
- try {
- out.writeInt(controlledResources.size());
- for (Iterator i= controlledResources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
- out.writeUTF(resource.getProjectRelativePath().toString());
- }
- out.flush();
- } catch (IOException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Unexpected problems during content generation");
- }
- return new ByteArrayInputStream(byteOut.toByteArray());
- }
-
- /*
- * @see IProjectNature#setProject(IProject)
- */
- public void setProject(IProject project) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Set project to " + project);
- }
- super.setProject(project);
- configureProject();
- }
-
- /*
- * @see IRepositoryProvider#getID()
- */
- public String getID() {
- return PessimisticFilesystemProviderPlugin.NATURE_ID;
- }
-
- /*
- * @see IRepositoryProvider#getFileModificationValidator()
- */
- public IFileModificationValidator getFileModificationValidator() {
- return validator;
- }
-
- /*
- * @see IRepositoryProvider#deconfigure()
- */
- public void deconfigure() {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Deconfigure " + getProject());
- }
-
- fControlledResources.clear();
- fireStateChanged(getSubtreeMembers(getProject()), true);
- }
-
- /*
- * @see IRepositoryProvider#configure()
- */
- public void configureProject() {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Configure " + getProject());
- }
-
- readControlFiles();
- fireStateChanged(getSubtreeMembers(getProject()), true);
- }
-
- /*
- * Reads the control files located in the project
- */
- private void readControlFiles() {
- IProject project= getProject();
- Set set= new HashSet(1);
- set.add(project);
- fControlledResources.put(project.getParent(), set);
- try {
- getProject().accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- if (CONTROL_FILE_NAME.equals(resource.getName())) {
- Set controlledResources= readControlFile((IFile)resource);
- fControlledResources.put(resource.getParent(), controlledResources);
- }
- return false;
- }
- return true;
- }
- });
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems traversing resource tree");
- }
- }
-
- /**
- * Checks the resources in by marking them read-only.
- */
- public void checkin(final IResource[] resources, IProgressMonitor monitor) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Check in:");
- if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
- }
- } else {
- System.out.println("null resources");
- }
- }
- if (resources == null || resources.length == 0) {
- return;
- }
- final Set modified= new HashSet(1);
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("Checking in resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isControlled(resource)) {
- if (resource.exists()) {
- resource.setReadOnly(true);
- modified.add(resource);
- }
- }
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- fireStateChanged(modified, false);
- }
-
- /**
- * Unchecks the resources out. In this provider this operation is
- * equivalent to checkin.
- *
- * @see PessimisticFilesystemProvider#checkin(IResource[], IProgressMonitor)
- */
- public void uncheckout(final IResource[] resources, IProgressMonitor monitor) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Uncheckout:");
- if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
- }
- } else {
- System.out.println("null resources");
- }
- }
- if (resources == null || resources.length == 0) {
- return;
- }
- final Set modified= new HashSet(1);
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("Unchecking in resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isControlled(resource)) {
- if (resource.exists()) {
- resource.setReadOnly(true);
- modified.add(resource);
- }
- }
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- fireStateChanged(modified, false);
- }
-
- /**
- * Checks the resources out by marking the resources read-write.
- */
- public void checkout(final IResource[] resources, IProgressMonitor monitor) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Check out:");
- if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
- }
- } else {
- System.out.println("null resources");
- }
- }
- if (resources == null || resources.length == 0) {
- return;
- }
- final Set modified= new HashSet(1);
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("Checking out resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isControlled(resource)) {
- if(resource.exists()) {
- resource.setReadOnly(false);
- modified.add(resource);
- }
- }
- }
- monitor.done();
- }
- };
- run(runnable, monitor);
- fireStateChanged(modified, false);
- }
-
- /**
- * Answers <code>true</code> if and only if the resource is
- * not <code>null</code>, controlled, not ignored, and checked out.
- * Otherwise this method answers <code>false</code>.
- */
- public boolean isCheckedout(IResource resource) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Is checked out: " + resource);
- }
- if (resource == null) {
- return false;
- }
- if (!isControlled(resource)) {
- return false;
- }
- if (isIgnored(resource)) {
- return false;
- }
- return !resource.isReadOnly();
- }
-
- /**
- * Answers <code>true</code> if the resource is not <code>null</code>,
- * and is controlled, <code>false</code> otherwise.
- */
- public boolean isControlled(IResource resource) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Is controlled: " + resource);
- }
- if (resource == null) {
- return false;
- }
- IProject project= getProject();
- if (!project.equals(resource.getProject())) {
- return false;
- }
- Set controlled= (Set)fControlledResources.get(resource.getParent());
- if (controlled == null) {
- return false;
- }
- return controlled.contains(resource);
- }
-
- /**
- * Answers <code>true</code> if the resource is ignored.
- * Resources are ignored if they are derived.
- * Will return <code>false</code> when a resource is derived, but
- * has explicitly been added to the control of this provider.
- */
- public boolean isIgnored (IResource resource) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Is ignored: " + resource);
- }
- if (resource.isDerived()) {
- if (isControlled(resource)) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * Answers <code>true</code> if the preference to change the content
- * of the file has been set to <code>true</code>, <code>false</code>
- * otherwise.
- */
- public boolean hasContentChanged(IResource resource) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
- System.out.println("Has content change: " + resource);
- }
-
- IPreferenceStore preferences= PessimisticFilesystemProviderPlugin.getInstance().getPreferenceStore();
- boolean change= preferences.getBoolean(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT);
- if (change) {
- try {
- if(resource.getType() == IResource.FILE) {
- try {
- appendText((IFile)resource, getRandomSnippet(), false);
- } catch (IOException e1) {
- }
- } else {
- resource.touch(null);
- }
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems touching resource: " + resource);
- }
- }
- return change;
- }
-
- public void appendText(IFile file, String text, boolean prepend) throws CoreException, IOException {
- String contents = getFileContents(file);
- StringBuffer buffer = new StringBuffer();
- if (prepend) {
- buffer.append(text);
- }
- buffer.append(contents);
- if (!prepend) {
- buffer.append(System.getProperty("line.separator") + text);
- }
- file.setContents(new ByteArrayInputStream(buffer.toString().getBytes()), false, false, null);
- }
-
- public static String getFileContents(IFile file) throws IOException, CoreException {
- StringBuffer buf = new StringBuffer();
- Reader reader = new InputStreamReader(new BufferedInputStream(file.getContents()));
- try {
- int c;
- while ((c = reader.read()) != -1) buf.append((char)c);
- } finally {
- reader.close();
- }
- return buf.toString();
- }
-
- public static String getRandomSnippet() {
- switch ((int) Math.round(Math.random() * 10)) {
- case 0 :
- return "este e' o meu conteudo (portuguese)";
- case 1 :
- return "Dann brauchen wir aber auch einen deutschen Satz!";
- case 2 :
- return "I'll be back";
- case 3 :
- return "don't worry, be happy";
- case 4 :
- return "there is no imagination for more sentences";
- case 5 :
- return "customize yours";
- case 6 :
- return "foo";
- case 7 :
- return "bar";
- case 8 :
- return "foobar";
- case 9 :
- return "case 9";
- default :
- return "these are my contents";
- }
- }
-
- /*
- * Notifies listeners that the state of the resources has changed.
- *
- * @param resources A collection of resources whose state has changed.
- * @param queueAfterWorkspaceOperation If <code>true</code>, indicates that the
- * notification should occur after the current workspace runnable
- * has completed.
- */
- private void fireStateChanged(final Collection resources, boolean queueAfterWorkspaceOperation) {
- if (resources == null || resources.isEmpty()) {
- return;
- }
-
- if (queueAfterWorkspaceOperation) {
- Thread t= new Thread(new Runnable() {
- public void run() {
- try {
- ResourcesPlugin.getWorkspace().run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- }
- },
- null);
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problem during empty runnable");
- }
- fireStateChanged(resources, false);
- }
- });
- t.start();
- } else {
- PessimisticFilesystemProviderPlugin.getInstance().fireResourcesChanged(
- (IResource[])resources.toArray(new IResource[resources.size()]));
- }
- }
-
- /*
- * Answers a collection of all of the resources contained below
- * the given resource and the resource itself.
- */
- private Collection getSubtreeMembers(IResource resource) {
- final Set resources= new HashSet(1);
- IResourceVisitor visitor= new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- switch (resource.getType()) {
- case IResource.PROJECT:
- case IResource.FOLDER:
- case IResource.FILE:
- resources.add(resource);
- return true;
- }
- return true;
- }
- };
- try {
- resource.accept(visitor);
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problem during resource visiting");
- }
- return resources;
- }
-
- /*
- * Runs a workspace operation reporting errors to the PessimisticFilesystemProviderPlugin.
- */
- private void run(IWorkspaceRunnable runnable, IProgressMonitor monitor) {
- try {
- ResourcesPlugin.getWorkspace().run(runnable, monitor);
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems during workspace operation.");
- }
- }
-}
-
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java
deleted file mode 100644
index df787013f..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * The plugin for the <code>PessimisticFilesystemProvider</code>.
- */
-public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
- /*
- * Singleton instance.
- */
- private static PessimisticFilesystemProviderPlugin instance;
- /*
- * The resource change listener which notifies the provider of
- * added and deleted files.
- */
- private ResourceChangeListener fListener;
- /*
- * The provider listeners
- */
- private List fListeners;
-
- /**
- * The plugin identifier
- */
- public static final String PLUGIN_ID = "org.eclipse.team.examples.pessimistic";
- /**
- * The nature identifier.
- */
- public static final String NATURE_ID = PLUGIN_ID + ".pessimisticnature";
-
- /**
- * Contstructor required by plugin lifecycle.
- */
- public PessimisticFilesystemProviderPlugin(IPluginDescriptor pluginDescriptor) {
- super(pluginDescriptor);
- instance = this;
- fListeners= new ArrayList(1);
- //setDebugging(true);
- }
-
- /**
- * Answers the singleton instance of this plugin.
- */
- public static PessimisticFilesystemProviderPlugin getInstance() {
- return instance;
- }
-
- /**
- * Initializes the default preferences for this plugin.
- */
- protected void initializeDefaultPreferences(IPreferenceStore store) {
- store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED,
- IPessimisticFilesystemConstants.OPTION_PROMPT);
- store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT,
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC);
- store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING);
- store.setDefault(
- IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL,
- IPessimisticFilesystemConstants.OPTION_PROMPT);
- store.setDefault(IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT, false);
- store.setDefault(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT, true);
- }
-
- /**
- * Convenience method for logging errors.
- */
- public void logError(Throwable exception, String message) {
- String pluginId= getDescriptor().getUniqueIdentifier();
- Status status= new Status(Status.ERROR, pluginId, Status.OK, message, exception);
- getLog().log(status);
- if (isDebugging()) {
- System.out.println(message);
- exception.printStackTrace();
- }
- }
-
- /**
- * Starts the resource listener.
- *
- * @see Plugin#startup()
- */
- public void startup() throws CoreException {
- fListener= new ResourceChangeListener();
- fListener.startup();
- super.startup();
- }
-
- /**
- * Stops the resource listener.
- *
- * @see Plugin#startup()
- */
- public void shutdown() throws CoreException {
- fListener.shutdown();
- fListener= null;
- super.shutdown();
- }
-
- /**
- * Notifies the registered <code>IResourceStateListener</code> objects
- * that the repository state for the resources has changed.
- *
- * @param resources Collection of resources that have changed.
- */
- public void fireResourcesChanged(IResource[] resources) {
- if (resources == null || resources.length == 0 || fListeners.isEmpty())
- return;
- for (Iterator i= fListeners.iterator(); i.hasNext();) {
- IResourceStateListener listener= (IResourceStateListener) i.next();
- listener.stateChanged(resources);
- }
- }
-
- /**
- * Adds the listener to the list of listeners that are notified when
- * the repository state of resources change.
- *
- * @param listener
- */
- public void addProviderListener(IResourceStateListener listener) {
- if (fListeners.contains(listener))
- return;
- fListeners.add(listener);
- }
-
-
- /**
- * Removes the listener from the list of listeners that are notified when
- * the repository state of resources change.
- *
- * @param listener
- */
- public void removeProviderListener(IResourceStateListener listener) {
- fListeners.remove(listener);
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
deleted file mode 100644
index 3701951b4..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import java.util.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.views.navigator.ResourceSorter;
-
-/**
- * The <code>PessimisticModificationValidator</code> is an
- * implementation of the <code>IFileModificationValidator</code> for the
- * <code>PessimisticFilesystemProvider</code>.
- *
- * @see PessimiticFilesystemProvider
- * @see IFileModificationValidator
- */
-public class PessimisticModificationValidator
- implements IFileModificationValidator {
- /*
- * The provider for this validator
- */
- private PessimisticFilesystemProvider fProvider;
-
- public PessimisticModificationValidator(PessimisticFilesystemProvider provider) {
- fProvider= provider;
- }
-
- /**
- * @see IFileModificationValidator#validateEdit(IFile[], Object)
- */
- public IStatus validateEdit(IFile[] files, Object context) {
- if (files.length == 0) {
- return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- }
-
- Set checkOut = new HashSet();
- int reloadCount = 0;
- int checkoutFailCount = 0;
-
- Map validateEditStatusMap= new HashMap(files.length);
-
- for ( int i = 0 ; i < files.length; i++ ) {
- IFile file= files[i];
-
- if (fProvider.isControlled(file) ) {
- if (fProvider.isCheckedout(file)) {
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
- } else {
- checkOut.add(file);
- }
- } else {
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT);
- }
- }
-
- if (!checkOut.isEmpty()) {
- if (context != null) {
- boolean shouldFail= shouldFailValidateEdit();
- int statusCode = checkout(checkOut, IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED, shouldFail, context);
- if (shouldFail) {
- return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "Fail Validate Edit Preference true", null);
- }
- if(statusCode == IStatus.CANCEL) {
- return new Status( IStatus.CANCEL, getUid(), IStatus.ERROR, "Checkout cancelled by user", null);
- }
- } else {
- if (isAutomaticCheckout()) {
- if (shouldFailValidateEdit()) {
- return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "Fail Validate Edit Preference true", null);
- }
-
- checkout(checkOut);
- }
- }
-
- for (Iterator i= checkOut.iterator(); i.hasNext(); ) {
- IFile file = (IFile) i.next();
-
- if ( fProvider.isCheckedout(file) ) {
- if ( !fProvider.hasContentChanged(file) ) {
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
- } else {
- reloadCount++;
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD );
- }
- } else {
- checkoutFailCount++;
- }
- }
- }
-
- if (reloadCount + checkoutFailCount == 0) {
- return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- }
-
- if (checkoutFailCount == files.length) {
- return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "NOTOK", null);
- }
-
- IStatus children[] = new Status[ files.length ];
-
- int mask = IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT |
- IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD;
-
- for (int i = 0; i < files.length; i++) {
- int result = getValidateEditStatus(validateEditStatusMap, files[i]);
- if ((result & mask) != 0) {
- children[i] = new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- } else {
- children[i] = new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "NOTOK", null);
- }
- }
- return new MultiStatus( getUid(), IStatus.OK, children, "MULTISTATUS", null);
- }
-
- /**
- * @see IFileModificationValidator#validateSave(IFile)
- */
- public IStatus validateSave(IFile file) {
- int checkedInFilesSaved = getPreferences().getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED);
- if (checkedInFilesSaved == IPessimisticFilesystemConstants.OPTION_DO_NOTHING) {
- return new Status( IStatus.OK, getUid(), IStatus.OK, "", null);
- }
-
-
- IStatus status = new Status( IStatus.OK, getUid(), IStatus.OK,
- "File is writable", null);
-
- if (!fProvider.isControlled(file)) {
- return status;
- }
-
- if (fProvider.isIgnored(file)) {
- return status;
- }
-
- if (fProvider.isCheckedout(file)) {
- return status;
- }
- Set files= new HashSet(1);
- files.add(file);
-
- checkout(files, IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED, false, null);
-
- if (fProvider.isCheckedout(file)) {
- return status;
- }
- return new Status(
- IStatus.ERROR,
- getUid(),
- IStatus.ERROR,
- file.getProjectRelativePath() + " could not be checked out",
- null);
- }
-
- /*
- * Convenience method to get the plugin id
- */
- private String getUid() {
- return PessimisticFilesystemProviderPlugin.PLUGIN_ID;
- }
-
- /*
- * Convenience method to answer if the fail validate edit preference
- * has been set.
- */
- private boolean shouldFailValidateEdit() {
- return getPreferences().getBoolean(IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT);
- }
-
- /*
- * Convenience method to answer if the check out preference is set to automatic.
- */
- private boolean isAutomaticCheckout() {
- return getPreferences().getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT) == IPessimisticFilesystemConstants.OPTION_AUTOMATIC;
- }
-
- /*
- * Optionally prompts the user to select which resources should be
- * checked out, and then checks the selected resources.
- */
- private int promptAndCheckout(Set resources, boolean beQuiet, boolean shouldFail, Object context) {
- if (resources.isEmpty()) {
- return IStatus.OK;
- }
-
- Set temp= new HashSet(resources.size());
- for(Iterator i= resources.iterator(); i.hasNext(); ) {
- IFile resource= (IFile)i.next();
- if (fProvider.isControlled(resource) && !fProvider.isCheckedout(resource))
- temp.add(resource);
- }
- resources= temp;
- final int[] statusCode = new int[] {IStatus.OK};
- if (!beQuiet && !resources.isEmpty()) {
- final Shell shell= getShell(context);
- if (shell != null && !shell.isDisposed()) {
- Display display = shell.getDisplay();
- final Set[] result = {resources};
- display.syncExec(new Runnable() {
- public void run() {
- ILabelProvider labelProvider= new WorkbenchLabelProvider();
- Object[] resourceArray= result[0].toArray();
- ITreeContentProvider contentProvider= new ResourceSetContentProvider(result[0]);
- CheckedTreeSelectionDialog dialog= new CheckedTreeSelectionDialog(shell, labelProvider, contentProvider);
- dialog.setMessage("Select resources to be checked out.");
- dialog.setTitle("Check out resources");
- dialog.setContainerMode(true);
- dialog.setBlockOnOpen(true);
- dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
- dialog.setExpandedElements(resourceArray);
- dialog.setInitialSelections(resourceArray);
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
- int status= dialog.open();
- result[0]= null;
- if (status == Window.OK) {
- Object[] results= dialog.getResult();
- result[0] = new HashSet(results.length);
- for (int i= 0; i < results.length; i++) {
- result[0].add(results[i]);
- }
- } else if(status == Window.CANCEL) {
- statusCode[0] = IStatus.CANCEL;
- }
- }
- });
- resources= result[0];
- } else {
- resources= null;
- PessimisticFilesystemProviderPlugin.getInstance().logError(new RuntimeException(), "Context is invalid: " + context);
- }
- }
-
- if (resources != null && !resources.isEmpty() && !shouldFail) {
- checkout(resources);
- }
- return statusCode[0];
- }
-
- /*
- * Checks out the files contained in the resources set
- */
- private void checkout(Set resources) {
- if (resources.isEmpty())
- return;
- IFile[] checkOut= new IFile[resources.size()];
- resources.toArray(checkOut);
- fProvider.checkout(checkOut, null);
- }
-
- /*
- * Convenience method to get the plugin preferences.
- */
- private IPreferenceStore getPreferences() {
- return PessimisticFilesystemProviderPlugin.getInstance().getPreferenceStore();
- }
-
- /*
- * Checks out the files if necessary and if the preferences allow.
- */
- private int checkout(Set resources, String itemId, boolean shouldFail, Object context) {
- if (resources.isEmpty()) {
- return IStatus.OK;
- }
-
- int preference= getPreferences().getInt(itemId);
-
- if (preference == IPessimisticFilesystemConstants.OPTION_DO_NOTHING)
- return IStatus.OK;
-
- boolean beQuiet= false;
- if (preference == IPessimisticFilesystemConstants.OPTION_AUTOMATIC) {
- beQuiet= true;
- }
- return promptAndCheckout(resources, beQuiet, shouldFail, context);
- }
-
- /*
- * Convenience method to set the validate edit status for the given resource.
- */
- private static void setValidateEditStatus(Map map, IFile resource, int status) {
- map.put(resource, new Integer(status));
- }
-
- /*
- * Convenience method to get the validate edit status for the given resource.
- */
- private static int getValidateEditStatus(Map map, IFile resource) {
- Integer i= (Integer)map.get(resource);
- if (i == null)
- return 0;
- return i.intValue();
- }
-
- /*
- * Convenience method to get a shell from an object.
- */
- private Shell getShell(Object context) {
- if (context instanceof Shell) {
- return (Shell)context;
- }
-
- if (context instanceof Control) {
- Control control= (Control)context;
- return control.getShell();
- }
-
- if (context instanceof Widget) {
- Widget widget= (Widget)context;
- return widget.getDisplay().getActiveShell();
- }
-
- return null;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java
deleted file mode 100644
index 2a206beaa..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.ui.*;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.views.navigator.ResourceSorter;
-
-/**
- * The <code>ResourceChangeListener</code> listens for resource changes
- * and (optionally) prompts the user to add the new resources to the
- * control of the repository provider.
- */
-public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceChangeListener {
- /*
- * Set of added resources
- */
- private Set fAdded;
- /*
- * Set of removed resources
- */
- private Set fRemoved;
-
- public ResourceChangeListener() {
- fAdded= new HashSet(1);
- fRemoved= new HashSet(1);
- }
-
- /**
- * Looks for the following changes:
- * <ul>
- * <li>Resources that are controlled and are removed</li>
- * <li>Resources that are added under a managed project</li>
- * </ul>
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource= delta.getResource();
- if (resource != null) {
- IProject project= resource.getProject();
- if (project != null) {
- PessimisticFilesystemProvider provider= (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- if (provider == null)
- return false;
- if (provider.isControlled(resource)) {
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- case IResourceDelta.ADDED:
- return true;
- case IResourceDelta.REMOVED:
- fRemoved.add(resource);
- return false;
- }
- } else {
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- case IResourceDelta.REMOVED:
- return true;
- case IResourceDelta.ADDED:
- // don't prompt for ignored resources
- if (!provider.isIgnored(resource)) {
- fAdded.add(resource);
- }
- return true;
- }
- }
- } else {
- return true;
- }
- }
- return false;
- }
-
- /*
- * Convenience method to return a resource array from a collection
- */
- private IResource[] toResourceArray(Collection collection) {
- if (collection.isEmpty()) {
- return new IResource[0];
- }
- IResource[] resources= new IResource[collection.size()];
- collection.toArray(resources);
- return resources;
- }
-
- /**
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged (IResourceChangeEvent event) {
- try {
- event.getDelta().accept(this);
- } catch (CoreException e) {
- e.printStackTrace();
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Exceptions during resource callback");
- }
-
- if (!fRemoved.isEmpty() || !fAdded.isEmpty()) {
- final IWorkspaceRunnable workspaceRunnable= new IWorkspaceRunnable() {
- public void run(final IProgressMonitor monitor) throws CoreException {
- if (!fRemoved.isEmpty()) {
- remove(monitor);
- }
-
- if (!fAdded.isEmpty()) {
- add(monitor);
- }
- }
- };
- // must fork since we are in resource callback.
- Runnable run= new Runnable() {
- public void run() {
- try {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- if (workspace != null) {
- workspace.run(workspaceRunnable, null);
- }
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems encountered during attempt to add/remove control.");
- }
- }
- };
- new Thread(run).start();
- }
- }
-
- /*
- * Convenience method to get the preference for what to do
- * when new resource have been detected.
- */
- private int getAddToControlPreference() {
- Preferences preferences= PessimisticFilesystemProviderPlugin.getInstance().getPluginPreferences();
- return preferences.getInt(IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL);
- }
-
- /*
- * Adds the resources to the control of the provider.
- * If the add to control preference is:
- * do nothing - does not add
- * automatic - adds all resources
- * prompt - brings up a prompt which requests that the user
- * select which resources to add
- */
- private void add(final IProgressMonitor monitor) {
- switch (getAddToControlPreference()) {
- case IPessimisticFilesystemConstants.OPTION_DO_NOTHING:
- break;
- case IPessimisticFilesystemConstants.OPTION_AUTOMATIC:
- addToControl(fAdded, monitor);
- break;
- case IPessimisticFilesystemConstants.OPTION_PROMPT:
- final Shell shell= getShell();
- if (shell != null && !shell.isDisposed()) {
- final Set resources= new HashSet(fAdded);
- Runnable run= new Runnable() {
- public void run() {
- CheckedTreeSelectionDialog dialog= new CheckedTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new ResourceSetContentProvider(resources));
- dialog.setMessage("Select the resources to be added to the control of the repository.");
- dialog.setTitle("Add resources to control");
- dialog.setContainerMode(true);
- dialog.setBlockOnOpen(true);
- dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
- Object[] resourceArray= resources.toArray();
- dialog.setExpandedElements(resourceArray);
- dialog.setInitialSelections(resourceArray);
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
- int status= dialog.open();
-
- if (status == Window.OK) {
- Object[] results= dialog.getResult();
- if (results != null) {
- Set resources= new HashSet(results.length);
- for (int i= 0; i < results.length; i++) {
- resources.add(results[i]);
- }
- addToControl(resources, monitor);
- }
- }
- }
- };
-
- Display display= shell.getDisplay();
- display.asyncExec(run);
- } else {
- PessimisticFilesystemProviderPlugin.getInstance().logError(null, "Could not aquire a shell");
- }
- break;
- }
- fAdded.clear();
- }
-
- /*
- * Adds the resources to the control of the provider.
- */
- private void addToControl(Collection resources, final IProgressMonitor monitor) {
- Map byProject= sortByProject(resources);
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
- PessimisticFilesystemProvider provider= (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- if (provider != null) {
- provider.addToControl(toResourceArray((Collection)byProject.get(project)), monitor);
- }
-
- }
- }
-
- /*
- * Removes the resources from the control of the provider.
- */
- private void remove(IProgressMonitor monitor) {
- Map byProject= sortByProject(fRemoved);
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
- PessimisticFilesystemProvider provider= (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- if (provider != null) {
- provider.removeFromControl(toResourceArray((Collection)byProject.get(project)), monitor);
- }
- }
- fRemoved.clear();
- }
-
- /*
- * Convenience method to sort the resources by project
- */
- private Map sortByProject(Collection resources) {
- Map byProject= new HashMap();
- for (Iterator i= resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
- IProject project= resource.getProject();
- Set set= (Set)byProject.get(project);
- if (set == null) {
- set= new HashSet(1);
- byProject.put(project, set);
- }
- set.add(resource);
- }
- return byProject;
- }
-
- /*
- * Convenience method which answers a shell with which to prompt.
- */
- private Shell getShell() {
- IWorkbench workbench= PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
- if (window == null) {
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- if (windows != null && windows.length > 0) {
- window= windows[0];
- }
- }
- if (window != null) {
- Shell shell= window.getShell();
- if (shell == null)
- return null;
- if (shell.isDisposed())
- return null;
- return shell;
- }
- }
- return null;
- }
-
- /**
- * Starts listening for changes.
- */
- public void startup() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
- System.out.println ("Resource callback registered");
- }
-
- /**
- * Stops listening for changes.
- */
- public void shutdown() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
- System.out.println ("Resource callback unregistered");
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java
deleted file mode 100644
index 0d3248b7c..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class ResourceSetContentProvider implements ITreeContentProvider {
- private static final Object[] EMPTY_ARRAY= new Object[0];
- private Map fResourceTree;
- private IResource[] fRoots;
-
- public ResourceSetContentProvider(Set resources) {
- fResourceTree= new HashMap(1);
- Set roots= new HashSet(resources);
- for(Iterator i= resources.iterator(); i.hasNext(); ) {
- IResource resource= (IResource)i.next();
- if(resource.getType() == IResource.ROOT) {
- continue; // root cannot be displayed
- }
- IResource parent= resource.getParent();
- if (roots.contains(parent)) {
- roots.remove(resource);
- Set set= (Set)fResourceTree.get(parent);
- if (set == null) {
- set= new HashSet(1);
- fResourceTree.put(parent, set);
- }
- set.add(resource);
- }
- }
- fRoots= (IResource[])roots.toArray(new IResource[roots.size()]);
- }
-
- public Object[] getChildren(Object parentElement) {
- Set set= (Set) fResourceTree.get(parentElement);
- if (set != null) {
- return set.toArray();
- }
- return EMPTY_ARRAY;
- }
-
- public Object getParent(Object element) {
- if (element instanceof IResource) {
- return ((IResource)element).getParent();
- }
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return fResourceTree.get(element) != null;
- }
-
- public Object[] getElements(Object inputElement) {
- return fRoots;
- }
-
- public void dispose() {
- fResourceTree= null;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java
deleted file mode 100644
index d7178d0f8..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-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.examples.pessimistic.PessimisticFilesystemProvider;
-
-/**
- * Adds the selected resources and their parent resources to
- * the control of the provider.
- */
-public class AddToControlAction extends PessimisticProviderAction {
-
- /**
- * Collects the selected resources, sorts them by project
- * and adds them to their respective repository providers.
- *
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- IResource[] resources= getSelectedResources();
- if (resources == null || resources.length == 0)
- return;
- Set resourceSet= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- while (resource.getType() != IResource.PROJECT && !isControlled(resource)) {
- resourceSet.add(resource);
- resource= resource.getParent();
- }
- }
- if (!resourceSet.isEmpty()) {
- final Map byProject= sortByProject(resourceSet);
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
- PessimisticFilesystemProvider provider= getProvider(project);
- if (provider != null) {
- Set set= (Set)byProject.get(project);
- IResource[] resources= new IResource[set.size()];
- set.toArray(resources);
- provider.addToControl(resources, monitor);
- }
- }
- }
- };
- runWithProgressDialog(runnable);
- }
- }
-
- /**
- * Answers <code>true</code> if the selected resource is not
- * a project (or the workspace root) and is not controlled.
- *
- * @see PessimisticProviderAction#shouldEnableFor(IResource)
- */
- protected boolean shouldEnableFor(IResource resource) {
- if (resource == null) {
- return false;
- }
- if ((resource.getType() & (IResource.ROOT | IResource.PROJECT)) != 0) {
- return false;
- }
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- return !provider.isControlled(resource);
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/BlankPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/BlankPage.java
deleted file mode 100644
index e7be75fc7..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/BlankPage.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A wizard page that is empty to workaround a bug.
- */
-public class BlankPage extends WizardPage {
-
- /**
- * Creates a blank page telling the user what is about to happen.
- */
- public BlankPage() {
- super("AddPessimisticFilesystemSupport");
- setTitle("Pessimistic filesystem provider");
- setDescription("Add pessimistic filesystem provider support to this project");
- setPageComplete(true);
- }
-
- /**
- * Creates an empty control.
- */
- public void createControl(Composite parent) {
- Composite client = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- client.setLayout(layout);
- setControl(client);
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckInAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckInAction.java
deleted file mode 100644
index fa4dd3759..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckInAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider;
-
-/**
- * Performs a check in on the selected resources. If a folder is
- * selected all of its children are recursively checked in.
- */
-public class CheckInAction extends SourceManagementAction {
-
- /**
- * Answers <code>true</code> if and only if the resource is
- * not null, controlled, not ignored, and is checked out.
- *
- * @see PessimisticProviderAction#shouldEnableFor(IResource)
- */
- protected boolean shouldEnableFor(IResource resource) {
- if (resource == null)
- return false;
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- if (!provider.isControlled(resource))
- return false;
- if (provider.isIgnored(resource))
- return false;
- return provider.isCheckedout(resource);
- }
-
- /*
- * @see SourceControlAction#manageResources(PessimisticFilesystemProvider, IResource[], IProgressMonitor)
- */
- protected void manageResources(PessimisticFilesystemProvider provider, IResource[] resources, IProgressMonitor monitor) {
- provider.checkin(resources, monitor);
- }
-
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckOutAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckOutAction.java
deleted file mode 100644
index 37e54dc45..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/CheckOutAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider;
-
-/**
- * Performs a check out on the selected resources. If a folder is
- * selected all of its children are recursively checked out.
- */
-public class CheckOutAction extends SourceManagementAction {
- /**
- * Answers <code>true</code> if and only if the <code>resource</code>
- * is not <code>null</code>, controlled, not ignored and not checked out.
- *
- * @see PessimisticProviderAction#shouldEnableFor(IResource)
- */
- protected boolean shouldEnableFor(IResource resource) {
- if (resource == null)
- return false;
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- if (!provider.isControlled(resource))
- return false;
- if (provider.isIgnored(resource))
- return false;
- return !provider.isCheckedout(resource);
- }
-
- /*
- * @see SourceControlAction#manageResources(PessimisticFilesystemProvider, IResource[], IProgressMonitor)
- */
- protected void manageResources(PessimisticFilesystemProvider provider, IResource[] resources, IProgressMonitor monitor) {
- provider.checkout(resources, monitor);
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/ConfigurationWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/ConfigurationWizard.java
deleted file mode 100644
index 4f9525da8..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/ConfigurationWizard.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * A wizard which adds the <code>PessimisticFilesystemProvider</code> nature
- * to a given project.
- */
-public class ConfigurationWizard extends Wizard implements IConfigurationWizard {
- /*
- * The project in question.
- */
- private IProject project;
-
- /*
- * @see Wizard#addPages()
- */
- public void addPages() {
- // workaround the wizard problem
- addPage(new BlankPage());
- }
-
- /*
- * @see Wizard#performFinish()
- */
- public boolean performFinish() {
- try {
- RepositoryProvider.map(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- } catch (TeamException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Could not set sharing on " + project);
- return false;
- }
- return true;
- }
-
- /*
- * @see IConfigurationWizard#init(IWorkbench, IProject)
- */
- public void init(IWorkbench workbench, IProject project) {
- this.project = project;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java
deleted file mode 100644
index 74757fd3f..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
-
-public class DisconnectAction extends PessimisticProviderAction {
- /**
- * Collects the selected resources, extracts the projects selected
- * and disconnects the projects from their respective providers.
- *
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
- System.out.println("Disconnect");
-
- IResource[] resources= getSelectedResources();
- if (resources == null || resources.length == 0)
- return;
- final Set projects= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (resource.getType() == IResource.PROJECT) {
- projects.add(resource.getProject());
- }
- }
- if (!projects.isEmpty()) {
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor)
- throws CoreException {
- for (Iterator i= projects.iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
- PessimisticFilesystemProvider provider= getProvider(project);
- if (provider != null) {
- try {
- RepositoryProvider.unmap(project);
- } catch (TeamException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Could not unmap " + project);
- }
- }
- }
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(runnable, monitor);
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problem during unmap runnable");
- }
-
- }
- };
- runWithProgressDialog(runnable);
- }
- }
-
- /**
- * Answers <code>true</code> if and only if the resource is a
- * project and is controlled by the pessimistic filesystem provider.
- *
- * @see PessimisticProviderAction#shouldEnableFor(IResource)
- */
- protected boolean shouldEnableFor(IResource resource) {
- if (resource.getType() == IResource.PROJECT) {
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- return true;
- }
- return false;
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java
deleted file mode 100644
index 8e4e64843..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.examples.pessimistic.*;
-
-/**
- * The <code>PessimisticDecorator</code> is a label provider
- * that decorates resources controlled by a <code>PessimisticFilesystemProvider</code>.
- */
-public class PessimisticDecorator extends LabelProvider implements ILabelDecorator, IResourceStateListener {
-
- private Set fDecoratedProjects;
-
- /**
- * Constructor needed for extension
- */
- public PessimisticDecorator() {
- fDecoratedProjects= new HashSet(1);
- PessimisticFilesystemProviderPlugin.getInstance().addProviderListener(this);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(String, Object)
- */
- public String decorateText(String text, Object element) {
- IResource resource= getResource(element);
- if (resource == null)
- return text;
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null) {
- return text;
- }
- if (provider.isControlled(resource)) {
- if (provider.isCheckedout(resource)) {
- return ">" + text;
- } else {
- return text;
- }
- } else {
- if (provider.isIgnored(resource)) {
- return "[ignored] " + text;
- } else {
- return "(not controlled) " + text;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(Image, Object)
- */
- public Image decorateImage(Image image, Object element) {
- return image;
- }
-
- /*
- * Convenience method to get the provider of a resource
- */
- private PessimisticFilesystemProvider getProvider(IResource resource) {
- IProject project= resource.getProject();
- if (project != null) {
- return (PessimisticFilesystemProvider) RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- }
- return null;
- }
-
- /*
- * Convenience method to get a resource from an object
- */
- 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;
- }
-
- /*
- * Fires label events
- */
- private void postLabelEvents(final LabelProviderChangedEvent[] events) {
- if (events != null && events.length > 0) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for (int i= 0; i < events.length; i++) {
- fireLabelProviderChanged(events[i]);
- }
- }
- });
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- public void dispose() {
- PessimisticFilesystemProviderPlugin.getInstance().removeProviderListener(this);
- super.dispose();
- }
-
- /*
- * @see org.eclipse.team.examples.pessimistic.IResourceStateListener#resourcesChanged(IResource[])
- */
- public void stateChanged(IResource[] resources) {
- if (resources.length > 0) {
- LabelProviderChangedEvent[] events= new LabelProviderChangedEvent[resources.length];
- for (int i= 0; i < resources.length; i++) {
- events[i]= new LabelProviderChangedEvent(this, resources[i]);
- }
- postLabelEvents(events);
- }
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticPreferencesPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticPreferencesPage.java
deleted file mode 100644
index 4bc37d635..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticPreferencesPage.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-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.examples.pessimistic.IPessimisticFilesystemConstants;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-/**
- * A preference page for the <code>PessimisticFilesystemProviderPlugin</code>.
- */
-public class PessimisticPreferencesPage
- extends PreferencePage
- implements IWorkbenchPreferencePage {
-
- /*
- * Widget for the files are edited preference
- */
- private Combo filesAreEditedCombo;
- /*
- * Widget for the files are edited without a context preference
- */
- private Combo filesAreEditedNoPromptCombo;
- /*
- * Widget for the files are saved preference
- */
- private Combo filesAreSavedCombo;
- /*
- * Widget for the files are edited preference
- */
- private Combo addToControlCombo;
- /*
- * Widget for the change file contents preference
- */
- private Button changeFileContents;
- /*
- * Widget for the fail validate edit preference
- */
- private Button failValidateEdit;
-
- /*
- * Option strings for the files are edited preference.
- */
- private static final String[] EDIT_OPTION_STRINGS=
- new String[] {
- "Prompt to checkout",
- "Checkout",
- "Do nothing", };
- /*
- * Option values for the files are edited preference.
- */
- private static final int[] EDIT_OPTION_KEYS=
- new int[] {
- IPessimisticFilesystemConstants.OPTION_PROMPT,
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING, };
-
- /*
- * Option strings for the files are edited without a context preference.
- */
- private static final String[] EDIT_NO_PROMPT_OPTION_STRINGS=
- new String[] {
- "Checkout",
- "Do nothing", };
- /*
- * Option values for the files are edited without a context preference.
- */
- private static final int[] EDIT_NO_PROMPT_OPTION_KEYS=
- new int[] {
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING, };
-
- /*
- * Option strings for the files are saved preference.
- */
- private static final String[] SAVE_OPTION_STRINGS=
- new String[] {
- "Checkout",
- "Do nothing", };
- /*
- * Option values for the files are saved preference.
- */
- private static final int[] SAVE_OPTION_KEYS=
- new int[] {
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING, };
-
- /*
- * Option strings for the add to control preference.
- */
- private static final String[] ADD_TO_CONTROL_OPTION_STRINGS=
- new String[] {
- "Prompt to add to control",
- "Add to control",
- "Do nothing", };
- /*
- * Option values for the add to control preference.
- */
- private static final int[] ADD_TO_CONTROL_OPTION_KEYS=
- new int[] {
- IPessimisticFilesystemConstants.OPTION_PROMPT,
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING, };
-
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
- */
- protected IPreferenceStore doGetPreferenceStore() {
- return PessimisticFilesystemProviderPlugin.getInstance().getPreferenceStore();
- }
-
-
- /*
- * Sets the layout to be a grid layout with the given number of columns.
- */
- protected void setDefaultLayout(Composite group, int columns) {
- GridLayout layout = new GridLayout();
- group.setLayout(layout);
-
- GridData data =
- new GridData(
- GridData.VERTICAL_ALIGN_FILL
- | GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
-
- layout.numColumns = columns;
- group.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- setDefaultLayout(composite, 1);
-
- Composite options = new Composite(composite, SWT.NULL);
- setDefaultLayout(options, 2);
-
- Label label = new Label(options, SWT.NONE);
- label.setText("File handling:");
- GridData gridData = new GridData();
- gridData.horizontalSpan = 2;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- label = new Label(options, SWT.NONE);
- label.setText("When checked in files are edited:");
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- filesAreEditedCombo= new Combo(options, SWT.BORDER | SWT.READ_ONLY);
- gridData = new GridData();
- gridData.horizontalSpan= 1;
- gridData.horizontalAlignment = GridData.FILL;
- filesAreEditedCombo.setLayoutData(gridData);
- filesAreEditedCombo.setItems(EDIT_OPTION_STRINGS);
-
- label = new Label(options, SWT.NONE);
- label.setText("When checked in files are edited programmatically:");
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- filesAreEditedNoPromptCombo= new Combo(options, SWT.BORDER | SWT.READ_ONLY);
- gridData = new GridData();
- gridData.horizontalSpan= 1;
- gridData.horizontalAlignment = GridData.FILL;
- filesAreEditedNoPromptCombo.setLayoutData(gridData);
- filesAreEditedNoPromptCombo.setItems(EDIT_NO_PROMPT_OPTION_STRINGS);
-
- label = new Label(options, SWT.NONE);
- label.setText("When checked in files are saved:");
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- filesAreSavedCombo= new Combo(options, SWT.BORDER | SWT.READ_ONLY);
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- filesAreSavedCombo.setLayoutData(gridData);
- filesAreSavedCombo.setItems(SAVE_OPTION_STRINGS);
-
- label = new Label(options, SWT.NONE);
- label.setText("When files are created:");
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- addToControlCombo= new Combo(options, SWT.BORDER | SWT.READ_ONLY);
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- addToControlCombo.setLayoutData(gridData);
- addToControlCombo.setItems(ADD_TO_CONTROL_OPTION_STRINGS);
-
- options = new Composite(composite, SWT.NULL);
- setDefaultLayout(options, 1);
-
- label = new Label(options, SWT.NONE);
- label.setText("Error cases:");
- gridData = new GridData();
- gridData.horizontalSpan = 1;
- gridData.horizontalAlignment = GridData.FILL;
- label.setLayoutData(gridData);
-
- failValidateEdit= new Button(options, SWT.CHECK | SWT.LEFT);
- failValidateEdit.setText("Fail validate edit");
- gridData = new GridData();
- failValidateEdit.setLayoutData(gridData);
-
- changeFileContents= new Button(options, SWT.CHECK | SWT.LEFT);
- changeFileContents.setText("Touch files during validate edit");
- gridData = new GridData();
- changeFileContents.setLayoutData(gridData);
-
- updatePreferencePage();
-
- return composite;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- IPreferenceStore store = getPreferenceStore();
-
- filesAreEditedCombo.select(
- getEditOptionIndex(store.getDefaultInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED)));
- filesAreEditedNoPromptCombo.select(
- getEditNoPromptOptionIndex(store.getDefaultInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT)));
- filesAreSavedCombo.select(
- getSaveOptionIndex(store.getDefaultInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED)));
- addToControlCombo.select(
- getAddToControlOptionIndex(store.getDefaultInt(IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL)));
- failValidateEdit.setSelection(
- store.getDefaultBoolean(IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT));
- changeFileContents.setSelection(
- store.getDefaultBoolean(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT));
- super.performDefaults();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- IPreferenceStore store = getPreferenceStore();
-
- int selectionIndex = filesAreEditedCombo.getSelectionIndex();
- if (selectionIndex != -1)
- store.setValue(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED,
- EDIT_OPTION_KEYS[selectionIndex]);
- selectionIndex = filesAreEditedNoPromptCombo.getSelectionIndex();
- if (selectionIndex != -1)
- store.setValue(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT,
- SAVE_OPTION_KEYS[selectionIndex]);
- selectionIndex = filesAreSavedCombo.getSelectionIndex();
- if (selectionIndex != -1)
- store.setValue(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED,
- SAVE_OPTION_KEYS[selectionIndex]);
- selectionIndex = addToControlCombo.getSelectionIndex();
- if (selectionIndex != -1)
- store.setValue(
- IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL,
- ADD_TO_CONTROL_OPTION_KEYS[selectionIndex]);
- store.setValue(
- IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT,
- failValidateEdit.getSelection());
- store.setValue(
- IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT,
- changeFileContents.getSelection());
- return true;
- }
-
- /*
- * Sets the widgets to have the state stored in the preferences.
- */
- protected void updatePreferencePage() {
- IPreferenceStore store = getPreferenceStore();
-
- filesAreEditedCombo.select(
- getEditOptionIndex(store.getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED)));
- filesAreEditedNoPromptCombo.select(
- getEditNoPromptOptionIndex(store.getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT)));
- filesAreSavedCombo.select(
- getSaveOptionIndex(store.getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED)));
- addToControlCombo.select(
- getAddToControlOptionIndex(store.getInt(IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL)));
- failValidateEdit.setSelection(
- store.getBoolean(IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT));
- changeFileContents.setSelection(
- store.getBoolean(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT));
- }
-
- /*
- * Answers the index of the given key.
- */
- protected int getEditOptionIndex(int key) {
- for(int i= 0; i < EDIT_OPTION_KEYS.length; i++) {
- if (EDIT_OPTION_KEYS[i] == key)
- return i;
- }
- return -1;
- }
-
- /*
- * Answers the index of the given key.
- */
- protected int getSaveOptionIndex(int key) {
- for(int i= 0; i < SAVE_OPTION_KEYS.length; i++) {
- if (SAVE_OPTION_KEYS[i] == key)
- return i;
- }
- return -1;
- }
-
- /*
- * Answers the index of the given key.
- */
- protected int getEditNoPromptOptionIndex(int key) {
- for(int i= 0; i < SAVE_OPTION_KEYS.length; i++) {
- if (SAVE_OPTION_KEYS[i] == key)
- return i;
- }
- return -1;
- }
-
- /*
- * Answers the index of the given key.
- */
- protected int getAddToControlOptionIndex(int key) {
- for(int i= 0; i < ADD_TO_CONTROL_OPTION_KEYS.length; i++) {
- if (ADD_TO_CONTROL_OPTION_KEYS[i] == key)
- return i;
- }
- return -1;
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java
deleted file mode 100644
index ec035b7ea..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider;
-import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * Abstract base action implementation for all pessimistic provider actions.
- * Provides convenience methods an abstractions.
- */
-public abstract class PessimisticProviderAction
- implements IObjectActionDelegate {
-
- /*
- * The current selection.
- */
- protected ISelection fSelection;
- /*
- * The current shell.
- */
- protected Shell fShell;
-
- /*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection = selection;
-
- boolean enabled= action.isEnabled();
- if (enabled != checkEnablement()) {
- action.setEnabled(!enabled);
- }
- }
-
- /*
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart part) {
- fShell= part.getSite().getShell();
- }
-
- /**
- * Answers <code>true</code> if this action should be enabled
- * for the given <code>resource</code>.
- */
- protected abstract boolean shouldEnableFor(IResource resource);
-
- /*
- * Checks to see if this action should be enabled.
- */
- protected boolean checkEnablement() {
- IResource[] resources= getSelectedResources();
- if (resources == null || resources.length == 0) {
- return false;
- } else {
- boolean enabled= false;
- for(int i= 0; !enabled && i < resources.length; i++) {
- if (shouldEnableFor(resources[i])) {
- enabled= true;
- }
- }
- return enabled;
- }
- }
-
- /**
- * Convenience method to get an array of resources from the selection.
- */
- protected IResource[] getSelectedResources() {
- ArrayList resources = null;
- if (!fSelection.isEmpty()) {
- resources = new ArrayList();
- Iterator elements = ((IStructuredSelection) fSelection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- if (next instanceof IResource) {
- resources.add(next);
- continue;
- }
- if (next instanceof IAdaptable) {
- IAdaptable a = (IAdaptable) next;
- Object adapter = a.getAdapter(IResource.class);
- if (adapter instanceof IResource) {
- resources.add(adapter);
- continue;
- }
- }
- }
- }
- if (resources != null && !resources.isEmpty()) {
- IResource[] result = new IResource[resources.size()];
- resources.toArray(result);
- return result;
- }
- return new IResource[0];
- }
-
- /**
- * Convenience method which answers <code>true</code> if the
- * resource is controlled by a <code>PessimisticFilesystemProvider</code>.
- */
- protected boolean isControlled(IResource resource) {
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- return provider.isControlled(resource);
- }
-
- /**
- * Convenience method which answers <code>true</code> if and only if the
- * resource is controlled by a <code>PessimisticFilesystemProvider</code>
- * and is checked out.
- */
- protected boolean isCheckedOut(IResource resource) {
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- return provider.isCheckedout(resource);
- }
-
- /**
- * Convenience method which answers <code>true</code> if and only if the
- * resource is controlled by a <code>PessimisticFilesystemProvider</code>
- * and the resource is ignored.
- */
- protected boolean isIgnored(IResource resource) {
- PessimisticFilesystemProvider provider= getProvider(resource);
- if (provider == null)
- return false;
- return provider.isIgnored(resource);
- }
-
- /**
- * Convenience method which answers the <code>PessimisticFilesystemProvider</code>
- * for the given <code>resource</code> or <code>null</code> if the
- * <code>resource</code> is not associated with a <code>PessimisticFilesystemProvider</code>.
- */
- protected PessimisticFilesystemProvider getProvider(IResource resource) {
- if (resource == null) {
- return null;
- }
- IProject project= resource.getProject();
- if (project == null) {
- return null;
- }
- return (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
- }
-
- /**
- * Convenience method which walks a resource tree and collects the
- * resources that this action would enable for.
- */
- protected void recursivelyAdd(IResource resource, Set resources) {
- if (isControlled(resource) && !isIgnored(resource)) {
- if (shouldEnableFor(resource)) {
- resources.add(resource);
- }
-
- if (resource instanceof IContainer) {
- IContainer container = (IContainer) resource;
- IResource[] members= null;
- try {
- members = container.members();
- } catch (CoreException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Exception traversing members");
- }
- if (members != null) {
- for (int i = 0; i < members.length; i++) {
- recursivelyAdd(members[i], resources);
- }
- }
- }
- }
- }
-
- /**
- * Convenience method which sorts the given <code>resources</code>
- * into a map of IProject -> Set of IResource objects.
- */
- protected Map sortByProject(Set resources) {
- Map byProject= new HashMap();
- if (resources != null) {
- for (Iterator i= resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
- IProject project= resource.getProject();
- Set set= (Set)byProject.get(project);
- if (set == null) {
- set= new HashSet(1);
- byProject.put(project, set);
- }
- set.add(resource);
- }
- }
- return byProject;
- }
-
- /**
- * Convenience method for displaying runnable progress
- * with a <code>ProgressMonitorDialog</code>.
- */
- protected void runWithProgressDialog(IRunnableWithProgress runnable) {
- try {
- new ProgressMonitorDialog(fShell).run(true, false, runnable);
- } catch (InvocationTargetException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems running action " + this);
- } catch (InterruptedException e) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems running action " + this);
- }
- }
-}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java
deleted file mode 100644
index 9a03edb10..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-package org.eclipse.team.examples.pessimistic.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-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.examples.pessimistic.PessimisticFilesystemProvider;
-
-/**
- * Removes the selected resources and their children resources from
- * the control of the provider.
- */
-public class RemoveFromControlAction extends PessimisticProviderAction {
-
- /**
- * Collects the selected resources into sets by project,
- * then removes the resources from the provider associated
- * with their containing project.
- *
- * @see org.eclipse.ui.IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- IResource[] resources= getSelectedResources();
- if (resources == null || resources.length == 0)
- return;
- Set resourceSet= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- recursivelyAdd(resource, resourceSet);
- }
- if (!resourceSet.isEmpty()) {