Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.diff.edit/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/build/antJavadoc.sh0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/build/javadoc.xml.template0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/build/overview.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/tutorials/Adapting_Comparison_Process.textile0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/tutorials/EMF_Compare_Export_Tutorial.textile0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/tutorials/User_Guide.textile0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.doc/tutorials/Using_Compare_Services.textile0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.epatch.dsl.tests/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.epatch.dsl.ui/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.epatch.dsl/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.epatch.tests/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.epatch/about.html0
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/.classpath7
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/.project28
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/META-INF/MANIFEST.MF35
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/build.properties17
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_books_Book.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_writers_Writer.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateLibrary_books_BookCopy.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Book.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BookCopy.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BooksModelFile.gifbin0 -> 346 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Catalog.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Library.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/LibraryModelFile.gifbin0 -> 346 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Writer.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/WritersModelFile.gifbin0 -> 346 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewBooks.gifbin0 -> 2462 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewLibrary.gifbin0 -> 2462 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewWriters.gifbin0 -> 2462 bytes
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/model/books.ecore18
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/model/library.ecore15
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/model/library.genmodel48
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/model/writers.ecore15
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/plugin.properties89
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/plugin.xml204
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Book.java142
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksFactory.java66
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksPackage.java323
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Catalog.java57
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BookImpl.java365
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksFactoryImpl.java124
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksPackageImpl.java303
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/CatalogImpl.java167
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksActionBarContributor.java441
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksEditor.java1799
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksModelWizard.java649
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BookItemProvider.java211
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BooksItemProviderAdapterFactory.java240
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/CatalogItemProvider.java175
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksAdapterFactory.java153
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceFactoryImpl.java56
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceImpl.java43
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksSwitch.java149
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/BookCopy.java94
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/Library.java84
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryFactory.java66
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryPackage.java295
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/BookCopyImpl.java246
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryFactoryImpl.java124
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryImpl.java238
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryPackageImpl.java290
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryActionBarContributor.java441
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryEditor.java1799
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryModelWizard.java650
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/BookCopyItemProvider.java172
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProvider.java202
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProviderAdapterFactory.java240
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryAdapterFactory.java153
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceFactoryImpl.java56
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceImpl.java43
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibrarySwitch.java149
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/provider/LibraryEditPlugin.java104
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Catalog.java57
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Writer.java88
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersFactory.java66
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersPackage.java267
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/CatalogImpl.java167
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WriterImpl.java257
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersFactoryImpl.java124
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersPackageImpl.java276
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersActionBarContributor.java441
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersEditor.java1799
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersModelWizard.java650
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/CatalogItemProvider.java175
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WriterItemProvider.java180
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WritersItemProviderAdapterFactory.java240
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersAdapterFactory.java153
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceFactoryImpl.java56
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceImpl.java43
-rw-r--r--plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersSwitch.java149
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.addressbook/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.diff.extension/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.diff.extension/src/org/eclipse/emf/compare/examples/diff/extension/DiffExtensionPlugin.java0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/about.html0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.properties0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.xml0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/Messages.java0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/action/ExportAsHTMLAction.java0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/messages.properties0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/wizard/ExportAsHTMLWizard.java0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples.export.xslt/templates/xslt/EMF-DIFF2HTML.xslt0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.emf.compare.examples/plugin.properties0
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/.classpath7
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/.gitignore4
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/.project28
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/META-INF/MANIFEST.MF21
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/build.properties6
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/plugin.properties14
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/plugin.xml54
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EMFCompareLogicalUIPlugin.java58
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EObjectTypedElement.java91
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/LogicalModelCompareInput.java58
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/adapter/EMFCompareAdapterFactory.java147
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFCompareSynchronizationAdapter.java187
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationContentProvider.java203
-rw-r--r--plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationLabelProvider.java138
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.classpath7
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.gitignore4
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.project28
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.emf.compare.logical/build.properties6
-rw-r--r--plugins/org.eclipse.emf.compare.logical/plugin.properties12
-rw-r--r--plugins/org.eclipse.emf.compare.logical/plugin.xml52
-rw-r--r--plugins/org.eclipse.emf.compare.logical/schema/ModelResolver.exsd186
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFCompareLogicalPlugin.java74
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFLogicalModelMessages.java82
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/RevisionedURIConverter.java200
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/emflogicalmodelmessages.properties13
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/EMFCompareExtensionRegistry.java72
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/IModelResolver.java61
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverDescriptor.java164
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverRegistryListener.java106
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResourceVisitor.java125
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ScopedModelResolver.java173
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFModelProvider.java141
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFResourceMapping.java375
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFDelta.java232
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFEObjectDelta.java239
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFModelDelta.java377
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFResourceDelta.java178
-rw-r--r--plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/service/MatchService.java22
-rw-r--r--plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/ModelCompareInput.java72
-rw-r--r--plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/internal/ModelComparator.java80
-rw-r--r--plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/viewer/structure/ModelStructureMergeViewer.java14
-rw-r--r--plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.compare/build.properties3
-rw-r--r--plugins/org.eclipse.emf.compare/codeStyle/EMFCompareCheckstyle5Configuration.xml4
-rw-r--r--plugins/org.eclipse.emf.compare/plugin.xml14
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/ContentTypePropertyTester.java96
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/DelegatingURIConverter.java201
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/EclipseModelUtils.java57
157 files changed, 21073 insertions, 35 deletions
diff --git a/plugins/org.eclipse.emf.compare.diff.edit/about.html b/plugins/org.eclipse.emf.compare.diff.edit/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.diff.edit/about.html
+++ b/plugins/org.eclipse.emf.compare.diff.edit/about.html
diff --git a/plugins/org.eclipse.emf.compare.doc/about.html b/plugins/org.eclipse.emf.compare.doc/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/about.html
+++ b/plugins/org.eclipse.emf.compare.doc/about.html
diff --git a/plugins/org.eclipse.emf.compare.doc/build/antJavadoc.sh b/plugins/org.eclipse.emf.compare.doc/build/antJavadoc.sh
index 653b5fdee..653b5fdee 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/build/antJavadoc.sh
+++ b/plugins/org.eclipse.emf.compare.doc/build/antJavadoc.sh
diff --git a/plugins/org.eclipse.emf.compare.doc/build/javadoc.xml.template b/plugins/org.eclipse.emf.compare.doc/build/javadoc.xml.template
index 7113cbbc6..7113cbbc6 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/build/javadoc.xml.template
+++ b/plugins/org.eclipse.emf.compare.doc/build/javadoc.xml.template
diff --git a/plugins/org.eclipse.emf.compare.doc/build/overview.html b/plugins/org.eclipse.emf.compare.doc/build/overview.html
index 2a8e71a7e..2a8e71a7e 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/build/overview.html
+++ b/plugins/org.eclipse.emf.compare.doc/build/overview.html
diff --git a/plugins/org.eclipse.emf.compare.doc/tutorials/Adapting_Comparison_Process.textile b/plugins/org.eclipse.emf.compare.doc/tutorials/Adapting_Comparison_Process.textile
index 4c0513693..4c0513693 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/tutorials/Adapting_Comparison_Process.textile
+++ b/plugins/org.eclipse.emf.compare.doc/tutorials/Adapting_Comparison_Process.textile
diff --git a/plugins/org.eclipse.emf.compare.doc/tutorials/EMF_Compare_Export_Tutorial.textile b/plugins/org.eclipse.emf.compare.doc/tutorials/EMF_Compare_Export_Tutorial.textile
index 2a9bf402b..2a9bf402b 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/tutorials/EMF_Compare_Export_Tutorial.textile
+++ b/plugins/org.eclipse.emf.compare.doc/tutorials/EMF_Compare_Export_Tutorial.textile
diff --git a/plugins/org.eclipse.emf.compare.doc/tutorials/User_Guide.textile b/plugins/org.eclipse.emf.compare.doc/tutorials/User_Guide.textile
index 15321c0ff..15321c0ff 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/tutorials/User_Guide.textile
+++ b/plugins/org.eclipse.emf.compare.doc/tutorials/User_Guide.textile
diff --git a/plugins/org.eclipse.emf.compare.doc/tutorials/Using_Compare_Services.textile b/plugins/org.eclipse.emf.compare.doc/tutorials/Using_Compare_Services.textile
index 6ebd3c9e2..6ebd3c9e2 100755..100644
--- a/plugins/org.eclipse.emf.compare.doc/tutorials/Using_Compare_Services.textile
+++ b/plugins/org.eclipse.emf.compare.doc/tutorials/Using_Compare_Services.textile
diff --git a/plugins/org.eclipse.emf.compare.epatch.dsl.tests/about.html b/plugins/org.eclipse.emf.compare.epatch.dsl.tests/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.epatch.dsl.tests/about.html
+++ b/plugins/org.eclipse.emf.compare.epatch.dsl.tests/about.html
diff --git a/plugins/org.eclipse.emf.compare.epatch.dsl.ui/about.html b/plugins/org.eclipse.emf.compare.epatch.dsl.ui/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.epatch.dsl.ui/about.html
+++ b/plugins/org.eclipse.emf.compare.epatch.dsl.ui/about.html
diff --git a/plugins/org.eclipse.emf.compare.epatch.dsl/about.html b/plugins/org.eclipse.emf.compare.epatch.dsl/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.epatch.dsl/about.html
+++ b/plugins/org.eclipse.emf.compare.epatch.dsl/about.html
diff --git a/plugins/org.eclipse.emf.compare.epatch.tests/about.html b/plugins/org.eclipse.emf.compare.epatch.tests/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.epatch.tests/about.html
+++ b/plugins/org.eclipse.emf.compare.epatch.tests/about.html
diff --git a/plugins/org.eclipse.emf.compare.epatch/about.html b/plugins/org.eclipse.emf.compare.epatch/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.epatch/about.html
+++ b/plugins/org.eclipse.emf.compare.epatch/about.html
diff --git a/plugins/org.eclipse.emf.compare.example.library/.classpath b/plugins/org.eclipse.emf.compare.example.library/.classpath
new file mode 100644
index 000000000..cedf0d0d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.compare.example.library/.project b/plugins/org.eclipse.emf.compare.example.library/.project
new file mode 100644
index 000000000..cb65e723d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.compare.example.library</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.compare.example.library/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.compare.example.library/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..3ec1a4462
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue May 10 15:39:00 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.emf.compare.example.library/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.example.library/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..332e2f9f1
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/META-INF/MANIFEST.MF
@@ -0,0 +1,35 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.compare.example.library;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin$Implementation
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.emf.compare.example.library.books,
+ org.eclipse.emf.compare.example.library.books.impl,
+ org.eclipse.emf.compare.example.library.books.presentation,
+ org.eclipse.emf.compare.example.library.books.provider,
+ org.eclipse.emf.compare.example.library.books.util,
+ org.eclipse.emf.compare.example.library.library,
+ org.eclipse.emf.compare.example.library.library.impl,
+ org.eclipse.emf.compare.example.library.library.presentation,
+ org.eclipse.emf.compare.example.library.library.provider,
+ org.eclipse.emf.compare.example.library.library.util,
+ org.eclipse.emf.compare.example.library.provider,
+ org.eclipse.emf.compare.example.library.writers,
+ org.eclipse.emf.compare.example.library.writers.impl,
+ org.eclipse.emf.compare.example.library.writers.presentation,
+ org.eclipse.emf.compare.example.library.writers.provider,
+ org.eclipse.emf.compare.example.library.writers.util
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources;visibility:=reexport,
+ org.eclipse.emf.ecore;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.eclipse.emf.edit;visibility:=reexport,
+ org.eclipse.emf.edit.ui;visibility:=reexport,
+ org.eclipse.ui.ide;visibility:=reexport,
+ org.eclipse.emf.compare.logical;bundle-version="1.0.0"
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.emf.compare.example.library/build.properties b/plugins/org.eclipse.emf.compare.example.library/build.properties
new file mode 100644
index 000000000..808e4c0e5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/build.properties
@@ -0,0 +1,17 @@
+# Copyright (c) 2011 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+
+bin.includes = .,\
+ icons/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
+source.. = src-gen/
+output.. = bin
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_books_Book.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_books_Book.gif
new file mode 100644
index 000000000..21b4d3934
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_books_Book.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_writers_Writer.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_writers_Writer.gif
new file mode 100644
index 000000000..4d684f498
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateCatalog_writers_Writer.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateLibrary_books_BookCopy.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateLibrary_books_BookCopy.gif
new file mode 100644
index 000000000..983575cad
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/ctool16/CreateLibrary_books_BookCopy.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Book.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Book.gif
new file mode 100644
index 000000000..c3370c7dd
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Book.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BookCopy.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BookCopy.gif
new file mode 100644
index 000000000..83afb9b3c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BookCopy.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BooksModelFile.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BooksModelFile.gif
new file mode 100644
index 000000000..96a88f811
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/BooksModelFile.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Catalog.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Catalog.gif
new file mode 100644
index 000000000..cb1755a71
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Catalog.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Library.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Library.gif
new file mode 100644
index 000000000..739ebbfa6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Library.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/LibraryModelFile.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/LibraryModelFile.gif
new file mode 100644
index 000000000..1ae5c0695
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/LibraryModelFile.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Writer.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Writer.gif
new file mode 100644
index 000000000..ef56c1408
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/Writer.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/WritersModelFile.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/WritersModelFile.gif
new file mode 100644
index 000000000..8b3ad8009
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/obj16/WritersModelFile.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewBooks.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewBooks.gif
new file mode 100644
index 000000000..426010601
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewBooks.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewLibrary.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewLibrary.gif
new file mode 100644
index 000000000..36775a513
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewLibrary.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewWriters.gif b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewWriters.gif
new file mode 100644
index 000000000..33f212f1c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/icons/full/wizban/NewWriters.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.compare.example.library/model/books.ecore b/plugins/org.eclipse.emf.compare.example.library/model/books.ecore
new file mode 100644
index 000000000..96f11cba7
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/model/books.ecore
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="books"
+ nsURI="http://www.eclipse.org/emf/compare/books" nsPrefix="books">
+ <eClassifiers xsi:type="ecore:EClass" name="Catalog">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
+ eType="#//Book" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Book">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="isbn" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
+ iD="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="title" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="authors" upperBound="-1"
+ eType="ecore:EClass writers.ecore#//Writer" eOpposite="writers.ecore#//Writer/books"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.example.library/model/library.ecore b/plugins/org.eclipse.emf.compare.example.library/model/library.ecore
new file mode 100644
index 000000000..41b3ef02e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/model/library.ecore
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="library"
+ nsURI="http://www.eclipse.org/emf/compare/library" nsPrefix="library">
+ <eClassifiers xsi:type="ecore:EClass" name="Library">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
+ eType="#//BookCopy" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="BookCopy">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="book" eType="ecore:EClass books.ecore#//Book"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="copies" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.example.library/model/library.genmodel b/plugins/org.eclipse.emf.compare.example.library/model/library.genmodel
new file mode 100644
index 000000000..14bdb5749
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/model/library.genmodel
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText=" Copyright (c) 2011 Obeo.&#xD;&#xA; All rights reserved. This program and the accompanying materials&#xD;&#xA; are made available under the terms of the Eclipse Public License v1.0&#xD;&#xA; which accompanies this distribution, and is available at&#xD;&#xA; http://www.eclipse.org/legal/epl-v10.html&#xD;&#xA; &#xD;&#xA; Contributors:&#xD;&#xA; Obeo - initial API and implementation"
+ modelDirectory="/org.eclipse.emf.compare.example.library/src-gen" editDirectory="/org.eclipse.emf.compare.example.library/src-gen"
+ editorDirectory="/org.eclipse.emf.compare.example.library/src-gen" modelPluginID="org.eclipse.emf.compare.example.library"
+ modelName="Library" editPluginClass="org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin"
+ editorPluginClass="org.eclipse.emf.compare.example.library.presentation.LibraryEditorPlugin"
+ nonNLSMarkers="true" codeFormatting="true" importerID="org.eclipse.emf.importer.ecore"
+ complianceLevel="5.0">
+ <foreignModel>library.ecore</foreignModel>
+ <genPackages prefix="Library" basePackage="org.eclipse.emf.compare.example.library"
+ resource="XMI" disposableProviderFactory="true" contentTypeIdentifier="org.eclipse.emf.compare.example.library.libraryContentType"
+ ecorePackage="library.ecore#/">
+ <genClasses ecoreClass="library.ecore#//Library">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Library/name"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference library.ecore#//Library/books"/>
+ </genClasses>
+ <genClasses ecoreClass="library.ecore#//BookCopy">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference library.ecore#//BookCopy/book"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//BookCopy/copies"/>
+ </genClasses>
+ </genPackages>
+ <genPackages prefix="Books" basePackage="org.eclipse.emf.compare.example.library"
+ resource="XMI" disposableProviderFactory="true" contentTypeIdentifier="org.eclipse.emf.compare.example.library.bookContentType"
+ ecorePackage="books.ecore#/">
+ <genClasses ecoreClass="books.ecore#//Catalog">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference books.ecore#//Catalog/books"/>
+ </genClasses>
+ <genClasses ecoreClass="books.ecore#//Book" labelFeature="#//books/Book/title">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute books.ecore#//Book/isbn"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute books.ecore#//Book/title"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute books.ecore#//Book/pages"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference books.ecore#//Book/authors"/>
+ </genClasses>
+ </genPackages>
+ <genPackages prefix="Writers" basePackage="org.eclipse.emf.compare.example.library"
+ resource="XMI" disposableProviderFactory="true" contentTypeIdentifier="org.eclipse.emf.compare.example.library.writerContentType"
+ ecorePackage="writers.ecore#/">
+ <genClasses ecoreClass="writers.ecore#//Catalog">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference writers.ecore#//Catalog/writers"/>
+ </genClasses>
+ <genClasses ecoreClass="writers.ecore#//Writer">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute writers.ecore#//Writer/name"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference writers.ecore#//Writer/books"/>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/plugins/org.eclipse.emf.compare.example.library/model/writers.ecore b/plugins/org.eclipse.emf.compare.example.library/model/writers.ecore
new file mode 100644
index 000000000..d8208c95a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/model/writers.ecore
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="writers"
+ nsURI="http://www.eclipse.org/emf/compare/writers" nsPrefix="writers">
+ <eClassifiers xsi:type="ecore:EClass" name="Catalog">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="writers" upperBound="-1"
+ eType="#//Writer" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Writer">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
+ eType="ecore:EClass books.ecore#//Book" eOpposite="books.ecore#//Book/authors"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.example.library/plugin.properties b/plugins/org.eclipse.emf.compare.example.library/plugin.properties
new file mode 100644
index 000000000..aaafb51bc
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/plugin.properties
@@ -0,0 +1,89 @@
+# Copyright (c) 2011 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+
+pluginName = Library Model
+providerName = www.example.org
+
+_UI_Library_content_type = Library File
+_UI_Books_content_type = Books File
+_UI_Writers_content_type = Writers File
+_UI_CreateChild_text = {0}
+_UI_CreateChild_text2 = {1} {0}
+_UI_CreateChild_text3 = {1}
+_UI_CreateChild_tooltip = Create New {0} Under {1} Feature
+_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}.
+_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent.
+ _UI_PropertyDescriptor_description = The {0} of the {1}
+ _UI_Library_type = Library
+_UI_BookCopy_type = Book Copy
+_UI_Catalog_type = Catalog
+_UI_Book_type = Book
+_UI_Writer_type = Writer
+_UI_Unknown_type = Object
+ _UI_Unknown_datatype= Value
+ _UI_Library_name_feature = Name
+_UI_Library_books_feature = Books
+_UI_BookCopy_book_feature = Book
+_UI_BookCopy_copies_feature = Copies
+_UI_Catalog_books_feature = Books
+_UI_Book_title_feature = Title
+_UI_Book_pages_feature = Pages
+_UI_Book_authors_feature = Authors
+_UI_Catalog_writers_feature = Writers
+_UI_Writer_name_feature = Name
+_UI_Writer_books_feature = Books
+_UI_Unknown_feature = Unspecified
+
+_UI_LibraryEditor_menu = &Library Editor
+_UI_BooksEditor_menu = &Books Editor
+_UI_WritersEditor_menu = &Writers Editor
+ _UI_CreateChild_menu_item = &New Child
+_UI_CreateSibling_menu_item = N&ew Sibling
+ _UI_ShowPropertiesView_menu_item = Show &Properties View
+_UI_RefreshViewer_menu_item = &Refresh
+ _UI_SelectionPage_label = Selection
+_UI_ParentPage_label = Parent
+_UI_ListPage_label = List
+_UI_TreePage_label = Tree
+_UI_TablePage_label = Table
+_UI_TreeWithColumnsPage_label = Tree with Columns
+_UI_ObjectColumn_label = Object
+_UI_SelfColumn_label = Self
+ _UI_NoObjectSelected = Selected Nothing
+_UI_SingleObjectSelected = Selected Object: {0}
+_UI_MultiObjectSelected = Selected {0} Objects
+ _UI_OpenEditorError_label = Open Editor
+ _UI_Wizard_category = Example EMF Model Creation Wizards
+ _UI_CreateModelError_message = Problems encountered in file "{0}"
+ _UI_LibraryModelWizard_label = Library Model
+_UI_LibraryModelWizard_description = Create a new Library model
+ _UI_LibraryEditor_label = Library Model Editor
+ _UI_LibraryEditorFilenameDefaultBase = My
+_UI_LibraryEditorFilenameExtensions = library
+ _UI_BooksModelWizard_label = Books Model
+_UI_BooksModelWizard_description = Create a new Books model
+ _UI_BooksEditor_label = Books Model Editor
+ _UI_BooksEditorFilenameDefaultBase = My
+_UI_BooksEditorFilenameExtensions = books
+ _UI_WritersModelWizard_label = Writers Model
+_UI_WritersModelWizard_description = Create a new Writers model
+ _UI_WritersEditor_label = Writers Model Editor
+ _UI_WritersEditorFilenameDefaultBase = My
+_UI_WritersEditorFilenameExtensions = writers
+ _UI_Wizard_label = New
+ _WARN_FilenameExtension = The file name must end in ''.{0}''
+_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
+ _UI_ModelObject = &Model Object
+_UI_XMLEncoding = &XML Encoding
+_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
+_UI_Wizard_initial_object_description = Select a model object to create
+ _UI_FileConflict_label = File Conflict
+_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?
+
+_UI_Book_isbn_feature = Isbn
diff --git a/plugins/org.eclipse.emf.compare.example.library/plugin.xml b/plugins/org.eclipse.emf.compare.example.library/plugin.xml
new file mode 100644
index 000000000..0d714bec3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/plugin.xml
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2011 Obeo.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Obeo - initial API and implementation
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.emf.compare.modelResolver">
+ <modelResolver
+ class="org.eclipse.emf.compare.logical.extension.ScopedModelResolver">
+ <contentType
+ value=
+ "org.eclipse.emf.compare.example.library.libraryContentType,
+ org.eclipse.emf.compare.example.library.bookContentType,
+ org.eclipse.emf.compare.example.library.writerContentType"/>
+ </modelResolver>
+ </extension>
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.emf.compare.example.library.writers.util.WritersResourceImpl"
+ class="org.eclipse.emf.compare.logical.adapter.EMFCompareAdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.emf.compare.example.library.library.util.LibraryResourceImpl"
+ class="org.eclipse.emf.compare.logical.adapter.EMFCompareAdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.emf.compare.example.library.books.util.BooksResourceImpl"
+ class="org.eclipse.emf.compare.logical.adapter.EMFCompareAdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ </factory>
+ </extension>
+
+<!-- GENERATED BY EMF -->
+ <extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
+ <factory
+ uri="http://www.eclipse.org/emf/compare/library"
+ class="org.eclipse.emf.compare.example.library.library.provider.LibraryItemProviderAdapterFactory"
+ supportedTypes=
+ "org.eclipse.emf.edit.provider.IEditingDomainItemProvider
+ org.eclipse.emf.edit.provider.IStructuredItemContentProvider
+ org.eclipse.emf.edit.provider.ITreeItemContentProvider
+ org.eclipse.emf.edit.provider.IItemLabelProvider
+ org.eclipse.emf.edit.provider.IItemPropertySource"/>
+ <factory
+ uri="http://www.eclipse.org/emf/compare/books"
+ class="org.eclipse.emf.compare.example.library.books.provider.BooksItemProviderAdapterFactory"
+ supportedTypes=
+ "org.eclipse.emf.edit.provider.IEditingDomainItemProvider
+ org.eclipse.emf.edit.provider.IStructuredItemContentProvider
+ org.eclipse.emf.edit.provider.ITreeItemContentProvider
+ org.eclipse.emf.edit.provider.IItemLabelProvider
+ org.eclipse.emf.edit.provider.IItemPropertySource"/>
+ <factory
+ uri="http://www.eclipse.org/emf/compare/writers"
+ class="org.eclipse.emf.compare.example.library.writers.provider.WritersItemProviderAdapterFactory"
+ supportedTypes=
+ "org.eclipse.emf.edit.provider.IEditingDomainItemProvider
+ org.eclipse.emf.edit.provider.IStructuredItemContentProvider
+ org.eclipse.emf.edit.provider.ITreeItemContentProvider
+ org.eclipse.emf.edit.provider.IItemLabelProvider
+ org.eclipse.emf.edit.provider.IItemPropertySource"/>
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri="http://www.eclipse.org/emf/compare/library"
+ class="org.eclipse.emf.compare.example.library.library.LibraryPackage"
+ genModel="model/library.genmodel"/>
+ <package
+ uri="http://www.eclipse.org/emf/compare/books"
+ class="org.eclipse.emf.compare.example.library.books.BooksPackage"
+ genModel="model/library.genmodel"/>
+ <package
+ uri="http://www.eclipse.org/emf/compare/writers"
+ class="org.eclipse.emf.compare.example.library.writers.WritersPackage"
+ genModel="model/library.genmodel"/>
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.content_parser">
+ <parser
+ contentTypeIdentifier="org.eclipse.emf.compare.example.library.libraryContentType"
+ class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"/>
+ <parser
+ contentTypeIdentifier="org.eclipse.emf.compare.example.library.bookContentType"
+ class="org.eclipse.emf.compare.example.library.books.util.BooksResourceFactoryImpl"/>
+ <parser
+ contentTypeIdentifier="org.eclipse.emf.compare.example.library.writerContentType"
+ class="org.eclipse.emf.compare.example.library.writers.util.WritersResourceFactoryImpl"/>
+ </extension>
+
+ <extension point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.emf.ecore.xmi"
+ file-extensions="library"
+ id="org.eclipse.emf.compare.example.library.libraryContentType"
+ name="%_UI_Library_content_type"
+ priority="normal">
+ <describer class="org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Describer">
+ <parameter name="namespace" value="http://www.eclipse.org/emf/compare/library"/>
+ <parameter name="kind" value="xmi"/>
+ </describer>
+ </content-type>
+ <content-type
+ base-type="org.eclipse.emf.ecore.xmi"
+ file-extensions="books"
+ id="org.eclipse.emf.compare.example.library.bookContentType"
+ name="%_UI_Books_content_type"
+ priority="normal">
+ <describer class="org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Describer">
+ <parameter name="namespace" value="http://www.eclipse.org/emf/compare/books"/>
+ <parameter name="kind" value="xmi"/>
+ </describer>
+ </content-type>
+ <content-type
+ base-type="org.eclipse.emf.ecore.xmi"
+ file-extensions="writers"
+ id="org.eclipse.emf.compare.example.library.writerContentType"
+ name="%_UI_Writers_content_type"
+ priority="normal">
+ <describer class="org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Describer">
+ <parameter name="namespace" value="http://www.eclipse.org/emf/compare/writers"/>
+ <parameter name="kind" value="xmi"/>
+ </describer>
+ </content-type>
+ </extension>
+
+ <extension point="org.eclipse.ui.newWizards">
+ <category
+ id="org.eclipse.emf.ecore.Wizard.category.ID"
+ name="%_UI_Wizard_category"/>
+ <wizard
+ id="org.eclipse.emf.compare.example.library.library.presentation.LibraryModelWizardID"
+ name="%_UI_LibraryModelWizard_label"
+ class="org.eclipse.emf.compare.example.library.library.presentation.LibraryModelWizard"
+ category="org.eclipse.emf.ecore.Wizard.category.ID"
+ icon="icons/full/obj16/LibraryModelFile.gif">
+ <description>%_UI_LibraryModelWizard_description</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ <wizard
+ id="org.eclipse.emf.compare.example.library.books.presentation.BooksModelWizardID"
+ name="%_UI_BooksModelWizard_label"
+ class="org.eclipse.emf.compare.example.library.books.presentation.BooksModelWizard"
+ category="org.eclipse.emf.ecore.Wizard.category.ID"
+ icon="icons/full/obj16/BooksModelFile.gif">
+ <description>%_UI_BooksModelWizard_description</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ <wizard
+ id="org.eclipse.emf.compare.example.library.writers.presentation.WritersModelWizardID"
+ name="%_UI_WritersModelWizard_label"
+ class="org.eclipse.emf.compare.example.library.writers.presentation.WritersModelWizard"
+ category="org.eclipse.emf.ecore.Wizard.category.ID"
+ icon="icons/full/obj16/WritersModelFile.gif">
+ <description>%_UI_WritersModelWizard_description</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ id="org.eclipse.emf.compare.example.library.library.presentation.LibraryEditorID"
+ name="%_UI_LibraryEditor_label"
+ icon="icons/full/obj16/LibraryModelFile.gif"
+ class="org.eclipse.emf.compare.example.library.library.presentation.LibraryEditor"
+ contributorClass="org.eclipse.emf.compare.example.library.library.presentation.LibraryActionBarContributor">
+ <contentTypeBinding contentTypeId="org.eclipse.emf.compare.example.library.libraryContentType"/>
+ </editor>
+ <editor
+ id="org.eclipse.emf.compare.example.library.books.presentation.BooksEditorID"
+ name="%_UI_BooksEditor_label"
+ icon="icons/full/obj16/BooksModelFile.gif"
+ class="org.eclipse.emf.compare.example.library.books.presentation.BooksEditor"
+ contributorClass="org.eclipse.emf.compare.example.library.books.presentation.BooksActionBarContributor">
+ <contentTypeBinding contentTypeId="org.eclipse.emf.compare.example.library.bookContentType"/>
+ </editor>
+ <editor
+ id="org.eclipse.emf.compare.example.library.writers.presentation.WritersEditorID"
+ name="%_UI_WritersEditor_label"
+ icon="icons/full/obj16/WritersModelFile.gif"
+ class="org.eclipse.emf.compare.example.library.writers.presentation.WritersEditor"
+ contributorClass="org.eclipse.emf.compare.example.library.writers.presentation.WritersActionBarContributor">
+ <contentTypeBinding contentTypeId="org.eclipse.emf.compare.example.library.writerContentType"/>
+ </editor>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Book.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Book.java
new file mode 100644
index 000000000..5b3b6ae25
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Book.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.writers.Writer;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Book</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.Book#getIsbn <em>Isbn</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.Book#getTitle <em>Title</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.Book#getPages <em>Pages</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.Book#getAuthors <em>Authors</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getBook()
+ * @model
+ * @generated
+ */
+public interface Book extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Isbn</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Isbn</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Isbn</em>' attribute.
+ * @see #setIsbn(String)
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getBook_Isbn()
+ * @model id="true" required="true"
+ * @generated
+ */
+ String getIsbn();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.books.Book#getIsbn <em>Isbn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Isbn</em>' attribute.
+ * @see #getIsbn()
+ * @generated
+ */
+ void setIsbn(String value);
+
+ /**
+ * Returns the value of the '<em><b>Title</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Title</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Title</em>' attribute.
+ * @see #setTitle(String)
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getBook_Title()
+ * @model required="true"
+ * @generated
+ */
+ String getTitle();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.books.Book#getTitle <em>Title</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Title</em>' attribute.
+ * @see #getTitle()
+ * @generated
+ */
+ void setTitle(String value);
+
+ /**
+ * Returns the value of the '<em><b>Pages</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Pages</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Pages</em>' attribute.
+ * @see #setPages(int)
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getBook_Pages()
+ * @model
+ * @generated
+ */
+ int getPages();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.books.Book#getPages <em>Pages</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Pages</em>' attribute.
+ * @see #getPages()
+ * @generated
+ */
+ void setPages(int value);
+
+ /**
+ * Returns the value of the '<em><b>Authors</b></em>' reference list.
+ * The list contents are of type {@link org.eclipse.emf.compare.example.library.writers.Writer}.
+ * It is bidirectional and its opposite is '{@link org.eclipse.emf.compare.example.library.writers.Writer#getBooks <em>Books</em>}'.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Authors</em>' reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Authors</em>' reference list.
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getBook_Authors()
+ * @see org.eclipse.emf.compare.example.library.writers.Writer#getBooks
+ * @model opposite="books"
+ * @generated
+ */
+ EList<Writer> getAuthors();
+
+} // Book
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksFactory.java
new file mode 100644
index 000000000..a0fe450e5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksFactory.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage
+ * @generated
+ */
+public interface BooksFactory extends EFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ BooksFactory eINSTANCE = org.eclipse.emf.compare.example.library.books.impl.BooksFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Catalog</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Catalog</em>'.
+ * @generated
+ */
+ Catalog createCatalog();
+
+ /**
+ * Returns a new object of class '<em>Book</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Book</em>'.
+ * @generated
+ */
+ Book createBook();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ BooksPackage getBooksPackage();
+
+} //BooksFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksPackage.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksPackage.java
new file mode 100644
index 000000000..ea2595207
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/BooksPackage.java
@@ -0,0 +1,323 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.BooksFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface BooksPackage extends EPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "books"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/emf/compare/books"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "books"; //$NON-NLS-1$
+
+ /**
+ * The package content type ID.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eCONTENT_TYPE = "org.eclipse.emf.compare.example.library.bookContentType"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ BooksPackage eINSTANCE = org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.books.impl.CatalogImpl <em>Catalog</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.impl.CatalogImpl
+ * @see org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl#getCatalog()
+ * @generated
+ */
+ int CATALOG = 0;
+
+ /**
+ * The feature id for the '<em><b>Books</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CATALOG__BOOKS = 0;
+
+ /**
+ * The number of structural features of the '<em>Catalog</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CATALOG_FEATURE_COUNT = 1;
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl <em>Book</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.impl.BookImpl
+ * @see org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl#getBook()
+ * @generated
+ */
+ int BOOK = 1;
+
+ /**
+ * The feature id for the '<em><b>Isbn</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK__ISBN = 0;
+
+ /**
+ * The feature id for the '<em><b>Title</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK__TITLE = 1;
+
+ /**
+ * The feature id for the '<em><b>Pages</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK__PAGES = 2;
+
+ /**
+ * The feature id for the '<em><b>Authors</b></em>' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK__AUTHORS = 3;
+
+ /**
+ * The number of structural features of the '<em>Book</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK_FEATURE_COUNT = 4;
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.books.Catalog <em>Catalog</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Catalog</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Catalog
+ * @generated
+ */
+ EClass getCatalog();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.emf.compare.example.library.books.Catalog#getBooks <em>Books</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Books</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Catalog#getBooks()
+ * @see #getCatalog()
+ * @generated
+ */
+ EReference getCatalog_Books();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.books.Book <em>Book</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Book</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Book
+ * @generated
+ */
+ EClass getBook();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.books.Book#getIsbn <em>Isbn</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Isbn</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Book#getIsbn()
+ * @see #getBook()
+ * @generated
+ */
+ EAttribute getBook_Isbn();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.books.Book#getTitle <em>Title</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Title</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Book#getTitle()
+ * @see #getBook()
+ * @generated
+ */
+ EAttribute getBook_Title();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.books.Book#getPages <em>Pages</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Pages</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Book#getPages()
+ * @see #getBook()
+ * @generated
+ */
+ EAttribute getBook_Pages();
+
+ /**
+ * Returns the meta object for the reference list '{@link org.eclipse.emf.compare.example.library.books.Book#getAuthors <em>Authors</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference list '<em>Authors</em>'.
+ * @see org.eclipse.emf.compare.example.library.books.Book#getAuthors()
+ * @see #getBook()
+ * @generated
+ */
+ EReference getBook_Authors();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ BooksFactory getBooksFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.books.impl.CatalogImpl <em>Catalog</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.impl.CatalogImpl
+ * @see org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl#getCatalog()
+ * @generated
+ */
+ EClass CATALOG = eINSTANCE.getCatalog();
+
+ /**
+ * The meta object literal for the '<em><b>Books</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference CATALOG__BOOKS = eINSTANCE.getCatalog_Books();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl <em>Book</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.impl.BookImpl
+ * @see org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl#getBook()
+ * @generated
+ */
+ EClass BOOK = eINSTANCE.getBook();
+
+ /**
+ * The meta object literal for the '<em><b>Isbn</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute BOOK__ISBN = eINSTANCE.getBook_Isbn();
+
+ /**
+ * The meta object literal for the '<em><b>Title</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute BOOK__TITLE = eINSTANCE.getBook_Title();
+
+ /**
+ * The meta object literal for the '<em><b>Pages</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute BOOK__PAGES = eINSTANCE.getBook_Pages();
+
+ /**
+ * The meta object literal for the '<em><b>Authors</b></em>' reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference BOOK__AUTHORS = eINSTANCE.getBook_Authors();
+
+ }
+
+} //BooksPackage
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Catalog.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Catalog.java
new file mode 100644
index 000000000..feb40d037
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/Catalog.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Catalog</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.Catalog#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getCatalog()
+ * @model
+ * @generated
+ */
+public interface Catalog extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Books</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.emf.compare.example.library.books.Book}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Books</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Books</em>' containment reference list.
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#getCatalog_Books()
+ * @model containment="true"
+ * @generated
+ */
+ EList<Book> getBooks();
+
+} // Catalog
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BookImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BookImpl.java
new file mode 100644
index 000000000..a882e905c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BookImpl.java
@@ -0,0 +1,365 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+
+import org.eclipse.emf.compare.example.library.writers.Writer;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Book</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl#getIsbn <em>Isbn</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl#getTitle <em>Title</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl#getPages <em>Pages</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.impl.BookImpl#getAuthors <em>Authors</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class BookImpl extends EObjectImpl implements Book {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The default value of the '{@link #getIsbn() <em>Isbn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIsbn()
+ * @generated
+ * @ordered
+ */
+ protected static final String ISBN_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getIsbn() <em>Isbn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIsbn()
+ * @generated
+ * @ordered
+ */
+ protected String isbn = ISBN_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getTitle() <em>Title</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected static final String TITLE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getTitle() <em>Title</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected String title = TITLE_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getPages() <em>Pages</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getPages()
+ * @generated
+ * @ordered
+ */
+ protected static final int PAGES_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getPages() <em>Pages</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getPages()
+ * @generated
+ * @ordered
+ */
+ protected int pages = PAGES_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getAuthors() <em>Authors</em>}' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAuthors()
+ * @generated
+ * @ordered
+ */
+ protected EList<Writer> authors;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BookImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return BooksPackage.Literals.BOOK;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getIsbn() {
+ return isbn;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setIsbn(String newIsbn) {
+ String oldIsbn = isbn;
+ isbn = newIsbn;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, BooksPackage.BOOK__ISBN, oldIsbn, isbn));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setTitle(String newTitle) {
+ String oldTitle = title;
+ title = newTitle;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, BooksPackage.BOOK__TITLE, oldTitle, title));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getPages() {
+ return pages;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setPages(int newPages) {
+ int oldPages = pages;
+ pages = newPages;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, BooksPackage.BOOK__PAGES, oldPages, pages));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<Writer> getAuthors() {
+ if (authors == null) {
+ authors = new EObjectWithInverseResolvingEList.ManyInverse<Writer>(Writer.class, this,
+ BooksPackage.BOOK__AUTHORS, WritersPackage.WRITER__BOOKS);
+ }
+ return authors;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case BooksPackage.BOOK__AUTHORS:
+ return ((InternalEList<InternalEObject>)(InternalEList<?>)getAuthors()).basicAdd(otherEnd,
+ msgs);
+ }
+ return super.eInverseAdd(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case BooksPackage.BOOK__AUTHORS:
+ return ((InternalEList<?>)getAuthors()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case BooksPackage.BOOK__ISBN:
+ return getIsbn();
+ case BooksPackage.BOOK__TITLE:
+ return getTitle();
+ case BooksPackage.BOOK__PAGES:
+ return getPages();
+ case BooksPackage.BOOK__AUTHORS:
+ return getAuthors();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case BooksPackage.BOOK__ISBN:
+ setIsbn((String)newValue);
+ return;
+ case BooksPackage.BOOK__TITLE:
+ setTitle((String)newValue);
+ return;
+ case BooksPackage.BOOK__PAGES:
+ setPages((Integer)newValue);
+ return;
+ case BooksPackage.BOOK__AUTHORS:
+ getAuthors().clear();
+ getAuthors().addAll((Collection<? extends Writer>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case BooksPackage.BOOK__ISBN:
+ setIsbn(ISBN_EDEFAULT);
+ return;
+ case BooksPackage.BOOK__TITLE:
+ setTitle(TITLE_EDEFAULT);
+ return;
+ case BooksPackage.BOOK__PAGES:
+ setPages(PAGES_EDEFAULT);
+ return;
+ case BooksPackage.BOOK__AUTHORS:
+ getAuthors().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case BooksPackage.BOOK__ISBN:
+ return ISBN_EDEFAULT == null ? isbn != null : !ISBN_EDEFAULT.equals(isbn);
+ case BooksPackage.BOOK__TITLE:
+ return TITLE_EDEFAULT == null ? title != null : !TITLE_EDEFAULT.equals(title);
+ case BooksPackage.BOOK__PAGES:
+ return pages != PAGES_EDEFAULT;
+ case BooksPackage.BOOK__AUTHORS:
+ return authors != null && !authors.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy())
+ return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (isbn: "); //$NON-NLS-1$
+ result.append(isbn);
+ result.append(", title: "); //$NON-NLS-1$
+ result.append(title);
+ result.append(", pages: "); //$NON-NLS-1$
+ result.append(pages);
+ result.append(')');
+ return result.toString();
+ }
+
+} //BookImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksFactoryImpl.java
new file mode 100644
index 000000000..4b6fe310d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksFactoryImpl.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.impl;
+
+import org.eclipse.emf.compare.example.library.books.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksFactoryImpl extends EFactoryImpl implements BooksFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static BooksFactory init() {
+ try {
+ BooksFactory theBooksFactory = (BooksFactory)EPackage.Registry.INSTANCE
+ .getEFactory("http://www.eclipse.org/emf/compare/books"); //$NON-NLS-1$
+ if (theBooksFactory != null) {
+ return theBooksFactory;
+ }
+ } catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new BooksFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case BooksPackage.CATALOG:
+ return createCatalog();
+ case BooksPackage.BOOK:
+ return createBook();
+ default:
+ throw new IllegalArgumentException(
+ "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Catalog createCatalog() {
+ CatalogImpl catalog = new CatalogImpl();
+ return catalog;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Book createBook() {
+ BookImpl book = new BookImpl();
+ return book;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksPackage getBooksPackage() {
+ return (BooksPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static BooksPackage getPackage() {
+ return BooksPackage.eINSTANCE;
+ }
+
+} //BooksFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksPackageImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksPackageImpl.java
new file mode 100644
index 000000000..8028a6e60
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/BooksPackageImpl.java
@@ -0,0 +1,303 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.impl;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+import org.eclipse.emf.compare.example.library.books.BooksFactory;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+import org.eclipse.emf.compare.example.library.books.Catalog;
+
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl;
+
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksPackageImpl extends EPackageImpl implements BooksPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass catalogEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass bookEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private BooksPackageImpl() {
+ super(eNS_URI, BooksFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link BooksPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static BooksPackage init() {
+ if (isInited)
+ return (BooksPackage)EPackage.Registry.INSTANCE.getEPackage(BooksPackage.eNS_URI);
+
+ // Obtain or create and register package
+ BooksPackageImpl theBooksPackage = (BooksPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof BooksPackageImpl ? EPackage.Registry.INSTANCE
+ .get(eNS_URI) : new BooksPackageImpl());
+
+ isInited = true;
+
+ // Obtain or create and register interdependencies
+ LibraryPackageImpl theLibraryPackage = (LibraryPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(LibraryPackage.eNS_URI) instanceof LibraryPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(LibraryPackage.eNS_URI) : LibraryPackage.eINSTANCE);
+ WritersPackageImpl theWritersPackage = (WritersPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(WritersPackage.eNS_URI) instanceof WritersPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(WritersPackage.eNS_URI) : WritersPackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theBooksPackage.createPackageContents();
+ theLibraryPackage.createPackageContents();
+ theWritersPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theBooksPackage.initializePackageContents();
+ theLibraryPackage.initializePackageContents();
+ theWritersPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theBooksPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(BooksPackage.eNS_URI, theBooksPackage);
+ return theBooksPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getCatalog() {
+ return catalogEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getCatalog_Books() {
+ return (EReference)catalogEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getBook() {
+ return bookEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getBook_Isbn() {
+ return (EAttribute)bookEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getBook_Title() {
+ return (EAttribute)bookEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getBook_Pages() {
+ return (EAttribute)bookEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getBook_Authors() {
+ return (EReference)bookEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksFactory getBooksFactory() {
+ return (BooksFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated)
+ return;
+ isCreated = true;
+
+ // Create classes and their features
+ catalogEClass = createEClass(CATALOG);
+ createEReference(catalogEClass, CATALOG__BOOKS);
+
+ bookEClass = createEClass(BOOK);
+ createEAttribute(bookEClass, BOOK__ISBN);
+ createEAttribute(bookEClass, BOOK__TITLE);
+ createEAttribute(bookEClass, BOOK__PAGES);
+ createEReference(bookEClass, BOOK__AUTHORS);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized)
+ return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ WritersPackage theWritersPackage = (WritersPackage)EPackage.Registry.INSTANCE
+ .getEPackage(WritersPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(catalogEClass, Catalog.class,
+ "Catalog", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(
+ getCatalog_Books(),
+ this.getBook(),
+ null,
+ "books", null, 0, -1, Catalog.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ initEClass(bookEClass, Book.class, "Book", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEAttribute(
+ getBook_Isbn(),
+ ecorePackage.getEString(),
+ "isbn", null, 1, 1, Book.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getBook_Title(),
+ ecorePackage.getEString(),
+ "title", null, 1, 1, Book.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getBook_Pages(),
+ ecorePackage.getEInt(),
+ "pages", null, 0, 1, Book.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getBook_Authors(),
+ theWritersPackage.getWriter(),
+ theWritersPackage.getWriter_Books(),
+ "authors", null, 0, -1, Book.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //BooksPackageImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/CatalogImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/CatalogImpl.java
new file mode 100644
index 000000000..d94d025d3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/impl/CatalogImpl.java
@@ -0,0 +1,167 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+import org.eclipse.emf.compare.example.library.books.Catalog;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Catalog</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.books.impl.CatalogImpl#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class CatalogImpl extends EObjectImpl implements Catalog {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached value of the '{@link #getBooks() <em>Books</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBooks()
+ * @generated
+ * @ordered
+ */
+ protected EList<Book> books;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CatalogImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return BooksPackage.Literals.CATALOG;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<Book> getBooks() {
+ if (books == null) {
+ books = new EObjectContainmentEList<Book>(Book.class, this, BooksPackage.CATALOG__BOOKS);
+ }
+ return books;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case BooksPackage.CATALOG__BOOKS:
+ return ((InternalEList<?>)getBooks()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case BooksPackage.CATALOG__BOOKS:
+ return getBooks();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case BooksPackage.CATALOG__BOOKS:
+ getBooks().clear();
+ getBooks().addAll((Collection<? extends Book>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case BooksPackage.CATALOG__BOOKS:
+ getBooks().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case BooksPackage.CATALOG__BOOKS:
+ return books != null && !books.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //CatalogImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksActionBarContributor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksActionBarContributor.java
new file mode 100644
index 000000000..f777fe1a3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksActionBarContributor.java
@@ -0,0 +1,441 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.SubContributionItem;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Books model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the active editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IEditorPart activeEditorPart;
+
+ /**
+ * This keeps track of the current selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionProvider selectionProvider;
+
+ /**
+ * This action opens the Properties view.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction showPropertiesViewAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction refreshViewerAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
+
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.refresh();
+ }
+ }
+ }
+ };
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createChildActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateChild actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createSiblingActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createSiblingMenuManager;
+
+ /**
+ * This creates an instance of the contributor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksActionBarContributor() {
+ super(ADDITIONS_LAST_STYLE);
+ loadResourceAction = new LoadResourceAction();
+ validateAction = new ValidateAction();
+ controlAction = new ControlAction();
+ }
+
+ /**
+ * This adds Separators for editor additions to the tool bar.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(new Separator("books-settings")); //$NON-NLS-1$
+ toolBarManager.add(new Separator("books-additions")); //$NON-NLS-1$
+ }
+
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ IMenuManager submenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_BooksEditor_menu"), "org.eclipse.emf.compare.example.library.booksMenuID"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("additions", submenuManager); //$NON-NLS-1$
+ submenuManager.add(new Separator("settings")); //$NON-NLS-1$
+ submenuManager.add(new Separator("actions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions-end")); //$NON-NLS-1$
+
+ // Prepare for CreateChild item addition or removal.
+ //
+ createChildMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createChildMenuManager); //$NON-NLS-1$
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createSiblingMenuManager); //$NON-NLS-1$
+
+ // Force an update because Eclipse hides empty menus now.
+ //
+ submenuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
+
+ addGlobalActions(submenuManager);
+ }
+
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setActiveEditor(IEditorPart part) {
+ super.setActiveEditor(part);
+ activeEditorPart = part;
+
+ // Switch to the new selection provider.
+ //
+ if (selectionProvider != null) {
+ selectionProvider.removeSelectionChangedListener(this);
+ }
+ if (part == null) {
+ selectionProvider = null;
+ } else {
+ selectionProvider = part.getSite().getSelectionProvider();
+ selectionProvider.addSelectionChangedListener(this);
+
+ // Fake a selection changed event to update the menus.
+ //
+ if (selectionProvider.getSelection() != null) {
+ selectionChanged(new SelectionChangedEvent(selectionProvider,
+ selectionProvider.getSelection()));
+ }
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null) {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null) {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null) {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null) {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
+ String contributionID) {
+ if (actions != null) {
+ for (IAction action : actions) {
+ if (contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ } else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
+ if (actions != null) {
+ IContributionItem[] items = manager.getItems();
+ for (int i = 0; i < items.length; i++) {
+ // Look into SubContributionItems
+ //
+ IContributionItem contributionItem = items[i];
+ while (contributionItem instanceof SubContributionItem) {
+ contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+ }
+
+ // Delete the ActionContributionItems with matching action.
+ //
+ if (contributionItem instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem)contributionItem).getAction();
+ if (actions.contains(action)) {
+ manager.remove(contributionItem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This populates the pop-up menu before it appears.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ MenuManager submenuManager = null;
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createSiblingActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+ }
+
+ /**
+ * This inserts global actions before the "additions-end" separator.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
+
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ menuManager.insertAfter("ui-actions", refreshViewerAction); //$NON-NLS-1$
+
+ super.addGlobalActions(menuManager);
+ }
+
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksEditor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksEditor.java
new file mode 100644
index 000000000..046f51c8e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksEditor.java
@@ -0,0 +1,1799 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.presentation;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.custom.CTabFolder;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.swt.layout.FillLayout;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+
+import org.eclipse.ui.dialogs.SaveAsDialog;
+
+import org.eclipse.ui.ide.IGotoMarker;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.ViewerPane;
+
+import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+
+import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
+
+import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+
+import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+
+import org.eclipse.emf.compare.example.library.books.provider.BooksItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.library.provider.LibraryItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.compare.example.library.writers.provider.WritersItemProviderAdapterFactory;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * This is an example of a Books model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the editing domain that is used to track all changes to the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ /**
+ * This is the one adapter factory used for providing views of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory adapterFactory;
+
+ /**
+ * This is the content outline page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IContentOutlinePage contentOutlinePage;
+
+ /**
+ * This is a kludge...
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStatusLineManager contentOutlineStatusLineManager;
+
+ /**
+ * This is the content outline page's viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer contentOutlineViewer;
+
+ /**
+ * This is the property sheet page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PropertySheetPage propertySheetPage;
+
+ /**
+ * This is the viewer that shadows the selection in the content outline.
+ * The parent relation must be correctly defined for this to work.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer selectionViewer;
+
+ /**
+ * This inverts the roll of parent and child in the content provider and show parents as a tree.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer parentViewer;
+
+ /**
+ * This shows how a tree view works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewer;
+
+ /**
+ * This shows how a list view works.
+ * A list viewer doesn't support icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ListViewer listViewer;
+
+ /**
+ * This shows how a table view works.
+ * A table can be used as a list with icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TableViewer tableViewer;
+
+ /**
+ * This shows how a tree view with columns works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewerWithColumns;
+
+ /**
+ * This keeps track of the active viewer pane, in the book.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ViewerPane currentViewerPane;
+
+ /**
+ * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Viewer currentViewer;
+
+ /**
+ * This listens to which ever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionChangedListener selectionChangedListener;
+
+ /**
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+
+ /**
+ * This keeps track of the selection of the editor as a whole.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelection editorSelection = StructuredSelection.EMPTY;
+
+ /**
+ * The MarkerHelper is responsible for creating workspace resource markers presented
+ * in Eclipse's Problems View.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected MarkerHelper markerHelper = new EditUIMarkerHelper();
+
+ /**
+ * This listens for when the outline becomes active
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IPartListener partListener = new IPartListener() {
+ public void partActivated(IWorkbenchPart p) {
+ if (p instanceof ContentOutline) {
+ if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
+ getActionBarContributor().setActiveEditor(BooksEditor.this);
+
+ setCurrentViewer(contentOutlineViewer);
+ }
+ } else if (p instanceof PropertySheet) {
+ if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
+ getActionBarContributor().setActiveEditor(BooksEditor.this);
+ handleActivate();
+ }
+ } else if (p == BooksEditor.this) {
+ handleActivate();
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partClosed(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partDeactivated(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partOpened(IWorkbenchPart p) {
+ // Ignore.
+ }
+ };
+
+ /**
+ * Resources that have been removed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been changed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been saved.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> savedResources = new ArrayList<Resource>();
+
+ /**
+ * Map to store the diagnostic associated with a resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
+
+ /**
+ * Controls whether the problem indication should be updated.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean updateProblemIndication = true;
+
+ /**
+ * Adapter used to update the problem indication when resources are demanded loaded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EContentAdapter problemIndicationAdapter = new EContentAdapter() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof Resource) {
+ switch (notification.getFeatureID(Resource.class)) {
+ case Resource.RESOURCE__IS_LOADED:
+ case Resource.RESOURCE__ERRORS:
+ case Resource.RESOURCE__WARNINGS: {
+ Resource resource = (Resource)notification.getNotifier();
+ Diagnostic diagnostic = analyzeResourceProblems(resource, null);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, diagnostic);
+ } else {
+ resourceToDiagnosticMap.remove(resource);
+ }
+
+ if (updateProblemIndication) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+ break;
+ }
+ }
+ } else {
+ super.notifyChanged(notification);
+ }
+ }
+
+ @Override
+ protected void setTarget(Resource target) {
+ basicSetTarget(target);
+ }
+
+ @Override
+ protected void unsetTarget(Resource target) {
+ basicUnsetTarget(target);
+ }
+ };
+
+ /**
+ * This listens for workspace changes.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ protected ResourceSet resourceSet = editingDomain.getResourceSet();
+
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ public boolean visit(IResourceDelta delta) {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if (delta.getKind() == IResourceDelta.REMOVED
+ || delta.getKind() == IResourceDelta.CHANGED
+ && delta.getFlags() != IResourceDelta.MARKERS) {
+ Resource resource = resourceSet.getResource(
+ URI.createPlatformResourceURI(delta.getFullPath().toString(), true),
+ false);
+ if (resource != null) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ removedResources.add(resource);
+ } else if (!savedResources.remove(resource)) {
+ changedResources.add(resource);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
+
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
+ }
+ }
+
+ final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getPage().closeEditor(BooksEditor.this, false);
+ }
+ }
+ });
+ }
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == BooksEditor.this) {
+ handleActivate();
+ }
+ }
+ });
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * Handles activation of the editor or it's associated views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleActivate() {
+ // Recompute the read only state.
+ //
+ if (editingDomain.getResourceToReadOnlyMap() != null) {
+ editingDomain.getResourceToReadOnlyMap().clear();
+
+ // Refresh any actions that may become enabled or disabled.
+ //
+ setSelection(getSelection());
+ }
+
+ if (!removedResources.isEmpty()) {
+ if (handleDirtyConflict()) {
+ getSite().getPage().closeEditor(BooksEditor.this, false);
+ } else {
+ removedResources.clear();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ } else if (!changedResources.isEmpty()) {
+ changedResources.removeAll(savedResources);
+ handleChangedResources();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+
+ /**
+ * Handles what to do with changed resources on activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleChangedResources() {
+ if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
+ editingDomain.getCommandStack().flush();
+
+ updateProblemIndication = false;
+ for (Resource resource : changedResources) {
+ if (resource.isLoaded()) {
+ resource.unload();
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ } catch (IOException exception) {
+ if (!resourceToDiagnosticMap.containsKey(resource)) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ }
+ }
+ }
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+ }
+
+ /**
+ * Updates the problems indication with the information described in the specified diagnostic.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void updateProblemIndication() {
+ if (updateProblemIndication) {
+ BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, null, new Object[] {editingDomain.getResourceSet()});
+ for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
+ if (childDiagnostic.getSeverity() != Diagnostic.OK) {
+ diagnostic.add(childDiagnostic);
+ }
+ }
+
+ int lastEditorPage = getPageCount() - 1;
+ if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
+ ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ setActivePage(lastEditorPage);
+ }
+ } else if (diagnostic.getSeverity() != Diagnostic.OK) {
+ ProblemEditorPart problemEditorPart = new ProblemEditorPart();
+ problemEditorPart.setDiagnostic(diagnostic);
+ problemEditorPart.setMarkerHelper(markerHelper);
+ try {
+ addPage(++lastEditorPage, problemEditorPart, getEditorInput());
+ setPageText(lastEditorPage, problemEditorPart.getPartName());
+ setActivePage(lastEditorPage);
+ showTabs();
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
+ markerHelper.deleteMarkers(editingDomain.getResourceSet());
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ try {
+ markerHelper.createMarkers(diagnostic);
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Shows a dialog that asks if conflicting changes should be discarded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean handleDirtyConflict() {
+ return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), //$NON-NLS-1$
+ getString("_WARN_FileConflict")); //$NON-NLS-1$
+ }
+
+ /**
+ * This creates a model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * This sets up the editing domain for the model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new LibraryItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new BooksItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new WritersItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
+ propertySheetPage.refresh();
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack,
+ new HashMap<Resource, Boolean>());
+ }
+
+ /**
+ * This is here for the listener to be able to call it.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void firePropertyChange(int action) {
+ super.firePropertyChange(action);
+ }
+
+ /**
+ * This sets the selection into whichever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelectionToViewer(Collection<?> collection) {
+ final Collection<?> theSelection = collection;
+ // Make sure it's okay.
+ //
+ if (theSelection != null && !theSelection.isEmpty()) {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ // Try to select the items in the current content viewer of the editor.
+ //
+ if (currentViewer != null) {
+ currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
+ }
+ }
+ };
+ getSite().getShell().getDisplay().asyncExec(runnable);
+ }
+ }
+
+ /**
+ * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
+ * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
+ * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getElements(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getChildren(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ Object parent = super.getParent(object);
+ return parent != null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getParent(Object object) {
+ return null;
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewerPane(ViewerPane viewerPane) {
+ if (currentViewerPane != viewerPane) {
+ if (currentViewerPane != null) {
+ currentViewerPane.showFocus(false);
+ }
+ currentViewerPane = viewerPane;
+ }
+ setCurrentViewer(currentViewerPane.getViewer());
+ }
+
+ /**
+ * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
+ * is the current one.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewer(Viewer viewer) {
+ // If it is changing...
+ //
+ if (currentViewer != viewer) {
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener = new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+
+ // Stop listening to the old one.
+ //
+ if (currentViewer != null) {
+ currentViewer.removeSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Start listening to the new one.
+ //
+ if (viewer != null) {
+ viewer.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Remember it.
+ //
+ currentViewer = viewer;
+
+ // Set the editors selection based on the current viewer's selection.
+ //
+ setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
+ }
+ }
+
+ /**
+ * This returns the viewer as required by the {@link IViewerProvider} interface.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Viewer getViewer() {
+ return currentViewer;
+ }
+
+ /**
+ * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
+ contextMenu.add(new Separator("additions")); //$NON-NLS-1$
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu = contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance()};
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain,
+ viewer));
+ }
+
+ /**
+ * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createModel() {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Exception exception = null;
+ Resource resource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ resource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ } catch (Exception e) {
+ exception = e;
+ resource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+
+ Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
+ }
+
+ /**
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
+ if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
+ BasicDiagnostic basicDiagnostic = new BasicDiagnostic(Diagnostic.ERROR,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception == null ? (Object)resource : exception});
+ basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
+ return basicDiagnostic;
+ } else if (exception != null) {
+ return new BasicDiagnostic(Diagnostic.ERROR, "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception});
+ } else {
+ return Diagnostic.OK_INSTANCE;
+ }
+ }
+
+ /**
+ * This is the method used by the framework to install your own controls.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ // Create a page for the selection tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ selectionViewer = (TreeViewer)viewerPane.getViewer();
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet()
+ .getResources().get(0)), true);
+ viewerPane.setTitle(editingDomain.getResourceSet());
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ }
+
+ // Create a page for the parent tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ parentViewer = (TreeViewer)viewerPane.getViewer();
+ parentViewer.setAutoExpandLevel(30);
+ parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
+ parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(parentViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ParentPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the list viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new ListViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ listViewer = (ListViewer)viewerPane.getViewer();
+ listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(listViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ListPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the tree viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ treeViewer = (TreeViewer)viewerPane.getViewer();
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(treeViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TableViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ tableViewer = (TableViewer)viewerPane.getViewer();
+
+ Table table = tableViewer.getTable();
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn objectColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(3, 100, true));
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+
+ TableColumn selfColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(2, 100, true));
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+
+ tableViewer.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(tableViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TablePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table tree viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), BooksEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
+
+ Tree tree = treeViewerWithColumns.getTree();
+ tree.setLayoutData(new FillLayout());
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+ objectColumn.setWidth(250);
+
+ TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+ selfColumn.setWidth(200);
+
+ treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(treeViewerWithColumns);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); //$NON-NLS-1$
+ }
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ setActivePage(0);
+ }
+ });
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter() {
+ boolean guard = false;
+
+ @Override
+ public void controlResized(ControlEvent event) {
+ if (!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+
+ /**
+ * If there is just one page in the multi-page editor part,
+ * this hides the single tab at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void hideTabs() {
+ if (getPageCount() <= 1) {
+ setPageText(0, ""); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(1);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y + 6);
+ }
+ }
+ }
+
+ /**
+ * If there is more than one page in the multi-page editor part,
+ * this shows the tabs at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void showTabs() {
+ if (getPageCount() > 1) {
+ setPageText(0, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y - 6);
+ }
+ }
+ }
+
+ /**
+ * This is used to track the active viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void pageChange(int pageIndex) {
+ super.pageChange(pageIndex);
+
+ if (contentOutlinePage != null) {
+ handleContentOutlineSelection(contentOutlinePage.getSelection());
+ }
+ }
+
+ /**
+ * This is how the framework determines which interfaces we implement.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class key) {
+ if (key.equals(IContentOutlinePage.class)) {
+ return showOutlineView() ? getContentOutlinePage() : null;
+ } else if (key.equals(IPropertySheetPage.class)) {
+ return getPropertySheetPage();
+ } else if (key.equals(IGotoMarker.class)) {
+ return this;
+ } else {
+ return super.getAdapter(key);
+ }
+ }
+
+ /**
+ * This accesses a cached version of the content outliner.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IContentOutlinePage getContentOutlinePage() {
+ if (contentOutlinePage == null) {
+ // The content outline is just a tree.
+ //
+ class MyContentOutlinePage extends ContentOutlinePage {
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer
+ .setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ contentOutlineViewer.setInput(editingDomain.getResourceSet());
+
+ // Make sure our popups work.
+ //
+ createContextMenuFor(contentOutlineViewer);
+
+ if (!editingDomain.getResourceSet().getResources().isEmpty()) {
+ // Select the root object in the view.
+ //
+ contentOutlineViewer.setSelection(new StructuredSelection(editingDomain
+ .getResourceSet().getResources().get(0)), true);
+ }
+ }
+
+ @Override
+ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
+ IStatusLineManager statusLineManager) {
+ super.makeContributions(menuManager, toolBarManager, statusLineManager);
+ contentOutlineStatusLineManager = statusLineManager;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ }
+
+ contentOutlinePage = new MyContentOutlinePage();
+
+ // Listen to selection so that we can handle it is a special way.
+ //
+ contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ }
+
+ return contentOutlinePage;
+ }
+
+ /**
+ * This accesses a cached version of the property sheet.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertySheetPage == null) {
+ propertySheetPage = new ExtendedPropertySheetPage(editingDomain) {
+ @Override
+ public void setSelectionToViewer(List<?> selection) {
+ BooksEditor.this.setSelectionToViewer(selection);
+ BooksEditor.this.setFocus();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ };
+ propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+ }
+
+ return propertySheetPage;
+ }
+
+ /**
+ * This deals with how we want selection in the outliner to affect the other views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void handleContentOutlineSelection(ISelection selection) {
+ if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
+ if (selectedElements.hasNext()) {
+ // Get the first selected element.
+ //
+ Object selectedElement = selectedElements.next();
+
+ // If it's the selection viewer, then we want it to select the same selection as this selection.
+ //
+ if (currentViewerPane.getViewer() == selectionViewer) {
+ ArrayList<Object> selectionList = new ArrayList<Object>();
+ selectionList.add(selectedElement);
+ while (selectedElements.hasNext()) {
+ selectionList.add(selectedElements.next());
+ }
+
+ // Set the selection to the widget.
+ //
+ selectionViewer.setSelection(new StructuredSelection(selectionList));
+ } else {
+ // Set the input to the widget.
+ //
+ if (currentViewerPane.getViewer().getInput() != selectedElement) {
+ currentViewerPane.getViewer().setInput(selectedElement);
+ currentViewerPane.setTitle(selectedElement);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply tests the command stack.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+ Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+
+ // Do the work within an operation because this is a long running activity that modifies the workbench.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for (Resource resource : editingDomain.getResourceSet().getResources()) {
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
+ && !editingDomain.isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ } catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ } catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+
+ /**
+ * This returns whether something has been persisted to the URI of the specified resource.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean isPersisted(Resource resource) {
+ boolean result = false;
+ try {
+ InputStream stream = editingDomain.getResourceSet().getURIConverter()
+ .createInputStream(resource.getURI());
+ if (stream != null) {
+ result = true;
+ stream.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ return result;
+ }
+
+ /**
+ * This always returns true because it is not currently supported.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * This also changes the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSaveAs() {
+ SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
+ saveAsDialog.open();
+ IPath path = saveAsDialog.getResult();
+ if (path != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true),
+ new FileEditorInput(file));
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void doSaveAs(URI uri, IEditorInput editorInput) {
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
+ .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
+ doSave(progressMonitor);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ try {
+ if (marker.getType().equals(EValidator.MARKER)) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+ EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
+ if (eObject != null) {
+ setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
+ }
+ }
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ /**
+ * This is called during startup.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) {
+ setSite(site);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ site.setSelectionProvider(this);
+ site.getPage().addPartListener(partListener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener,
+ IResourceChangeEvent.POST_CHANGE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setFocus() {
+ if (currentViewerPane != null) {
+ currentViewerPane.setFocus();
+ } else {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ISelection getSelection() {
+ return editorSelection;
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
+ * Calling this result will notify the listeners.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelection(ISelection selection) {
+ editorSelection = selection;
+
+ for (ISelectionChangedListener listener : selectionChangedListeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ setStatusLineManager(selection);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setStatusLineManager(ISelection selection) {
+ IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager
+ : getActionBars().getStatusLineManager();
+
+ if (statusLineManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> collection = ((IStructuredSelection)selection).toList();
+ switch (collection.size()) {
+ case 0: {
+ statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
+ break;
+ }
+ case 1: {
+ String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection
+ .iterator().next());
+ statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); //$NON-NLS-1$
+ break;
+ }
+ default: {
+ statusLineManager.setMessage(getString(
+ "_UI_MultiObjectSelected", Integer.toString(collection.size()))); //$NON-NLS-1$
+ break;
+ }
+ }
+ } else {
+ statusLineManager.setMessage(""); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key) {
+ return LibraryEditPlugin.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1) {
+ return LibraryEditPlugin.INSTANCE.getString(key, new Object[] {s1});
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void menuAboutToShow(IMenuManager menuManager) {
+ ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomainActionBarContributor getActionBarContributor() {
+ return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IActionBars getActionBars() {
+ return getActionBarContributor().getActionBars();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public AdapterFactory getAdapterFactory() {
+ return adapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void dispose() {
+ updateProblemIndication = false;
+
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ getSite().getPage().removePartListener(partListener);
+
+ adapterFactory.dispose();
+
+ if (getActionBarContributor().getActiveEditor() == this) {
+ getActionBarContributor().setActiveEditor(null);
+ }
+
+ if (propertySheetPage != null) {
+ propertySheetPage.dispose();
+ }
+
+ if (contentOutlinePage != null) {
+ contentOutlinePage.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * Returns whether the outline view should be presented to the user.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean showOutlineView() {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksModelWizard.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksModelWizard.java
new file mode 100644
index 000000000..e8513dc62
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/presentation/BooksModelWizard.java
@@ -0,0 +1,649 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.presentation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.CommonPlugin;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+import org.eclipse.emf.compare.example.library.books.BooksFactory;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is a simple wizard for creating a new model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksModelWizard extends Wizard implements INewWizard {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS = Collections.unmodifiableList(Arrays
+ .asList(LibraryEditPlugin.INSTANCE
+ .getString("_UI_BooksEditorFilenameExtensions").split("\\s*,\\s*"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS = LibraryEditPlugin.INSTANCE.getString(
+ "_UI_BooksEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /**
+ * This caches an instance of the model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BooksPackage booksPackage = BooksPackage.eINSTANCE;
+
+ /**
+ * This caches an instance of the model factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BooksFactory booksFactory = booksPackage.getBooksFactory();
+
+ /**
+ * This is the file creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BooksModelWizardNewFileCreationPage newFileCreationPage;
+
+ /**
+ * This is the initial object creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BooksModelWizardInitialObjectCreationPage initialObjectCreationPage;
+
+ /**
+ * Remember the selection during initialization for populating the default container.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * Remember the workbench during initialization.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IWorkbench workbench;
+
+ /**
+ * Caches the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected List<String> initialObjectNames;
+
+ /**
+ * This just records the information.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(LibraryEditPlugin.INSTANCE.getString("_UI_Wizard_label")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE
+ .getImageDescriptor(LibraryEditPlugin.INSTANCE.getImage("full/wizban/NewBooks"))); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getInitialObjectNames() {
+ if (initialObjectNames == null) {
+ initialObjectNames = new ArrayList<String>();
+ for (EClassifier eClassifier : booksPackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract()) {
+ initialObjectNames.add(eClass.getName());
+ }
+ }
+ }
+ Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
+ }
+ return initialObjectNames;
+ }
+
+ /**
+ * Create a new model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EObject createInitialModel() {
+ EClass eClass = (EClass)booksPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
+ EObject rootObject = booksFactory.create(eClass);
+ return rootObject;
+ }
+
+ /**
+ * Do the work after everything is specified.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI, BooksPackage.eCONTENT_TYPE);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ resource.save(options);
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ } finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor(
+ new FileEditorInput(modelFile),
+ workbench
+ .getEditorRegistry()
+ .getDefaultEditor(
+ modelFile.getFullPath().toString(),
+ Platform.getContentTypeManager().getContentType(
+ BooksPackage.eCONTENT_TYPE)).getId());
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), LibraryEditPlugin.INSTANCE
+ .getString("_UI_OpenEditorError_label"), exception.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+
+ return true;
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ /**
+ * This is the one page of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class BooksModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
+ setErrorMessage(LibraryEditPlugin.INSTANCE.getString(key,
+ new Object[] {FORMATTED_FILE_EXTENSIONS}));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(getContainerFullPath().append(getFileName()));
+ }
+ }
+
+ /**
+ * This is the page where the type of object to create is selected.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class BooksModelWizardInitialObjectCreationPage extends WizardPage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo initialObjectField;
+
+ /**
+ * @generated
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ */
+ protected List<String> encodings;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo encodingField;
+
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksModelWizardInitialObjectCreationPage(String pageId) {
+ super(pageId);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 12;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ }
+
+ Label containerLabel = new Label(composite, SWT.LEFT);
+ {
+ containerLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_ModelObject")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ containerLabel.setLayoutData(data);
+ }
+
+ initialObjectField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ initialObjectField.setLayoutData(data);
+ }
+
+ for (String objectName : getInitialObjectNames()) {
+ initialObjectField.add(getLabel(objectName));
+ }
+
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.select(0);
+ }
+ initialObjectField.addModifyListener(validator);
+
+ Label encodingLabel = new Label(composite, SWT.LEFT);
+ {
+ encodingLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncoding")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ encodingLabel.setLayoutData(data);
+ }
+ encodingField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ encodingField.setLayoutData(data);
+ }
+
+ for (String encoding : getEncodings()) {
+ encodingField.add(encoding);
+ }
+
+ encodingField.select(0);
+ encodingField.addModifyListener(validator);
+
+ setPageComplete(validatePage());
+ setControl(composite);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ModifyListener validator = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ };
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean validatePage() {
+ return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.clearSelection();
+ encodingField.setFocus();
+ } else {
+ encodingField.clearSelection();
+ initialObjectField.setFocus();
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getInitialObjectName() {
+ String label = initialObjectField.getText();
+
+ for (String name : getInitialObjectNames()) {
+ if (getLabel(name).equals(label)) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getEncoding() {
+ return encodingField.getText();
+ }
+
+ /**
+ * Returns the label for the specified type name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected String getLabel(String typeName) {
+ try {
+ return LibraryEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (MissingResourceException mre) {
+ LibraryEditPlugin.INSTANCE.log(mre);
+ }
+ return typeName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getEncodings() {
+ if (encodings == null) {
+ encodings = new ArrayList<String>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(
+ LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens();) //$NON-NLS-1$
+ {
+ encodings.add(stringTokenizer.nextToken());
+ }
+ }
+ return encodings;
+ }
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ newFileCreationPage = new BooksModelWizardNewFileCreationPage("Whatever", selection); //$NON-NLS-1$
+ newFileCreationPage.setTitle(LibraryEditPlugin.INSTANCE.getString("_UI_BooksModelWizard_label")); //$NON-NLS-1$
+ newFileCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_BooksModelWizard_description")); //$NON-NLS-1$
+ newFileCreationPage.setFileName(LibraryEditPlugin.INSTANCE
+ .getString("_UI_BooksEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ addPage(newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = LibraryEditPlugin.INSTANCE
+ .getString("_UI_BooksEditorFilenameDefaultBase"); //$NON-NLS-1$
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ }
+ newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ initialObjectCreationPage = new BooksModelWizardInitialObjectCreationPage("Whatever2"); //$NON-NLS-1$
+ initialObjectCreationPage
+ .setTitle(LibraryEditPlugin.INSTANCE.getString("_UI_BooksModelWizard_label")); //$NON-NLS-1$
+ initialObjectCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_Wizard_initial_object_description")); //$NON-NLS-1$
+ addPage(initialObjectCreationPage);
+ }
+
+ /**
+ * Get the file from the page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return newFileCreationPage.getModelFile();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BookItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BookItemProvider.java
new file mode 100644
index 000000000..0ddd5c410
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BookItemProvider.java
@@ -0,0 +1,211 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.books.Book} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BookItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BookItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addIsbnPropertyDescriptor(object);
+ addTitlePropertyDescriptor(object);
+ addPagesPropertyDescriptor(object);
+ addAuthorsPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Isbn feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addIsbnPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Book_isbn_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Book_isbn_feature", "_UI_Book_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ BooksPackage.Literals.BOOK__ISBN, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Title feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addTitlePropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Book_title_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Book_title_feature", "_UI_Book_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ BooksPackage.Literals.BOOK__TITLE, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Pages feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addPagesPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Book_pages_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Book_pages_feature", "_UI_Book_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ BooksPackage.Literals.BOOK__PAGES, true, false, false,
+ ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Authors feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addAuthorsPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_Book_authors_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Book_authors_feature", "_UI_Book_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ BooksPackage.Literals.BOOK__AUTHORS, true, false, true, null, null, null));
+ }
+
+ /**
+ * This returns Book.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/Book")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ String label = ((Book)object).getTitle();
+ return label == null || label.length() == 0 ? getString("_UI_Book_type") : //$NON-NLS-1$
+ getString("_UI_Book_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(Book.class)) {
+ case BooksPackage.BOOK__ISBN:
+ case BooksPackage.BOOK__TITLE:
+ case BooksPackage.BOOK__PAGES:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false,
+ true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BooksItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BooksItemProviderAdapterFactory.java
new file mode 100644
index 000000000..1636ed336
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/BooksItemProviderAdapterFactory.java
@@ -0,0 +1,240 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.compare.example.library.books.util.BooksAdapterFactory;
+
+import org.eclipse.emf.edit.provider.ChangeNotifier;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.IDisposable;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+
+/**
+ * This is the factory that is used to provide the interfaces needed to support Viewers.
+ * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
+ * The adapters also support Eclipse property sheets.
+ * Note that most of the adapters are shared among multiple instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class BooksItemProviderAdapterFactory extends BooksAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the root adapter factory that delegates to this adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory parentAdapterFactory;
+
+ /**
+ * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IChangeNotifier changeNotifier = new ChangeNotifier();
+
+ /**
+ * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Object> supportedTypes = new ArrayList<Object>();
+
+ /**
+ * This constructs an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksItemProviderAdapterFactory() {
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ supportedTypes.add(IItemPropertySource.class);
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.books.Catalog} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CatalogItemProvider catalogItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.books.Catalog}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createCatalogAdapter() {
+ if (catalogItemProvider == null) {
+ catalogItemProvider = new CatalogItemProvider(this);
+ }
+
+ return catalogItemProvider;
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.books.Book} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BookItemProvider bookItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.books.Book}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createBookAdapter() {
+ if (bookItemProvider == null) {
+ bookItemProvider = new BookItemProvider(this);
+ }
+
+ return bookItemProvider;
+ }
+
+ /**
+ * This returns the root adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ComposeableAdapterFactory getRootAdapterFactory() {
+ return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
+ }
+
+ /**
+ * This sets the composed adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
+ this.parentAdapterFactory = parentAdapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return supportedTypes.contains(type) || super.isFactoryForType(type);
+ }
+
+ /**
+ * This implementation substitutes the factory itself as the key for the adapter.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter adapt(Notifier notifier, Object type) {
+ return super.adapt(notifier, this);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object adapt(Object object, Object type) {
+ if (isFactoryForType(type)) {
+ Object adapter = super.adapt(object, type);
+ if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
+ return adapter;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This adds a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.addListener(notifyChangedListener);
+ }
+
+ /**
+ * This removes a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.removeListener(notifyChangedListener);
+ }
+
+ /**
+ * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void fireNotifyChanged(Notification notification) {
+ changeNotifier.fireNotifyChanged(notification);
+
+ if (parentAdapterFactory != null) {
+ parentAdapterFactory.fireNotifyChanged(notification);
+ }
+ }
+
+ /**
+ * This disposes all of the item providers created by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void dispose() {
+ if (catalogItemProvider != null)
+ catalogItemProvider.dispose();
+ if (bookItemProvider != null)
+ bookItemProvider.dispose();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/CatalogItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/CatalogItemProvider.java
new file mode 100644
index 000000000..05ba160db
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/provider/CatalogItemProvider.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.compare.example.library.books.BooksFactory;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+import org.eclipse.emf.compare.example.library.books.Catalog;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.books.Catalog} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class CatalogItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CatalogItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(BooksPackage.Literals.CATALOG__BOOKS);
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
+ * This returns Catalog.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/Catalog")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_Catalog_type"); //$NON-NLS-1$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(Catalog.class)) {
+ case BooksPackage.CATALOG__BOOKS:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true,
+ false));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add(createChildParameter(BooksPackage.Literals.CATALOG__BOOKS,
+ BooksFactory.eINSTANCE.createBook()));
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksAdapterFactory.java
new file mode 100644
index 000000000..ff8772234
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksAdapterFactory.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.compare.example.library.books.*;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage
+ * @generated
+ */
+public class BooksAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static BooksPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = BooksPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BooksSwitch<Adapter> modelSwitch = new BooksSwitch<Adapter>() {
+ @Override
+ public Adapter caseCatalog(Catalog object) {
+ return createCatalogAdapter();
+ }
+
+ @Override
+ public Adapter caseBook(Book object) {
+ return createBookAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.books.Catalog <em>Catalog</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.books.Catalog
+ * @generated
+ */
+ public Adapter createCatalogAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.books.Book <em>Book</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.books.Book
+ * @generated
+ */
+ public Adapter createBookAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //BooksAdapterFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceFactoryImpl.java
new file mode 100644
index 000000000..612c9b7d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceFactoryImpl.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource Factory</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.util.BooksResourceImpl
+ * @generated
+ */
+public class BooksResourceFactoryImpl extends ResourceFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksResourceFactoryImpl() {
+ super();
+ }
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Resource createResource(URI uri) {
+ Resource result = new BooksResourceImpl(uri);
+ return result;
+ }
+
+} //BooksResourceFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceImpl.java
new file mode 100644
index 000000000..58e058322
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksResourceImpl.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.util.BooksResourceFactoryImpl
+ * @generated
+ */
+public class BooksResourceImpl extends XMIResourceImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public BooksResourceImpl(URI uri) {
+ super(uri);
+ }
+
+} //BooksResourceImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksSwitch.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksSwitch.java
new file mode 100644
index 000000000..a82862fd8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/books/util/BooksSwitch.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.books.util;
+
+import org.eclipse.emf.compare.example.library.books.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.books.BooksPackage
+ * @generated
+ */
+public class BooksSwitch<T> extends Switch<T> {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static BooksPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BooksSwitch() {
+ if (modelPackage == null) {
+ modelPackage = BooksPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @parameter ePackage the package in question.
+ * @return whether this is a switch for the given package.
+ * @generated
+ */
+ @Override
+ protected boolean isSwitchFor(EPackage ePackage) {
+ return ePackage == modelPackage;
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case BooksPackage.CATALOG: {
+ Catalog catalog = (Catalog)theEObject;
+ T result = caseCatalog(catalog);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ case BooksPackage.BOOK: {
+ Book book = (Book)theEObject;
+ T result = caseBook(book);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Catalog</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Catalog</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseCatalog(Catalog object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Book</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Book</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseBook(Book object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //BooksSwitch
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/BookCopy.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/BookCopy.java
new file mode 100644
index 000000000..b88923d39
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/BookCopy.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Book Copy</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.BookCopy#getBook <em>Book</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.BookCopy#getCopies <em>Copies</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getBookCopy()
+ * @model
+ * @generated
+ */
+public interface BookCopy extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Book</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Book</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Book</em>' reference.
+ * @see #setBook(Book)
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getBookCopy_Book()
+ * @model
+ * @generated
+ */
+ Book getBook();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.library.BookCopy#getBook <em>Book</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Book</em>' reference.
+ * @see #getBook()
+ * @generated
+ */
+ void setBook(Book value);
+
+ /**
+ * Returns the value of the '<em><b>Copies</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Copies</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Copies</em>' attribute.
+ * @see #setCopies(int)
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getBookCopy_Copies()
+ * @model
+ * @generated
+ */
+ int getCopies();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.library.BookCopy#getCopies <em>Copies</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Copies</em>' attribute.
+ * @see #getCopies()
+ * @generated
+ */
+ void setCopies(int value);
+
+} // BookCopy
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/Library.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/Library.java
new file mode 100644
index 000000000..f8fd91c2f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/Library.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Library</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.Library#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.Library#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getLibrary()
+ * @model
+ * @generated
+ */
+public interface Library extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getLibrary_Name()
+ * @model required="true"
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.library.Library#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Books</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.emf.compare.example.library.library.BookCopy}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Books</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Books</em>' containment reference list.
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#getLibrary_Books()
+ * @model containment="true"
+ * @generated
+ */
+ EList<BookCopy> getBooks();
+
+} // Library
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryFactory.java
new file mode 100644
index 000000000..4a3ef918d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryFactory.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage
+ * @generated
+ */
+public interface LibraryFactory extends EFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ LibraryFactory eINSTANCE = org.eclipse.emf.compare.example.library.library.impl.LibraryFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Library</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Library</em>'.
+ * @generated
+ */
+ Library createLibrary();
+
+ /**
+ * Returns a new object of class '<em>Book Copy</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Book Copy</em>'.
+ * @generated
+ */
+ BookCopy createBookCopy();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ LibraryPackage getLibraryPackage();
+
+} //LibraryFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryPackage.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryPackage.java
new file mode 100644
index 000000000..75136a32e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/LibraryPackage.java
@@ -0,0 +1,295 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.LibraryFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface LibraryPackage extends EPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "library"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/emf/compare/library"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "library"; //$NON-NLS-1$
+
+ /**
+ * The package content type ID.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eCONTENT_TYPE = "org.eclipse.emf.compare.example.library.libraryContentType"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ LibraryPackage eINSTANCE = org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.library.impl.LibraryImpl <em>Library</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryImpl
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl#getLibrary()
+ * @generated
+ */
+ int LIBRARY = 0;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int LIBRARY__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>Books</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int LIBRARY__BOOKS = 1;
+
+ /**
+ * The number of structural features of the '<em>Library</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int LIBRARY_FEATURE_COUNT = 2;
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl <em>Book Copy</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl#getBookCopy()
+ * @generated
+ */
+ int BOOK_COPY = 1;
+
+ /**
+ * The feature id for the '<em><b>Book</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK_COPY__BOOK = 0;
+
+ /**
+ * The feature id for the '<em><b>Copies</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK_COPY__COPIES = 1;
+
+ /**
+ * The number of structural features of the '<em>Book Copy</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int BOOK_COPY_FEATURE_COUNT = 2;
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.library.Library <em>Library</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Library</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.Library
+ * @generated
+ */
+ EClass getLibrary();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.library.Library#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.Library#getName()
+ * @see #getLibrary()
+ * @generated
+ */
+ EAttribute getLibrary_Name();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.emf.compare.example.library.library.Library#getBooks <em>Books</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Books</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.Library#getBooks()
+ * @see #getLibrary()
+ * @generated
+ */
+ EReference getLibrary_Books();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.library.BookCopy <em>Book Copy</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Book Copy</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.BookCopy
+ * @generated
+ */
+ EClass getBookCopy();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.emf.compare.example.library.library.BookCopy#getBook <em>Book</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Book</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.BookCopy#getBook()
+ * @see #getBookCopy()
+ * @generated
+ */
+ EReference getBookCopy_Book();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.library.BookCopy#getCopies <em>Copies</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Copies</em>'.
+ * @see org.eclipse.emf.compare.example.library.library.BookCopy#getCopies()
+ * @see #getBookCopy()
+ * @generated
+ */
+ EAttribute getBookCopy_Copies();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ LibraryFactory getLibraryFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.library.impl.LibraryImpl <em>Library</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryImpl
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl#getLibrary()
+ * @generated
+ */
+ EClass LIBRARY = eINSTANCE.getLibrary();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute LIBRARY__NAME = eINSTANCE.getLibrary_Name();
+
+ /**
+ * The meta object literal for the '<em><b>Books</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference LIBRARY__BOOKS = eINSTANCE.getLibrary_Books();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl <em>Book Copy</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl
+ * @see org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl#getBookCopy()
+ * @generated
+ */
+ EClass BOOK_COPY = eINSTANCE.getBookCopy();
+
+ /**
+ * The meta object literal for the '<em><b>Book</b></em>' reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference BOOK_COPY__BOOK = eINSTANCE.getBookCopy_Book();
+
+ /**
+ * The meta object literal for the '<em><b>Copies</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute BOOK_COPY__COPIES = eINSTANCE.getBookCopy_Copies();
+
+ }
+
+} //LibraryPackage
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/BookCopyImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/BookCopyImpl.java
new file mode 100644
index 000000000..3b243e99b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/BookCopyImpl.java
@@ -0,0 +1,246 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+
+import org.eclipse.emf.compare.example.library.library.BookCopy;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Book Copy</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl#getBook <em>Book</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.impl.BookCopyImpl#getCopies <em>Copies</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class BookCopyImpl extends EObjectImpl implements BookCopy {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached value of the '{@link #getBook() <em>Book</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBook()
+ * @generated
+ * @ordered
+ */
+ protected Book book;
+
+ /**
+ * The default value of the '{@link #getCopies() <em>Copies</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCopies()
+ * @generated
+ * @ordered
+ */
+ protected static final int COPIES_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getCopies() <em>Copies</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCopies()
+ * @generated
+ * @ordered
+ */
+ protected int copies = COPIES_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BookCopyImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return LibraryPackage.Literals.BOOK_COPY;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Book getBook() {
+ if (book != null && book.eIsProxy()) {
+ InternalEObject oldBook = (InternalEObject)book;
+ book = (Book)eResolveProxy(oldBook);
+ if (book != oldBook) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, LibraryPackage.BOOK_COPY__BOOK,
+ oldBook, book));
+ }
+ }
+ return book;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Book basicGetBook() {
+ return book;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setBook(Book newBook) {
+ Book oldBook = book;
+ book = newBook;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, LibraryPackage.BOOK_COPY__BOOK, oldBook,
+ book));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getCopies() {
+ return copies;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCopies(int newCopies) {
+ int oldCopies = copies;
+ copies = newCopies;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, LibraryPackage.BOOK_COPY__COPIES,
+ oldCopies, copies));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case LibraryPackage.BOOK_COPY__BOOK:
+ if (resolve)
+ return getBook();
+ return basicGetBook();
+ case LibraryPackage.BOOK_COPY__COPIES:
+ return getCopies();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case LibraryPackage.BOOK_COPY__BOOK:
+ setBook((Book)newValue);
+ return;
+ case LibraryPackage.BOOK_COPY__COPIES:
+ setCopies((Integer)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case LibraryPackage.BOOK_COPY__BOOK:
+ setBook((Book)null);
+ return;
+ case LibraryPackage.BOOK_COPY__COPIES:
+ setCopies(COPIES_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case LibraryPackage.BOOK_COPY__BOOK:
+ return book != null;
+ case LibraryPackage.BOOK_COPY__COPIES:
+ return copies != COPIES_EDEFAULT;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy())
+ return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (copies: "); //$NON-NLS-1$
+ result.append(copies);
+ result.append(')');
+ return result.toString();
+ }
+
+} //BookCopyImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryFactoryImpl.java
new file mode 100644
index 000000000..6ab300719
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryFactoryImpl.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.impl;
+
+import org.eclipse.emf.compare.example.library.library.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryFactoryImpl extends EFactoryImpl implements LibraryFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static LibraryFactory init() {
+ try {
+ LibraryFactory theLibraryFactory = (LibraryFactory)EPackage.Registry.INSTANCE
+ .getEFactory("http://www.eclipse.org/emf/compare/library"); //$NON-NLS-1$
+ if (theLibraryFactory != null) {
+ return theLibraryFactory;
+ }
+ } catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new LibraryFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case LibraryPackage.LIBRARY:
+ return createLibrary();
+ case LibraryPackage.BOOK_COPY:
+ return createBookCopy();
+ default:
+ throw new IllegalArgumentException(
+ "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Library createLibrary() {
+ LibraryImpl library = new LibraryImpl();
+ return library;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BookCopy createBookCopy() {
+ BookCopyImpl bookCopy = new BookCopyImpl();
+ return bookCopy;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryPackage getLibraryPackage() {
+ return (LibraryPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static LibraryPackage getPackage() {
+ return LibraryPackage.eINSTANCE;
+ }
+
+} //LibraryFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryImpl.java
new file mode 100644
index 000000000..206b14213
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryImpl.java
@@ -0,0 +1,238 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.library.BookCopy;
+import org.eclipse.emf.compare.example.library.library.Library;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Library</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.impl.LibraryImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.library.impl.LibraryImpl#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class LibraryImpl extends EObjectImpl implements Library {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getBooks() <em>Books</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBooks()
+ * @generated
+ * @ordered
+ */
+ protected EList<BookCopy> books;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return LibraryPackage.Literals.LIBRARY;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, LibraryPackage.LIBRARY__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<BookCopy> getBooks() {
+ if (books == null) {
+ books = new EObjectContainmentEList<BookCopy>(BookCopy.class, this, LibraryPackage.LIBRARY__BOOKS);
+ }
+ return books;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case LibraryPackage.LIBRARY__BOOKS:
+ return ((InternalEList<?>)getBooks()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case LibraryPackage.LIBRARY__NAME:
+ return getName();
+ case LibraryPackage.LIBRARY__BOOKS:
+ return getBooks();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case LibraryPackage.LIBRARY__NAME:
+ setName((String)newValue);
+ return;
+ case LibraryPackage.LIBRARY__BOOKS:
+ getBooks().clear();
+ getBooks().addAll((Collection<? extends BookCopy>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case LibraryPackage.LIBRARY__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case LibraryPackage.LIBRARY__BOOKS:
+ getBooks().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case LibraryPackage.LIBRARY__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case LibraryPackage.LIBRARY__BOOKS:
+ return books != null && !books.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy())
+ return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: "); //$NON-NLS-1$
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+} //LibraryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryPackageImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryPackageImpl.java
new file mode 100644
index 000000000..c583c5ea5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/impl/LibraryPackageImpl.java
@@ -0,0 +1,290 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.impl;
+
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+
+import org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl;
+
+import org.eclipse.emf.compare.example.library.library.BookCopy;
+import org.eclipse.emf.compare.example.library.library.Library;
+import org.eclipse.emf.compare.example.library.library.LibraryFactory;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryPackageImpl extends EPackageImpl implements LibraryPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass libraryEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass bookCopyEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private LibraryPackageImpl() {
+ super(eNS_URI, LibraryFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link LibraryPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static LibraryPackage init() {
+ if (isInited)
+ return (LibraryPackage)EPackage.Registry.INSTANCE.getEPackage(LibraryPackage.eNS_URI);
+
+ // Obtain or create and register package
+ LibraryPackageImpl theLibraryPackage = (LibraryPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof LibraryPackageImpl ? EPackage.Registry.INSTANCE
+ .get(eNS_URI) : new LibraryPackageImpl());
+
+ isInited = true;
+
+ // Obtain or create and register interdependencies
+ BooksPackageImpl theBooksPackage = (BooksPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI) instanceof BooksPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI) : BooksPackage.eINSTANCE);
+ WritersPackageImpl theWritersPackage = (WritersPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(WritersPackage.eNS_URI) instanceof WritersPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(WritersPackage.eNS_URI) : WritersPackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theLibraryPackage.createPackageContents();
+ theBooksPackage.createPackageContents();
+ theWritersPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theLibraryPackage.initializePackageContents();
+ theBooksPackage.initializePackageContents();
+ theWritersPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theLibraryPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(LibraryPackage.eNS_URI, theLibraryPackage);
+ return theLibraryPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getLibrary() {
+ return libraryEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getLibrary_Name() {
+ return (EAttribute)libraryEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getLibrary_Books() {
+ return (EReference)libraryEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getBookCopy() {
+ return bookCopyEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getBookCopy_Book() {
+ return (EReference)bookCopyEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getBookCopy_Copies() {
+ return (EAttribute)bookCopyEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryFactory getLibraryFactory() {
+ return (LibraryFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated)
+ return;
+ isCreated = true;
+
+ // Create classes and their features
+ libraryEClass = createEClass(LIBRARY);
+ createEAttribute(libraryEClass, LIBRARY__NAME);
+ createEReference(libraryEClass, LIBRARY__BOOKS);
+
+ bookCopyEClass = createEClass(BOOK_COPY);
+ createEReference(bookCopyEClass, BOOK_COPY__BOOK);
+ createEAttribute(bookCopyEClass, BOOK_COPY__COPIES);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized)
+ return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ BooksPackage theBooksPackage = (BooksPackage)EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(libraryEClass, Library.class,
+ "Library", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEAttribute(
+ getLibrary_Name(),
+ ecorePackage.getEString(),
+ "name", null, 1, 1, Library.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getLibrary_Books(),
+ this.getBookCopy(),
+ null,
+ "books", null, 0, -1, Library.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ initEClass(bookCopyEClass, BookCopy.class,
+ "BookCopy", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(
+ getBookCopy_Book(),
+ theBooksPackage.getBook(),
+ null,
+ "book", null, 0, 1, BookCopy.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getBookCopy_Copies(),
+ ecorePackage.getEInt(),
+ "copies", null, 0, 1, BookCopy.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //LibraryPackageImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryActionBarContributor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryActionBarContributor.java
new file mode 100644
index 000000000..9ab9b0502
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryActionBarContributor.java
@@ -0,0 +1,441 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.SubContributionItem;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Library model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the active editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IEditorPart activeEditorPart;
+
+ /**
+ * This keeps track of the current selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionProvider selectionProvider;
+
+ /**
+ * This action opens the Properties view.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction showPropertiesViewAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction refreshViewerAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
+
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.refresh();
+ }
+ }
+ }
+ };
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createChildActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateChild actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createSiblingActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createSiblingMenuManager;
+
+ /**
+ * This creates an instance of the contributor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryActionBarContributor() {
+ super(ADDITIONS_LAST_STYLE);
+ loadResourceAction = new LoadResourceAction();
+ validateAction = new ValidateAction();
+ controlAction = new ControlAction();
+ }
+
+ /**
+ * This adds Separators for editor additions to the tool bar.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(new Separator("library-settings")); //$NON-NLS-1$
+ toolBarManager.add(new Separator("library-additions")); //$NON-NLS-1$
+ }
+
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ IMenuManager submenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_LibraryEditor_menu"), "org.eclipse.emf.compare.example.library.libraryMenuID"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("additions", submenuManager); //$NON-NLS-1$
+ submenuManager.add(new Separator("settings")); //$NON-NLS-1$
+ submenuManager.add(new Separator("actions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions-end")); //$NON-NLS-1$
+
+ // Prepare for CreateChild item addition or removal.
+ //
+ createChildMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createChildMenuManager); //$NON-NLS-1$
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createSiblingMenuManager); //$NON-NLS-1$
+
+ // Force an update because Eclipse hides empty menus now.
+ //
+ submenuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
+
+ addGlobalActions(submenuManager);
+ }
+
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setActiveEditor(IEditorPart part) {
+ super.setActiveEditor(part);
+ activeEditorPart = part;
+
+ // Switch to the new selection provider.
+ //
+ if (selectionProvider != null) {
+ selectionProvider.removeSelectionChangedListener(this);
+ }
+ if (part == null) {
+ selectionProvider = null;
+ } else {
+ selectionProvider = part.getSite().getSelectionProvider();
+ selectionProvider.addSelectionChangedListener(this);
+
+ // Fake a selection changed event to update the menus.
+ //
+ if (selectionProvider.getSelection() != null) {
+ selectionChanged(new SelectionChangedEvent(selectionProvider,
+ selectionProvider.getSelection()));
+ }
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null) {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null) {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null) {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null) {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
+ String contributionID) {
+ if (actions != null) {
+ for (IAction action : actions) {
+ if (contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ } else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
+ if (actions != null) {
+ IContributionItem[] items = manager.getItems();
+ for (int i = 0; i < items.length; i++) {
+ // Look into SubContributionItems
+ //
+ IContributionItem contributionItem = items[i];
+ while (contributionItem instanceof SubContributionItem) {
+ contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+ }
+
+ // Delete the ActionContributionItems with matching action.
+ //
+ if (contributionItem instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem)contributionItem).getAction();
+ if (actions.contains(action)) {
+ manager.remove(contributionItem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This populates the pop-up menu before it appears.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ MenuManager submenuManager = null;
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createSiblingActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+ }
+
+ /**
+ * This inserts global actions before the "additions-end" separator.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
+
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ menuManager.insertAfter("ui-actions", refreshViewerAction); //$NON-NLS-1$
+
+ super.addGlobalActions(menuManager);
+ }
+
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryEditor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryEditor.java
new file mode 100644
index 000000000..35c0bb162
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryEditor.java
@@ -0,0 +1,1799 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.presentation;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.custom.CTabFolder;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.swt.layout.FillLayout;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+
+import org.eclipse.ui.dialogs.SaveAsDialog;
+
+import org.eclipse.ui.ide.IGotoMarker;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.ViewerPane;
+
+import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+
+import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
+
+import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+
+import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+
+import org.eclipse.emf.compare.example.library.library.provider.LibraryItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.books.provider.BooksItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.compare.example.library.writers.provider.WritersItemProviderAdapterFactory;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * This is an example of a Library model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the editing domain that is used to track all changes to the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ /**
+ * This is the one adapter factory used for providing views of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory adapterFactory;
+
+ /**
+ * This is the content outline page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IContentOutlinePage contentOutlinePage;
+
+ /**
+ * This is a kludge...
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStatusLineManager contentOutlineStatusLineManager;
+
+ /**
+ * This is the content outline page's viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer contentOutlineViewer;
+
+ /**
+ * This is the property sheet page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PropertySheetPage propertySheetPage;
+
+ /**
+ * This is the viewer that shadows the selection in the content outline.
+ * The parent relation must be correctly defined for this to work.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer selectionViewer;
+
+ /**
+ * This inverts the roll of parent and child in the content provider and show parents as a tree.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer parentViewer;
+
+ /**
+ * This shows how a tree view works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewer;
+
+ /**
+ * This shows how a list view works.
+ * A list viewer doesn't support icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ListViewer listViewer;
+
+ /**
+ * This shows how a table view works.
+ * A table can be used as a list with icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TableViewer tableViewer;
+
+ /**
+ * This shows how a tree view with columns works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewerWithColumns;
+
+ /**
+ * This keeps track of the active viewer pane, in the book.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ViewerPane currentViewerPane;
+
+ /**
+ * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Viewer currentViewer;
+
+ /**
+ * This listens to which ever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionChangedListener selectionChangedListener;
+
+ /**
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+
+ /**
+ * This keeps track of the selection of the editor as a whole.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelection editorSelection = StructuredSelection.EMPTY;
+
+ /**
+ * The MarkerHelper is responsible for creating workspace resource markers presented
+ * in Eclipse's Problems View.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected MarkerHelper markerHelper = new EditUIMarkerHelper();
+
+ /**
+ * This listens for when the outline becomes active
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IPartListener partListener = new IPartListener() {
+ public void partActivated(IWorkbenchPart p) {
+ if (p instanceof ContentOutline) {
+ if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
+ getActionBarContributor().setActiveEditor(LibraryEditor.this);
+
+ setCurrentViewer(contentOutlineViewer);
+ }
+ } else if (p instanceof PropertySheet) {
+ if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
+ getActionBarContributor().setActiveEditor(LibraryEditor.this);
+ handleActivate();
+ }
+ } else if (p == LibraryEditor.this) {
+ handleActivate();
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partClosed(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partDeactivated(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partOpened(IWorkbenchPart p) {
+ // Ignore.
+ }
+ };
+
+ /**
+ * Resources that have been removed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been changed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been saved.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> savedResources = new ArrayList<Resource>();
+
+ /**
+ * Map to store the diagnostic associated with a resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
+
+ /**
+ * Controls whether the problem indication should be updated.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean updateProblemIndication = true;
+
+ /**
+ * Adapter used to update the problem indication when resources are demanded loaded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EContentAdapter problemIndicationAdapter = new EContentAdapter() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof Resource) {
+ switch (notification.getFeatureID(Resource.class)) {
+ case Resource.RESOURCE__IS_LOADED:
+ case Resource.RESOURCE__ERRORS:
+ case Resource.RESOURCE__WARNINGS: {
+ Resource resource = (Resource)notification.getNotifier();
+ Diagnostic diagnostic = analyzeResourceProblems(resource, null);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, diagnostic);
+ } else {
+ resourceToDiagnosticMap.remove(resource);
+ }
+
+ if (updateProblemIndication) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+ break;
+ }
+ }
+ } else {
+ super.notifyChanged(notification);
+ }
+ }
+
+ @Override
+ protected void setTarget(Resource target) {
+ basicSetTarget(target);
+ }
+
+ @Override
+ protected void unsetTarget(Resource target) {
+ basicUnsetTarget(target);
+ }
+ };
+
+ /**
+ * This listens for workspace changes.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ protected ResourceSet resourceSet = editingDomain.getResourceSet();
+
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ public boolean visit(IResourceDelta delta) {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if (delta.getKind() == IResourceDelta.REMOVED
+ || delta.getKind() == IResourceDelta.CHANGED
+ && delta.getFlags() != IResourceDelta.MARKERS) {
+ Resource resource = resourceSet.getResource(
+ URI.createPlatformResourceURI(delta.getFullPath().toString(), true),
+ false);
+ if (resource != null) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ removedResources.add(resource);
+ } else if (!savedResources.remove(resource)) {
+ changedResources.add(resource);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
+
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
+ }
+ }
+
+ final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getPage().closeEditor(LibraryEditor.this, false);
+ }
+ }
+ });
+ }
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == LibraryEditor.this) {
+ handleActivate();
+ }
+ }
+ });
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * Handles activation of the editor or it's associated views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleActivate() {
+ // Recompute the read only state.
+ //
+ if (editingDomain.getResourceToReadOnlyMap() != null) {
+ editingDomain.getResourceToReadOnlyMap().clear();
+
+ // Refresh any actions that may become enabled or disabled.
+ //
+ setSelection(getSelection());
+ }
+
+ if (!removedResources.isEmpty()) {
+ if (handleDirtyConflict()) {
+ getSite().getPage().closeEditor(LibraryEditor.this, false);
+ } else {
+ removedResources.clear();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ } else if (!changedResources.isEmpty()) {
+ changedResources.removeAll(savedResources);
+ handleChangedResources();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+
+ /**
+ * Handles what to do with changed resources on activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleChangedResources() {
+ if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
+ editingDomain.getCommandStack().flush();
+
+ updateProblemIndication = false;
+ for (Resource resource : changedResources) {
+ if (resource.isLoaded()) {
+ resource.unload();
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ } catch (IOException exception) {
+ if (!resourceToDiagnosticMap.containsKey(resource)) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ }
+ }
+ }
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+ }
+
+ /**
+ * Updates the problems indication with the information described in the specified diagnostic.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void updateProblemIndication() {
+ if (updateProblemIndication) {
+ BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, null, new Object[] {editingDomain.getResourceSet()});
+ for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
+ if (childDiagnostic.getSeverity() != Diagnostic.OK) {
+ diagnostic.add(childDiagnostic);
+ }
+ }
+
+ int lastEditorPage = getPageCount() - 1;
+ if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
+ ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ setActivePage(lastEditorPage);
+ }
+ } else if (diagnostic.getSeverity() != Diagnostic.OK) {
+ ProblemEditorPart problemEditorPart = new ProblemEditorPart();
+ problemEditorPart.setDiagnostic(diagnostic);
+ problemEditorPart.setMarkerHelper(markerHelper);
+ try {
+ addPage(++lastEditorPage, problemEditorPart, getEditorInput());
+ setPageText(lastEditorPage, problemEditorPart.getPartName());
+ setActivePage(lastEditorPage);
+ showTabs();
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
+ markerHelper.deleteMarkers(editingDomain.getResourceSet());
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ try {
+ markerHelper.createMarkers(diagnostic);
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Shows a dialog that asks if conflicting changes should be discarded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean handleDirtyConflict() {
+ return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), //$NON-NLS-1$
+ getString("_WARN_FileConflict")); //$NON-NLS-1$
+ }
+
+ /**
+ * This creates a model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * This sets up the editing domain for the model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new LibraryItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new BooksItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new WritersItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
+ propertySheetPage.refresh();
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack,
+ new HashMap<Resource, Boolean>());
+ }
+
+ /**
+ * This is here for the listener to be able to call it.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void firePropertyChange(int action) {
+ super.firePropertyChange(action);
+ }
+
+ /**
+ * This sets the selection into whichever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelectionToViewer(Collection<?> collection) {
+ final Collection<?> theSelection = collection;
+ // Make sure it's okay.
+ //
+ if (theSelection != null && !theSelection.isEmpty()) {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ // Try to select the items in the current content viewer of the editor.
+ //
+ if (currentViewer != null) {
+ currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
+ }
+ }
+ };
+ getSite().getShell().getDisplay().asyncExec(runnable);
+ }
+ }
+
+ /**
+ * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
+ * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
+ * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getElements(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getChildren(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ Object parent = super.getParent(object);
+ return parent != null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getParent(Object object) {
+ return null;
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewerPane(ViewerPane viewerPane) {
+ if (currentViewerPane != viewerPane) {
+ if (currentViewerPane != null) {
+ currentViewerPane.showFocus(false);
+ }
+ currentViewerPane = viewerPane;
+ }
+ setCurrentViewer(currentViewerPane.getViewer());
+ }
+
+ /**
+ * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
+ * is the current one.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewer(Viewer viewer) {
+ // If it is changing...
+ //
+ if (currentViewer != viewer) {
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener = new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+
+ // Stop listening to the old one.
+ //
+ if (currentViewer != null) {
+ currentViewer.removeSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Start listening to the new one.
+ //
+ if (viewer != null) {
+ viewer.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Remember it.
+ //
+ currentViewer = viewer;
+
+ // Set the editors selection based on the current viewer's selection.
+ //
+ setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
+ }
+ }
+
+ /**
+ * This returns the viewer as required by the {@link IViewerProvider} interface.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Viewer getViewer() {
+ return currentViewer;
+ }
+
+ /**
+ * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
+ contextMenu.add(new Separator("additions")); //$NON-NLS-1$
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu = contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance()};
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain,
+ viewer));
+ }
+
+ /**
+ * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createModel() {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Exception exception = null;
+ Resource resource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ resource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ } catch (Exception e) {
+ exception = e;
+ resource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+
+ Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
+ }
+
+ /**
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
+ if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
+ BasicDiagnostic basicDiagnostic = new BasicDiagnostic(Diagnostic.ERROR,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception == null ? (Object)resource : exception});
+ basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
+ return basicDiagnostic;
+ } else if (exception != null) {
+ return new BasicDiagnostic(Diagnostic.ERROR, "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception});
+ } else {
+ return Diagnostic.OK_INSTANCE;
+ }
+ }
+
+ /**
+ * This is the method used by the framework to install your own controls.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ // Create a page for the selection tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ selectionViewer = (TreeViewer)viewerPane.getViewer();
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet()
+ .getResources().get(0)), true);
+ viewerPane.setTitle(editingDomain.getResourceSet());
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ }
+
+ // Create a page for the parent tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ parentViewer = (TreeViewer)viewerPane.getViewer();
+ parentViewer.setAutoExpandLevel(30);
+ parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
+ parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(parentViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ParentPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the list viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new ListViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ listViewer = (ListViewer)viewerPane.getViewer();
+ listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(listViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ListPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the tree viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ treeViewer = (TreeViewer)viewerPane.getViewer();
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(treeViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TableViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ tableViewer = (TableViewer)viewerPane.getViewer();
+
+ Table table = tableViewer.getTable();
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn objectColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(3, 100, true));
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+
+ TableColumn selfColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(2, 100, true));
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+
+ tableViewer.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(tableViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TablePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table tree viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), LibraryEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
+
+ Tree tree = treeViewerWithColumns.getTree();
+ tree.setLayoutData(new FillLayout());
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+ objectColumn.setWidth(250);
+
+ TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+ selfColumn.setWidth(200);
+
+ treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(treeViewerWithColumns);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); //$NON-NLS-1$
+ }
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ setActivePage(0);
+ }
+ });
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter() {
+ boolean guard = false;
+
+ @Override
+ public void controlResized(ControlEvent event) {
+ if (!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+
+ /**
+ * If there is just one page in the multi-page editor part,
+ * this hides the single tab at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void hideTabs() {
+ if (getPageCount() <= 1) {
+ setPageText(0, ""); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(1);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y + 6);
+ }
+ }
+ }
+
+ /**
+ * If there is more than one page in the multi-page editor part,
+ * this shows the tabs at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void showTabs() {
+ if (getPageCount() > 1) {
+ setPageText(0, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y - 6);
+ }
+ }
+ }
+
+ /**
+ * This is used to track the active viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void pageChange(int pageIndex) {
+ super.pageChange(pageIndex);
+
+ if (contentOutlinePage != null) {
+ handleContentOutlineSelection(contentOutlinePage.getSelection());
+ }
+ }
+
+ /**
+ * This is how the framework determines which interfaces we implement.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class key) {
+ if (key.equals(IContentOutlinePage.class)) {
+ return showOutlineView() ? getContentOutlinePage() : null;
+ } else if (key.equals(IPropertySheetPage.class)) {
+ return getPropertySheetPage();
+ } else if (key.equals(IGotoMarker.class)) {
+ return this;
+ } else {
+ return super.getAdapter(key);
+ }
+ }
+
+ /**
+ * This accesses a cached version of the content outliner.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IContentOutlinePage getContentOutlinePage() {
+ if (contentOutlinePage == null) {
+ // The content outline is just a tree.
+ //
+ class MyContentOutlinePage extends ContentOutlinePage {
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer
+ .setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ contentOutlineViewer.setInput(editingDomain.getResourceSet());
+
+ // Make sure our popups work.
+ //
+ createContextMenuFor(contentOutlineViewer);
+
+ if (!editingDomain.getResourceSet().getResources().isEmpty()) {
+ // Select the root object in the view.
+ //
+ contentOutlineViewer.setSelection(new StructuredSelection(editingDomain
+ .getResourceSet().getResources().get(0)), true);
+ }
+ }
+
+ @Override
+ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
+ IStatusLineManager statusLineManager) {
+ super.makeContributions(menuManager, toolBarManager, statusLineManager);
+ contentOutlineStatusLineManager = statusLineManager;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ }
+
+ contentOutlinePage = new MyContentOutlinePage();
+
+ // Listen to selection so that we can handle it is a special way.
+ //
+ contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ }
+
+ return contentOutlinePage;
+ }
+
+ /**
+ * This accesses a cached version of the property sheet.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertySheetPage == null) {
+ propertySheetPage = new ExtendedPropertySheetPage(editingDomain) {
+ @Override
+ public void setSelectionToViewer(List<?> selection) {
+ LibraryEditor.this.setSelectionToViewer(selection);
+ LibraryEditor.this.setFocus();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ };
+ propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+ }
+
+ return propertySheetPage;
+ }
+
+ /**
+ * This deals with how we want selection in the outliner to affect the other views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void handleContentOutlineSelection(ISelection selection) {
+ if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
+ if (selectedElements.hasNext()) {
+ // Get the first selected element.
+ //
+ Object selectedElement = selectedElements.next();
+
+ // If it's the selection viewer, then we want it to select the same selection as this selection.
+ //
+ if (currentViewerPane.getViewer() == selectionViewer) {
+ ArrayList<Object> selectionList = new ArrayList<Object>();
+ selectionList.add(selectedElement);
+ while (selectedElements.hasNext()) {
+ selectionList.add(selectedElements.next());
+ }
+
+ // Set the selection to the widget.
+ //
+ selectionViewer.setSelection(new StructuredSelection(selectionList));
+ } else {
+ // Set the input to the widget.
+ //
+ if (currentViewerPane.getViewer().getInput() != selectedElement) {
+ currentViewerPane.getViewer().setInput(selectedElement);
+ currentViewerPane.setTitle(selectedElement);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply tests the command stack.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+ Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+
+ // Do the work within an operation because this is a long running activity that modifies the workbench.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for (Resource resource : editingDomain.getResourceSet().getResources()) {
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
+ && !editingDomain.isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ } catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ } catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+
+ /**
+ * This returns whether something has been persisted to the URI of the specified resource.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean isPersisted(Resource resource) {
+ boolean result = false;
+ try {
+ InputStream stream = editingDomain.getResourceSet().getURIConverter()
+ .createInputStream(resource.getURI());
+ if (stream != null) {
+ result = true;
+ stream.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ return result;
+ }
+
+ /**
+ * This always returns true because it is not currently supported.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * This also changes the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSaveAs() {
+ SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
+ saveAsDialog.open();
+ IPath path = saveAsDialog.getResult();
+ if (path != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true),
+ new FileEditorInput(file));
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void doSaveAs(URI uri, IEditorInput editorInput) {
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
+ .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
+ doSave(progressMonitor);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ try {
+ if (marker.getType().equals(EValidator.MARKER)) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+ EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
+ if (eObject != null) {
+ setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
+ }
+ }
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ /**
+ * This is called during startup.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) {
+ setSite(site);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ site.setSelectionProvider(this);
+ site.getPage().addPartListener(partListener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener,
+ IResourceChangeEvent.POST_CHANGE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setFocus() {
+ if (currentViewerPane != null) {
+ currentViewerPane.setFocus();
+ } else {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ISelection getSelection() {
+ return editorSelection;
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
+ * Calling this result will notify the listeners.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelection(ISelection selection) {
+ editorSelection = selection;
+
+ for (ISelectionChangedListener listener : selectionChangedListeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ setStatusLineManager(selection);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setStatusLineManager(ISelection selection) {
+ IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager
+ : getActionBars().getStatusLineManager();
+
+ if (statusLineManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> collection = ((IStructuredSelection)selection).toList();
+ switch (collection.size()) {
+ case 0: {
+ statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
+ break;
+ }
+ case 1: {
+ String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection
+ .iterator().next());
+ statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); //$NON-NLS-1$
+ break;
+ }
+ default: {
+ statusLineManager.setMessage(getString(
+ "_UI_MultiObjectSelected", Integer.toString(collection.size()))); //$NON-NLS-1$
+ break;
+ }
+ }
+ } else {
+ statusLineManager.setMessage(""); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key) {
+ return LibraryEditPlugin.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1) {
+ return LibraryEditPlugin.INSTANCE.getString(key, new Object[] {s1});
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void menuAboutToShow(IMenuManager menuManager) {
+ ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomainActionBarContributor getActionBarContributor() {
+ return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IActionBars getActionBars() {
+ return getActionBarContributor().getActionBars();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public AdapterFactory getAdapterFactory() {
+ return adapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void dispose() {
+ updateProblemIndication = false;
+
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ getSite().getPage().removePartListener(partListener);
+
+ adapterFactory.dispose();
+
+ if (getActionBarContributor().getActiveEditor() == this) {
+ getActionBarContributor().setActiveEditor(null);
+ }
+
+ if (propertySheetPage != null) {
+ propertySheetPage.dispose();
+ }
+
+ if (contentOutlinePage != null) {
+ contentOutlinePage.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * Returns whether the outline view should be presented to the user.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean showOutlineView() {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryModelWizard.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryModelWizard.java
new file mode 100644
index 000000000..195fb0fab
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/presentation/LibraryModelWizard.java
@@ -0,0 +1,650 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.presentation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.CommonPlugin;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+import org.eclipse.emf.compare.example.library.library.LibraryFactory;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is a simple wizard for creating a new model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryModelWizard extends Wizard implements INewWizard {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS = Collections.unmodifiableList(Arrays
+ .asList(LibraryEditPlugin.INSTANCE
+ .getString("_UI_LibraryEditorFilenameExtensions").split("\\s*,\\s*"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS = LibraryEditPlugin.INSTANCE.getString(
+ "_UI_LibraryEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /**
+ * This caches an instance of the model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryPackage libraryPackage = LibraryPackage.eINSTANCE;
+
+ /**
+ * This caches an instance of the model factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryFactory libraryFactory = libraryPackage.getLibraryFactory();
+
+ /**
+ * This is the file creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryModelWizardNewFileCreationPage newFileCreationPage;
+
+ /**
+ * This is the initial object creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryModelWizardInitialObjectCreationPage initialObjectCreationPage;
+
+ /**
+ * Remember the selection during initialization for populating the default container.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * Remember the workbench during initialization.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IWorkbench workbench;
+
+ /**
+ * Caches the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected List<String> initialObjectNames;
+
+ /**
+ * This just records the information.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(LibraryEditPlugin.INSTANCE.getString("_UI_Wizard_label")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE
+ .getImageDescriptor(LibraryEditPlugin.INSTANCE.getImage("full/wizban/NewLibrary"))); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getInitialObjectNames() {
+ if (initialObjectNames == null) {
+ initialObjectNames = new ArrayList<String>();
+ for (EClassifier eClassifier : libraryPackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract()) {
+ initialObjectNames.add(eClass.getName());
+ }
+ }
+ }
+ Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
+ }
+ return initialObjectNames;
+ }
+
+ /**
+ * Create a new model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EObject createInitialModel() {
+ EClass eClass = (EClass)libraryPackage.getEClassifier(initialObjectCreationPage
+ .getInitialObjectName());
+ EObject rootObject = libraryFactory.create(eClass);
+ return rootObject;
+ }
+
+ /**
+ * Do the work after everything is specified.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI, LibraryPackage.eCONTENT_TYPE);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ resource.save(options);
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ } finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor(
+ new FileEditorInput(modelFile),
+ workbench
+ .getEditorRegistry()
+ .getDefaultEditor(
+ modelFile.getFullPath().toString(),
+ Platform.getContentTypeManager().getContentType(
+ LibraryPackage.eCONTENT_TYPE)).getId());
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), LibraryEditPlugin.INSTANCE
+ .getString("_UI_OpenEditorError_label"), exception.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+
+ return true;
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ /**
+ * This is the one page of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class LibraryModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
+ setErrorMessage(LibraryEditPlugin.INSTANCE.getString(key,
+ new Object[] {FORMATTED_FILE_EXTENSIONS}));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(getContainerFullPath().append(getFileName()));
+ }
+ }
+
+ /**
+ * This is the page where the type of object to create is selected.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class LibraryModelWizardInitialObjectCreationPage extends WizardPage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo initialObjectField;
+
+ /**
+ * @generated
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ */
+ protected List<String> encodings;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo encodingField;
+
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryModelWizardInitialObjectCreationPage(String pageId) {
+ super(pageId);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 12;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ }
+
+ Label containerLabel = new Label(composite, SWT.LEFT);
+ {
+ containerLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_ModelObject")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ containerLabel.setLayoutData(data);
+ }
+
+ initialObjectField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ initialObjectField.setLayoutData(data);
+ }
+
+ for (String objectName : getInitialObjectNames()) {
+ initialObjectField.add(getLabel(objectName));
+ }
+
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.select(0);
+ }
+ initialObjectField.addModifyListener(validator);
+
+ Label encodingLabel = new Label(composite, SWT.LEFT);
+ {
+ encodingLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncoding")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ encodingLabel.setLayoutData(data);
+ }
+ encodingField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ encodingField.setLayoutData(data);
+ }
+
+ for (String encoding : getEncodings()) {
+ encodingField.add(encoding);
+ }
+
+ encodingField.select(0);
+ encodingField.addModifyListener(validator);
+
+ setPageComplete(validatePage());
+ setControl(composite);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ModifyListener validator = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ };
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean validatePage() {
+ return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.clearSelection();
+ encodingField.setFocus();
+ } else {
+ encodingField.clearSelection();
+ initialObjectField.setFocus();
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getInitialObjectName() {
+ String label = initialObjectField.getText();
+
+ for (String name : getInitialObjectNames()) {
+ if (getLabel(name).equals(label)) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getEncoding() {
+ return encodingField.getText();
+ }
+
+ /**
+ * Returns the label for the specified type name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected String getLabel(String typeName) {
+ try {
+ return LibraryEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (MissingResourceException mre) {
+ LibraryEditPlugin.INSTANCE.log(mre);
+ }
+ return typeName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getEncodings() {
+ if (encodings == null) {
+ encodings = new ArrayList<String>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(
+ LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens();) //$NON-NLS-1$
+ {
+ encodings.add(stringTokenizer.nextToken());
+ }
+ }
+ return encodings;
+ }
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ newFileCreationPage = new LibraryModelWizardNewFileCreationPage("Whatever", selection); //$NON-NLS-1$
+ newFileCreationPage.setTitle(LibraryEditPlugin.INSTANCE.getString("_UI_LibraryModelWizard_label")); //$NON-NLS-1$
+ newFileCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_LibraryModelWizard_description")); //$NON-NLS-1$
+ newFileCreationPage.setFileName(LibraryEditPlugin.INSTANCE
+ .getString("_UI_LibraryEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ addPage(newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = LibraryEditPlugin.INSTANCE
+ .getString("_UI_LibraryEditorFilenameDefaultBase"); //$NON-NLS-1$
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ }
+ newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ initialObjectCreationPage = new LibraryModelWizardInitialObjectCreationPage("Whatever2"); //$NON-NLS-1$
+ initialObjectCreationPage.setTitle(LibraryEditPlugin.INSTANCE
+ .getString("_UI_LibraryModelWizard_label")); //$NON-NLS-1$
+ initialObjectCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_Wizard_initial_object_description")); //$NON-NLS-1$
+ addPage(initialObjectCreationPage);
+ }
+
+ /**
+ * Get the file from the page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return newFileCreationPage.getModelFile();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/BookCopyItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/BookCopyItemProvider.java
new file mode 100644
index 000000000..468ccb3f4
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/BookCopyItemProvider.java
@@ -0,0 +1,172 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.emf.compare.example.library.library.BookCopy;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.library.BookCopy} object.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+public class BookCopyItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ public BookCopyItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addBookPropertyDescriptor(object);
+ addCopiesPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Book feature.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addBookPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_BookCopy_book_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_BookCopy_book_feature", "_UI_BookCopy_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ LibraryPackage.Literals.BOOK_COPY__BOOK, true, false, true, null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Copies feature.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addCopiesPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_BookCopy_copies_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_BookCopy_copies_feature", "_UI_BookCopy_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ LibraryPackage.Literals.BOOK_COPY__COPIES, true, false, false,
+ ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This returns BookCopy.gif.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/BookCopy")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ @Override
+ public String getText(Object object) {
+ BookCopy bookCopy = (BookCopy)object;
+ if (!bookCopy.eIsProxy() && bookCopy.getBook() != null && !bookCopy.getBook().eIsProxy()) {
+ String label = bookCopy.getBook().getTitle();
+ return getString("_UI_BookCopy_type") + " " + bookCopy.getCopies() + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return getString("_UI_BookCopy_type") + " " + bookCopy.getCopies(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(BookCopy.class)) {
+ case LibraryPackage.BOOK_COPY__COPIES:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false,
+ true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProvider.java
new file mode 100644
index 000000000..bce60b8a6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProvider.java
@@ -0,0 +1,202 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.compare.example.library.library.Library;
+import org.eclipse.emf.compare.example.library.library.LibraryFactory;
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.library.Library} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addNamePropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Name feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addNamePropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Library_name_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_Library_name_feature", "_UI_Library_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ LibraryPackage.Literals.LIBRARY__NAME, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(LibraryPackage.Literals.LIBRARY__BOOKS);
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
+ * This returns Library.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/Library")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ String label = ((Library)object).getName();
+ return label == null || label.length() == 0 ? getString("_UI_Library_type") : //$NON-NLS-1$
+ getString("_UI_Library_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(Library.class)) {
+ case LibraryPackage.LIBRARY__NAME:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false,
+ true));
+ return;
+ case LibraryPackage.LIBRARY__BOOKS:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true,
+ false));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add(createChildParameter(LibraryPackage.Literals.LIBRARY__BOOKS,
+ LibraryFactory.eINSTANCE.createBookCopy()));
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProviderAdapterFactory.java
new file mode 100644
index 000000000..6c29c533b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/provider/LibraryItemProviderAdapterFactory.java
@@ -0,0 +1,240 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.compare.example.library.library.util.LibraryAdapterFactory;
+
+import org.eclipse.emf.edit.provider.ChangeNotifier;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.IDisposable;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+
+/**
+ * This is the factory that is used to provide the interfaces needed to support Viewers.
+ * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
+ * The adapters also support Eclipse property sheets.
+ * Note that most of the adapters are shared among multiple instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class LibraryItemProviderAdapterFactory extends LibraryAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the root adapter factory that delegates to this adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory parentAdapterFactory;
+
+ /**
+ * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IChangeNotifier changeNotifier = new ChangeNotifier();
+
+ /**
+ * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Object> supportedTypes = new ArrayList<Object>();
+
+ /**
+ * This constructs an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryItemProviderAdapterFactory() {
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ supportedTypes.add(IItemPropertySource.class);
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.library.Library} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibraryItemProvider libraryItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.library.Library}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createLibraryAdapter() {
+ if (libraryItemProvider == null) {
+ libraryItemProvider = new LibraryItemProvider(this);
+ }
+
+ return libraryItemProvider;
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.library.BookCopy} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected BookCopyItemProvider bookCopyItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.library.BookCopy}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createBookCopyAdapter() {
+ if (bookCopyItemProvider == null) {
+ bookCopyItemProvider = new BookCopyItemProvider(this);
+ }
+
+ return bookCopyItemProvider;
+ }
+
+ /**
+ * This returns the root adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ComposeableAdapterFactory getRootAdapterFactory() {
+ return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
+ }
+
+ /**
+ * This sets the composed adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
+ this.parentAdapterFactory = parentAdapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return supportedTypes.contains(type) || super.isFactoryForType(type);
+ }
+
+ /**
+ * This implementation substitutes the factory itself as the key for the adapter.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter adapt(Notifier notifier, Object type) {
+ return super.adapt(notifier, this);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object adapt(Object object, Object type) {
+ if (isFactoryForType(type)) {
+ Object adapter = super.adapt(object, type);
+ if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
+ return adapter;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This adds a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.addListener(notifyChangedListener);
+ }
+
+ /**
+ * This removes a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.removeListener(notifyChangedListener);
+ }
+
+ /**
+ * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void fireNotifyChanged(Notification notification) {
+ changeNotifier.fireNotifyChanged(notification);
+
+ if (parentAdapterFactory != null) {
+ parentAdapterFactory.fireNotifyChanged(notification);
+ }
+ }
+
+ /**
+ * This disposes all of the item providers created by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void dispose() {
+ if (libraryItemProvider != null)
+ libraryItemProvider.dispose();
+ if (bookCopyItemProvider != null)
+ bookCopyItemProvider.dispose();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryAdapterFactory.java
new file mode 100644
index 000000000..071577c04
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryAdapterFactory.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.compare.example.library.library.*;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage
+ * @generated
+ */
+public class LibraryAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static LibraryPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = LibraryPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected LibrarySwitch<Adapter> modelSwitch = new LibrarySwitch<Adapter>() {
+ @Override
+ public Adapter caseLibrary(Library object) {
+ return createLibraryAdapter();
+ }
+
+ @Override
+ public Adapter caseBookCopy(BookCopy object) {
+ return createBookCopyAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.library.Library <em>Library</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.library.Library
+ * @generated
+ */
+ public Adapter createLibraryAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.library.BookCopy <em>Book Copy</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.library.BookCopy
+ * @generated
+ */
+ public Adapter createBookCopyAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //LibraryAdapterFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceFactoryImpl.java
new file mode 100644
index 000000000..07389b491
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceFactoryImpl.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource Factory</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.util.LibraryResourceImpl
+ * @generated
+ */
+public class LibraryResourceFactoryImpl extends ResourceFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryResourceFactoryImpl() {
+ super();
+ }
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Resource createResource(URI uri) {
+ Resource result = new LibraryResourceImpl(uri);
+ return result;
+ }
+
+} //LibraryResourceFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceImpl.java
new file mode 100644
index 000000000..ec47eae19
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibraryResourceImpl.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.util.LibraryResourceFactoryImpl
+ * @generated
+ */
+public class LibraryResourceImpl extends XMIResourceImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public LibraryResourceImpl(URI uri) {
+ super(uri);
+ }
+
+} //LibraryResourceImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibrarySwitch.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibrarySwitch.java
new file mode 100644
index 000000000..77b019a51
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/library/util/LibrarySwitch.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.library.util;
+
+import org.eclipse.emf.compare.example.library.library.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.library.LibraryPackage
+ * @generated
+ */
+public class LibrarySwitch<T> extends Switch<T> {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static LibraryPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibrarySwitch() {
+ if (modelPackage == null) {
+ modelPackage = LibraryPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @parameter ePackage the package in question.
+ * @return whether this is a switch for the given package.
+ * @generated
+ */
+ @Override
+ protected boolean isSwitchFor(EPackage ePackage) {
+ return ePackage == modelPackage;
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case LibraryPackage.LIBRARY: {
+ Library library = (Library)theEObject;
+ T result = caseLibrary(library);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ case LibraryPackage.BOOK_COPY: {
+ BookCopy bookCopy = (BookCopy)theEObject;
+ T result = caseBookCopy(bookCopy);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Library</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Library</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseLibrary(Library object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Book Copy</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Book Copy</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseBookCopy(BookCopy object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //LibrarySwitch
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/provider/LibraryEditPlugin.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/provider/LibraryEditPlugin.java
new file mode 100644
index 000000000..697dd1ec3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/provider/LibraryEditPlugin.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.provider;
+
+import org.eclipse.emf.common.EMFPlugin;
+
+import org.eclipse.emf.common.ui.EclipseUIPlugin;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+/**
+ * This is the central singleton for the Library editor plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public final class LibraryEditPlugin extends EMFPlugin {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final LibraryEditPlugin INSTANCE = new LibraryEditPlugin();
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Implementation plugin;
+
+ /**
+ * Create the instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public LibraryEditPlugin() {
+ super(new ResourceLocator[] {});
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Implementation extends EclipseUIPlugin {
+ /**
+ * Creates an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Catalog.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Catalog.java
new file mode 100644
index 000000000..7259c8bfb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Catalog.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Catalog</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.Catalog#getWriters <em>Writers</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#getCatalog()
+ * @model
+ * @generated
+ */
+public interface Catalog extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Writers</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.emf.compare.example.library.writers.Writer}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Writers</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Writers</em>' containment reference list.
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#getCatalog_Writers()
+ * @model containment="true"
+ * @generated
+ */
+ EList<Writer> getWriters();
+
+} // Catalog
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Writer.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Writer.java
new file mode 100644
index 000000000..609b0e82b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/Writer.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Writer</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.Writer#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.Writer#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#getWriter()
+ * @model
+ * @generated
+ */
+public interface Writer extends EObject {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#getWriter_Name()
+ * @model required="true"
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.compare.example.library.writers.Writer#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Books</b></em>' reference list.
+ * The list contents are of type {@link org.eclipse.emf.compare.example.library.books.Book}.
+ * It is bidirectional and its opposite is '{@link org.eclipse.emf.compare.example.library.books.Book#getAuthors <em>Authors</em>}'.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Books</em>' reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Books</em>' reference list.
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#getWriter_Books()
+ * @see org.eclipse.emf.compare.example.library.books.Book#getAuthors
+ * @model opposite="authors"
+ * @generated
+ */
+ EList<Book> getBooks();
+
+} // Writer
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersFactory.java
new file mode 100644
index 000000000..59c8e19cf
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersFactory.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage
+ * @generated
+ */
+public interface WritersFactory extends EFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ WritersFactory eINSTANCE = org.eclipse.emf.compare.example.library.writers.impl.WritersFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Catalog</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Catalog</em>'.
+ * @generated
+ */
+ Catalog createCatalog();
+
+ /**
+ * Returns a new object of class '<em>Writer</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Writer</em>'.
+ * @generated
+ */
+ Writer createWriter();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ WritersPackage getWritersPackage();
+
+} //WritersFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersPackage.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersPackage.java
new file mode 100644
index 000000000..c270f29d9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/WritersPackage.java
@@ -0,0 +1,267 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.WritersFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface WritersPackage extends EPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "writers"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/emf/compare/writers"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "writers"; //$NON-NLS-1$
+
+ /**
+ * The package content type ID.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eCONTENT_TYPE = "org.eclipse.emf.compare.example.library.writerContentType"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ WritersPackage eINSTANCE = org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.writers.impl.CatalogImpl <em>Catalog</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.impl.CatalogImpl
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl#getCatalog()
+ * @generated
+ */
+ int CATALOG = 0;
+
+ /**
+ * The feature id for the '<em><b>Writers</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CATALOG__WRITERS = 0;
+
+ /**
+ * The number of structural features of the '<em>Catalog</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CATALOG_FEATURE_COUNT = 1;
+
+ /**
+ * The meta object id for the '{@link org.eclipse.emf.compare.example.library.writers.impl.WriterImpl <em>Writer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WriterImpl
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl#getWriter()
+ * @generated
+ */
+ int WRITER = 1;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int WRITER__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>Books</b></em>' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int WRITER__BOOKS = 1;
+
+ /**
+ * The number of structural features of the '<em>Writer</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int WRITER_FEATURE_COUNT = 2;
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.writers.Catalog <em>Catalog</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Catalog</em>'.
+ * @see org.eclipse.emf.compare.example.library.writers.Catalog
+ * @generated
+ */
+ EClass getCatalog();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.emf.compare.example.library.writers.Catalog#getWriters <em>Writers</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Writers</em>'.
+ * @see org.eclipse.emf.compare.example.library.writers.Catalog#getWriters()
+ * @see #getCatalog()
+ * @generated
+ */
+ EReference getCatalog_Writers();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.compare.example.library.writers.Writer <em>Writer</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Writer</em>'.
+ * @see org.eclipse.emf.compare.example.library.writers.Writer
+ * @generated
+ */
+ EClass getWriter();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.compare.example.library.writers.Writer#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.emf.compare.example.library.writers.Writer#getName()
+ * @see #getWriter()
+ * @generated
+ */
+ EAttribute getWriter_Name();
+
+ /**
+ * Returns the meta object for the reference list '{@link org.eclipse.emf.compare.example.library.writers.Writer#getBooks <em>Books</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference list '<em>Books</em>'.
+ * @see org.eclipse.emf.compare.example.library.writers.Writer#getBooks()
+ * @see #getWriter()
+ * @generated
+ */
+ EReference getWriter_Books();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ WritersFactory getWritersFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.writers.impl.CatalogImpl <em>Catalog</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.impl.CatalogImpl
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl#getCatalog()
+ * @generated
+ */
+ EClass CATALOG = eINSTANCE.getCatalog();
+
+ /**
+ * The meta object literal for the '<em><b>Writers</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference CATALOG__WRITERS = eINSTANCE.getCatalog_Writers();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.compare.example.library.writers.impl.WriterImpl <em>Writer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WriterImpl
+ * @see org.eclipse.emf.compare.example.library.writers.impl.WritersPackageImpl#getWriter()
+ * @generated
+ */
+ EClass WRITER = eINSTANCE.getWriter();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute WRITER__NAME = eINSTANCE.getWriter_Name();
+
+ /**
+ * The meta object literal for the '<em><b>Books</b></em>' reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference WRITER__BOOKS = eINSTANCE.getWriter_Books();
+
+ }
+
+} //WritersPackage
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/CatalogImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/CatalogImpl.java
new file mode 100644
index 000000000..f566ef952
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/CatalogImpl.java
@@ -0,0 +1,167 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.writers.Catalog;
+import org.eclipse.emf.compare.example.library.writers.Writer;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Catalog</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.impl.CatalogImpl#getWriters <em>Writers</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class CatalogImpl extends EObjectImpl implements Catalog {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached value of the '{@link #getWriters() <em>Writers</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getWriters()
+ * @generated
+ * @ordered
+ */
+ protected EList<Writer> writers;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CatalogImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return WritersPackage.Literals.CATALOG;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<Writer> getWriters() {
+ if (writers == null) {
+ writers = new EObjectContainmentEList<Writer>(Writer.class, this, WritersPackage.CATALOG__WRITERS);
+ }
+ return writers;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case WritersPackage.CATALOG__WRITERS:
+ return ((InternalEList<?>)getWriters()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case WritersPackage.CATALOG__WRITERS:
+ return getWriters();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case WritersPackage.CATALOG__WRITERS:
+ getWriters().clear();
+ getWriters().addAll((Collection<? extends Writer>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case WritersPackage.CATALOG__WRITERS:
+ getWriters().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case WritersPackage.CATALOG__WRITERS:
+ return writers != null && !writers.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //CatalogImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WriterImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WriterImpl.java
new file mode 100644
index 000000000..7dbedaa63
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WriterImpl.java
@@ -0,0 +1,257 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.compare.example.library.books.Book;
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+
+import org.eclipse.emf.compare.example.library.writers.Writer;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Writer</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.impl.WriterImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.compare.example.library.writers.impl.WriterImpl#getBooks <em>Books</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class WriterImpl extends EObjectImpl implements Writer {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getBooks() <em>Books</em>}' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBooks()
+ * @generated
+ * @ordered
+ */
+ protected EList<Book> books;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WriterImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return WritersPackage.Literals.WRITER;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, WritersPackage.WRITER__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<Book> getBooks() {
+ if (books == null) {
+ books = new EObjectWithInverseResolvingEList.ManyInverse<Book>(Book.class, this,
+ WritersPackage.WRITER__BOOKS, BooksPackage.BOOK__AUTHORS);
+ }
+ return books;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case WritersPackage.WRITER__BOOKS:
+ return ((InternalEList<InternalEObject>)(InternalEList<?>)getBooks())
+ .basicAdd(otherEnd, msgs);
+ }
+ return super.eInverseAdd(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case WritersPackage.WRITER__BOOKS:
+ return ((InternalEList<?>)getBooks()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case WritersPackage.WRITER__NAME:
+ return getName();
+ case WritersPackage.WRITER__BOOKS:
+ return getBooks();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case WritersPackage.WRITER__NAME:
+ setName((String)newValue);
+ return;
+ case WritersPackage.WRITER__BOOKS:
+ getBooks().clear();
+ getBooks().addAll((Collection<? extends Book>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case WritersPackage.WRITER__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case WritersPackage.WRITER__BOOKS:
+ getBooks().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case WritersPackage.WRITER__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case WritersPackage.WRITER__BOOKS:
+ return books != null && !books.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy())
+ return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: "); //$NON-NLS-1$
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+} //WriterImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersFactoryImpl.java
new file mode 100644
index 000000000..4d9a3b424
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersFactoryImpl.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.impl;
+
+import org.eclipse.emf.compare.example.library.writers.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersFactoryImpl extends EFactoryImpl implements WritersFactory {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static WritersFactory init() {
+ try {
+ WritersFactory theWritersFactory = (WritersFactory)EPackage.Registry.INSTANCE
+ .getEFactory("http://www.eclipse.org/emf/compare/writers"); //$NON-NLS-1$
+ if (theWritersFactory != null) {
+ return theWritersFactory;
+ }
+ } catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new WritersFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case WritersPackage.CATALOG:
+ return createCatalog();
+ case WritersPackage.WRITER:
+ return createWriter();
+ default:
+ throw new IllegalArgumentException(
+ "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Catalog createCatalog() {
+ CatalogImpl catalog = new CatalogImpl();
+ return catalog;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Writer createWriter() {
+ WriterImpl writer = new WriterImpl();
+ return writer;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersPackage getWritersPackage() {
+ return (WritersPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static WritersPackage getPackage() {
+ return WritersPackage.eINSTANCE;
+ }
+
+} //WritersFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersPackageImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersPackageImpl.java
new file mode 100644
index 000000000..c1cb56095
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/impl/WritersPackageImpl.java
@@ -0,0 +1,276 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.impl;
+
+import org.eclipse.emf.compare.example.library.books.BooksPackage;
+
+import org.eclipse.emf.compare.example.library.books.impl.BooksPackageImpl;
+
+import org.eclipse.emf.compare.example.library.library.LibraryPackage;
+
+import org.eclipse.emf.compare.example.library.library.impl.LibraryPackageImpl;
+
+import org.eclipse.emf.compare.example.library.writers.Catalog;
+import org.eclipse.emf.compare.example.library.writers.Writer;
+import org.eclipse.emf.compare.example.library.writers.WritersFactory;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersPackageImpl extends EPackageImpl implements WritersPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass catalogEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass writerEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private WritersPackageImpl() {
+ super(eNS_URI, WritersFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link WritersPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static WritersPackage init() {
+ if (isInited)
+ return (WritersPackage)EPackage.Registry.INSTANCE.getEPackage(WritersPackage.eNS_URI);
+
+ // Obtain or create and register package
+ WritersPackageImpl theWritersPackage = (WritersPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof WritersPackageImpl ? EPackage.Registry.INSTANCE
+ .get(eNS_URI) : new WritersPackageImpl());
+
+ isInited = true;
+
+ // Obtain or create and register interdependencies
+ LibraryPackageImpl theLibraryPackage = (LibraryPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(LibraryPackage.eNS_URI) instanceof LibraryPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(LibraryPackage.eNS_URI) : LibraryPackage.eINSTANCE);
+ BooksPackageImpl theBooksPackage = (BooksPackageImpl)(EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI) instanceof BooksPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI) : BooksPackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theWritersPackage.createPackageContents();
+ theLibraryPackage.createPackageContents();
+ theBooksPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theWritersPackage.initializePackageContents();
+ theLibraryPackage.initializePackageContents();
+ theBooksPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theWritersPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(WritersPackage.eNS_URI, theWritersPackage);
+ return theWritersPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getCatalog() {
+ return catalogEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getCatalog_Writers() {
+ return (EReference)catalogEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getWriter() {
+ return writerEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getWriter_Name() {
+ return (EAttribute)writerEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getWriter_Books() {
+ return (EReference)writerEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersFactory getWritersFactory() {
+ return (WritersFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated)
+ return;
+ isCreated = true;
+
+ // Create classes and their features
+ catalogEClass = createEClass(CATALOG);
+ createEReference(catalogEClass, CATALOG__WRITERS);
+
+ writerEClass = createEClass(WRITER);
+ createEAttribute(writerEClass, WRITER__NAME);
+ createEReference(writerEClass, WRITER__BOOKS);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized)
+ return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ BooksPackage theBooksPackage = (BooksPackage)EPackage.Registry.INSTANCE
+ .getEPackage(BooksPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(catalogEClass, Catalog.class,
+ "Catalog", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(
+ getCatalog_Writers(),
+ this.getWriter(),
+ null,
+ "writers", null, 0, -1, Catalog.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ initEClass(writerEClass, Writer.class,
+ "Writer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEAttribute(
+ getWriter_Name(),
+ ecorePackage.getEString(),
+ "name", null, 1, 1, Writer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getWriter_Books(),
+ theBooksPackage.getBook(),
+ theBooksPackage.getBook_Authors(),
+ "books", null, 0, -1, Writer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //WritersPackageImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersActionBarContributor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersActionBarContributor.java
new file mode 100644
index 000000000..eb208337c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersActionBarContributor.java
@@ -0,0 +1,441 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.SubContributionItem;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Writers model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the active editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IEditorPart activeEditorPart;
+
+ /**
+ * This keeps track of the current selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionProvider selectionProvider;
+
+ /**
+ * This action opens the Properties view.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction showPropertiesViewAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction refreshViewerAction = new Action(
+ LibraryEditPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
+
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.refresh();
+ }
+ }
+ }
+ };
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createChildActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateChild actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createSiblingActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createSiblingMenuManager;
+
+ /**
+ * This creates an instance of the contributor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersActionBarContributor() {
+ super(ADDITIONS_LAST_STYLE);
+ loadResourceAction = new LoadResourceAction();
+ validateAction = new ValidateAction();
+ controlAction = new ControlAction();
+ }
+
+ /**
+ * This adds Separators for editor additions to the tool bar.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(new Separator("writers-settings")); //$NON-NLS-1$
+ toolBarManager.add(new Separator("writers-additions")); //$NON-NLS-1$
+ }
+
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ IMenuManager submenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_WritersEditor_menu"), "org.eclipse.emf.compare.example.library.writersMenuID"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("additions", submenuManager); //$NON-NLS-1$
+ submenuManager.add(new Separator("settings")); //$NON-NLS-1$
+ submenuManager.add(new Separator("actions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions")); //$NON-NLS-1$
+ submenuManager.add(new Separator("additions-end")); //$NON-NLS-1$
+
+ // Prepare for CreateChild item addition or removal.
+ //
+ createChildMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createChildMenuManager); //$NON-NLS-1$
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(
+ LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ submenuManager.insertBefore("additions", createSiblingMenuManager); //$NON-NLS-1$
+
+ // Force an update because Eclipse hides empty menus now.
+ //
+ submenuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
+
+ addGlobalActions(submenuManager);
+ }
+
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setActiveEditor(IEditorPart part) {
+ super.setActiveEditor(part);
+ activeEditorPart = part;
+
+ // Switch to the new selection provider.
+ //
+ if (selectionProvider != null) {
+ selectionProvider.removeSelectionChangedListener(this);
+ }
+ if (part == null) {
+ selectionProvider = null;
+ } else {
+ selectionProvider = part.getSite().getSelectionProvider();
+ selectionProvider.addSelectionChangedListener(this);
+
+ // Fake a selection changed event to update the menus.
+ //
+ if (selectionProvider.getSelection() != null) {
+ selectionChanged(new SelectionChangedEvent(selectionProvider,
+ selectionProvider.getSelection()));
+ }
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null) {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null) {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null) {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null) {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
+ String contributionID) {
+ if (actions != null) {
+ for (IAction action : actions) {
+ if (contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ } else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
+ if (actions != null) {
+ IContributionItem[] items = manager.getItems();
+ for (int i = 0; i < items.length; i++) {
+ // Look into SubContributionItems
+ //
+ IContributionItem contributionItem = items[i];
+ while (contributionItem instanceof SubContributionItem) {
+ contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+ }
+
+ // Delete the ActionContributionItems with matching action.
+ //
+ if (contributionItem instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem)contributionItem).getAction();
+ if (actions.contains(action)) {
+ manager.remove(contributionItem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This populates the pop-up menu before it appears.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ MenuManager submenuManager = null;
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+
+ submenuManager = new MenuManager(LibraryEditPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ populateManager(submenuManager, createSiblingActions, null);
+ menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
+ }
+
+ /**
+ * This inserts global actions before the "additions-end" separator.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
+
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ menuManager.insertAfter("ui-actions", refreshViewerAction); //$NON-NLS-1$
+
+ super.addGlobalActions(menuManager);
+ }
+
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersEditor.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersEditor.java
new file mode 100644
index 000000000..28796a83a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersEditor.java
@@ -0,0 +1,1799 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.presentation;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.custom.CTabFolder;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.swt.layout.FillLayout;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+
+import org.eclipse.ui.dialogs.SaveAsDialog;
+
+import org.eclipse.ui.ide.IGotoMarker;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.ViewerPane;
+
+import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+
+import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
+
+import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+
+import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+
+import org.eclipse.emf.compare.example.library.writers.provider.WritersItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.books.provider.BooksItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.library.provider.LibraryItemProviderAdapterFactory;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * This is an example of a Writers model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the editing domain that is used to track all changes to the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ /**
+ * This is the one adapter factory used for providing views of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory adapterFactory;
+
+ /**
+ * This is the content outline page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IContentOutlinePage contentOutlinePage;
+
+ /**
+ * This is a kludge...
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStatusLineManager contentOutlineStatusLineManager;
+
+ /**
+ * This is the content outline page's viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer contentOutlineViewer;
+
+ /**
+ * This is the property sheet page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PropertySheetPage propertySheetPage;
+
+ /**
+ * This is the viewer that shadows the selection in the content outline.
+ * The parent relation must be correctly defined for this to work.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer selectionViewer;
+
+ /**
+ * This inverts the roll of parent and child in the content provider and show parents as a tree.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer parentViewer;
+
+ /**
+ * This shows how a tree view works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewer;
+
+ /**
+ * This shows how a list view works.
+ * A list viewer doesn't support icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ListViewer listViewer;
+
+ /**
+ * This shows how a table view works.
+ * A table can be used as a list with icons.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TableViewer tableViewer;
+
+ /**
+ * This shows how a tree view with columns works.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer treeViewerWithColumns;
+
+ /**
+ * This keeps track of the active viewer pane, in the book.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ViewerPane currentViewerPane;
+
+ /**
+ * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Viewer currentViewer;
+
+ /**
+ * This listens to which ever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionChangedListener selectionChangedListener;
+
+ /**
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+
+ /**
+ * This keeps track of the selection of the editor as a whole.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelection editorSelection = StructuredSelection.EMPTY;
+
+ /**
+ * The MarkerHelper is responsible for creating workspace resource markers presented
+ * in Eclipse's Problems View.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected MarkerHelper markerHelper = new EditUIMarkerHelper();
+
+ /**
+ * This listens for when the outline becomes active
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IPartListener partListener = new IPartListener() {
+ public void partActivated(IWorkbenchPart p) {
+ if (p instanceof ContentOutline) {
+ if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
+ getActionBarContributor().setActiveEditor(WritersEditor.this);
+
+ setCurrentViewer(contentOutlineViewer);
+ }
+ } else if (p instanceof PropertySheet) {
+ if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
+ getActionBarContributor().setActiveEditor(WritersEditor.this);
+ handleActivate();
+ }
+ } else if (p == WritersEditor.this) {
+ handleActivate();
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partClosed(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partDeactivated(IWorkbenchPart p) {
+ // Ignore.
+ }
+
+ public void partOpened(IWorkbenchPart p) {
+ // Ignore.
+ }
+ };
+
+ /**
+ * Resources that have been removed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been changed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been saved.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> savedResources = new ArrayList<Resource>();
+
+ /**
+ * Map to store the diagnostic associated with a resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
+
+ /**
+ * Controls whether the problem indication should be updated.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean updateProblemIndication = true;
+
+ /**
+ * Adapter used to update the problem indication when resources are demanded loaded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EContentAdapter problemIndicationAdapter = new EContentAdapter() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof Resource) {
+ switch (notification.getFeatureID(Resource.class)) {
+ case Resource.RESOURCE__IS_LOADED:
+ case Resource.RESOURCE__ERRORS:
+ case Resource.RESOURCE__WARNINGS: {
+ Resource resource = (Resource)notification.getNotifier();
+ Diagnostic diagnostic = analyzeResourceProblems(resource, null);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, diagnostic);
+ } else {
+ resourceToDiagnosticMap.remove(resource);
+ }
+
+ if (updateProblemIndication) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+ break;
+ }
+ }
+ } else {
+ super.notifyChanged(notification);
+ }
+ }
+
+ @Override
+ protected void setTarget(Resource target) {
+ basicSetTarget(target);
+ }
+
+ @Override
+ protected void unsetTarget(Resource target) {
+ basicUnsetTarget(target);
+ }
+ };
+
+ /**
+ * This listens for workspace changes.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ protected ResourceSet resourceSet = editingDomain.getResourceSet();
+
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ public boolean visit(IResourceDelta delta) {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if (delta.getKind() == IResourceDelta.REMOVED
+ || delta.getKind() == IResourceDelta.CHANGED
+ && delta.getFlags() != IResourceDelta.MARKERS) {
+ Resource resource = resourceSet.getResource(
+ URI.createPlatformResourceURI(delta.getFullPath().toString(), true),
+ false);
+ if (resource != null) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ removedResources.add(resource);
+ } else if (!savedResources.remove(resource)) {
+ changedResources.add(resource);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
+
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
+ }
+ }
+
+ final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getPage().closeEditor(WritersEditor.this, false);
+ }
+ }
+ });
+ }
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == WritersEditor.this) {
+ handleActivate();
+ }
+ }
+ });
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * Handles activation of the editor or it's associated views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleActivate() {
+ // Recompute the read only state.
+ //
+ if (editingDomain.getResourceToReadOnlyMap() != null) {
+ editingDomain.getResourceToReadOnlyMap().clear();
+
+ // Refresh any actions that may become enabled or disabled.
+ //
+ setSelection(getSelection());
+ }
+
+ if (!removedResources.isEmpty()) {
+ if (handleDirtyConflict()) {
+ getSite().getPage().closeEditor(WritersEditor.this, false);
+ } else {
+ removedResources.clear();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ } else if (!changedResources.isEmpty()) {
+ changedResources.removeAll(savedResources);
+ handleChangedResources();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+
+ /**
+ * Handles what to do with changed resources on activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void handleChangedResources() {
+ if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
+ editingDomain.getCommandStack().flush();
+
+ updateProblemIndication = false;
+ for (Resource resource : changedResources) {
+ if (resource.isLoaded()) {
+ resource.unload();
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ } catch (IOException exception) {
+ if (!resourceToDiagnosticMap.containsKey(resource)) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ }
+ }
+ }
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+ }
+
+ /**
+ * Updates the problems indication with the information described in the specified diagnostic.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void updateProblemIndication() {
+ if (updateProblemIndication) {
+ BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, null, new Object[] {editingDomain.getResourceSet()});
+ for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
+ if (childDiagnostic.getSeverity() != Diagnostic.OK) {
+ diagnostic.add(childDiagnostic);
+ }
+ }
+
+ int lastEditorPage = getPageCount() - 1;
+ if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
+ ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ setActivePage(lastEditorPage);
+ }
+ } else if (diagnostic.getSeverity() != Diagnostic.OK) {
+ ProblemEditorPart problemEditorPart = new ProblemEditorPart();
+ problemEditorPart.setDiagnostic(diagnostic);
+ problemEditorPart.setMarkerHelper(markerHelper);
+ try {
+ addPage(++lastEditorPage, problemEditorPart, getEditorInput());
+ setPageText(lastEditorPage, problemEditorPart.getPartName());
+ setActivePage(lastEditorPage);
+ showTabs();
+ } catch (PartInitException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
+ markerHelper.deleteMarkers(editingDomain.getResourceSet());
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ try {
+ markerHelper.createMarkers(diagnostic);
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Shows a dialog that asks if conflicting changes should be discarded.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean handleDirtyConflict() {
+ return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), //$NON-NLS-1$
+ getString("_WARN_FileConflict")); //$NON-NLS-1$
+ }
+
+ /**
+ * This creates a model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * This sets up the editing domain for the model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new LibraryItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new BooksItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new WritersItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
+ propertySheetPage.refresh();
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack,
+ new HashMap<Resource, Boolean>());
+ }
+
+ /**
+ * This is here for the listener to be able to call it.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void firePropertyChange(int action) {
+ super.firePropertyChange(action);
+ }
+
+ /**
+ * This sets the selection into whichever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelectionToViewer(Collection<?> collection) {
+ final Collection<?> theSelection = collection;
+ // Make sure it's okay.
+ //
+ if (theSelection != null && !theSelection.isEmpty()) {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ // Try to select the items in the current content viewer of the editor.
+ //
+ if (currentViewer != null) {
+ currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
+ }
+ }
+ };
+ getSite().getShell().getDisplay().asyncExec(runnable);
+ }
+ }
+
+ /**
+ * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
+ * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
+ * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getElements(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object[] getChildren(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ Object parent = super.getParent(object);
+ return parent != null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getParent(Object object) {
+ return null;
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewerPane(ViewerPane viewerPane) {
+ if (currentViewerPane != viewerPane) {
+ if (currentViewerPane != null) {
+ currentViewerPane.showFocus(false);
+ }
+ currentViewerPane = viewerPane;
+ }
+ setCurrentViewer(currentViewerPane.getViewer());
+ }
+
+ /**
+ * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
+ * is the current one.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCurrentViewer(Viewer viewer) {
+ // If it is changing...
+ //
+ if (currentViewer != viewer) {
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener = new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+
+ // Stop listening to the old one.
+ //
+ if (currentViewer != null) {
+ currentViewer.removeSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Start listening to the new one.
+ //
+ if (viewer != null) {
+ viewer.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Remember it.
+ //
+ currentViewer = viewer;
+
+ // Set the editors selection based on the current viewer's selection.
+ //
+ setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
+ }
+ }
+
+ /**
+ * This returns the viewer as required by the {@link IViewerProvider} interface.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Viewer getViewer() {
+ return currentViewer;
+ }
+
+ /**
+ * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
+ contextMenu.add(new Separator("additions")); //$NON-NLS-1$
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu = contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance()};
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain,
+ viewer));
+ }
+
+ /**
+ * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createModel() {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Exception exception = null;
+ Resource resource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ resource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ } catch (Exception e) {
+ exception = e;
+ resource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+
+ Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
+ }
+
+ /**
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
+ if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
+ BasicDiagnostic basicDiagnostic = new BasicDiagnostic(Diagnostic.ERROR,
+ "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception == null ? (Object)resource : exception});
+ basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
+ return basicDiagnostic;
+ } else if (exception != null) {
+ return new BasicDiagnostic(Diagnostic.ERROR, "org.eclipse.emf.compare.example.library", //$NON-NLS-1$
+ 0, getString("_UI_CreateModelError_message", resource.getURI()), //$NON-NLS-1$
+ new Object[] {exception});
+ } else {
+ return Diagnostic.OK_INSTANCE;
+ }
+ }
+
+ /**
+ * This is the method used by the framework to install your own controls.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ // Create a page for the selection tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ selectionViewer = (TreeViewer)viewerPane.getViewer();
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet()
+ .getResources().get(0)), true);
+ viewerPane.setTitle(editingDomain.getResourceSet());
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ }
+
+ // Create a page for the parent tree view.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ parentViewer = (TreeViewer)viewerPane.getViewer();
+ parentViewer.setAutoExpandLevel(30);
+ parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
+ parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(parentViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ParentPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the list viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new ListViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ listViewer = (ListViewer)viewerPane.getViewer();
+ listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(listViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ListPage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the tree viewer
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ treeViewer = (TreeViewer)viewerPane.getViewer();
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(treeViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TableViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ tableViewer = (TableViewer)viewerPane.getViewer();
+
+ Table table = tableViewer.getTable();
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn objectColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(3, 100, true));
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+
+ TableColumn selfColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(2, 100, true));
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+
+ tableViewer.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(tableViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TablePage_label")); //$NON-NLS-1$
+ }
+
+ // This is the page for the table tree viewer.
+ //
+ {
+ ViewerPane viewerPane = new ViewerPane(getSite().getPage(), WritersEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
+
+ Tree tree = treeViewerWithColumns.getTree();
+ tree.setLayoutData(new FillLayout());
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
+ objectColumn.setText(getString("_UI_ObjectColumn_label")); //$NON-NLS-1$
+ objectColumn.setResizable(true);
+ objectColumn.setWidth(250);
+
+ TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
+ selfColumn.setText(getString("_UI_SelfColumn_label")); //$NON-NLS-1$
+ selfColumn.setResizable(true);
+ selfColumn.setWidth(200);
+
+ treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"}); //$NON-NLS-1$ //$NON-NLS-2$
+ treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(treeViewerWithColumns);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); //$NON-NLS-1$
+ }
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ setActivePage(0);
+ }
+ });
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter() {
+ boolean guard = false;
+
+ @Override
+ public void controlResized(ControlEvent event) {
+ if (!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+
+ /**
+ * If there is just one page in the multi-page editor part,
+ * this hides the single tab at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void hideTabs() {
+ if (getPageCount() <= 1) {
+ setPageText(0, ""); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(1);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y + 6);
+ }
+ }
+ }
+
+ /**
+ * If there is more than one page in the multi-page editor part,
+ * this shows the tabs at the bottom.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void showTabs() {
+ if (getPageCount() > 1) {
+ setPageText(0, getString("_UI_SelectionPage_label")); //$NON-NLS-1$
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y - 6);
+ }
+ }
+ }
+
+ /**
+ * This is used to track the active viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void pageChange(int pageIndex) {
+ super.pageChange(pageIndex);
+
+ if (contentOutlinePage != null) {
+ handleContentOutlineSelection(contentOutlinePage.getSelection());
+ }
+ }
+
+ /**
+ * This is how the framework determines which interfaces we implement.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class key) {
+ if (key.equals(IContentOutlinePage.class)) {
+ return showOutlineView() ? getContentOutlinePage() : null;
+ } else if (key.equals(IPropertySheetPage.class)) {
+ return getPropertySheetPage();
+ } else if (key.equals(IGotoMarker.class)) {
+ return this;
+ } else {
+ return super.getAdapter(key);
+ }
+ }
+
+ /**
+ * This accesses a cached version of the content outliner.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IContentOutlinePage getContentOutlinePage() {
+ if (contentOutlinePage == null) {
+ // The content outline is just a tree.
+ //
+ class MyContentOutlinePage extends ContentOutlinePage {
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer
+ .setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ contentOutlineViewer.setInput(editingDomain.getResourceSet());
+
+ // Make sure our popups work.
+ //
+ createContextMenuFor(contentOutlineViewer);
+
+ if (!editingDomain.getResourceSet().getResources().isEmpty()) {
+ // Select the root object in the view.
+ //
+ contentOutlineViewer.setSelection(new StructuredSelection(editingDomain
+ .getResourceSet().getResources().get(0)), true);
+ }
+ }
+
+ @Override
+ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
+ IStatusLineManager statusLineManager) {
+ super.makeContributions(menuManager, toolBarManager, statusLineManager);
+ contentOutlineStatusLineManager = statusLineManager;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ }
+
+ contentOutlinePage = new MyContentOutlinePage();
+
+ // Listen to selection so that we can handle it is a special way.
+ //
+ contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ }
+
+ return contentOutlinePage;
+ }
+
+ /**
+ * This accesses a cached version of the property sheet.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertySheetPage == null) {
+ propertySheetPage = new ExtendedPropertySheetPage(editingDomain) {
+ @Override
+ public void setSelectionToViewer(List<?> selection) {
+ WritersEditor.this.setSelectionToViewer(selection);
+ WritersEditor.this.setFocus();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ };
+ propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+ }
+
+ return propertySheetPage;
+ }
+
+ /**
+ * This deals with how we want selection in the outliner to affect the other views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void handleContentOutlineSelection(ISelection selection) {
+ if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
+ if (selectedElements.hasNext()) {
+ // Get the first selected element.
+ //
+ Object selectedElement = selectedElements.next();
+
+ // If it's the selection viewer, then we want it to select the same selection as this selection.
+ //
+ if (currentViewerPane.getViewer() == selectionViewer) {
+ ArrayList<Object> selectionList = new ArrayList<Object>();
+ selectionList.add(selectedElement);
+ while (selectedElements.hasNext()) {
+ selectionList.add(selectedElements.next());
+ }
+
+ // Set the selection to the widget.
+ //
+ selectionViewer.setSelection(new StructuredSelection(selectionList));
+ } else {
+ // Set the input to the widget.
+ //
+ if (currentViewerPane.getViewer().getInput() != selectedElement) {
+ currentViewerPane.getViewer().setInput(selectedElement);
+ currentViewerPane.setTitle(selectedElement);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply tests the command stack.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+ Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+
+ // Do the work within an operation because this is a long running activity that modifies the workbench.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for (Resource resource : editingDomain.getResourceSet().getResources()) {
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
+ && !editingDomain.isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ } catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource,
+ analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ } catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+
+ /**
+ * This returns whether something has been persisted to the URI of the specified resource.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean isPersisted(Resource resource) {
+ boolean result = false;
+ try {
+ InputStream stream = editingDomain.getResourceSet().getURIConverter()
+ .createInputStream(resource.getURI());
+ if (stream != null) {
+ result = true;
+ stream.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ return result;
+ }
+
+ /**
+ * This always returns true because it is not currently supported.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * This also changes the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSaveAs() {
+ SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
+ saveAsDialog.open();
+ IPath path = saveAsDialog.getResult();
+ if (path != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true),
+ new FileEditorInput(file));
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void doSaveAs(URI uri, IEditorInput editorInput) {
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
+ .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
+ doSave(progressMonitor);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ try {
+ if (marker.getType().equals(EValidator.MARKER)) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+ EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
+ if (eObject != null) {
+ setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
+ }
+ }
+ }
+ } catch (CoreException exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ /**
+ * This is called during startup.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) {
+ setSite(site);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ site.setSelectionProvider(this);
+ site.getPage().addPartListener(partListener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener,
+ IResourceChangeEvent.POST_CHANGE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setFocus() {
+ if (currentViewerPane != null) {
+ currentViewerPane.setFocus();
+ } else {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ISelection getSelection() {
+ return editorSelection;
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
+ * Calling this result will notify the listeners.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelection(ISelection selection) {
+ editorSelection = selection;
+
+ for (ISelectionChangedListener listener : selectionChangedListeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ setStatusLineManager(selection);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setStatusLineManager(ISelection selection) {
+ IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager
+ : getActionBars().getStatusLineManager();
+
+ if (statusLineManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> collection = ((IStructuredSelection)selection).toList();
+ switch (collection.size()) {
+ case 0: {
+ statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
+ break;
+ }
+ case 1: {
+ String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection
+ .iterator().next());
+ statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); //$NON-NLS-1$
+ break;
+ }
+ default: {
+ statusLineManager.setMessage(getString(
+ "_UI_MultiObjectSelected", Integer.toString(collection.size()))); //$NON-NLS-1$
+ break;
+ }
+ }
+ } else {
+ statusLineManager.setMessage(""); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key) {
+ return LibraryEditPlugin.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1) {
+ return LibraryEditPlugin.INSTANCE.getString(key, new Object[] {s1});
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void menuAboutToShow(IMenuManager menuManager) {
+ ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomainActionBarContributor getActionBarContributor() {
+ return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IActionBars getActionBars() {
+ return getActionBarContributor().getActionBars();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public AdapterFactory getAdapterFactory() {
+ return adapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void dispose() {
+ updateProblemIndication = false;
+
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ getSite().getPage().removePartListener(partListener);
+
+ adapterFactory.dispose();
+
+ if (getActionBarContributor().getActiveEditor() == this) {
+ getActionBarContributor().setActiveEditor(null);
+ }
+
+ if (propertySheetPage != null) {
+ propertySheetPage.dispose();
+ }
+
+ if (contentOutlinePage != null) {
+ contentOutlinePage.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * Returns whether the outline view should be presented to the user.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean showOutlineView() {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersModelWizard.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersModelWizard.java
new file mode 100644
index 000000000..15056c2c8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/presentation/WritersModelWizard.java
@@ -0,0 +1,650 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.presentation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.CommonPlugin;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+import org.eclipse.emf.compare.example.library.writers.WritersFactory;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is a simple wizard for creating a new model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersModelWizard extends Wizard implements INewWizard {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS = Collections.unmodifiableList(Arrays
+ .asList(LibraryEditPlugin.INSTANCE
+ .getString("_UI_WritersEditorFilenameExtensions").split("\\s*,\\s*"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS = LibraryEditPlugin.INSTANCE.getString(
+ "_UI_WritersEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /**
+ * This caches an instance of the model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WritersPackage writersPackage = WritersPackage.eINSTANCE;
+
+ /**
+ * This caches an instance of the model factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WritersFactory writersFactory = writersPackage.getWritersFactory();
+
+ /**
+ * This is the file creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WritersModelWizardNewFileCreationPage newFileCreationPage;
+
+ /**
+ * This is the initial object creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WritersModelWizardInitialObjectCreationPage initialObjectCreationPage;
+
+ /**
+ * Remember the selection during initialization for populating the default container.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * Remember the workbench during initialization.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IWorkbench workbench;
+
+ /**
+ * Caches the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected List<String> initialObjectNames;
+
+ /**
+ * This just records the information.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(LibraryEditPlugin.INSTANCE.getString("_UI_Wizard_label")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE
+ .getImageDescriptor(LibraryEditPlugin.INSTANCE.getImage("full/wizban/NewWriters"))); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getInitialObjectNames() {
+ if (initialObjectNames == null) {
+ initialObjectNames = new ArrayList<String>();
+ for (EClassifier eClassifier : writersPackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract()) {
+ initialObjectNames.add(eClass.getName());
+ }
+ }
+ }
+ Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
+ }
+ return initialObjectNames;
+ }
+
+ /**
+ * Create a new model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EObject createInitialModel() {
+ EClass eClass = (EClass)writersPackage.getEClassifier(initialObjectCreationPage
+ .getInitialObjectName());
+ EObject rootObject = writersFactory.create(eClass);
+ return rootObject;
+ }
+
+ /**
+ * Do the work after everything is specified.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI, WritersPackage.eCONTENT_TYPE);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ resource.save(options);
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ } finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor(
+ new FileEditorInput(modelFile),
+ workbench
+ .getEditorRegistry()
+ .getDefaultEditor(
+ modelFile.getFullPath().toString(),
+ Platform.getContentTypeManager().getContentType(
+ WritersPackage.eCONTENT_TYPE)).getId());
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), LibraryEditPlugin.INSTANCE
+ .getString("_UI_OpenEditorError_label"), exception.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+
+ return true;
+ } catch (Exception exception) {
+ LibraryEditPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ /**
+ * This is the one page of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class WritersModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
+ setErrorMessage(LibraryEditPlugin.INSTANCE.getString(key,
+ new Object[] {FORMATTED_FILE_EXTENSIONS}));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(getContainerFullPath().append(getFileName()));
+ }
+ }
+
+ /**
+ * This is the page where the type of object to create is selected.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class WritersModelWizardInitialObjectCreationPage extends WizardPage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo initialObjectField;
+
+ /**
+ * @generated
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ */
+ protected List<String> encodings;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo encodingField;
+
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersModelWizardInitialObjectCreationPage(String pageId) {
+ super(pageId);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 12;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ }
+
+ Label containerLabel = new Label(composite, SWT.LEFT);
+ {
+ containerLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_ModelObject")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ containerLabel.setLayoutData(data);
+ }
+
+ initialObjectField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ initialObjectField.setLayoutData(data);
+ }
+
+ for (String objectName : getInitialObjectNames()) {
+ initialObjectField.add(getLabel(objectName));
+ }
+
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.select(0);
+ }
+ initialObjectField.addModifyListener(validator);
+
+ Label encodingLabel = new Label(composite, SWT.LEFT);
+ {
+ encodingLabel.setText(LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncoding")); //$NON-NLS-1$
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ encodingLabel.setLayoutData(data);
+ }
+ encodingField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ encodingField.setLayoutData(data);
+ }
+
+ for (String encoding : getEncodings()) {
+ encodingField.add(encoding);
+ }
+
+ encodingField.select(0);
+ encodingField.addModifyListener(validator);
+
+ setPageComplete(validatePage());
+ setControl(composite);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ModifyListener validator = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ };
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean validatePage() {
+ return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.clearSelection();
+ encodingField.setFocus();
+ } else {
+ encodingField.clearSelection();
+ initialObjectField.setFocus();
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getInitialObjectName() {
+ String label = initialObjectField.getText();
+
+ for (String name : getInitialObjectNames()) {
+ if (getLabel(name).equals(label)) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getEncoding() {
+ return encodingField.getText();
+ }
+
+ /**
+ * Returns the label for the specified type name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected String getLabel(String typeName) {
+ try {
+ return LibraryEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (MissingResourceException mre) {
+ LibraryEditPlugin.INSTANCE.log(mre);
+ }
+ return typeName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getEncodings() {
+ if (encodings == null) {
+ encodings = new ArrayList<String>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(
+ LibraryEditPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens();) //$NON-NLS-1$
+ {
+ encodings.add(stringTokenizer.nextToken());
+ }
+ }
+ return encodings;
+ }
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ newFileCreationPage = new WritersModelWizardNewFileCreationPage("Whatever", selection); //$NON-NLS-1$
+ newFileCreationPage.setTitle(LibraryEditPlugin.INSTANCE.getString("_UI_WritersModelWizard_label")); //$NON-NLS-1$
+ newFileCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_WritersModelWizard_description")); //$NON-NLS-1$
+ newFileCreationPage.setFileName(LibraryEditPlugin.INSTANCE
+ .getString("_UI_WritersEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ addPage(newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = LibraryEditPlugin.INSTANCE
+ .getString("_UI_WritersEditorFilenameDefaultBase"); //$NON-NLS-1$
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ }
+ newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ initialObjectCreationPage = new WritersModelWizardInitialObjectCreationPage("Whatever2"); //$NON-NLS-1$
+ initialObjectCreationPage.setTitle(LibraryEditPlugin.INSTANCE
+ .getString("_UI_WritersModelWizard_label")); //$NON-NLS-1$
+ initialObjectCreationPage.setDescription(LibraryEditPlugin.INSTANCE
+ .getString("_UI_Wizard_initial_object_description")); //$NON-NLS-1$
+ addPage(initialObjectCreationPage);
+ }
+
+ /**
+ * Get the file from the page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return newFileCreationPage.getModelFile();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/CatalogItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/CatalogItemProvider.java
new file mode 100644
index 000000000..a7012e08f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/CatalogItemProvider.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.compare.example.library.writers.Catalog;
+import org.eclipse.emf.compare.example.library.writers.WritersFactory;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.writers.Catalog} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class CatalogItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CatalogItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(WritersPackage.Literals.CATALOG__WRITERS);
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
+ * This returns Catalog.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/Catalog")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_Catalog_type"); //$NON-NLS-1$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(Catalog.class)) {
+ case WritersPackage.CATALOG__WRITERS:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true,
+ false));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add(createChildParameter(WritersPackage.Literals.CATALOG__WRITERS,
+ WritersFactory.eINSTANCE.createWriter()));
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WriterItemProvider.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WriterItemProvider.java
new file mode 100644
index 000000000..504700d51
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WriterItemProvider.java
@@ -0,0 +1,180 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.compare.example.library.provider.LibraryEditPlugin;
+
+import org.eclipse.emf.compare.example.library.writers.Writer;
+import org.eclipse.emf.compare.example.library.writers.WritersPackage;
+
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.compare.example.library.writers.Writer} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WriterItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WriterItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addNamePropertyDescriptor(object);
+ addBooksPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Name feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addNamePropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Writer_name_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_Writer_name_feature", "_UI_Writer_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ WritersPackage.Literals.WRITER__NAME, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Books feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addBooksPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_Writer_books_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_Writer_books_feature", "_UI_Writer_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ WritersPackage.Literals.WRITER__BOOKS, true, false, true, null, null, null));
+ }
+
+ /**
+ * This returns Writer.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/Writer")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ String label = ((Writer)object).getName();
+ return label == null || label.length() == 0 ? getString("_UI_Writer_type") : //$NON-NLS-1$
+ getString("_UI_Writer_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(Writer.class)) {
+ case WritersPackage.WRITER__NAME:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false,
+ true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return LibraryEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WritersItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WritersItemProviderAdapterFactory.java
new file mode 100644
index 000000000..e901eb1dd
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/provider/WritersItemProviderAdapterFactory.java
@@ -0,0 +1,240 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.compare.example.library.writers.util.WritersAdapterFactory;
+
+import org.eclipse.emf.edit.provider.ChangeNotifier;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.IDisposable;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+
+/**
+ * This is the factory that is used to provide the interfaces needed to support Viewers.
+ * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
+ * The adapters also support Eclipse property sheets.
+ * Note that most of the adapters are shared among multiple instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class WritersItemProviderAdapterFactory extends WritersAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * This keeps track of the root adapter factory that delegates to this adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ComposedAdapterFactory parentAdapterFactory;
+
+ /**
+ * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IChangeNotifier changeNotifier = new ChangeNotifier();
+
+ /**
+ * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Object> supportedTypes = new ArrayList<Object>();
+
+ /**
+ * This constructs an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersItemProviderAdapterFactory() {
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ supportedTypes.add(IItemPropertySource.class);
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.writers.Catalog} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CatalogItemProvider catalogItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.writers.Catalog}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createCatalogAdapter() {
+ if (catalogItemProvider == null) {
+ catalogItemProvider = new CatalogItemProvider(this);
+ }
+
+ return catalogItemProvider;
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.example.library.writers.Writer} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WriterItemProvider writerItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.compare.example.library.writers.Writer}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createWriterAdapter() {
+ if (writerItemProvider == null) {
+ writerItemProvider = new WriterItemProvider(this);
+ }
+
+ return writerItemProvider;
+ }
+
+ /**
+ * This returns the root adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ComposeableAdapterFactory getRootAdapterFactory() {
+ return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
+ }
+
+ /**
+ * This sets the composed adapter factory that contains this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
+ this.parentAdapterFactory = parentAdapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return supportedTypes.contains(type) || super.isFactoryForType(type);
+ }
+
+ /**
+ * This implementation substitutes the factory itself as the key for the adapter.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter adapt(Notifier notifier, Object type) {
+ return super.adapt(notifier, this);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object adapt(Object object, Object type) {
+ if (isFactoryForType(type)) {
+ Object adapter = super.adapt(object, type);
+ if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
+ return adapter;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This adds a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.addListener(notifyChangedListener);
+ }
+
+ /**
+ * This removes a listener.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.removeListener(notifyChangedListener);
+ }
+
+ /**
+ * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void fireNotifyChanged(Notification notification) {
+ changeNotifier.fireNotifyChanged(notification);
+
+ if (parentAdapterFactory != null) {
+ parentAdapterFactory.fireNotifyChanged(notification);
+ }
+ }
+
+ /**
+ * This disposes all of the item providers created by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void dispose() {
+ if (catalogItemProvider != null)
+ catalogItemProvider.dispose();
+ if (writerItemProvider != null)
+ writerItemProvider.dispose();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersAdapterFactory.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersAdapterFactory.java
new file mode 100644
index 000000000..a3d515d59
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersAdapterFactory.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.compare.example.library.writers.*;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage
+ * @generated
+ */
+public class WritersAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static WritersPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = WritersPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected WritersSwitch<Adapter> modelSwitch = new WritersSwitch<Adapter>() {
+ @Override
+ public Adapter caseCatalog(Catalog object) {
+ return createCatalogAdapter();
+ }
+
+ @Override
+ public Adapter caseWriter(Writer object) {
+ return createWriterAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.writers.Catalog <em>Catalog</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.writers.Catalog
+ * @generated
+ */
+ public Adapter createCatalogAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.example.library.writers.Writer <em>Writer</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.compare.example.library.writers.Writer
+ * @generated
+ */
+ public Adapter createWriterAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //WritersAdapterFactory
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceFactoryImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceFactoryImpl.java
new file mode 100644
index 000000000..249f3c51c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceFactoryImpl.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource Factory</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.util.WritersResourceImpl
+ * @generated
+ */
+public class WritersResourceFactoryImpl extends ResourceFactoryImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersResourceFactoryImpl() {
+ super();
+ }
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Resource createResource(URI uri) {
+ Resource result = new WritersResourceImpl(uri);
+ return result;
+ }
+
+} //WritersResourceFactoryImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceImpl.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceImpl.java
new file mode 100644
index 000000000..a2a9dfdc0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersResourceImpl.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.util.WritersResourceFactoryImpl
+ * @generated
+ */
+public class WritersResourceImpl extends XMIResourceImpl {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public WritersResourceImpl(URI uri) {
+ super(uri);
+ }
+
+} //WritersResourceImpl
diff --git a/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersSwitch.java b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersSwitch.java
new file mode 100644
index 000000000..12a99e7e9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.example.library/src-gen/org/eclipse/emf/compare/example/library/writers/util/WritersSwitch.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.example.library.writers.util;
+
+import org.eclipse.emf.compare.example.library.writers.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.compare.example.library.writers.WritersPackage
+ * @generated
+ */
+public class WritersSwitch<T> extends Switch<T> {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String copyright = " Copyright (c) 2011 Obeo.\r\n All rights reserved. This program and the accompanying materials\r\n are made available under the terms of the Eclipse Public License v1.0\r\n which accompanies this distribution, and is available at\r\n http://www.eclipse.org/legal/epl-v10.html\r\n \r\n Contributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
+
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static WritersPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WritersSwitch() {
+ if (modelPackage == null) {
+ modelPackage = WritersPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @parameter ePackage the package in question.
+ * @return whether this is a switch for the given package.
+ * @generated
+ */
+ @Override
+ protected boolean isSwitchFor(EPackage ePackage) {
+ return ePackage == modelPackage;
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case WritersPackage.CATALOG: {
+ Catalog catalog = (Catalog)theEObject;
+ T result = caseCatalog(catalog);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ case WritersPackage.WRITER: {
+ Writer writer = (Writer)theEObject;
+ T result = caseWriter(writer);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Catalog</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Catalog</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseCatalog(Catalog object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Writer</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Writer</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseWriter(Writer object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //WritersSwitch
diff --git a/plugins/org.eclipse.emf.compare.examples.addressbook/about.html b/plugins/org.eclipse.emf.compare.examples.addressbook/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.addressbook/about.html
+++ b/plugins/org.eclipse.emf.compare.examples.addressbook/about.html
diff --git a/plugins/org.eclipse.emf.compare.examples.diff.extension/about.html b/plugins/org.eclipse.emf.compare.examples.diff.extension/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.diff.extension/about.html
+++ b/plugins/org.eclipse.emf.compare.examples.diff.extension/about.html
diff --git a/plugins/org.eclipse.emf.compare.examples.diff.extension/src/org/eclipse/emf/compare/examples/diff/extension/DiffExtensionPlugin.java b/plugins/org.eclipse.emf.compare.examples.diff.extension/src/org/eclipse/emf/compare/examples/diff/extension/DiffExtensionPlugin.java
index b05be691e..b05be691e 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.diff.extension/src/org/eclipse/emf/compare/examples/diff/extension/DiffExtensionPlugin.java
+++ b/plugins/org.eclipse.emf.compare.examples.diff.extension/src/org/eclipse/emf/compare/examples/diff/extension/DiffExtensionPlugin.java
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/about.html b/plugins/org.eclipse.emf.compare.examples.export.xslt/about.html
index 670d10856..670d10856 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/about.html
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/about.html
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.properties b/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.properties
index 40ce23e0e..40ce23e0e 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.properties
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.properties
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.xml b/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.xml
index 2fce31cd5..2fce31cd5 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.xml
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/plugin.xml
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/Messages.java b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/Messages.java
index c5b3c1d04..c5b3c1d04 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/Messages.java
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/Messages.java
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/action/ExportAsHTMLAction.java b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/action/ExportAsHTMLAction.java
index 73c5dc05a..73c5dc05a 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/action/ExportAsHTMLAction.java
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/action/ExportAsHTMLAction.java
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/messages.properties b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/messages.properties
index 82e681e7b..82e681e7b 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/messages.properties
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/messages.properties
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/wizard/ExportAsHTMLWizard.java b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/wizard/ExportAsHTMLWizard.java
index 9a642e027..9a642e027 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/wizard/ExportAsHTMLWizard.java
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/src/org/eclipse/emf/compare/examples/export/xslt/wizard/ExportAsHTMLWizard.java
diff --git a/plugins/org.eclipse.emf.compare.examples.export.xslt/templates/xslt/EMF-DIFF2HTML.xslt b/plugins/org.eclipse.emf.compare.examples.export.xslt/templates/xslt/EMF-DIFF2HTML.xslt
index 115725d4b..115725d4b 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples.export.xslt/templates/xslt/EMF-DIFF2HTML.xslt
+++ b/plugins/org.eclipse.emf.compare.examples.export.xslt/templates/xslt/EMF-DIFF2HTML.xslt
diff --git a/plugins/org.eclipse.emf.compare.examples/plugin.properties b/plugins/org.eclipse.emf.compare.examples/plugin.properties
index 02f5488b3..02f5488b3 100755..100644
--- a/plugins/org.eclipse.emf.compare.examples/plugin.properties
+++ b/plugins/org.eclipse.emf.compare.examples/plugin.properties
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/.classpath b/plugins/org.eclipse.emf.compare.logical.ui/.classpath
new file mode 100644
index 000000000..2d1a4302f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/.gitignore b/plugins/org.eclipse.emf.compare.logical.ui/.gitignore
new file mode 100644
index 000000000..2db576b4a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/.gitignore
@@ -0,0 +1,4 @@
+bin/
+*~
+*.rej
+*.bak
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/.project b/plugins/org.eclipse.emf.compare.logical.ui/.project
new file mode 100644
index 000000000..d76c2ffa2
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.compare.logical.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.compare.logical.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..d985ed6cb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Mar 16 16:04:49 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.logical.ui/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..7ad7b5ce2
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.compare.logical.ui;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.emf.compare,
+ org.eclipse.team.ui,
+ org.eclipse.compare,
+ org.eclipse.team.core,
+ org.eclipse.ui.navigator,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.compare.ui,
+ org.eclipse.emf.compare.logical
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-Activator: org.eclipse.emf.compare.logical.ui.EMFCompareLogicalUIPlugin
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/build.properties b/plugins/org.eclipse.emf.compare.logical.ui/build.properties
new file mode 100644
index 000000000..8665ac2ff
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/plugin.properties b/plugins/org.eclipse.emf.compare.logical.ui/plugin.properties
new file mode 100644
index 000000000..9e1d464df
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/plugin.properties
@@ -0,0 +1,14 @@
+################################################################################
+# Copyright (c) 2006, 2011 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+################################################################################
+pluginName = EMF Compare Logical Resources Integration UI
+providerName = Eclipse Modeling Project
+
+syncProviderName = EMF Compare \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/plugin.xml b/plugins/org.eclipse.emf.compare.logical.ui/plugin.xml
new file mode 100644
index 000000000..14bc5c758
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/plugin.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <!--
+ Providing the synchronization adapter, in charge of providing a compare input from the synchronize view
+ -->
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.emf.compare.logical.model.EMFModelProvider"
+ class="org.eclipse.emf.compare.logical.ui.adapter.EMFCompareAdapterFactory">
+ <adapter
+ type="org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter">
+ </adapter>
+ </factory>
+ </extension>
+ <!--
+ Providing the necessary content provider for the Synchronize view to display the EMF Compare team provider
+ -->
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
+ viewerId="org.eclipse.team.ui.navigatorViewer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.emf.compare.navigator.extension"
+ isRoot="true"/>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+ <extension
+ point="org.eclipse.team.ui.teamContentProviders">
+ <teamContentProvider
+ contentExtensionId="org.eclipse.emf.compare.navigator.extension"
+ modelProviderId="org.eclipse.emf.compare.model.provider">
+ </teamContentProvider>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ id="org.eclipse.emf.compare.navigator.extension"
+ contentProvider="org.eclipse.emf.compare.logical.ui.synchronize.EMFSynchronizationContentProvider"
+ labelProvider="org.eclipse.emf.compare.logical.ui.synchronize.EMFSynchronizationLabelProvider"
+ name="%syncProviderName">
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.emf.compare.logical.model.EMFModelProvider"/>
+ <instanceof value="org.eclipse.team.core.mapping.ISynchronizationScope"/>
+ <instanceof value="org.eclipse.team.core.mapping.ISynchronizationContext"/>
+ </or>
+ </enablement>
+ </navigatorContent>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EMFCompareLogicalUIPlugin.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EMFCompareLogicalUIPlugin.java
new file mode 100644
index 000000000..ebc961c7a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EMFCompareLogicalUIPlugin.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class EMFCompareLogicalUIPlugin extends Plugin {
+ /** The plug-in ID. */
+ public static final String PLUGIN_ID = "org.eclipse.emf.compare.logical.ui"; //$NON-NLS-1$
+
+ /** This plugin's shared instance. */
+ private static EMFCompareLogicalUIPlugin plugin;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ plugin = this;
+ super.start(context);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static EMFCompareLogicalUIPlugin getDefault() {
+ return plugin;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EObjectTypedElement.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EObjectTypedElement.java
new file mode 100644
index 000000000..5df661da8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/EObjectTypedElement.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This implementation of an {@link ITypedElement} will allow us to wrap an EObject.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EObjectTypedElement implements ITypedElement, IStreamContentAccessor {
+ /** This will be used as the type of our wrappers in order to determine the structure and content viewers. */
+ public static final String EMF_TYPE = "EMF.TYPE"; //$NON-NLS-1$
+
+ /** Name of the wrapped EObject. */
+ private final String name;
+
+ /** Icon of the wrapped EObject. */
+ private final Image image;
+
+ /**
+ * Wraps the given <em>eObject</em> within a new {@link ITypedElement}, using the given
+ * {@link ILabelProvider} in order to determine this EObject's text and icon.
+ *
+ * @param eObject
+ * The EObject to wrap.
+ * @param labelProvider
+ * Label provider for the <em>eObject</em>'s text and icon.
+ */
+ public EObjectTypedElement(EObject eObject, ILabelProvider labelProvider) {
+ this.name = labelProvider.getText(eObject);
+ this.image = labelProvider.getImage(eObject);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.compare.IStreamContentAccessor#getContents()
+ */
+ public InputStream getContents() throws CoreException {
+ /*
+ * FIXME this method and its corresponding 'implements' have only been implemented here in order to
+ * work around bug 293926. Remove this as soon as this bug is fixed.
+ */
+ return new ByteArrayInputStream(new byte[] {' '});
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.compare.ITypedElement#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.compare.ITypedElement#getImage()
+ */
+ public Image getImage() {
+ return image;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.compare.ITypedElement#getType()
+ */
+ public String getType() {
+ return EMF_TYPE;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/LogicalModelCompareInput.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/LogicalModelCompareInput.java
new file mode 100644
index 000000000..e94aefc6d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/LogicalModelCompareInput.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSetSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
+import org.eclipse.emf.compare.util.AdapterUtils;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+
+/**
+ * Overrides EMF Compare's {@link ModelCompareInput} in order to return properly typed elements so that
+ * platform compare can find the accurate structure and content viewers.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class LogicalModelCompareInput extends ModelCompareInput {
+ /**
+ * Instantiates our compare input given its comparison result.
+ *
+ * @param snapshot
+ * Result of the comparison we wish to display.
+ */
+ public LogicalModelCompareInput(ComparisonResourceSetSnapshot snapshot) {
+ super(snapshot);
+ }
+
+ /**
+ * Instantiates our compare input given its comparison result.
+ *
+ * @param snapshot
+ * Result of the comparison we wish to display.
+ */
+ public LogicalModelCompareInput(ComparisonResourceSnapshot snapshot) {
+ super(snapshot);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.ui.ModelCompareInput#createTypedElement(org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ protected ITypedElement createTypedElement(EObject eObject) {
+ return new EObjectTypedElement(eObject, new AdapterFactoryLabelProvider(
+ AdapterUtils.getAdapterFactory()));
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/adapter/EMFCompareAdapterFactory.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/adapter/EMFCompareAdapterFactory.java
new file mode 100644
index 000000000..8054ae06d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/adapter/EMFCompareAdapterFactory.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui.adapter;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.emf.compare.logical.model.EMFModelProvider;
+import org.eclipse.emf.compare.logical.model.EMFResourceMapping;
+import org.eclipse.emf.compare.logical.ui.synchronize.EMFCompareSynchronizationAdapter;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
+
+/**
+ * This will be used to adapt EMF types to various parts of the logical model framework.
+ * <p>
+ * Note that the adapting of various objects to {@link ResourceMapping} will not be configured by default,
+ * each project will have to adapt his own {@link Resource}s and {@link EObject}s to {@link ResourceMapping}s
+ * if desired; adapting the generic superclasses that are "{@link Resource}" and "{@link EObject}" would be
+ * too intrusive.
+ * </p>
+ * <p>
+ * A third-party plugin can use this adapter factory for his own objects. For example
+ *
+ * <pre>
+ * &lt;extension point="org.eclipse.core.runtime.adapters">
+ * &lt;factory
+ * adaptableType="org.eclipse.emf.compare.example.library.writers.util.WritersResourceImpl"
+ * class="org.eclipse.emf.compare.logical.adapter.EMFCompareAdapterFactory">
+ * &lt;adapter
+ * type="org.eclipse.core.resources.mapping.ResourceMapping">
+ * &lt;/adapter>
+ * &lt;/factory>
+ * &lt;extension>
+ * </pre>
+ *
+ * will allow "double-click" comparison from the synchronize view on "Writer" objects.
+ * </p>
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class EMFCompareAdapterFactory implements IAdapterFactory {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ Object adapter = null;
+ if (adapterType == ISynchronizationCompareAdapter.class) {
+ if (adaptableObject instanceof EMFModelProvider || adaptableObject instanceof EObject
+ || adaptableObject instanceof Resource) {
+ adapter = new EMFCompareSynchronizationAdapter(EMFModelProvider.PROVIDER_ID);
+ }
+ } else if (adapterType == ResourceMapping.class) {
+ if (adaptableObject instanceof EObject) {
+ adapter = createResourceMapping((EObject)adaptableObject);
+ } else if (adaptableObject instanceof Resource) {
+ adapter = createResourceMapping((Resource)adaptableObject);
+ } else if (adaptableObject instanceof IFile) {
+ adapter = createResourceMapping((IFile)adaptableObject);
+ }
+ }
+ return adapter;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @SuppressWarnings("rawtypes")
+ public Class[] getAdapterList() {
+ return new Class[] {ISynchronizationCompareAdapter.class,};
+ }
+
+ /**
+ * This will try and create a resource mapping for the given EObject.
+ *
+ * @param eObject
+ * The EObject for which we need a resource mapping.
+ * @return The resource mapping if it could be created, <code>null</code> otherwise.
+ */
+ private ResourceMapping createResourceMapping(EObject eObject) {
+ Resource eResource = eObject.eResource();
+ if (eResource != null) {
+ return createResourceMapping(eResource);
+ }
+ return null;
+ }
+
+ /**
+ * This will try and create a resource mapping for the given Resource.
+ *
+ * @param eResource
+ * The EMF Resource for which we need a resource mapping.
+ * @return The resource mapping if it could be created, <code>null</code> otherwise.
+ */
+ private ResourceMapping createResourceMapping(Resource eResource) {
+ IResource iResource = EclipseModelUtils.findIResource(eResource);
+ if (iResource instanceof IFile) {
+ // We'll use our own Resource Set to resolve the logical model
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource emfResource = resourceSet.getResource(eResource.getURI(), true);
+ return new EMFResourceMapping((IFile)iResource, emfResource, EMFModelProvider.PROVIDER_ID);
+ }
+ return null;
+ }
+
+ /**
+ * This will try and create a resource mapping for the given IFile.
+ *
+ * @param iFile
+ * The IFile for which we need a resource mapping.
+ * @return The resource mapping if it could be created, <code>null</code> otherwise.
+ */
+ private ResourceMapping createResourceMapping(IFile iFile) {
+ if (iFile.exists() && iFile.isAccessible()) {
+ Resource eResource = null;
+ try {
+ eResource = EclipseModelUtils.getResource(iFile, new ResourceSetImpl());
+ } catch (IOException e) {
+ // Will return 'null'
+ }
+ if (eResource != null) {
+ return new EMFResourceMapping(iFile, eResource, EMFModelProvider.PROVIDER_ID);
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFCompareSynchronizationAdapter.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFCompareSynchronizationAdapter.java
new file mode 100644
index 000000000..3e0f65e63
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFCompareSynchronizationAdapter.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui.synchronize;
+
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSetSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.logical.model.EMFModelProvider;
+import org.eclipse.emf.compare.logical.synchronization.EMFModelDelta;
+import org.eclipse.emf.compare.logical.ui.LogicalModelCompareInput;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.ui.mapping.SynchronizationCompareAdapter;
+import org.eclipse.ui.IMemento;
+
+/**
+ * This implementation of a {@link SynchronizationCompareAdapter} will be used to determine the difference
+ * between two EMF logical models.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFCompareSynchronizationAdapter extends SynchronizationCompareAdapter {
+ /** Identifier of the model this adapter will compare. */
+ private final String modelProviderId;
+
+ /**
+ * Instantiates our adapter given the identifier of the logical model to compare.
+ *
+ * @param modelProviderId
+ * Identifier of the model this adapter will compare.
+ */
+ public EMFCompareSynchronizationAdapter(String modelProviderId) {
+ this.modelProviderId = modelProviderId;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationCompareAdapter#hasCompareInput(org.eclipse.team.core.mapping.ISynchronizationContext,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean hasCompareInput(ISynchronizationContext context, Object object) {
+ EMFModelDelta delta = EMFModelDelta.getDelta(context);
+ return delta != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationCompareAdapter#asCompareInput(org.eclipse.team.core.mapping.ISynchronizationContext,
+ * java.lang.Object)
+ */
+ @Override
+ public ICompareInput asCompareInput(ISynchronizationContext context, Object object) {
+ EMFModelDelta delta = EMFModelDelta.getDelta(context);
+ if (delta == null) {
+ /*
+ * We'll be here when using "Compare With" actions on a folder, then "open in compare editor" for
+ * one of the files that are part of an EMF model.
+ */
+ try {
+ final ResourceMapping[] mappings = context.getScope().getMappings();
+ if (object instanceof IResource
+ && mappings.length == 1
+ && "org.eclipse.core.resources.modelProvider".equals(mappings[0].getModelProviderId())) { //$NON-NLS-1$
+ ResourceMapping[] additionalMappings = ((EMFModelProvider)ModelProvider
+ .getModelProviderDescriptor(modelProviderId).getModelProvider()).getMappings(
+ (IResource)object, context.getScope().getContext(), new NullProgressMonitor());
+ EMFModelProvider.cacheAdditionalMappings(context, additionalMappings);
+ }
+ initialize(context, new NullProgressMonitor());
+ delta = EMFModelDelta.getDelta(context);
+ } catch (CoreException e) {
+ // FIXME log
+ }
+ }
+
+ ICompareInput input = null;
+ if (delta != null) {
+ if (object instanceof EObject) {
+ input = asCompareInput(context, delta, (EObject)object);
+ } else if (object instanceof Resource) {
+ input = asCompareInput(context, delta, (Resource)object);
+ } else {
+ input = asCompareInput(delta);
+ }
+ }
+ return input;
+ }
+
+ /**
+ * Creates a new compare input for the given delta.
+ *
+ * @return The created compare input.
+ */
+ private ICompareInput asCompareInput(EMFModelDelta delta) {
+ ComparisonSnapshot snapshot = delta.getComparisonSnapshot();
+ if (snapshot instanceof ComparisonResourceSetSnapshot) {
+ return new LogicalModelCompareInput((ComparisonResourceSetSnapshot)snapshot);
+ }
+ return new LogicalModelCompareInput((ComparisonResourceSnapshot)snapshot);
+ }
+
+ /**
+ * Creates a new Compare input for the given EObject given the pre-computed delta.
+ *
+ * @param context
+ * Context from which to extract the saveable buffer.
+ * @param modelDelta
+ * Comparison delta from which to focus on a given EObject.
+ * @param object
+ * The object to focus on.
+ * @return The created compare input.
+ */
+ private ICompareInput asCompareInput(ISynchronizationContext context, EMFModelDelta modelDelta,
+ EObject object) {
+ // FIXME is there a way to set the initial selection of the compare editor? for now, ignore it.
+ return asCompareInput(modelDelta);
+ }
+
+ /**
+ * Creates a new Compare input for the given EMF Resource given the pre-computed delta.
+ *
+ * @param context
+ * Context from which to extract the saveable buffer.
+ * @param modelDelta
+ * Comparison delta from which to focus on a given EMF Resource.
+ * @param resource
+ * The EMF Resource to focus on.
+ * @return The created compare input.
+ */
+ private ICompareInput asCompareInput(ISynchronizationContext context, EMFModelDelta modelDelta,
+ Resource resource) {
+ // FIXME is there a way to set the initial selection of the compare editor? for now, ignore it.
+ return asCompareInput(modelDelta);
+ }
+
+ /**
+ * Initializes this compare adapter given the current synchronization context.
+ *
+ * @param context
+ * The context from which to retrieve comparison information.
+ * @param monitor
+ * Monitor on which to display progress information.
+ * @throws CoreException
+ * Thrown if the comparison failed somehow.
+ */
+ public void initialize(ISynchronizationContext context, IProgressMonitor monitor) throws CoreException {
+ EMFModelDelta.createDelta(context, modelProviderId, monitor);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter#restore(org.eclipse.ui.IMemento)
+ */
+ public ResourceMapping[] restore(IMemento memento) {
+ return new ResourceMapping[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter#save(org.eclipse.core.resources.mapping.ResourceMapping[],
+ * org.eclipse.ui.IMemento)
+ */
+ public void save(ResourceMapping[] mappings, IMemento memento) {
+ // Don't save
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationContentProvider.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationContentProvider.java
new file mode 100644
index 000000000..06a0db7b3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationContentProvider.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui.synchronize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.compare.logical.EMFLogicalModelMessages;
+import org.eclipse.emf.compare.logical.model.EMFModelProvider;
+import org.eclipse.emf.compare.logical.model.EMFResourceMapping;
+import org.eclipse.emf.compare.logical.synchronization.EMFDelta;
+import org.eclipse.emf.compare.logical.synchronization.EMFModelDelta;
+import org.eclipse.emf.compare.util.AdapterUtils;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
+import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
+
+/**
+ * This will be used to provide content information to the synchronize view's navigator when asked about EMF
+ * synchronization state.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFSynchronizationContentProvider extends SynchronizationContentProvider {
+ /** This will be used to determine icons and labels of the EObjects. */
+ private final AdapterFactoryContentProvider delegateContentProvider;
+
+ /** Initialization is a long running process; and we do not want to initialize this more than once. */
+ private boolean isInitializing;
+
+ /**
+ * Instantiates our content provider.
+ */
+ public EMFSynchronizationContentProvider() {
+ this.delegateContentProvider = new AdapterFactoryContentProvider(AdapterUtils.getAdapterFactory());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ delegateContentProvider.dispose();
+ super.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getDelegateContentProvider()
+ */
+ @Override
+ protected ITreeContentProvider getDelegateContentProvider() {
+ return delegateContentProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#isInitialized(org.eclipse.team.core.mapping.ISynchronizationContext)
+ */
+ @Override
+ protected boolean isInitialized(ISynchronizationContext context) {
+ return !isInitializing && context.getCache().get(EMFModelProvider.SYNCHRONIZATION_CACHE_KEY) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#requestInitialization(org.eclipse.team.core.mapping.ISynchronizationContext)
+ */
+ @Override
+ protected void requestInitialization(final ISynchronizationContext context) {
+ if (!isInitializing) {
+ isInitializing = true;
+ Job emfSynchronizationJob = new Job(EMFLogicalModelMessages.getString("synchronize.job.label")) { //$NON-NLS-1$
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ EMFCompareSynchronizationAdapter emfCompareAdapter = null;
+ ModelProvider modelProvider = getModelProvider();
+ if (modelProvider instanceof EMFModelProvider) {
+ Object adapter = modelProvider.getAdapter(ISynchronizationCompareAdapter.class);
+ if (adapter instanceof EMFCompareSynchronizationAdapter) {
+ emfCompareAdapter = (EMFCompareSynchronizationAdapter)adapter;
+ }
+ }
+
+ if (emfCompareAdapter != null) {
+ try {
+ emfCompareAdapter.initialize(context, monitor);
+ } catch (CoreException e) {
+ // FIXME we couldn't carry on with the comparison. Log and let Eclipse do its job
+ }
+ }
+
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ refresh();
+ }
+ });
+
+ isInitializing = false;
+ return Status.OK_STATUS;
+ }
+ };
+ emfSynchronizationJob.schedule();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getChildrenInContext(org.eclipse.team.core.mapping.ISynchronizationContext,
+ * java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ protected Object[] getChildrenInContext(ISynchronizationContext context, Object parent, Object[] children) {
+ Object cachedDelta = context.getCache().get(EMFModelProvider.SYNCHRONIZATION_CACHE_KEY);
+ if (cachedDelta instanceof EMFModelDelta) {
+ EMFModelDelta delta = (EMFModelDelta)cachedDelta;
+ List<Object> childrenInScope = new ArrayList<Object>();
+ for (Object child : children) {
+ EMFDelta childDelta = delta.getChildDeltaFor(child);
+ if (childDelta != null
+ && (childDelta.getKind() == IDiff.NO_CHANGE || includeDirection(childDelta
+ .getDirection()))) {
+ childrenInScope.add(child);
+ }
+ }
+ return childrenInScope.toArray(new Object[childrenInScope.size()]);
+ }
+ return super.getChildrenInContext(context, parent, children);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getTraversals(org.eclipse.team.core.mapping.ISynchronizationContext,
+ * java.lang.Object)
+ */
+ @Override
+ protected ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object) {
+ // We're taking care of the traversal in getChildrenInContext()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getModelProviderId()
+ */
+ @Override
+ protected String getModelProviderId() {
+ return EMFModelProvider.PROVIDER_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getModelRoot()
+ */
+ @Override
+ protected Object getModelRoot() {
+ ResourceSet modelRoot = null;
+ // Try and find the current resource set
+ ResourceMapping[] mappings = getScope().getMappings();
+ for (ResourceMapping mapping : mappings) {
+ if (EMFModelProvider.PROVIDER_ID.equals(mapping.getModelProviderId())
+ && mapping instanceof EMFResourceMapping) {
+ EMFResourceMapping emfMapping = (EMFResourceMapping)mapping;
+ ResourceSet local = emfMapping.getLocalResourceSet();
+
+ if (modelRoot == null || modelRoot.getResources().size() < local.getResources().size()) {
+ modelRoot = local;
+ }
+ }
+ }
+ return modelRoot;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationLabelProvider.java b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationLabelProvider.java
new file mode 100644
index 000000000..7ae86222d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical.ui/src/org/eclipse/emf/compare/logical/ui/synchronize/EMFSynchronizationLabelProvider.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.ui.synchronize;
+
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.compare.logical.model.EMFModelProvider;
+import org.eclipse.emf.compare.logical.synchronization.EMFDelta;
+import org.eclipse.emf.compare.logical.synchronization.EMFModelDelta;
+import org.eclipse.emf.compare.util.AdapterUtils;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.ui.mapping.SynchronizationLabelProvider;
+
+/**
+ * This will be used to provide label information to the synchronize view's navigator when asked about EMF
+ * synchronization state.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFSynchronizationLabelProvider extends SynchronizationLabelProvider {
+ /** Our delegate label provider. */
+ private ILabelProvider delegateLabelProvider;
+
+ /**
+ * Instantiates our label provider.
+ */
+ public EMFSynchronizationLabelProvider() {
+ delegateLabelProvider = new DelegateLabelProvider(AdapterUtils.getAdapterFactory());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#getDelegateLabelProvider()
+ */
+ @Override
+ protected ILabelProvider getDelegateLabelProvider() {
+ return delegateLabelProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ delegateLabelProvider.dispose();
+ super.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#getDiff(java.lang.Object)
+ */
+ @Override
+ protected IDiff getDiff(Object element) {
+ Object cachedDelta = getContext().getCache().get(EMFModelProvider.SYNCHRONIZATION_CACHE_KEY);
+ if (cachedDelta instanceof EMFModelDelta) {
+ EMFDelta elementDelta = ((EMFModelDelta)cachedDelta).getChildDeltaFor(element);
+ if (elementDelta != null) {
+ return elementDelta.getDiff();
+ }
+ }
+ return super.getDiff(element);
+ }
+
+ /**
+ * The objects displayed by this label provider's associated viewer may be wrapped by the logical
+ * resources framework. Thus, a plain {@link AdapterFactoryLabelProvider} could not find the proper label
+ * and icons. We'll use this particular implementation to unwrap the objects before providing them to the
+ * {@link AdapterFactoryLabelProvider}.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+ private class DelegateLabelProvider extends AdapterFactoryLabelProvider {
+ /**
+ * Default constructor.
+ *
+ * @param adapterFactory
+ * The wrapped adapter factory.
+ */
+ public DelegateLabelProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object object) {
+ if (object instanceof ModelProvider) {
+ return ((ModelProvider)object).getDescriptor().getLabel();
+ }
+ return super.getText(unwrap(object));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object object) {
+ return super.getImage(unwrap(object));
+ }
+
+ /**
+ * Unwraps the given Object if it is part of the logical resources framework.
+ *
+ * @param object
+ * Object we are to unwrap.
+ * @return The unwrapped object if it is part of the logical resources framework, <em>object</em>
+ * itself otherwise.
+ */
+ private Object unwrap(Object object) {
+ if (object instanceof ResourceMapping) {
+ return ((ResourceMapping)object).getModelObject();
+ }
+ return object;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/.classpath b/plugins/org.eclipse.emf.compare.logical/.classpath
new file mode 100644
index 000000000..2d1a4302f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.compare.logical/.gitignore b/plugins/org.eclipse.emf.compare.logical/.gitignore
new file mode 100644
index 000000000..2db576b4a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.gitignore
@@ -0,0 +1,4 @@
+bin/
+*~
+*.rej
+*.bak
diff --git a/plugins/org.eclipse.emf.compare.logical/.project b/plugins/org.eclipse.emf.compare.logical/.project
new file mode 100644
index 000000000..1f1aead90
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.compare.logical</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..d985ed6cb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Mar 16 16:04:49 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..4aa4bfb57
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.compare.logical;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.eclipse.emf.compare.logical.EMFCompareLogicalPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.compare,
+ org.eclipse.team.core,
+ org.eclipse.core.filesystem,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.compare.match
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.eclipse.emf.compare.logical,
+ org.eclipse.emf.compare.logical.extension,
+ org.eclipse.emf.compare.logical.model,
+ org.eclipse.emf.compare.logical.synchronization
diff --git a/plugins/org.eclipse.emf.compare.logical/build.properties b/plugins/org.eclipse.emf.compare.logical/build.properties
new file mode 100644
index 000000000..8665ac2ff
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.compare.logical/plugin.properties b/plugins/org.eclipse.emf.compare.logical/plugin.properties
new file mode 100644
index 000000000..f1bd8fbd5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/plugin.properties
@@ -0,0 +1,12 @@
+################################################################################
+# Copyright (c) 2006, 2011 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+################################################################################
+pluginName = EMF Compare Logical Resources Integration
+providerName = Eclipse Modeling Project \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.logical/plugin.xml b/plugins/org.eclipse.emf.compare.logical/plugin.xml
new file mode 100644
index 000000000..939ef71f2
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/plugin.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org.eclipse.emf.compare.modelResolver" name="Model Resolver" schema="schema/ModelResolver.exsd"/>
+
+ <extension
+ id="org.eclipse.emf.compare.model.provider"
+ name="EMF Compare"
+ point="org.eclipse.core.resources.modelProviders">
+ <modelProvider
+ class="org.eclipse.emf.compare.logical.model.EMFModelProvider">
+ </modelProvider>
+ <enablement>
+ <and>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ </adapt>
+ <or>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.compare.ui.contenttype.ModelContentType">
+ </test>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.ecore">
+ </test>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.ecore.xmi">
+ </test>
+ </or>
+ </and>
+ </enablement>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.compare.structureMergeViewers">
+ <viewer
+ class="org.eclipse.emf.compare.ui.viewer.structure.ModelStructureMergeViewerCreator"
+ extensions="EMF.TYPE"
+ id="org.eclipse.emf.compare.logical.ModelStructureMergeViewer"/>
+ </extension>
+ <extension
+ point="org.eclipse.compare.contentMergeViewers">
+ <viewer
+ class="org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewerCreator"
+ extensions="EMF.TYPE"
+ id="org.eclipse.emf.compare.logical.ModelContentMergeViewer"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.emf.compare.logical/schema/ModelResolver.exsd b/plugins/org.eclipse.emf.compare.logical/schema/ModelResolver.exsd
new file mode 100644
index 000000000..c2e76a2f0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/schema/ModelResolver.exsd
@@ -0,0 +1,186 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.compare.logical" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.compare.logical" id="org.eclipse.emf.compare.modelResolver" name="Model Resolver"/>
+ </appinfo>
+ <documentation>
+ This extension point can be used in order to tell EMF Compare how to resolve the resource set of a given IResource.
+
+Take note that EMF Compare will use the very first model resolver that can be applied to a given IResource and discard subsequent ones.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="modelResolver"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="modelResolver">
+ <annotation>
+ <documentation>
+ Describes a Model Resolver and its enablement value.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice>
+ <element ref="fileExtension"/>
+ <element ref="contentType"/>
+ <element ref="namespace"/>
+ </choice>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Fully qualified name of a class that implements org.eclipse.emf.compare.logical.extension.IModelResolver.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.compare.logical.extension.IModelResolver"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="fileExtension">
+ <annotation>
+ <documentation>
+ Extension of the files that this model resolver consider as part of the models it can resolve. Can be multiple file extensions separated with commas.
+
+Note : &quot;*&quot; is accepted as a wildcard for all extensions ... but should not be used as it would prevent any other model resolver to be provided to the framework.
+
+Example : &lt;fileExtension value=&quot;uml, ecore&quot;/&gt;
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contentType">
+ <annotation>
+ <documentation>
+ Content type of the files that this model resolver consider as part of the models it can resolve. Can be multiple content types identifiers separated with commas.
+
+Example : &lt;contentType value=&quot;org.eclipse.emf.ecore, org.eclipse.emf.ecore.xmi&quot;/&gt;
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="namespace">
+ <annotation>
+ <documentation>
+ Namespace of the packages that this model resolver consider as part of the models it can resolve. These correspond to the package NsURI. More than a single NsURI can be set here, comma-separated. They will be interpreted as regular expressions.
+
+Example : &lt;namespace value=&quot;http://www.eclipse.org/uml2/(.*)/UML&quot;/&gt;
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ This is an example that can be used &quot;out of the box&quot; to use the modelResolver extension point with a resolver that will look in the parent of the selected file for other EMF resources that would reference it.
+
+&lt;extension point = &quot;org.eclipse.emf.compare.modelResolver&quot;&gt;
+ &lt;modelResolver class=&quot;org.eclipse.emf.compare.logical.extension.ScopedModelResolver&quot;&gt;
+ &lt;fileExtension value=&quot;uml&quot;/&gt;
+ &lt;/modelResolver&gt;
+&lt;/extension&gt;
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ See org.eclipse.emf.compare.logical.extension.ScopedModelResolver
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011 Obeo.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Obeo - initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFCompareLogicalPlugin.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFCompareLogicalPlugin.java
new file mode 100644
index 000000000..2091ba2f3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFCompareLogicalPlugin.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical;
+
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.emf.compare.logical.extension.EMFCompareExtensionRegistry;
+import org.eclipse.emf.compare.logical.extension.ModelResolverRegistryListener;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class EMFCompareLogicalPlugin extends Plugin {
+ /** The plug-in ID. */
+ public static final String PLUGIN_ID = "org.eclipse.emf.compare.logical"; //$NON-NLS-1$
+
+ /** This plugin's shared instance. */
+ private static EMFCompareLogicalPlugin plugin;
+
+ /** The registry listener that will be used to react to model provider changes. */
+ private ModelResolverRegistryListener modelProviderListener = new ModelResolverRegistryListener();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ plugin = this;
+ super.start(context);
+
+ final IExtensionRegistry registry = Platform.getExtensionRegistry();
+ registry.addListener(modelProviderListener,
+ ModelResolverRegistryListener.MODEL_RESOLVER_EXTENSION_POINT);
+ modelProviderListener.parseInitialContributions();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+
+ final IExtensionRegistry registry = Platform.getExtensionRegistry();
+ registry.removeListener(modelProviderListener);
+ EMFCompareExtensionRegistry.clearRegistry();
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static EMFCompareLogicalPlugin getDefault() {
+ return plugin;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFLogicalModelMessages.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFLogicalModelMessages.java
new file mode 100644
index 000000000..33f406069
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFLogicalModelMessages.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class to access externalized Strings for EMF Compare's logical model integration.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public final class EMFLogicalModelMessages {
+ /** Full qualified path to the properties file in which to seek the keys. */
+ private static final String BUNDLE_NAME = "org.eclipse.emf.compare.logical.emflogicalmodelmessages"; //$NON-NLS-1$
+
+ /** Contains the locale specific {@link String}s needed by this plug-in. */
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ /**
+ * Utility classes don't need to (and shouldn't) be instantiated.
+ */
+ private EMFLogicalModelMessages() {
+ // prevents instantiation
+ }
+
+ /**
+ * This will return an unformatted String from the resource bundle.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @return An unformatted String from the bundle.
+ */
+ private static String internalGetString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Returns the specified {@link String} from the resource bundle.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @return The String from the resource bundle associated with <code>key</code>.
+ * <code>'!' + key + '!'</code> will be returned in case we didn't find it in the bundle.
+ */
+ public static String getString(String key) {
+ // Pass through MessageFormat so that we're consistent in the handling of special chars such as the
+ // apostrophe
+ return MessageFormat.format(internalGetString(key), new Object[] {});
+ }
+
+ /**
+ * Returns a String from the resource bundle bound with the given arguments.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @param arguments
+ * Arguments for the String formatting.
+ * @return formatted {@link String}.
+ * @see MessageFormat#format(String, Object[])
+ */
+ public static String getString(String key, Object... arguments) {
+ if (arguments == null) {
+ return getString(key);
+ }
+ return MessageFormat.format(internalGetString(key), arguments);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/RevisionedURIConverter.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/RevisionedURIConverter.java
new file mode 100644
index 000000000..8cf6bbea1
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/RevisionedURIConverter.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileState;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.util.DelegatingURIConverter;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.history.IFileHistory;
+import org.eclipse.team.core.history.IFileHistoryProvider;
+import org.eclipse.team.core.history.IFileRevision;
+
+/**
+ * This {@link URIConverter} will be used in order to fetch remote contents instead of local contents when
+ * loading resources.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class RevisionedURIConverter extends DelegatingURIConverter {
+ /** The revision of the base resource. This revision's timestamp will be used to resolve proxies. */
+ private IFileRevision baseRevision;
+
+ /**
+ * Instantiates our URI converter given its delegate.
+ *
+ * @param delegate
+ * Our delegate URI converter.
+ * @param storage
+ * IStorage of the base revision against which this URI converter should resolve URIs.
+ * @throws CoreException
+ * This will be thrown if we couldn't adapt the given <em>storage</em> into a file revision.
+ */
+ public RevisionedURIConverter(URIConverter delegate, IStorage storage) throws CoreException {
+ super(delegate);
+
+ setStorage(storage);
+ }
+
+ /**
+ * Sets the storage of the base revision against which this URI converter is to resolve URIs.
+ *
+ * @param storage
+ * IStorage of the base revision against which this URI converter should resolve URIs.
+ * @throws CoreException
+ * This will be thrown if we couldn't adapt the given <em>storage</em> into a file revision.
+ */
+ public void setStorage(IStorage storage) throws CoreException {
+ Object revision = storage.getAdapter(IFileRevision.class);
+ if (!(revision instanceof IFileRevision)) {
+ revision = Platform.getAdapterManager().getAdapter(storage, IFileRevision.class);
+ }
+
+ if (revision instanceof IFileRevision) {
+ baseRevision = (IFileRevision)revision;
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, EMFCompareLogicalPlugin.PLUGIN_ID,
+ EMFLogicalModelMessages.getString("storage.adapt.failure", storage.getFullPath()))); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.util.DelegatingURIConverter#createInputStream(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ InputStream stream = null;
+
+ final URI normalizedUri = normalize(uri);
+ // If this uri points to the plugins directory, load it locally
+ if (normalizedUri.isPlatformPlugin() || normalizedUri.toString().matches("(\\.\\./)+?plugins/.*")) { //$NON-NLS-1$
+ stream = super.createInputStream(normalizedUri, options);
+ } else {
+ // Otherwise, load it from the repository (resource might not yet (or no longer) exist locally)
+ final IResource targetFile;
+ if (normalizedUri.isPlatform()) {
+ targetFile = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(normalizedUri.trimFragment().toPlatformString(true)));
+ } else {
+ /*
+ * FIXME Deresolve the URI against the workspace root, if it cannot be done, delegate to
+ * super.createInputStream()
+ */
+ targetFile = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(normalizedUri.trimFragment().toString()));
+ }
+
+ if (targetFile != null) {
+ stream = openRevisionStream(targetFile);
+ } else {
+ // FIXME The file URI couldn't be resolved in the workspace...
+ }
+
+ if (stream == null) {
+ return super.createInputStream(uri, options);
+ }
+ }
+
+ return stream;
+ }
+
+ /**
+ * Opens an input stream on the contents of the first revision of the file designed by <em>targetURI</em>
+ * which timestamp is inferior or equal to that of {@link #baseRevision}. If no such revision exist, we'll
+ * use the closest to the {@link #baseRevision}'s timestamp we can find, hoping that it does correspond to
+ * the sought revision.
+ * <p>
+ * Take good note that the <em>targetFile</em> may not exist locally. This handle will only serve in order
+ * to retrieve its repository provider.
+ * </p>
+ *
+ * @param targetFile
+ * The resource we seek a revision of.
+ * @return The opened input stream. May be <code>null</code> if we failed to open it.
+ */
+ private InputStream openRevisionStream(IResource targetFile) {
+ InputStream stream = null;
+ final RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(targetFile.getProject());
+
+ if (repositoryProvider != null) {
+ final IFileHistoryProvider historyProvider = repositoryProvider.getFileHistoryProvider();
+ final IFileHistory history = historyProvider.getFileHistoryFor(targetFile,
+ IFileHistoryProvider.NONE, new NullProgressMonitor());
+
+ if (history != null) {
+ /*
+ * This file exists on the repository. Try and find a revision that is older than the base
+ * revision, or the closest higher if no older revision can be found.
+ */
+ IFileRevision soughtRevision = null;
+ for (final IFileRevision revision : history.getFileRevisions()) {
+ if (revision.getTimestamp() <= baseRevision.getTimestamp()) {
+ soughtRevision = revision;
+ break;
+ } else if (soughtRevision == null
+ || soughtRevision.getTimestamp() >= revision.getTimestamp()) {
+ soughtRevision = revision;
+ }
+ }
+
+ if (soughtRevision != null) {
+ try {
+ stream = soughtRevision.getStorage(new NullProgressMonitor()).getContents();
+ } catch (CoreException e) {
+ // FIXME log this : failed to retrieve revision contents
+ }
+ }
+ }
+ }
+
+ if (stream != null && targetFile.exists()) {
+ // Either this file is not connected to a repository, or we failed to retrieve a revision.
+ // Search through local history.
+ try {
+ IFileState soughtState = null;
+ for (final IFileState state : ((IFile)targetFile).getHistory(new NullProgressMonitor())) {
+ if (state.getModificationTime() <= baseRevision.getTimestamp()) {
+ soughtState = state;
+ break;
+ }
+ }
+
+ if (soughtState != null) {
+ stream = soughtState.getContents();
+ } else {
+ stream = ((IFile)targetFile).getContents();
+ }
+ } catch (CoreException e) {
+ // FIXME log this : failed to retrieve local contents
+ }
+ }
+
+ return stream;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/emflogicalmodelmessages.properties b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/emflogicalmodelmessages.properties
new file mode 100644
index 000000000..210b2f027
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/emflogicalmodelmessages.properties
@@ -0,0 +1,13 @@
+################################################################################
+# Copyright (c) 2006, 2011 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+################################################################################
+## note : apostrophes need to be doubled in these messages or they'll be ignored
+synchronize.job.label = Querying EMF synchronization state
+storage.adapt.failure = Failed to retrieve an actual file revision for {0} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/EMFCompareExtensionRegistry.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/EMFCompareExtensionRegistry.java
new file mode 100644
index 000000000..340d7fd95
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/EMFCompareExtensionRegistry.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This will contain all of the EMF Compare extensions parsed from its extension points.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class EMFCompareExtensionRegistry {
+ /** List of all the model resolvers contributed through "org.eclipse.emf.compare.modelResolver". */
+ private static final List<ModelResolverDescriptor> MODEL_RESOLVERS = new ArrayList<ModelResolverDescriptor>();
+
+ /** This class should not be instantiated. */
+ private EMFCompareExtensionRegistry() {
+ // hides default constructor.
+ }
+
+ /**
+ * Adds a model resolver to the registry.
+ *
+ * @param modelResolver
+ * Model resolver that is to be added to its registry.
+ */
+ public static void addModelResolver(ModelResolverDescriptor modelResolver) {
+ MODEL_RESOLVERS.add(modelResolver);
+ }
+
+ /**
+ * Removes all extensions from this registry. This will be called at plugin stopping and should never be
+ * used.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void clearRegistry() {
+ MODEL_RESOLVERS.clear();
+ }
+
+ /**
+ * This will return a copy of the registered model resolvers list.
+ *
+ * @return A copy of the registered model resolvers list.
+ */
+ public static List<ModelResolverDescriptor> getRegisteredModelResolvers() {
+ return new ArrayList<ModelResolverDescriptor>(MODEL_RESOLVERS);
+ }
+
+ /**
+ * Removes a model resolver from this registry.
+ *
+ * @param modelResolverClassName
+ * Qualified class name of the model resolver that is to be removed from the reigstry.
+ */
+ public static void removeModelResolver(String modelResolverClassName) {
+ for (ModelResolverDescriptor descriptor : getRegisteredModelResolvers()) {
+ if (descriptor.getExtensionClassName().equals(modelResolverClassName)) {
+ MODEL_RESOLVERS.remove(descriptor);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/IModelResolver.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/IModelResolver.java
new file mode 100644
index 000000000..f38c0626b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/IModelResolver.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * Implementations of this interface can be used in order to tell EMF Compare how to resolve all of the
+ * Logical model corresponding to a given {@link IFile}.
+ * <p>
+ * The main reason for this is that there is no generic way to find the parent resource of a controlled
+ * fragment if this fragment does not reference its parent explicitely. If "a.ecore" contains "b.ecore", we
+ * cannot find "a.ecore" from "b.ecore" without loading every single model of the workspace and trying to
+ * determine whether they contains links to "b.ecore".
+ * </p>
+ * <p>
+ * The generic algorithm used by EMF Compare is a simple call to
+ * {@link org.eclipse.emf.ecore.util.EcoreUtil#resolveAll(Resource)} on the resource containing the selected
+ * IFile. This only allows us to find the children fragments of the selected file, not its parents. If clients
+ * of the API need a better search for the parent, they should implement this and extend the
+ * <code>org.eclipse.emf.compare.modelResolver</code> extension point.
+ * </p>
+ * <p>
+ * This extension point will only be used in order to resolve the <b>local</b> resource set. When this is
+ * done, we will determine which of the resolved resources is the root of the containment tree, and use it to
+ * resolve the remote resource sets.
+ * </p>
+ * <p>
+ * Take note that the very first model resolver which enablement is <code>true</code> for a given resource
+ * will be used, and the framework will discard others.
+ * </p>
+ * <p>
+ * See also {@link ScopedModelResolver} for an example implementation that seeks through all the base
+ * resource's containing project for cross referencing resources that would be part of its logical model.
+ * </p>
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ * @see org.eclipse.emf.compare.logical.extension.ScopedModelResolver
+ */
+public interface IModelResolver {
+ /**
+ * This will be called by EMF Compare in order to resolve the whole logical model containing the given
+ * Resource. <em>eResource</em> can be either the logical model root or a leaf of its containment
+ * hierarchy.
+ *
+ * @param iFile
+ * The file for which we seek the full logical model.
+ * @param eResource
+ * The EMF {@link Resource} contained by the given <em>file</em>.
+ */
+ void resolve(IFile iFile, Resource eResource);
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverDescriptor.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverDescriptor.java
new file mode 100644
index 000000000..6cece487d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverDescriptor.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.emf.compare.util.ModelIdentifier;
+
+/**
+ * Describes a extension as contributed to the "org.eclipse.emf.compare.modelResolver" extension point.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class ModelResolverDescriptor {
+ /** Name of the attribute holding the {@link IModelResolver} qualified names. */
+ public static final String MODEL_RESOLVER_CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ /** Name of the attribute holding the file extension(s) this resolver applies to. */
+ public static final String MODEL_RESOLVER_FILE_EXTENSION_TAG = "fileExtension"; //$NON-NLS-1$
+
+ /** Name of the attribute holding the content type(s) this resolver applies to. */
+ public static final String MODEL_RESOLVER_CONTENT_TYPE_TAG = "contentType"; //$NON-NLS-1$
+
+ /** Name of the attribute holding the namespace(s) this resolver applies to. */
+ public static final String MODEL_RESOLVER_NAMESPACE_TAG = "namespace"; //$NON-NLS-1$
+
+ /** This attribute is common to the "enablement" tags : fileExtension, contentType, namespace. */
+ public static final String ENABLEMENT_TAG_VALUE = "value"; //$NON-NLS-1$
+
+ /**
+ * This can be used by plugin developers to define a model resolver that applies on "all" file extensions.
+ */
+ public static final String EXTENSIONS_WILDCARD = "*"; //$NON-NLS-1$
+
+ /** All of our "enablement" tags accept comma-separated values. */
+ public static final String VALUE_SEPARATOR = ","; //$NON-NLS-1$
+
+ /** Configuration element of this descriptor. */
+ private final IConfigurationElement element;
+
+ /** Qualified class name of the model resolver. This will be used as an id to remove contributions. */
+ private final String extensionClassName;
+
+ /** Content type(s) of the models this resolver applies to. */
+ private final String contentType;
+
+ /** File extension(s) of the models this resolver applies to. */
+ private final String fileExtension;
+
+ /** Namespace(s) of the models this resolver applies to. */
+ private final String namespace;
+
+ /** We only need to create the instance once, this will keep reference to it. */
+ private IModelResolver modelResolver;
+
+ /**
+ * Creates a descriptor corresponding to the information of the given <em>element</em>.
+ *
+ * @param element
+ * Configuration element from which to create this descriptor.
+ */
+ public ModelResolverDescriptor(IConfigurationElement element) {
+ this.element = element;
+ this.extensionClassName = element.getAttribute(MODEL_RESOLVER_CLASS_ATTRIBUTE);
+
+ IConfigurationElement[] contentTypeConfig = element.getChildren(MODEL_RESOLVER_CONTENT_TYPE_TAG);
+ if (contentTypeConfig.length > 0) {
+ contentType = contentTypeConfig[0].getAttribute(ENABLEMENT_TAG_VALUE);
+ } else {
+ contentType = null;
+ }
+
+ IConfigurationElement[] fileExtensionConfig = element.getChildren(MODEL_RESOLVER_FILE_EXTENSION_TAG);
+ if (fileExtensionConfig.length > 0) {
+ fileExtension = fileExtensionConfig[0].getAttribute(ENABLEMENT_TAG_VALUE);
+ } else {
+ fileExtension = null;
+ }
+
+ IConfigurationElement[] namespaceConfig = element.getChildren(MODEL_RESOLVER_NAMESPACE_TAG);
+ if (namespaceConfig.length > 0) {
+ namespace = namespaceConfig[0].getAttribute(ENABLEMENT_TAG_VALUE);
+ } else {
+ namespace = null;
+ }
+ }
+
+ /**
+ * Returns this descriptor's model resolver qualified name.
+ *
+ * @return This descriptor's model resolver qualified name.
+ */
+ public String getExtensionClassName() {
+ return extensionClassName;
+ }
+
+ /**
+ * Creates an instance of this descriptor's model resolver if needed, then return it.
+ *
+ * @return An instance of this descriptor's model resolver.
+ */
+ public IModelResolver getModelResolver() {
+ if (modelResolver == null) {
+ try {
+ modelResolver = (IModelResolver)element
+ .createExecutableExtension(MODEL_RESOLVER_CLASS_ATTRIBUTE);
+ } catch (CoreException e) {
+ // FIXME log this!
+ }
+ }
+ return modelResolver;
+ }
+
+ /**
+ * This will be used by the framework in order to determine whether this descriptor's model resolver can
+ * be used for the given model identifier.
+ *
+ * @param identifier
+ * Identifier of the EMF Resource which logical model is to be resolved.
+ * @return <code>true</code> if this descriptor's model resolver can be used for the given model
+ * identifier, <code>false</code> otherwise.
+ */
+ public boolean canResolve(ModelIdentifier identifier) {
+ /*
+ * Note that a given model resolver can only have a single one of file extension, namespace or content
+ * type defined
+ */
+ boolean canResolve = false;
+ if (fileExtension != null) {
+ String[] validExtensions = fileExtension.split(VALUE_SEPARATOR);
+ for (String validExtension : validExtensions) {
+ canResolve = identifier.getExtension().equals(validExtension.trim())
+ || EXTENSIONS_WILDCARD.equals(validExtension.trim());
+ }
+ } else if (contentType != null) {
+ String[] validContentTypes = contentType.split(VALUE_SEPARATOR);
+ IContentTypeManager ctManager = Platform.getContentTypeManager();
+ for (int i = 0; i < validContentTypes.length && !canResolve; i++) {
+ IContentType expected = ctManager.getContentType(validContentTypes[i].trim());
+ IContentType actual = ctManager.getContentType(identifier.getContentType());
+ if (expected != null && actual != null) {
+ canResolve = actual.isKindOf(expected);
+ }
+ }
+ } else if (namespace != null) {
+ String[] validNamespaces = namespace.split(VALUE_SEPARATOR);
+ for (String validNamespace : validNamespaces) {
+ canResolve = identifier.getNamespace().matches(validNamespace.trim());
+ }
+ }
+ return canResolve;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverRegistryListener.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverRegistryListener.java
new file mode 100644
index 000000000..66171b928
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResolverRegistryListener.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryEventListener;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * This listener will allow us to be aware of contribution changes against the model resolver extension point.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class ModelResolverRegistryListener implements IRegistryEventListener {
+ /** Name of the extension point to parse for extensions. */
+ public static final String MODEL_RESOLVER_EXTENSION_POINT = "org.eclipse.emf.compare.modelResolver"; //$NON-NLS-1$
+
+ /** Name of the extension point's "modelResolver" tag. */
+ private static final String MODEL_RESOLVER_TAG = "modelResolver"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IRegistryEventListener#added(org.eclipse.core.runtime.IExtension[])
+ */
+ public void added(IExtension[] extensions) {
+ for (IExtension extension : extensions) {
+ parseExtension(extension);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IRegistryEventListener#added(org.eclipse.core.runtime.IExtensionPoint[])
+ */
+ public void added(IExtensionPoint[] extensionPoints) {
+ // no need to listen to this event
+ }
+
+ /**
+ * Though this listener reacts to the extension point changes, there could have been contributions before
+ * it's been registered. This will parse these initial contributions.
+ */
+ public void parseInitialContributions() {
+ final IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ for (IExtension extension : registry.getExtensionPoint(MODEL_RESOLVER_EXTENSION_POINT)
+ .getExtensions()) {
+ parseExtension(extension);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IRegistryEventListener#removed(org.eclipse.core.runtime.IExtension[])
+ */
+ public void removed(IExtension[] extensions) {
+ for (IExtension extension : extensions) {
+ final IConfigurationElement[] configElements = extension.getConfigurationElements();
+ for (IConfigurationElement elem : configElements) {
+ if (MODEL_RESOLVER_TAG.equals(elem.getName())) {
+ final String modelResolverClassName = elem
+ .getAttribute(ModelResolverDescriptor.MODEL_RESOLVER_CLASS_ATTRIBUTE);
+ EMFCompareExtensionRegistry.removeModelResolver(modelResolverClassName);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IRegistryEventListener#removed(org.eclipse.core.runtime.IExtensionPoint[])
+ */
+ public void removed(IExtensionPoint[] extensionPoints) {
+ // no need to listen to this event
+ }
+
+ /**
+ * Parses a single extension contribution.
+ *
+ * @param extension
+ * Parses the given extension and adds its contribution to the registry.
+ */
+ private void parseExtension(IExtension extension) {
+ final IConfigurationElement[] configElements = extension.getConfigurationElements();
+ for (IConfigurationElement element : configElements) {
+ if (MODEL_RESOLVER_TAG.equals(element.getName())) {
+ EMFCompareExtensionRegistry.addModelResolver(new ModelResolverDescriptor(element));
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResourceVisitor.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResourceVisitor.java
new file mode 100644
index 000000000..8c0ef9221
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ModelResourceVisitor.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * This implementation of a resource visitor will allow us to browse all models in a given hierarchy.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class ModelResourceVisitor implements IResourceVisitor {
+ /** Content types of the files to consider as potential parents. */
+ private static final String[] MODEL_CONTENT_TYPES = new String[] {
+ "org.eclipse.emf.compare.ui.contenttype.ModelContentType", "org.eclipse.emf.ecore", //$NON-NLS-1$ //$NON-NLS-2$
+ "org.eclipse.emf.ecore.xmi",}; //$NON-NLS-1$
+
+ /** Resource Set in which we should load the temporary resources. */
+ private final ResourceSet resourceSet;
+
+ /**
+ * Instantiates a resource visitor given the ResourceSet in which to load the temporary resources.
+ *
+ * @param resourceSet
+ * ResourceSet in which to load the temporary resources.
+ */
+ public ModelResourceVisitor(ResourceSet resourceSet) {
+ this.resourceSet = resourceSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource)
+ */
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ boolean isModel = false;
+ for (String contentType : MODEL_CONTENT_TYPES) {
+ if (hasContentType(file, contentType)) {
+ isModel = true;
+ }
+ }
+
+ if (isModel) {
+ try {
+ EclipseModelUtils.getResource(file, resourceSet);
+ return true;
+ } catch (IOException e) {
+ // will return false;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This will return <code>true</code> if and only if the given IFile has the given <em>contentTypeId</em>
+ * configured (as returned by {@link IContentTypeManager#findContentTypesFor(InputStream, String)
+ * Platform.getContentTypeManager().findContentTypesFor(InputStream, String)}.
+ *
+ * @param resource
+ * The resource from which to test the content types.
+ * @param contentTypeId
+ * Fully qualified identifier of the content type this <em>resource</em> has to feature.
+ * @return <code>true</code> if the given {@link IFile} has the given content type.
+ */
+ private boolean hasContentType(IFile resource, String contentTypeId) {
+ IContentTypeManager ctManager = Platform.getContentTypeManager();
+ IContentType expected = ctManager.getContentType(contentTypeId);
+ if (expected == null) {
+ return false;
+ }
+
+ InputStream resourceContent = null;
+ IContentType[] contentTypes = null;
+ try {
+ resourceContent = resource.getContents();
+ contentTypes = ctManager.findContentTypesFor(resourceContent, resource.getName());
+ } catch (CoreException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } catch (IOException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } finally {
+ if (resourceContent != null) {
+ try {
+ resourceContent.close();
+ } catch (IOException e) {
+ // would have already been caught by the outer try, leave the stream open
+ }
+ }
+ }
+
+ boolean hasContentType = false;
+ if (contentTypes != null) {
+ for (int i = 0; i < contentTypes.length && !hasContentType; i++) {
+ if (contentTypes[i].isKindOf(expected)) {
+ hasContentType = true;
+ }
+ }
+ }
+ return hasContentType;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ScopedModelResolver.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ScopedModelResolver.java
new file mode 100644
index 000000000..703fa3b92
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/extension/ScopedModelResolver.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.extension;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * This implementation of an {@link IModelResolver} can be used to search within a given scope (IProject,
+ * IFolder...) containing our base resource for its potential parents.
+ * <p>
+ * Take note that this implementation is generic, and thus extremely costly.
+ * </p>
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class ScopedModelResolver implements IModelResolver {
+ /** Keeps track of the resources we've already walked up. */
+ private Set<Resource> walkedResources = new HashSet<Resource>();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.extension.IModelResolver#resolve(org.eclipse.core.resources.IFile,
+ * org.eclipse.emf.ecore.resource.Resource)
+ */
+ public void resolve(IFile iFile, Resource eResource) {
+ // We'll load every "model" resource we find in this temporary resource set.
+ ResourceSet temporaryResourceSet = new ResourceSetImpl();
+
+ IContainer container = getScope(iFile);
+ try {
+ container.accept(new ModelResourceVisitor(temporaryResourceSet));
+ } catch (CoreException e) {
+ // FIXME log
+ }
+
+ /*
+ * We now have a temporary resource set containing all EMF resources of this project. We'll now try
+ * and find all Resources that reference "eResource".
+ */
+ URI resourceURI = eResource.getURI();
+ Resource baseResource = temporaryResourceSet.getResource(resourceURI, false);
+ if (baseResource != null) {
+ EcoreUtil.CrossReferencer crossReferencer = new EcoreUtil.CrossReferencer(temporaryResourceSet) {
+ private static final long serialVersionUID = 1L;
+
+ {
+ crossReference();
+ }
+ };
+ Set<Resource> crossReferencingResources = findCrossReferencingResources(crossReferencer,
+ baseResource);
+
+ /*
+ * We now know all resources that reference "baseResource", close or far. These compose the whole
+ * logical model which "baseResource" is a part of. Resolve them all in the base resource set.
+ */
+ ResourceSet baseResourceSet = eResource.getResourceSet();
+ for (Resource crossReferencing : crossReferencingResources) {
+ baseResourceSet.getResource(crossReferencing.getURI(), true);
+ }
+
+ // Then, unload every temporary resource we've loaded
+ for (Resource temporaryResource : temporaryResourceSet.getResources()) {
+ temporaryResource.unload();
+ }
+ temporaryResourceSet.getResources().clear();
+ }
+
+ // Ensure that the resource set is fully resolved
+ EcoreUtil.resolveAll(eResource.getResourceSet());
+ }
+
+ /**
+ * This will be used to retrieve the "scope" in which this resolver should seek for referencing Resources.
+ *
+ * @param iFile
+ * The file containing the "selected Resource" of
+ * @return
+ */
+ protected IContainer getScope(IFile iFile) {
+ return iFile.getParent();
+ }
+
+ /**
+ * This will try and find all Resources that reference <em>baseResource</em> by walking its cross
+ * referencing tree.
+ *
+ * @param crossReferencer
+ * Cross referencer initialized on <em>baseResource</em>'s resource set.
+ * @param baseResource
+ * Resource we seek all cross references of.
+ * @return All Resources that reference <em>baseResource</em>.
+ */
+ protected Set<Resource> findCrossReferencingResources(EcoreUtil.CrossReferencer crossReferencer,
+ Resource baseResource) {
+ Set<Resource> crossReferencingResources = new HashSet<Resource>();
+ if (walkedResources.contains(baseResource)) {
+ return crossReferencingResources;
+ }
+ walkedResources.add(baseResource);
+
+ for (EObject root : baseResource.getContents()) {
+ crossReferencingResources.addAll(findCrossReferencingResources(crossReferencer, root));
+
+ Iterator<EObject> rootContent = root.eAllContents();
+ while (rootContent.hasNext()) {
+ crossReferencingResources.addAll(findCrossReferencingResources(crossReferencer,
+ rootContent.next()));
+ }
+ }
+
+ // We also need to walk up the cross referencing tree of those cross referencing resources
+ for (Resource crossReferencing : new HashSet<Resource>(crossReferencingResources)) {
+ crossReferencingResources
+ .addAll(findCrossReferencingResources(crossReferencer, crossReferencing));
+ }
+
+ return crossReferencingResources;
+ }
+
+ /**
+ * This will try and find all Resources that reference <em>object</em> by walking its cross referencing
+ * tree.
+ *
+ * @param crossReferencer
+ * Cross referencer initialized on <em>object</em>'s resource set.
+ * @param object
+ * The object we seek all cross references of.
+ * @return All Resources that reference <em>object</em>.
+ */
+ protected Set<Resource> findCrossReferencingResources(EcoreUtil.CrossReferencer crossReferencer,
+ EObject object) {
+ Set<Resource> crossReferencingResources = new HashSet<Resource>();
+
+ Resource baseResource = object.eResource();
+ Collection<EStructuralFeature.Setting> crossReferences = crossReferencer.get(object);
+ if (crossReferences != null) {
+ Iterator<EStructuralFeature.Setting> crossReferenceIterator = crossReferences.iterator();
+ while (crossReferenceIterator.hasNext()) {
+ EObject nextObject = crossReferenceIterator.next().getEObject();
+ Resource nextResource = nextObject.eResource();
+ if (baseResource != nextResource) {
+ crossReferencingResources.add(nextResource);
+ }
+ }
+ }
+
+ return crossReferencingResources;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFModelProvider.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFModelProvider.java
new file mode 100644
index 000000000..09609269c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFModelProvider.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+
+/**
+ * This implementation of a {@link ModelProvider} will be used to provide the logical model associated with
+ * EMF models.
+ * <p>
+ * Concretely, an EMF model can span multiple physical resources (fragmented models); this model provider can
+ * be used to find all of these associated physical resources.
+ * </p>
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFModelProvider extends ModelProvider {
+ /** ID of this model provider. Must match the definition from the plugin.xml. */
+ public static final String PROVIDER_ID = "org.eclipse.emf.compare.model.provider"; //$NON-NLS-1$
+
+ /** Cache key for the logical model buffer within the synchronization cache. */
+ public static final String SYNCHRONIZATION_CACHE_KEY = EMFModelProvider.PROVIDER_ID + ".sync.cache"; //$NON-NLS-1$
+
+ /** We may need to provide additional mappings to the scope. */
+ private static final String EMF_ADDITIONAL_MAPPINGS = EMFModelProvider.PROVIDER_ID
+ + ".additional.mappings"; //$NON-NLS-1$
+
+ /**
+ * Caches the given mappings within the given synchronization context.
+ *
+ * @param context
+ * Context in which to cache the given additional mappings.
+ * @param additionalMappings
+ * Additional mappings discovered for this context.
+ */
+ public static void cacheAdditionalMappings(ISynchronizationContext context,
+ ResourceMapping[] additionalMappings) {
+ context.getCache().put(EMFModelProvider.EMF_ADDITIONAL_MAPPINGS, additionalMappings);
+ }
+
+ /**
+ * If we needed to retrieve additional mappings for the given context's scope, this will return them.
+ *
+ * @param context
+ * The context to check for additional mappings.
+ * @return The additional mappings for the given context if any, <code>null</code> otherwise.
+ */
+ public static ResourceMapping[] getAdditionalMappings(ISynchronizationContext context) {
+ return (ResourceMapping[])context.getCache().get(EMFModelProvider.EMF_ADDITIONAL_MAPPINGS);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ModelProvider#getMappings(org.eclipse.core.resources.IResource,
+ * org.eclipse.core.resources.mapping.ResourceMappingContext,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ /*
+ * TODO check that this also works when synchronizing a folder containing a fragmented model which
+ * fragment(s) are located in another folder.
+ */
+ if (resource instanceof IFile && resource.exists() && resource.isAccessible()) {
+ return getMappings((IFile)resource, monitor);
+ }
+ return super.getMappings(resource, context, monitor);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ModelProvider#validateChange(org.eclipse.core.resources.IResourceDelta,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public IStatus validateChange(IResourceDelta delta, IProgressMonitor monitor) {
+ // FIXME code this
+ return super.validateChange(delta, monitor);
+ }
+
+ /**
+ * Return the {@link ResourceMapping}s that cover the given {@link IFile}.
+ *
+ * @param file
+ * The file for which to determine mappings.
+ * @param monitor
+ * A progress monitor, or <code>null</code> if progress reporting is not desired.
+ * @return The {@link ResourceMapping}s that cover the given {@link IFile}.
+ */
+ private ResourceMapping[] getMappings(IFile file, IProgressMonitor monitor) {
+ List<ResourceMapping> mappings = new ArrayList<ResourceMapping>();
+ // FIXME find a way to dispose of this resource set
+ try {
+ Resource resource = EclipseModelUtils.getResource(file, createLogicalModelResourceSet());
+ if (resource != null) {
+ mappings.add(new EMFResourceMapping(file, resource, PROVIDER_ID));
+ }
+ } catch (IOException e) {
+ // return an empty array
+ }
+ return mappings.toArray(new ResourceMapping[mappings.size()]);
+ }
+
+ /**
+ * Creates the resource set that should be used to load this model's resources.
+ *
+ * @return The resource set that should be used to load this model's resources.
+ */
+ private ResourceSet createLogicalModelResourceSet() {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ return resourceSet;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFResourceMapping.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFResourceMapping.java
new file mode 100644
index 000000000..c3badf40f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/model/EMFResourceMapping.java
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.logical.RevisionedURIConverter;
+import org.eclipse.emf.compare.logical.extension.EMFCompareExtensionRegistry;
+import org.eclipse.emf.compare.logical.extension.ModelResolverDescriptor;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.compare.util.ModelIdentifier;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+// FIXME find a way to properly dispose of the three resource sets
+/**
+ * This will be used to map EMF {@link Resource}s to their physical {@link IResource}s.
+ * <p>
+ * Take note that this will keep references to all three resource sets (local, remote and ancestor) in order
+ * to avoid doing more than one {@link EcoreUtil#resolveAll(org.eclipse.emf.ecore.resource.ResourceSet)} for
+ * these. We need to do one on each here in order to determine whether either one of them references a
+ * resource that no longer exist in the others.
+ * </p>
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFResourceMapping extends ResourceMapping {
+ /** The physical resource of this mapping. */
+ private final IFile file;
+
+ /** The EMF Resource of this mapping. */
+ private final Resource emfResource;
+
+ /** Keep reference to the local resource set. */
+ private ResourceSet localResourceSet;
+
+ /** Keep reference to the remote resource set. */
+ private ResourceSet remoteResourceSet;
+
+ /** Keep reference to the ancestor resource set. */
+ private ResourceSet ancestorResourceSet;
+
+ /** The Model provider for which this mapping has been created. */
+ private final String providerId;
+
+ /** This will keep track of the {@link IResource}s this logical model spans. */
+ private Set<IResource> iResourcesInScope;
+
+ /** We will use this boolean to prevent us from resolving the full logical model more than once. */
+ private boolean isResolved;
+
+ /**
+ * Instantiates our mapping given both the physical {@link IResource} and the logical {@link Resource}.
+ *
+ * @param file
+ * The physical resource of this mapping.
+ * @param emfResource
+ * The EMF Resource of this mapping.
+ * @param providerId
+ * The Model provider for which this mapping should be created.
+ */
+ public EMFResourceMapping(IFile file, Resource emfResource, String providerId) {
+ this.file = file;
+ this.emfResource = emfResource;
+ this.providerId = providerId;
+ this.localResourceSet = emfResource.getResourceSet();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getModelObject()
+ */
+ @Override
+ public Object getModelObject() {
+ return emfResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getModelProviderId()
+ */
+ @Override
+ public String getModelProviderId() {
+ return providerId;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getProjects()
+ */
+ @Override
+ public IProject[] getProjects() {
+ Set<IResource> physicalResources = resolvePhysicalResources();
+
+ Set<IProject> projects = new LinkedHashSet<IProject>(physicalResources.size());
+ for (IResource iResource : physicalResources) {
+ projects.add(iResource.getProject());
+ }
+
+ return projects.toArray(new IProject[projects.size()]);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getTraversals(org.eclipse.core.resources.mapping.ResourceMappingContext,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
+ throws CoreException {
+ if (!isResolved) {
+ resolveLocalResourceSet();
+
+ if (context instanceof RemoteResourceMappingContext) {
+ RemoteResourceMappingContext remoteContext = (RemoteResourceMappingContext)context;
+
+ for (Resource eResource : localResourceSet.getResources()) {
+ final IFile localFile;
+ if (eResource == emfResource) {
+ localFile = file;
+ } else {
+ localFile = (IFile)EclipseModelUtils.findIResource(eResource);
+ }
+
+ IStorage remoteContents = remoteContext.fetchRemoteContents(localFile, monitor);
+ IStorage ancestorContents = remoteContext.fetchBaseContents(localFile, monitor);
+
+ if (remoteContents != null) {
+ if (remoteResourceSet == null) {
+ remoteResourceSet = createRemoteResourceSet(localFile, remoteContents);
+ } else {
+ RevisionedURIConverter converter = (RevisionedURIConverter)remoteResourceSet
+ .getURIConverter();
+ converter.setStorage(remoteContents);
+ }
+ loadRemoteResource(eResource.getURI(), remoteContents, remoteResourceSet);
+ }
+ if (ancestorContents != null) {
+ if (ancestorResourceSet == null) {
+ ancestorResourceSet = createRemoteResourceSet(localFile, ancestorContents);
+ } else {
+ RevisionedURIConverter converter = (RevisionedURIConverter)ancestorResourceSet
+ .getURIConverter();
+ converter.setStorage(ancestorContents);
+ }
+ loadRemoteResource(eResource.getURI(), ancestorContents, ancestorResourceSet);
+ }
+ }
+
+ // There is a chance that the resource did not exist on the repository
+ if (remoteResourceSet != null) {
+ EcoreUtil.resolveAll(remoteResourceSet);
+ }
+ if (ancestorResourceSet != null) {
+ EcoreUtil.resolveAll(ancestorResourceSet);
+ }
+ }
+
+ resolvePhysicalResources();
+
+ isResolved = true;
+ }
+
+ /*
+ * All of our resource sets are now fully resolved. Browse them to find all IResources than constitute
+ * this logical model, whether they exist locally or not.
+ */
+
+ ResourceTraversal traversal = new ResourceTraversal(
+ iResourcesInScope.toArray(new IResource[iResourcesInScope.size()]), IResource.DEPTH_ONE,
+ IResource.NONE);
+
+ return new ResourceTraversal[] {traversal,};
+ }
+
+ /**
+ * Forces the re-resolution of this resource mapping in the given context.
+ *
+ * @param context
+ * Context in which to replay the model resolving.
+ * @param monitor
+ * Monitor on which to display progress information.
+ * @throws CoreException
+ * Thrown if we cannot resolve the logical model in this context.
+ */
+ public void forceResolving(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ isResolved = false;
+ remoteResourceSet = null;
+ ancestorResourceSet = null;
+ iResourcesInScope = null;
+
+ getTraversals(context, monitor);
+ }
+
+ /**
+ * Returns the resource set in which the local variant of the logical model has been loaded.
+ *
+ * @return The resource set in which the local variant of the logical model has been loaded.
+ */
+ public ResourceSet getLocalResourceSet() {
+ return localResourceSet;
+ }
+
+ /**
+ * Returns the resource set in which the remote variant of the logical model has been loaded.
+ *
+ * @return The resource set in which the remote variant of the logical model has been loaded.
+ */
+ public ResourceSet getRemoteResourceSet() {
+ return remoteResourceSet;
+ }
+
+ /**
+ * Returns the resource set in which the ancestor variant of the logical model has been loaded.
+ *
+ * @return The resource set in which the ancestor variant of the logical model has been loaded.
+ */
+ public ResourceSet getAncestorResourceSet() {
+ return ancestorResourceSet;
+ }
+
+ /**
+ * Browse through all three resource sets and resolve the physical {@link IResource}s than constitute this
+ * logical model.
+ *
+ * @return The list of all physical resources that constitute this logical model.
+ */
+ public Set<IResource> resolvePhysicalResources() {
+ if (localResourceSet == null) {
+ // FIXME throw exception of some kind
+ }
+ if (iResourcesInScope != null) {
+ return iResourcesInScope;
+ }
+
+ iResourcesInScope = new LinkedHashSet<IResource>();
+
+ for (Resource eResource : localResourceSet.getResources()) {
+ if (eResource == emfResource) {
+ iResourcesInScope.add(file);
+ } else {
+ IResource iResource = EclipseModelUtils.findIResource(eResource);
+ if (iResource != null) {
+ iResourcesInScope.add(iResource);
+ }
+ }
+ }
+
+ if (remoteResourceSet != null) {
+ for (Resource eResource : remoteResourceSet.getResources()) {
+ IResource iResource = EclipseModelUtils.findIResource(eResource);
+ if (iResource != null) {
+ iResourcesInScope.add(iResource);
+ }
+ }
+ }
+
+ if (ancestorResourceSet != null) {
+ for (Resource eResource : ancestorResourceSet.getResources()) {
+ IResource iResource = EclipseModelUtils.findIResource(eResource);
+ if (iResource != null) {
+ iResourcesInScope.add(iResource);
+ }
+ }
+ }
+
+ return iResourcesInScope;
+ }
+
+ /**
+ * This will try and resolve all logical resources that constitute this model in the local resource set.
+ *
+ * @return The list of all logical resources that constitute this model.
+ */
+ private void resolveLocalResourceSet() {
+ Iterator<ModelResolverDescriptor> modelResolverIterator = EMFCompareExtensionRegistry
+ .getRegisteredModelResolvers().iterator();
+ boolean resolved = false;
+ while (!resolved && modelResolverIterator.hasNext()) {
+ ModelResolverDescriptor descriptor = modelResolverIterator.next();
+ if (descriptor.canResolve(new ModelIdentifier(emfResource))) {
+ descriptor.getModelResolver().resolve(file, emfResource);
+ resolved = true;
+ }
+ }
+ if (!resolved) {
+ EcoreUtil.resolveAll(localResourceSet);
+ }
+ }
+
+ /**
+ * Loads the given <em>storage</em> as an EMF {@link Resource} in the given resource set..
+ *
+ * @param resourceURI
+ * URI of the resource contained in <em>storage</em>.
+ * @param storage
+ * The {@link IStorage} from which to fetch the parent EMF Resource contents.
+ * @param resourceSet
+ * Resource set in which to load the remote logical model.
+ * @throws CoreException
+ * Thrown if we cannot load this storage as an EMF {@link Resource}.
+ */
+ private static void loadRemoteResource(URI resourceURI, IStorage storage, ResourceSet resourceSet)
+ throws CoreException {
+ Resource resource = resourceSet.createResource(resourceURI);
+
+ InputStream remoteStream = null;
+ try {
+ remoteStream = storage.getContents();
+ resource.load(remoteStream, Collections.emptyMap());
+ } catch (IOException e) {
+ // FIXME log
+ } finally {
+ if (remoteStream != null) {
+ try {
+ remoteStream.close();
+ } catch (IOException e) {
+ // FIXME log
+ }
+ }
+ }
+ }
+
+ /**
+ * This will be used internally in order to create a resource set that can resolve remote URIs against
+ * their actual revision.
+ *
+ * @param baseResource
+ * The first resource that will be loaded from this resource set.
+ * @param storage
+ * The {@link IStorage} that contains the "base" resource (the first we'll load) and against
+ * which timestamp we'll have to resolve URIs.
+ * @return The created resource set.
+ * @throws CoreException
+ * This will be thrown if we cannot retrieve a file revision for the given storage.
+ */
+ private static ResourceSet createRemoteResourceSet(IResource baseResource, IStorage storage)
+ throws CoreException {
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ resourceSet.setURIConverter(new RevisionedURIConverter(resourceSet.getURIConverter(), storage));
+
+ return resourceSet;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFDelta.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFDelta.java
new file mode 100644
index 000000000..da742d68e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFDelta.java
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.synchronization;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IThreeWayDiff;
+import org.eclipse.team.core.diff.ITwoWayDiff;
+
+/**
+ * This class will wraps an {@link IDiff} and serve as the basis of all of our EMF model element deltas.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public abstract class EMFDelta {
+ /** Children of this delta. */
+ private final List<EMFDelta> children = new ArrayList<EMFDelta>();
+
+ /** Parent of this delta. */
+ private EMFDelta parent;
+
+ /**
+ * Create a delta for the given element
+ */
+ public EMFDelta(EMFDelta parent) {
+ this.parent = parent;
+ if (parent != null) {
+ parent.getChildren().add(this);
+ }
+ }
+
+ /**
+ * Clears out the content of this delta.
+ */
+ public void clear() {
+ for (EMFDelta child : getChildren()) {
+ child.clear();
+ }
+ children.clear();
+ }
+
+ /**
+ * Searches through the children of this delta to check whether it contains a delta for the given
+ * <em>object</em>. If <em>this</em> is itself a delta for <em>object</em>, then simply return
+ * <em>this</em>.
+ *
+ * @param object
+ * The object we seek a child delta for.
+ * @return <em>this</em> if it is a delta for <em>object</em>. Otherwise, the child delta if any,
+ * <code>null</code> if none.
+ */
+ public EMFDelta getChildDeltaFor(Object object) {
+ EMFDelta childDelta = null;
+ if (this.isDeltaFor(object)) {
+ return this;
+ }
+
+ // Search the direct children
+ Iterator<EMFDelta> childIterator = getChildren().iterator();
+ while (childDelta == null && childIterator.hasNext()) {
+ EMFDelta child = childIterator.next();
+ if (child.isDeltaFor(object)) {
+ childDelta = child;
+ }
+ }
+
+ // It wasn't a direct children, perform a deep search
+ if (childDelta == null) {
+ childIterator = getChildren().iterator();
+ while (childDelta == null && childIterator.hasNext()) {
+ EMFDelta child = childIterator.next();
+ childDelta = child.getChildDeltaFor(object);
+ }
+ }
+
+ return childDelta;
+ }
+
+ /**
+ * Checks whether this delta represents a change in the given <em>object</em>.
+ *
+ * @param object
+ * The object to consider.
+ * @return <code>true</code> if this delta represents a change in the given <em>object</em>,
+ * <code>false</code> otherwise.
+ */
+ public boolean isDeltaFor(Object object) {
+ Object local = getLocal();
+ Object remote = getRemote();
+ Object ancestor = getAncestor();
+
+ boolean isDelta = false;
+ if (local != null && (local == object || local.equals(object))) {
+ isDelta = true;
+ }
+ if (!isDelta && remote != null && (remote == object || remote.equals(object))) {
+ isDelta = true;
+ }
+ if (!isDelta && ancestor != null && (ancestor == object || ancestor.equals(object))) {
+ isDelta = true;
+ }
+
+ return isDelta;
+ }
+
+ /**
+ * Return all of the children of this delta.
+ *
+ * @return All of the children of this delta.
+ */
+ public List<EMFDelta> getChildren() {
+ return children;
+ }
+
+ /**
+ * Returns the parent of this delta.
+ *
+ * @return The parent of this delta.
+ */
+ public EMFDelta getParent() {
+ return parent;
+ }
+
+ /**
+ * Returns the root of this delta's containing tree.
+ *
+ * @return The root of this delta's containing tree.
+ */
+ public EMFModelDelta getRoot() {
+ EMFDelta parentDelta = getParent();
+ while (parentDelta != null && !(parentDelta instanceof EMFModelDelta)) {
+ parentDelta = parentDelta.getParent();
+ }
+ return (EMFModelDelta)parentDelta;
+ }
+
+ /**
+ * Returns the actual {@link IDiff} behind this delta.
+ *
+ * @return The actual {@link IDiff} behind this delta.
+ */
+ public abstract IDiff getDiff();
+
+ /**
+ * Returns the kind of this difference. This is equivalent to calling {@link #getDiff()}.
+ * {@link IDiff#getKind()}.
+ *
+ * @return Kind of this difference.
+ * @see IDiff#getKind()
+ */
+ public int getKind() {
+ if (getDiff() == null) {
+ return IDiff.NO_CHANGE;
+ }
+ return getDiff().getKind();
+ }
+
+ /**
+ * Returns the direction of this difference.
+ *
+ * @return Direction of this difference.
+ * @see IThreeWayDiff#getDirection()
+ */
+ public int getDirection() {
+ if (getDiff() == null || getDiff() instanceof ITwoWayDiff) {
+ return IDiff.NO_CHANGE;
+ }
+ return ((IThreeWayDiff)getDiff()).getDirection();
+ }
+
+ /**
+ * This will return the {@link IPath} to the object this is a delta for.
+ *
+ * @return The path to the object this is a delta for.
+ */
+ public abstract IPath getPath();
+
+ /**
+ * Creates a child to this delta that will reflect the given {@link DiffElement}.
+ *
+ * @param diffElement
+ * The diff element the newly created child should represent.
+ */
+ protected void createChildDelta(DiffElement diffElement) {
+ if (diffElement instanceof DiffGroup && ((DiffGroup)diffElement).getSubchanges() > 0) {
+ new EMFEObjectDelta(this, (DiffGroup)diffElement);
+ }
+ }
+
+ /**
+ * Returns the remote variant of this delta's model object.
+ *
+ * @return The remote variant of this delta's model object.
+ */
+ public abstract Object getRemote();
+
+ /**
+ * Returns the local variant of this delta's model object.
+ *
+ * @return The local variant of this delta's model object.
+ */
+ public abstract Object getLocal();
+
+ /**
+ * Returns the ancestor variant of this delta's model object.
+ *
+ * @return The ancestor variant of this delta's model object.
+ */
+ public abstract Object getAncestor();
+
+ /**
+ * Creates the children delta for this Resource delta.
+ *
+ * @param diffModel
+ * The diff model from which to retrieve children diffs.
+ */
+ protected abstract void createChildren();
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFEObjectDelta.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFEObjectDelta.java
new file mode 100644
index 000000000..72581ae4f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFEObjectDelta.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.synchronization;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.impl.ConflictingDiffElementImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.ITwoWayDiff;
+import org.eclipse.team.core.diff.provider.ThreeWayDiff;
+import org.eclipse.team.core.diff.provider.TwoWayDiff;
+
+/**
+ * This subclass of an {@link EMFDelta} will act as a container for other deltas. It is the counterpart of EMF
+ * Compare {@link DiffGroup}s.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFEObjectDelta extends EMFDelta {
+ /** Keeps track of the local EObject for which this instance holds deltas. */
+ private EObject localObject;
+
+ /** Keeps track of the remote EObject for which this instance holds deltas. */
+ private EObject remoteObject;
+
+ /** Keeps track of the ancestor EObject for which this instance holds deltas. */
+ private EObject ancestorObject;
+
+ /** The EMF Compare's {@link DiffGroup} this delta reflects. */
+ private DiffGroup diffGroup;
+
+ /** This will only serve in order to decorate the navigator's labels. */
+ private IDiff diff;
+
+ /**
+ * Instantiates this delta given the {@link DiffGroup} it should represent.
+ *
+ * @param parent
+ * Parent of this delta.
+ * @param diffGroup
+ * The DiffGroup for which to create this delta.
+ */
+ public EMFEObjectDelta(EMFDelta parent, DiffGroup diffGroup) {
+ super(parent);
+ this.diffGroup = diffGroup;
+
+ // Find back the three objects to which this group correspond
+ EObject rightObject = diffGroup.getRightParent();
+ String uriFragment = EcoreUtil.getURI(rightObject).fragment();
+
+ EMFDelta resourceDeltaContainer = parent;
+ while (resourceDeltaContainer.getParent() != null
+ && !(resourceDeltaContainer instanceof EMFResourceDelta)) {
+ resourceDeltaContainer = resourceDeltaContainer.getParent();
+ }
+
+ if (resourceDeltaContainer instanceof EMFResourceDelta) {
+ Resource localResource = (Resource)((EMFResourceDelta)resourceDeltaContainer).getLocal();
+ Resource remoteResource = (Resource)((EMFResourceDelta)resourceDeltaContainer).getRemote();
+ Resource ancestorResource = (Resource)((EMFResourceDelta)resourceDeltaContainer).getAncestor();
+
+ localObject = localResource.getEObject(uriFragment);
+ remoteObject = remoteResource.getEObject(uriFragment);
+ if (ancestorResource != null) {
+ ancestorObject = ancestorResource.getEObject(uriFragment);
+ }
+ }
+
+ createChildren();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#clear()
+ */
+ @Override
+ public void clear() {
+ localObject = null;
+ remoteObject = null;
+ ancestorObject = null;
+ diffGroup = null;
+ diff = null;
+
+ super.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getDiff()
+ */
+ @Override
+ public IDiff getDiff() {
+ if (diff == null) {
+ int localKind = IDiff.NO_CHANGE;
+ int remoteKind = IDiff.NO_CHANGE;
+ // Browse the diff group and check wether we have local and/or remote changes
+ Iterator<DiffElement> subDiffIterator = getAllSubDifferences(diffGroup).iterator();
+ while ((localKind == IDiff.NO_CHANGE || remoteKind == IDiff.NO_CHANGE)
+ && subDiffIterator.hasNext()) {
+ DiffElement child = subDiffIterator.next();
+
+ if (child.isRemote()) {
+ remoteKind = IDiff.CHANGE;
+ } else {
+ localKind = IDiff.CHANGE;
+ }
+ }
+
+ if (ancestorObject != null) {
+ ITwoWayDiff localDiff = new TwoWayDiff(getPath(), localKind, 0);
+ ITwoWayDiff remoteDiff = new TwoWayDiff(getPath(), remoteKind, 0);
+ diff = new ThreeWayDiff(localDiff, remoteDiff);
+ } else {
+ diff = new TwoWayDiff(getPath(), localKind, 0);
+ }
+ }
+ return diff;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getRemote()
+ */
+ @Override
+ public Object getRemote() {
+ return remoteObject;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getLocal()
+ */
+ @Override
+ public Object getLocal() {
+ return localObject;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getAncestor()
+ */
+ @Override
+ public Object getAncestor() {
+ return ancestorObject;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ URI uri = EcoreUtil.getURI(diffGroup.getRightParent());
+ return new Path(uri.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#createChildren()
+ */
+ @Override
+ protected void createChildren() {
+ for (DiffElement diffElement : diffGroup.getSubDiffElements()) {
+ createChildDelta(diffElement);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#isDeltaFor(java.lang.Object)
+ */
+ @Override
+ public boolean isDeltaFor(Object object) {
+ if (!(object instanceof EObject)) {
+ // No use going any further
+ return false;
+ }
+
+ // Local and remote could be null, but all three can not
+ final URI objectURI;
+ if (localObject != null) {
+ objectURI = EcoreUtil.getURI(localObject);
+ } else if (remoteObject != null) {
+ objectURI = EcoreUtil.getURI(remoteObject);
+ } else {
+ objectURI = EcoreUtil.getURI(ancestorObject);
+ }
+
+ return objectURI.equals(EcoreUtil.getURI((EObject)object));
+ }
+
+ /**
+ * Returns the list of all sub-differences of the given DiffElement recursively.
+ *
+ * @param element
+ * The element we seek the sub-differences of.
+ * @return The list of all differences under the given {@link DiffElement}, less the sub-DiffGroups
+ * themselves.
+ */
+ private static EList<DiffElement> getAllSubDifferences(DiffElement element) {
+ EList<DiffElement> ownedDifferences = new BasicEList<DiffElement>();
+
+ for (DiffElement diff : element.getSubDiffElements()) {
+ if (diff instanceof DiffGroup || diff instanceof ConflictingDiffElementImpl) {
+ ownedDifferences.addAll(getAllSubDifferences(diff));
+ } else {
+ ownedDifferences.add(diff);
+ }
+ }
+
+ return ownedDifferences;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFModelDelta.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFModelDelta.java
new file mode 100644
index 000000000..f042273b8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFModelDelta.java
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.synchronization;
+
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.compare.EMFCompareException;
+import org.eclipse.emf.compare.EMFComparePlugin;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSetSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.DiffFactory;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.DiffResourceSet;
+import org.eclipse.emf.compare.diff.service.DiffService;
+import org.eclipse.emf.compare.logical.model.EMFModelProvider;
+import org.eclipse.emf.compare.logical.model.EMFResourceMapping;
+import org.eclipse.emf.compare.match.MatchOptions;
+import org.eclipse.emf.compare.match.engine.GenericMatchScopeProvider;
+import org.eclipse.emf.compare.match.metamodel.MatchFactory;
+import org.eclipse.emf.compare.match.metamodel.MatchResourceSet;
+import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.util.EMFCompareMap;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IDiffTree;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+
+/**
+ * This class will serve as the root of our logical model deltas.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFModelDelta extends EMFDelta {
+ /** Identifier of the model provider for which this delta has been created. */
+ private String modelProviderId;
+
+ /** Synchronization context of this delta. */
+ private ISynchronizationContext context;
+
+ /** Keeps track of the local resource set for which this instance holds deltas. */
+ private ResourceSet localResourceSet;
+
+ /** Keeps track of the remote resource set for which this instance holds deltas. */
+ private ResourceSet remoteResourceSet;
+
+ /** Keeps track of the ancestor resource set for which this instance holds deltas. */
+ private ResourceSet ancestorResourceSet;
+
+ /** Cached result of this comparison. */
+ private ComparisonSnapshot comparisonSnapshot;
+
+ /**
+ * Creates the root of our model delta.
+ *
+ * @param context
+ * Synchronization context of this delta.
+ * @param modelProviderId
+ * Identifier of the model provider for which this delta should be created.
+ */
+ private EMFModelDelta(ISynchronizationContext context, String modelProviderId) {
+ super(null);
+ this.modelProviderId = modelProviderId;
+ this.context = context;
+ }
+
+ /**
+ * Initializes a synchronization delta given the identifier of the model provider that required this delta
+ * and the current synchronization context.
+ *
+ * @param context
+ * Synchronization context of this delta.
+ * @param modelProviderId
+ * Identifier of the model provider for which this delta should be created.
+ * @param monitor
+ * Monitor on which to display progress information.
+ * @return The created Synchronization delta.
+ * @throws CoreException
+ * Thrown when the comparison failed somehow.
+ */
+ public static EMFModelDelta createDelta(ISynchronizationContext context, String modelProviderId,
+ IProgressMonitor monitor) throws CoreException {
+ EMFModelDelta delta = new EMFModelDelta(context, modelProviderId);
+
+ delta.initialize(monitor);
+ context.getCache().put(EMFModelProvider.SYNCHRONIZATION_CACHE_KEY, delta);
+
+ return delta;
+ }
+
+ /**
+ * This will return the cached delta within the given context.
+ *
+ * @param context
+ * Context from which to retrieve the cached delta.
+ * @return The cached delta.
+ */
+ public static EMFModelDelta getDelta(ISynchronizationContext context) {
+ return (EMFModelDelta)context.getCache().get(EMFModelProvider.SYNCHRONIZATION_CACHE_KEY);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#clear()
+ */
+ @Override
+ public void clear() {
+ /*
+ * FIXME we're nulling out the references, but the resource mapping isn't disposed ... where could we
+ * unload the resources?
+ */
+ localResourceSet = null;
+ remoteResourceSet = null;
+ ancestorResourceSet = null;
+
+ comparisonSnapshot = null;
+
+ super.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getAncestor()
+ */
+ @Override
+ public Object getAncestor() {
+ return ancestorResourceSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getLocal()
+ */
+ @Override
+ public Object getLocal() {
+ return localResourceSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getRemote()
+ */
+ @Override
+ public Object getRemote() {
+ return remoteResourceSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getDiff()
+ */
+ @Override
+ public IDiff getDiff() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ return Path.EMPTY;
+ }
+
+ /**
+ * Returns the underlying comparison snapshot.
+ *
+ * @return The underlying comparison snapshot.
+ */
+ public ComparisonSnapshot getComparisonSnapshot() {
+ return comparisonSnapshot;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#createChildren()
+ */
+ @Override
+ protected void createChildren() {
+ IDiffTree diffTree = context.getDiffTree();
+
+ if (comparisonSnapshot instanceof ComparisonResourceSetSnapshot) {
+ ComparisonResourceSetSnapshot resourceSetSnapshot = (ComparisonResourceSetSnapshot)comparisonSnapshot;
+
+ for (DiffModel diffModel : resourceSetSnapshot.getDiffResourceSet().getDiffModels()) {
+ // Are there any differences in this model?
+ if (diffModel.getSubchanges() <= 0) {
+ continue;
+ }
+
+ // Find all three resources
+ Resource local = null;
+ Resource remote = null;
+ Resource ancestor = null;
+ Iterator<EObject> leftRootsIterator = diffModel.getLeftRoots().iterator();
+ while (local == null && leftRootsIterator.hasNext()) {
+ EObject leftRoot = leftRootsIterator.next();
+ local = leftRoot.eResource();
+ }
+ Iterator<EObject> rightRootsIterator = diffModel.getRightRoots().iterator();
+ while (remote == null && rightRootsIterator.hasNext()) {
+ EObject rightRoot = rightRootsIterator.next();
+ remote = rightRoot.eResource();
+ }
+ Iterator<EObject> ancestorRootsIterator = diffModel.getAncestorRoots().iterator();
+ while (ancestor == null && ancestorRootsIterator.hasNext()) {
+ EObject ancestorRoot = ancestorRootsIterator.next();
+ ancestor = ancestorRoot.eResource();
+ }
+
+ IResource localResource = EclipseModelUtils.findIResource(local);
+ if (localResource != null) {
+ IDiff diff = diffTree.getDiff(localResource.getFullPath());
+ new EMFResourceDelta(this, diffModel, diff, local, remote, ancestor);
+ }
+ }
+ } else {
+ // We only allow for resource set comparisons
+ }
+ }
+
+ /**
+ * This will be called internally to create or reset the comparison delta.
+ *
+ * @param monitor
+ * Monitor on which to display progress information.
+ * @throws CoreException
+ * Thrown if we did not manage to load the remote resources.
+ */
+ private void initialize(IProgressMonitor monitor) throws CoreException {
+ clear();
+ // FIXME monitor.subTask("comparing models")
+
+ // Retrieve all three resource sets from the scope
+ ResourceMapping[] mappings = EMFModelProvider.getAdditionalMappings(context);
+ if (mappings == null) {
+ mappings = context.getScope().getMappings();
+ }
+
+ for (ResourceMapping mapping : mappings) {
+ if (modelProviderId.equals(mapping.getModelProviderId()) && mapping instanceof EMFResourceMapping) {
+ EMFResourceMapping emfMapping = (EMFResourceMapping)mapping;
+ ResourceSet local = emfMapping.getLocalResourceSet();
+ ResourceSet remote = emfMapping.getRemoteResourceSet();
+ ResourceSet ancestor = emfMapping.getAncestorResourceSet();
+ // If any one of these is null, continue on to the next mapping
+ if (local == null || remote == null || ancestor == null) {
+ // Continue
+ } else if (localResourceSet == null
+ || localResourceSet.getResources().size() < local.getResources().size()) {
+ localResourceSet = local;
+ remoteResourceSet = remote;
+ ancestorResourceSet = ancestor;
+ }
+ }
+ }
+
+ /*
+ * If all three resource sets were null on all mappings, try to force their resolution (called when
+ * using right-click > compare with... actions from an EMF model editor).
+ */
+ if (localResourceSet == null) {
+ // Seek an EMFResourceMapping
+ EMFResourceMapping emfMapping = null;
+ for (int i = 0; i < mappings.length && emfMapping == null; i++) {
+ ResourceMapping mapping = mappings[i];
+ if (modelProviderId.equals(mapping.getModelProviderId())
+ && mapping instanceof EMFResourceMapping) {
+ emfMapping = (EMFResourceMapping)mapping;
+ }
+ }
+
+ if (emfMapping != null) {
+ emfMapping.forceResolving(context.getScope().getContext(), monitor);
+
+ localResourceSet = emfMapping.getLocalResourceSet();
+ remoteResourceSet = emfMapping.getRemoteResourceSet();
+ ancestorResourceSet = emfMapping.getAncestorResourceSet();
+ }
+ }
+
+ // Ask EMF Compare to compute the DiffModel
+ comparisonSnapshot = compare(localResourceSet, remoteResourceSet, ancestorResourceSet, monitor);
+
+ // Then prepare the delta
+ createChildren();
+ }
+
+ /**
+ * This will delegate to the EMF Compare core in order to compare the logical model contained in the given
+ * resource sets.
+ *
+ * @param local
+ * The resource set containing the local variant of the logical model.
+ * @param remote
+ * The resource set containing the remote variant of the logical model.
+ * @param ancestor
+ * The resource set containing the ancestor variant of the logical model.
+ * @param monitor
+ * Monitor on which to display progress information.
+ * @return The result of this comparison.
+ */
+ private ComparisonSnapshot compare(ResourceSet local, ResourceSet remote, ResourceSet ancestor,
+ IProgressMonitor monitor) {
+ // Note that the ancestor can legitimately be null
+ if (local == null || remote == null) {
+ // FIXME throw something at user's face
+ }
+
+ ComparisonSnapshot comparisonResult = doResourceSetCompare(local, remote, ancestor, monitor);
+
+ comparisonResult.setDate(Calendar.getInstance().getTime());
+
+ return comparisonResult;
+ }
+
+ private ComparisonSnapshot doResourceSetCompare(ResourceSet local, ResourceSet remote,
+ ResourceSet ancestor, IProgressMonitor monitor) {
+ final ComparisonResourceSetSnapshot snapshot = DiffFactory.eINSTANCE
+ .createComparisonResourceSetSnapshot();
+ snapshot.setDiffResourceSet(DiffFactory.eINSTANCE.createDiffResourceSet());
+ snapshot.setMatchResourceSet(MatchFactory.eINSTANCE.createMatchResourceSet());
+
+ try {
+ final Map<String, Object> options = new EMFCompareMap<String, Object>();
+ options.put(MatchOptions.OPTION_PROGRESS_MONITOR, monitor);
+
+ final MatchResourceSet match;
+ if (ancestor == null) {
+ options.put(MatchOptions.OPTION_MATCH_SCOPE_PROVIDER, new GenericMatchScopeProvider(local,
+ remote));
+ match = MatchService.doResourceSetMatch(local, remote, options);
+ } else {
+ options.put(MatchOptions.OPTION_MATCH_SCOPE_PROVIDER, new GenericMatchScopeProvider(local,
+ remote, ancestor));
+ match = MatchService.doResourceSetMatch(local, remote, ancestor, options);
+ }
+
+ final DiffResourceSet diff = DiffService.doDiff(match, ancestor != null);
+ snapshot.setDiffResourceSet(diff);
+ snapshot.setMatchResourceSet(match);
+ } catch (final InterruptedException e) {
+ EMFComparePlugin.log(e, false);
+ } catch (final EMFCompareException e) {
+ EMFComparePlugin.log(e, false);
+ }
+
+ return snapshot;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFResourceDelta.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFResourceDelta.java
new file mode 100644
index 000000000..e4cba4c51
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/synchronization/EMFResourceDelta.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.logical.synchronization;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.util.EclipseModelUtils;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.team.core.diff.IDiff;
+
+/**
+ * This subclass of an {@link EMFDelta} will describe changes in EMF Resources.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">laurent Goubet</a>
+ */
+public class EMFResourceDelta extends EMFDelta {
+ /** Keeps track of the local resource for which this instance holds deltas. */
+ private Resource localResource;
+
+ /** Keeps track of the remote resource for which this instance holds deltas. */
+ private Resource remoteResource;
+
+ /** Keeps track of the ancestor resource for which this instance holds deltas. */
+ private Resource ancestorResource;
+
+ /** The actual diff as interpretable by the platform. */
+ private IDiff diff;
+
+ /** The EMF Compare's {@link DiffModel} this delta reflects. */
+ private DiffModel diffModel;
+
+ /**
+ * Instantiates our resource delta given all necessary information.
+ *
+ * @param parent
+ * Our parent model delta.
+ * @param diffModel
+ * The diff model we represent.
+ * @param resourceDiff
+ * The actual resource diff computed by the platform.
+ * @param localResource
+ * The local variant of the resource for which we'll hold deltas.
+ * @param remoteResource
+ * The remote variant of the resource for which we'll hold deltas.
+ * @param ancestorResource
+ * The ancestor variant of the resource for which we'll hold deltas.
+ */
+ public EMFResourceDelta(EMFDelta parent, DiffModel diffModel, IDiff resourceDiff, Resource localResource,
+ Resource remoteResource, Resource ancestorResource) {
+ super(parent);
+ this.diff = resourceDiff;
+ this.diffModel = diffModel;
+ this.localResource = localResource;
+ this.remoteResource = remoteResource;
+ this.ancestorResource = ancestorResource;
+
+ createChildren();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#clear()
+ */
+ @Override
+ public void clear() {
+ localResource = null;
+ remoteResource = null;
+ ancestorResource = null;
+ diff = null;
+ diffModel = null;
+
+ super.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getLocal()
+ */
+ @Override
+ public Object getLocal() {
+ return localResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getAncestor()
+ */
+ @Override
+ public Object getAncestor() {
+ return ancestorResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getRemote()
+ */
+ @Override
+ public Object getRemote() {
+ return remoteResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getDiff()
+ */
+ @Override
+ public IDiff getDiff() {
+ return diff;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ IResource localIResource = EclipseModelUtils.findIResource(localResource);
+ if (localIResource != null) {
+ return localIResource.getFullPath();
+ }
+ return Path.EMPTY;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#isDeltaFor(java.lang.Object)
+ */
+ @Override
+ public boolean isDeltaFor(Object object) {
+ if (!(object instanceof Resource)) {
+ // No use going any further
+ return false;
+ }
+
+ boolean isDelta = false;
+ IResource localIResource = EclipseModelUtils.findIResource(localResource);
+ IResource compareTo = EclipseModelUtils.findIResource((Resource)object);
+ if (localIResource != null && compareTo != null) {
+ isDelta = localIResource.getFullPath().equals(compareTo.getFullPath());
+ }
+ return isDelta;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.logical.synchronization.EMFDelta#createChildren()
+ */
+ @Override
+ protected void createChildren() {
+ // diff models contain a "parentless" diff group as root. Ignore it and switch to its children.
+ if (diffModel.getOwnedElements().size() == 1) {
+ DiffGroup group = (DiffGroup)diffModel.getOwnedElements().get(0);
+ for (DiffElement childDiff : group.getSubDiffElements()) {
+ createChildDelta(childDiff);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/service/MatchService.java b/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/service/MatchService.java
index 7be90979c..8b93dbba1 100644
--- a/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/service/MatchService.java
+++ b/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/service/MatchService.java
@@ -127,8 +127,8 @@ public final class MatchService {
*/
public static MatchModel doMatch(EObject leftRoot, EObject rightRoot, EObject ancestor,
Map<String, Object> options) throws InterruptedException {
- final IMatchEngine engine = getBestMatchEngine(leftRoot.eResource(), rightRoot.eResource(), ancestor
- .eResource());
+ final IMatchEngine engine = getBestMatchEngine(leftRoot.eResource(), rightRoot.eResource(),
+ ancestor.eResource());
final MatchModel result = engine.modelMatch(leftRoot, rightRoot, ancestor, options);
engine.reset();
return result;
@@ -241,8 +241,8 @@ public final class MatchService {
applyExternalFilter(scopeProvider);
final List<Resource> remainingLeftResources = new ArrayList<Resource>(leftResourceSet.getResources());
- final List<Resource> remainingRightResources = new ArrayList<Resource>(rightResourceSet
- .getResources());
+ final List<Resource> remainingRightResources = new ArrayList<Resource>(
+ rightResourceSet.getResources());
applyScopeFilter(leftScope, remainingLeftResources);
applyScopeFilter(rightScope, remainingRightResources);
@@ -329,10 +329,10 @@ public final class MatchService {
final IMatchScope ancestorScope = scopeProvider.getAncestorScope();
applyExternalFilter(scopeProvider);
final List<Resource> remainingLeftResources = new ArrayList<Resource>(leftResourceSet.getResources());
- final List<Resource> remainingRightResources = new ArrayList<Resource>(rightResourceSet
- .getResources());
- final List<Resource> remainingAncestorResources = new ArrayList<Resource>(ancestorResourceSet
- .getResources());
+ final List<Resource> remainingRightResources = new ArrayList<Resource>(
+ rightResourceSet.getResources());
+ final List<Resource> remainingAncestorResources = new ArrayList<Resource>(
+ ancestorResourceSet.getResources());
applyScopeFilter(leftScope, remainingLeftResources);
applyScopeFilter(rightScope, remainingRightResources);
applyScopeFilter(ancestorScope, remainingAncestorResources);
@@ -358,13 +358,15 @@ public final class MatchService {
final Resource matchedRight = findMatchingResource(res, remainingRightResources);
final Resource matchedAncestor = findMatchingResource(res, remainingAncestorResources);
if (matchedRight != null && findMatchingResource(matchedRight, remainingLeftResources) == res) {
- remainingLeftResources.remove(res);
- remainingRightResources.remove(matchedRight);
if (matchedAncestor != null
&& findMatchingResource(matchedAncestor, remainingLeftResources) == res) {
+ remainingLeftResources.remove(res);
+ remainingRightResources.remove(matchedRight);
remainingAncestorResources.remove(matchedAncestor);
match.getMatchModels().add(doResourceMatch(res, matchedRight, matchedAncestor, options));
} else {
+ remainingLeftResources.remove(res);
+ remainingRightResources.remove(matchedRight);
match.getMatchModels().add(doResourceMatch(res, matchedRight, options));
}
} else {
diff --git a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/ModelCompareInput.java b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/ModelCompareInput.java
index ce7d4dbce..4123bd29e 100644
--- a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/ModelCompareInput.java
+++ b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/ModelCompareInput.java
@@ -19,6 +19,9 @@ import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.compare.diff.merge.service.MergeService;
import org.eclipse.emf.compare.diff.metamodel.AttributeChange;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSetSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
import org.eclipse.emf.compare.diff.metamodel.DiffModel;
@@ -64,6 +67,9 @@ public class ModelCompareInput implements ICompareInput {
/** The compare input we've originaly been fed. */
private ICompareInput initialInput;
+ /** If a comparison has already been made, this will hold the corresponding snapshot. */
+ private ComparisonSnapshot comparisonSnapshot;
+
/**
* Creates a CompareInput given the resulting {@link org.eclipse.emf.compare.match.diff.match.MatchModel
* match} and {@link org.eclipse.emf.compare.match.diff.diff.DiffModel diff} of the comparison.
@@ -104,8 +110,7 @@ public class ModelCompareInput implements ICompareInput {
* The input provider which has been used for this comparison.
* @since 1.1
*/
- public ModelCompareInput(MatchModel matchModel, DiffModel diffModel,
- ICompareInputDetailsProvider provider) {
+ public ModelCompareInput(MatchModel matchModel, DiffModel diffModel, ICompareInputDetailsProvider provider) {
this(matchModel, diffModel);
if (provider != null) {
leftResource = provider.getLeftResource();
@@ -139,6 +144,30 @@ public class ModelCompareInput implements ICompareInput {
}
/**
+ * Constructs a {@link ModelCompareInput} wrapped around the given Comparison snapshot.
+ *
+ * @param snapshot
+ * Snapshot of the input's comparison.
+ * @since 1.2
+ */
+ public ModelCompareInput(ComparisonResourceSetSnapshot snapshot) {
+ this(snapshot.getMatchResourceSet(), snapshot.getDiffResourceSet());
+ this.comparisonSnapshot = snapshot;
+ }
+
+ /**
+ * Constructs a {@link ModelCompareInput} wrapped around the given Comparison snapshot.
+ *
+ * @param snapshot
+ * Snapshot of the input's comparison.
+ * @since 1.2
+ */
+ public ModelCompareInput(ComparisonResourceSnapshot snapshot) {
+ this(snapshot.getMatch(), snapshot.getDiff());
+ this.comparisonSnapshot = snapshot;
+ }
+
+ /**
* {@inheritDoc}
*
* @see ICompareInput#addCompareInputChangeListener(ICompareInputChangeListener)
@@ -202,7 +231,7 @@ public class ModelCompareInput implements ICompareInput {
ITypedElement ancestor = null;
if (ancestorResource != null) {
if (ancestorResource.getContents().size() > 0) {
- ancestor = new TypedElementWrapper(ancestorResource.getContents().get(0));
+ ancestor = createTypedElement(ancestorResource.getContents().get(0));
}
} else {
MatchModel matchModel = null;
@@ -212,7 +241,7 @@ public class ModelCompareInput implements ICompareInput {
matchModel = ((MatchResourceSet)match).getMatchModels().get(0);
}
if (matchModel != null && !matchModel.getAncestorRoots().isEmpty()) {
- ancestor = new TypedElementWrapper(matchModel.getAncestorRoots().get(0));
+ ancestor = createTypedElement(matchModel.getAncestorRoots().get(0));
}
}
return ancestor;
@@ -242,6 +271,16 @@ public class ModelCompareInput implements ICompareInput {
}
/**
+ * Returns the comparison snapshot initially fed to this compare input.
+ *
+ * @return The comparison snapshot initially fed to this compare input.
+ * @since 1.2
+ */
+ public ComparisonSnapshot getComparisonSnapshot() {
+ return comparisonSnapshot;
+ }
+
+ /**
* Returns this ModelCompareInput's DiffModel.
*
* @return This ModelCompareInput's DiffModel.
@@ -329,7 +368,7 @@ public class ModelCompareInput implements ICompareInput {
ITypedElement left = null;
if (leftResource != null) {
if (leftResource.getContents().size() > 0) {
- left = new TypedElementWrapper(leftResource.getContents().get(0));
+ left = createTypedElement(leftResource.getContents().get(0));
}
} else {
MatchModel matchModel = null;
@@ -339,9 +378,9 @@ public class ModelCompareInput implements ICompareInput {
matchModel = ((MatchResourceSet)match).getMatchModels().get(0);
}
if (matchModel == null || matchModel.getLeftRoots().isEmpty()) {
- left = new TypedElementWrapper(null);
+ left = createTypedElement(null);
} else {
- left = new TypedElementWrapper(matchModel.getLeftRoots().get(0));
+ left = createTypedElement(matchModel.getLeftRoots().get(0));
}
}
return left;
@@ -407,7 +446,7 @@ public class ModelCompareInput implements ICompareInput {
ITypedElement right = null;
if (rightResource != null) {
if (rightResource.getContents().size() > 0) {
- right = new TypedElementWrapper(rightResource.getContents().get(0));
+ right = createTypedElement(rightResource.getContents().get(0));
}
} else {
MatchModel matchModel = null;
@@ -417,9 +456,9 @@ public class ModelCompareInput implements ICompareInput {
matchModel = ((MatchResourceSet)match).getMatchModels().get(0);
}
if (matchModel == null || matchModel.getRightRoots().isEmpty()) {
- right = new TypedElementWrapper(null);
+ right = createTypedElement(null);
} else {
- right = new TypedElementWrapper(matchModel.getRightRoots().get(0));
+ right = createTypedElement(matchModel.getRightRoots().get(0));
}
}
return right;
@@ -496,4 +535,17 @@ public class ModelCompareInput implements ICompareInput {
listener.compareInputChanged(this);
}
}
+
+ /**
+ * Creates the {@link ITypedElement} that is to be returned from all three of {@link #getAncestor()},
+ * {@link #getLeft()} and {@link #getRight()}.
+ *
+ * @param eObject
+ * EObject we are to wrap within an {@link ITypedElement}.
+ * @return {@link ITypedElement} to be returned for this compare input's sides.
+ * @since 1.2
+ */
+ protected ITypedElement createTypedElement(EObject eObject) {
+ return new TypedElementWrapper(eObject);
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/internal/ModelComparator.java b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/internal/ModelComparator.java
index dd74a0c39..1fa0126d4 100644
--- a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/internal/ModelComparator.java
+++ b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/internal/ModelComparator.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.ui.internal;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Date;
@@ -24,10 +25,14 @@ import java.util.Set;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.IResourceProvider;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.ResourceNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
+import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -54,6 +59,7 @@ import org.eclipse.emf.compare.match.service.MatchService;
import org.eclipse.emf.compare.ui.EMFCompareUIMessages;
import org.eclipse.emf.compare.ui.EMFCompareUIPlugin;
import org.eclipse.emf.compare.ui.ICompareInputDetailsProvider;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
import org.eclipse.emf.compare.ui.team.AbstractTeamHandler;
import org.eclipse.emf.compare.ui.util.EMFCompareConstants;
import org.eclipse.emf.compare.util.EMFCompareMap;
@@ -69,6 +75,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
import org.eclipse.ui.PlatformUI;
/**
@@ -210,8 +218,8 @@ public final class ModelComparator implements ICompareInputDetailsProvider {
* This will parse {@link #TEAM_HANDLERS_EXTENSION_POINT} for team handlers.
*/
private static void parseExtensionMetaData() {
- final IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(
- TEAM_HANDLERS_EXTENSION_POINT).getExtensions();
+ final IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(TEAM_HANDLERS_EXTENSION_POINT).getExtensions();
// The RevisionComparisonHandler will be added last in the registry to allow clients override
TeamHandlerDescriptor revisionHandler = null;
for (final IExtension extension : extensions) {
@@ -265,8 +273,8 @@ public final class ModelComparator implements ICompareInputDetailsProvider {
configuration.setLeftEditable(configuration.isLeftEditable() && !isLeftRemote());
configuration.setRightEditable(configuration.isRightEditable() && !isRightRemote());
- configuration.setProperty(EMFCompareConstants.PROPERTY_COMPARISON_TIME, end.getTime()
- - start.getTime());
+ configuration.setProperty(EMFCompareConstants.PROPERTY_COMPARISON_TIME,
+ end.getTime() - start.getTime());
if (isLeftRemote()) {
if (doResourceMatchOnly) {
configuration.setLeftLabel(EMFCompareUIMessages.getString(EMFCompareUIMessages
@@ -472,6 +480,12 @@ public final class ModelComparator implements ICompareInputDetailsProvider {
rightElement = input.getRight();
ancestorElement = input.getAncestor();
+ // check whether this comparison hasn't already been played (workaround for #345415)
+ if (handleResourceMapping(input)) {
+ loadingSucceeded = true;
+ return loadingSucceeded;
+ }
+
try {
// This will be sufficient when comparing local resources
loadingSucceeded = handleLocalResources(leftElement, rightElement, ancestorElement);
@@ -531,6 +545,64 @@ public final class ModelComparator implements ICompareInputDetailsProvider {
}
/**
+ * This is a workaround for bug 345415 and needs to be removed ASAP when this bug is fixed. Basically,
+ * Platform/Compare does not call our ModelProvider when using the action
+ * "right-click > Open In Compare Editor". We then do the work ourselves here... but with insufficient
+ * information. We'll need to access non-API fields along the way.
+ *
+ * @param input
+ * The input we've been fed by Platform/Compare.
+ * @return <code>true</code> if we managed to find a ResourceMapping with a {@link ModelCompareInput}
+ * corresponding to <em>input</em>, <code>false</code> otherwise.
+ */
+ private boolean handleResourceMapping(ICompareInput input) {
+ final IResourceProvider resourceProvider = (IResourceProvider)Platform.getAdapterManager()
+ .getAdapter(leftElement, IResourceProvider.class);
+ if (resourceProvider != null) {
+ final IResource localResource = resourceProvider.getResource();
+ final IModelProviderDescriptor[] descriptors = ModelProvider.getModelProviderDescriptors();
+ for (int i = 0; i < descriptors.length; i++) {
+ final IModelProviderDescriptor descriptor = descriptors[i];
+ try {
+ final IResource[] resources = descriptor
+ .getMatchingResources(new IResource[] {localResource, });
+ if (resources.length > 0) {
+ final ModelProvider modelProvider = descriptor.getModelProvider();
+ final ISynchronizationCompareAdapter compareAdapter = (ISynchronizationCompareAdapter)Platform
+ .getAdapterManager().getAdapter(modelProvider,
+ ISynchronizationCompareAdapter.class);
+ // FIXME until 345415 is fixed, we need to find the proper model provider from here...
+ // ... which requires access to non-API things.
+ final Field contextField = input.getClass().getDeclaredField("context"); //$NON-NLS-1$
+ contextField.setAccessible(true);
+ final ISynchronizationContext context = (ISynchronizationContext)contextField
+ .get(input);
+ final ICompareInput actualInput = compareAdapter.asCompareInput(context,
+ localResource);
+
+ if (actualInput instanceof ModelCompareInput) {
+ comparisonResult = ((ModelCompareInput)actualInput).getComparisonSnapshot();
+ return true;
+ }
+ }
+ } catch (CoreException e) {
+ // FIXME log
+ } catch (SecurityException e) {
+ // FIXME remove when 345415 is fixed
+ } catch (NoSuchFieldException e) {
+ // FIXME remove when 345415 is fixed
+ } catch (IllegalArgumentException e) {
+ // FIXME remove when 345415 is fixed
+ } catch (IllegalAccessException e) {
+ // FIXME remove when 345415 is fixed
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
* We might want to create an editor for an already compared configuration. This enables us to do so.
*
* @param snapshot
diff --git a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/viewer/structure/ModelStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/viewer/structure/ModelStructureMergeViewer.java
index 278f16569..52c653dcc 100644
--- a/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/viewer/structure/ModelStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ui/src/org/eclipse/emf/compare/ui/viewer/structure/ModelStructureMergeViewer.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
import org.eclipse.emf.compare.ui.CompareTextDialog;
import org.eclipse.emf.compare.ui.EMFCompareUIMessages;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
import org.eclipse.emf.compare.ui.export.ExportMenu;
import org.eclipse.emf.compare.ui.internal.ModelComparator;
import org.eclipse.emf.compare.ui.util.EMFCompareConstants;
@@ -258,9 +259,16 @@ public class ModelStructureMergeViewer extends TreeViewer {
super.inputChanged(input, oldInput);
if (input != null) {
- if (!(input instanceof ComparisonSnapshot) && input != oldInput) {
- final ComparisonSnapshot snapshot = ModelComparator.getComparator(configuration)
- .getComparisonResult();
+ final ComparisonSnapshot snapshot;
+ if (input instanceof ModelCompareInput
+ && ((ModelCompareInput)input).getComparisonSnapshot() != null) {
+ snapshot = ((ModelCompareInput)input).getComparisonSnapshot();
+ } else if (!(input instanceof ComparisonSnapshot) && input != oldInput) {
+ snapshot = ModelComparator.getComparator(configuration).getComparisonResult();
+ } else {
+ snapshot = null;
+ }
+ if (snapshot != null) {
Object match = null;
// check whether a resource or resource set comparison was performed
if (snapshot instanceof ComparisonResourceSnapshot) {
diff --git a/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
index 34f8f4bd9..42c279a29 100644
--- a/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
@@ -6,7 +6,8 @@ Bundle-Version: 1.2.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.emf.compare.EMFComparePlugin
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.resources;resolution:=optional,
+Require-Bundle: org.eclipse.core.expressions;resolution:=optional,
+ org.eclipse.core.resources;resolution:=optional,
org.eclipse.core.runtime;resolution:=optional,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
diff --git a/plugins/org.eclipse.emf.compare/build.properties b/plugins/org.eclipse.emf.compare/build.properties
index 0e22d9c79..3250cd696 100644
--- a/plugins/org.eclipse.emf.compare/build.properties
+++ b/plugins/org.eclipse.emf.compare/build.properties
@@ -17,7 +17,8 @@ bin.includes = META-INF/,\
about.ini,\
about.mappings,\
about.properties,\
- modeling32.png
+ modeling32.png,\
+ plugin.xml
src.includes = META-INF/,\
about.html,\
plugin.properties
diff --git a/plugins/org.eclipse.emf.compare/codeStyle/EMFCompareCheckstyle5Configuration.xml b/plugins/org.eclipse.emf.compare/codeStyle/EMFCompareCheckstyle5Configuration.xml
index 103c64351..bb5416869 100644
--- a/plugins/org.eclipse.emf.compare/codeStyle/EMFCompareCheckstyle5Configuration.xml
+++ b/plugins/org.eclipse.emf.compare/codeStyle/EMFCompareCheckstyle5Configuration.xml
@@ -321,14 +321,14 @@ Checkstyle 5.0 compatible
<module name="RegexpSingleline">
<property name="severity" value="error"/>
<property name="format" value="Copyright\s\(c\)\s(20[0-9]{2},?\s)+"/>
- <property name="message" value="Copyright must be present in the file with the pattern &quot;Copyright (c) 2006, 2011 Obeo.&quot;"/>
+ <property name="message" value="Copyright must be present in the file with the pattern &quot;Copyright (c) 2006, 2009 Obeo.&quot;"/>
<property name="minimum" value="1"/>
<property name="maximum" value="1"/>
</module>
<module name="RegexpSingleline">
<property name="severity" value="error"/>
<property name="id" value="illegal.regex.encoding"/>
- <property name="format" value="[^a-zA-Z0-9_!:;,\.\+\(\)/\\\]\[{}\-\*&lt;&gt;%@\&amp; \|\t\n&quot;' =$#\r\?éèàê\^~]"/>
+ <property name="format" value="[^a-zA-Z0-9_!:;,\.\+\(\)/\\\]\[{}\-\*&lt;&gt;%@\&amp; \|\t\n&quot;' =$#\r\?éèàê\^]"/>
<property name="message" value="Character could cause encoding issue."/>
</module>
<module name="SuppressionCommentFilter"/>
diff --git a/plugins/org.eclipse.emf.compare/plugin.xml b/plugins/org.eclipse.emf.compare/plugin.xml
new file mode 100644
index 000000000..13ce864de
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.emf.compare.util.ContentTypePropertyTester"
+ id="org.eclipse.emf.compare.contentTypeTester"
+ namespace="org.eclipse.emf.compare.contentType"
+ properties="contentTypeId"
+ type="org.eclipse.core.resources.IResource">
+ </propertyTester>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/ContentTypePropertyTester.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/ContentTypePropertyTester.java
new file mode 100644
index 000000000..04f9871d4
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/ContentTypePropertyTester.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+
+/**
+ * This will be used as a property tester for plugin.xml 'enablement' values. Specifically, we'll use this to
+ * check whether a given IFile has a given content type ID.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ * @since 1.2
+ */
+public class ContentTypePropertyTester extends PropertyTester {
+ /** Name of the property we'll test with this tester. */
+ private static final String PROPERTY_CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String,
+ * java.lang.Object[], java.lang.Object)
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof IFile && expectedValue instanceof String) {
+ if (PROPERTY_CONTENT_TYPE_ID.equals(property)) {
+ return hasContentType((IFile)receiver, (String)expectedValue);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * This will return <code>true</code> if and only if the given IFile has the given <em>contentTypeId</em>
+ * configured (as returned by {@link IContentTypeManager#findContentTypesFor(InputStream, String)
+ * Platform.getContentTypeManager().findContentTypesFor(InputStream, String)}.
+ *
+ * @param resource
+ * The resource from which to test the content types.
+ * @param contentTypeId
+ * Fully qualified identifier of the content type this <em>resource</em> has to feature.
+ * @return <code>true</code> if the given {@link IFile} has the given content type.
+ */
+ private static boolean hasContentType(IFile resource, String contentTypeId) {
+ final IContentTypeManager ctManager = Platform.getContentTypeManager();
+ final IContentType expected = ctManager.getContentType(contentTypeId);
+ if (expected == null) {
+ return false;
+ }
+
+ InputStream resourceContent = null;
+ IContentType[] contentTypes = null;
+ try {
+ resourceContent = resource.getContents();
+ contentTypes = ctManager.findContentTypesFor(resourceContent, resource.getName());
+ } catch (CoreException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } catch (IOException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } finally {
+ if (resourceContent != null) {
+ try {
+ resourceContent.close();
+ } catch (IOException e) {
+ // would have already been caught by the outer try, leave the stream open
+ }
+ }
+ }
+
+ boolean hasContentType = false;
+ if (contentTypes != null) {
+ for (int i = 0; i < contentTypes.length && !hasContentType; i++) {
+ if (contentTypes[i].isKindOf(expected)) {
+ hasContentType = true;
+ }
+ }
+ }
+ return hasContentType;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/DelegatingURIConverter.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/DelegatingURIConverter.java
new file mode 100644
index 000000000..f19510c86
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/DelegatingURIConverter.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ContentHandler;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.URIHandler;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+
+/**
+ * This implementation of an {@link URIConverter URI Converter} will delegate all calls to another.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ * @since 1.2
+ */
+public class DelegatingURIConverter extends ExtensibleURIConverterImpl {
+ /** Our delegate {@link URIConverter}. */
+ private URIConverter delegate;
+
+ /**
+ * Instantiates our {@link URIConverter} given its delegate.
+ *
+ * @param delegateURIConverter
+ * Our delegate {@link URIConverter}.
+ */
+ public DelegatingURIConverter(URIConverter delegateURIConverter) {
+ this.delegate = delegateURIConverter;
+
+ // Reset what has been done by the super constructor
+ uriHandlers.clear();
+ contentHandlers.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#contentDescription(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public Map<String, ?> contentDescription(URI uri, Map<?, ?> options) throws IOException {
+ return delegate.contentDescription(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#createInputStream(org.eclipse.emf.common.util.URI)
+ */
+ @Override
+ public InputStream createInputStream(URI uri) throws IOException {
+ return delegate.createInputStream(uri);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#createInputStream(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ return delegate.createInputStream(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#createOutputStream(org.eclipse.emf.common.util.URI)
+ */
+ @Override
+ public OutputStream createOutputStream(URI uri) throws IOException {
+ return delegate.createOutputStream(uri);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#createOutputStream(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public OutputStream createOutputStream(URI uri, Map<?, ?> options) throws IOException {
+ return delegate.createOutputStream(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#delete(org.eclipse.emf.common.util.URI, java.util.Map)
+ */
+ @Override
+ public void delete(URI uri, Map<?, ?> options) throws IOException {
+ delegate.delete(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#exists(org.eclipse.emf.common.util.URI, java.util.Map)
+ */
+ @Override
+ public boolean exists(URI uri, Map<?, ?> options) {
+ return delegate.exists(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#getAttributes(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) {
+ return delegate.getAttributes(uri, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#getContentHandlers()
+ */
+ @Override
+ public EList<ContentHandler> getContentHandlers() {
+ // This will be called during init, before the delegate is set
+ if (delegate == null) {
+ return super.getContentHandlers();
+ }
+ return delegate.getContentHandlers();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#getURIHandler(org.eclipse.emf.common.util.URI)
+ */
+ @Override
+ public URIHandler getURIHandler(URI uri) {
+ return delegate.getURIHandler(uri);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#getURIHandlers()
+ */
+ @Override
+ public EList<URIHandler> getURIHandlers() {
+ // This will be called during init, before the delegate is set
+ if (delegate == null) {
+ return super.getURIHandlers();
+ }
+ return delegate.getURIHandlers();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
+ */
+ @Override
+ public Map<URI, URI> getURIMap() {
+ return delegate.getURIMap();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#normalize(org.eclipse.emf.common.util.URI)
+ */
+ @Override
+ public URI normalize(URI uri) {
+ return delegate.normalize(uri);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecore.resource.URIConverter#setAttributes(org.eclipse.emf.common.util.URI,
+ * java.util.Map, java.util.Map)
+ */
+ @Override
+ public void setAttributes(URI uri, Map<String, ?> attributes, Map<?, ?> options) throws IOException {
+ delegate.setAttributes(uri, attributes, options);
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/EclipseModelUtils.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/EclipseModelUtils.java
index d2c6b3ea6..8675da612 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/EclipseModelUtils.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/util/EclipseModelUtils.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.util.Collections;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -86,8 +87,8 @@ public final class EclipseModelUtils {
registry = Resource.Factory.Registry.INSTANCE;
resourceFactory = registry.getContentTypeToFactoryMap().get(contentType);
if (resourceFactory != null) {
- resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(contentType,
- resourceFactory);
+ resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap()
+ .put(contentType, resourceFactory);
}
}
@@ -169,8 +170,8 @@ public final class EclipseModelUtils {
} catch (IOException e) {
// If it failed, load the file assuming it is in the plugins
resourceSet.getResources().remove(modelResource);
- modelResource = ModelUtils.createResource(URI.createPlatformPluginURI(file.getFullPath()
- .toOSString(), true), resourceSet);
+ modelResource = ModelUtils.createResource(
+ URI.createPlatformPluginURI(file.getFullPath().toOSString(), true), resourceSet);
try {
modelResource.load(Collections.emptyMap());
} catch (IOException ee) {
@@ -202,4 +203,52 @@ public final class EclipseModelUtils {
public static EObject load(IPath path, ResourceSet resourceSet) throws IOException {
return load(ResourcesPlugin.getWorkspace().getRoot().getFile(path), resourceSet);
}
+
+ /**
+ * Returns the EMF {@link Resource} saved within the given {@link IFile}.
+ *
+ * @param file
+ * The file from which to load an EMF {@link Resource}.
+ * @param resourceSet
+ * The resource set in which to load the model.
+ * @return The EMF {@link Resource} saved within the given {@link IFile}.
+ * @throws IOException
+ * If the given file cannot be loaded.
+ * @since 1.2
+ */
+ public static Resource getResource(IFile file, ResourceSet resourceSet) throws IOException {
+ for (Resource resource : resourceSet.getResources()) {
+ if (resource.getURI().toString().equals(file.getFullPath().toString())) {
+ return resource;
+ }
+ }
+ return ModelUtils.load(URI.createPlatformResourceURI(file.getFullPath().toString(), true),
+ resourceSet).eResource();
+ }
+
+ /**
+ * This will try and find the {@link IResource} containing the given EMF {@link Resource}. Note that the
+ * returned resource might not exist in the workspace if the EMF {@link Resource} has been loaded from a
+ * repository.
+ *
+ * @param eResource
+ * The logical resource for which we need a physical resource.
+ * @return The {@link IResource} that contains the given EMF {@link Resource}.
+ * @since 1.2
+ */
+ public static IResource findIResource(Resource eResource) {
+ final URI uri = eResource.getURI();
+ IResource iResource = null;
+ if (uri != null) {
+ if (uri.isPlatformResource()) {
+ final IPath path = new Path(uri.trimFragment().toPlatformString(true));
+ iResource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ } else {
+ // FIXME URI should be deresolved against the workspace root
+ final IPath path = new Path(uri.trimFragment().path());
+ iResource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ }
+ }
+ return iResource;
+ }
}

Back to the top