Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2007-04-25 20:43:59 +0000
committerpfullbright2007-04-25 20:43:59 +0000
commite0d72e09133326de640470b8ceb90238b5948984 (patch)
tree6327ea5f3d10873e56906e642427a955d637530f
parentfb5519ce98bfc917d4f3eec2668a3c74f07f49eb (diff)
downloadwebtools.dali-e0d72e09133326de640470b8ceb90238b5948984.tar.gz
webtools.dali-e0d72e09133326de640470b8ceb90238b5948984.tar.xz
webtools.dali-e0d72e09133326de640470b8ceb90238b5948984.zip
renamed
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/.classpath13
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/.cvsignore1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/META-INF/MANIFEST.MF52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/build.properties19
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/dtool16/new_jpaproject_wiz.gifbin0 -> 372 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/jpa_facet.gifbin0 -> 896 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/new_jpaproject_wiz.gifbin0 -> 991 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_details.gifbin0 -> 953 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_perspective.gifbin0 -> 896 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_structure.gifbin0 -> 900 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/basic.gifbin0 -> 897 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddable.gifbin0 -> 1003 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embedded.gifbin0 -> 905 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddedId.gifbin0 -> 953 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity-mappings.gifbin0 -> 974 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity.gifbin0 -> 1010 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/id.gifbin0 -> 938 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-many.gifbin0 -> 328 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-one.gifbin0 -> 307 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/mapped-superclass.gifbin0 -> 1005 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-attribute-mapping.gifbin0 -> 911 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-type-mapping.gifbin0 -> 586 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-many.gifbin0 -> 306 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-one.gifbin0 -> 283 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence-unit.gifbin0 -> 931 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence.gifbin0 -> 961 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/transient.gifbin0 -> 892 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/version.gifbin0 -> 321 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/icons/full/wizban/jpa_facet_wizban.gifbin0 -> 3485 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.properties50
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.xml237
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui.properties68
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_mappings.properties160
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_xml.properties36
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd119
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaHelpContextIds.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IPreferenceConstants.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaCompletionProposalComputer.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiIcons.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiMessages.java119
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiPlugin.java91
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/PlatformRegistry.java156
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentAttributeToXml.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentClassAction.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java259
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/ProjectAction.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentAttributeFromXml.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentClassAction.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/SynchronizeClassesAction.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaComposite.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaController.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaDetailsPage.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaComposite.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsPage.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsProvider.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java167
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java394
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java292
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/dialogs/AddPersistentClassDialog.java269
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/ITypeMappingUiProvider.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaDetailsProvider.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/BasicMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultBasicMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultEmbeddedMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddableUiProvider.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedIdMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EntityUiProvider.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/IdMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToManyMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToOneMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/MappedSuperclassUiProvider.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullAttributeMappingUiProvider.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullTypeMappingUiProvider.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToManyMappingUiProvider.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToOneMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/TransientMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/VersionMappingUiProvider.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaCompilationUnitItemProvider.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentAttributeItemProvider.java92
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentTypeItemProvider.java88
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaStructureProvider.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JpaCoreJavaItemProviderAdapterFactory.java166
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullLabelProvider.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullTreeContentProvider.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsImages.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsMessages.java178
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/AbstractJoinColumnDialog.java178
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/BasicComposite.java308
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java424
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CommonWidgets.java241
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java379
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddableComposite.java125
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedAttributeOverridesComposite.java337
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedComposite.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedIdComposite.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java282
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityNameCombo.java165
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EnumComboViewer.java180
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java268
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java177
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/IdComposite.java437
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InheritanceComposite.java296
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InverseJoinColumnDialog.java81
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java412
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnDialog.java128
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInAssociationOverrideDialog.java134
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInJoinTableDialog.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnsComposite.java347
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java491
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/LobCheckBox.java128
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToManyComposite.java169
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToOneComposite.java116
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java149
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java125
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToManyComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToOneComposite.java133
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OrderByComposite.java295
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java494
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnDialog.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java402
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java178
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/StringWithDefaultChooser.java274
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableCombo.java332
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java193
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java534
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TargetEntityChooser.java223
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TransientComposite.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/VersionComposite.java150
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/perspective/JpaPerspectiveFactory.java78
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/prefs/JpaPreferencePage.java204
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/DataModelPropertyPage.java299
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java272
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/AbstractSelectionParticipant.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/ISelectionManager.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/ISelectionParticipant.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaDetailsSelectionParticipant.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaStructureSelectionParticipant.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/Selection.java70
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/SelectionEvent.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/SelectionManager.java264
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/SelectionManagerFactory.java103
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/SelectionParticipantFactory.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java170
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/structure/IJpaStructureProvider.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/AbstractJpaView.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/JpaDetailsView.java167
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/JpaStructureView.java288
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/CComboViewer.java151
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ScrolledPageContent.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java360
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java156
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java453
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetWizardPage.java411
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/NewJpaProjectFirstPage.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/NewJpaProjectWizard.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/JpaUiXmlMessages.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/AccessTypeComboViewer.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/CascadePersistCheckBox.java128
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/CommonWidgets.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/MetaDataCompleteComboViewer.java138
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/PersistenceUnitMetadataSection.java276
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlDetailsProvider.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlEntityMappingsDetailsPage.java266
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java133
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaClassChooser.java249
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlMappingMetadataCompleteCheckBox.java128
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPackageChooser.java255
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java163
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java171
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/EntityMappingsItemProvider.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/JpaCoreXmlItemProviderAdapterFactory.java197
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/XmlPersistentAttributeItemProvider.java102
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/XmlPersistentTypeItemProvider.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/XmlRootContentNodeItemProvider.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/structure/XmlStructureProvider.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.classpath12
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.cvsignore3
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF11
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/build.properties16
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/plugin.properties24
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java70
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java1505
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java910
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java2417
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java1006
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Filter.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java733
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java348
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java167
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JavaType.java232
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java305
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java1816
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java182
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java78
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java124
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java144
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java229
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java118
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java130
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java223
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java93
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java154
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java94
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java175
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.classpath12
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.cvsignore1
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF16
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/build.properties16
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/plugin.properties22
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JpaCoreTests.java36
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java81
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JavaEntityTests.java42
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaCoreContentJavaMappingsTests.java28
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaJavaTestCase.java52
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/AnnotationTestCase.java429
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/CombinationIndexedDeclarationAnnotationAdapterTests.java728
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java164
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JpaCoreJdtUtilityTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java542
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedDeclarationAnnotationAdapterTests.java763
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedIndexedDeclarationAnnotationAdapterTests.java2209
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/SimpleDeclarationAnnotationAdapterTests.java204
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java67
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaCoreModelTests.java27
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/ModelInitializationTests.java90
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java48
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java148
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java60
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java195
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/test.xml44
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.classpath7
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.cvsignore1
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF16
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/build.properties5
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties20
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties19
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties19
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties20
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/plugin.properties15
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/DbTestPlugin.java54
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JpaDbTests.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java42
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java385
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java64
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java60
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java60
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java64
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.classpath7
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore1
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/build.properties15
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties24
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java59
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java548
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java289
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java1972
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java594
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java448
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java107
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java66
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java250
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JpaUtilityTests.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java214
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java74
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java101
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java698
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java156
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java135
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java126
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java150
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java119
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java252
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java408
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java333
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java403
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java53
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java63
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java127
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java119
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java285
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java183
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java98
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JpaUtilityIteratorsTests.java53
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java140
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java118
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java203
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java71
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java111
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java216
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java306
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java197
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/test.xml44
324 files changed, 51597 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/.classpath b/jpa/plugins/org.eclipse.jpt.ui/.classpath
new file mode 100644
index 0000000000..d4c5e62338
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/.classpath
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="property_files"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
+ <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.ui/.cvsignore b/jpa/plugins/org.eclipse.jpt.ui/.cvsignore
new file mode 100644
index 0000000000..ba077a4031
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/jpa/plugins/org.eclipse.jpt.ui/.project b/jpa/plugins/org.eclipse.jpt.ui/.project
new file mode 100644
index 0000000000..50ef9e3305
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jpt.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/jpa/plugins/org.eclipse.jpt.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..d206a55ed7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,52 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.eclipse.jpt.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.jpt.ui.internal.JpaUiPlugin
+Bundle-ClassPath: .
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.jem,
+ org.eclipse.jface.text,
+ org.eclipse.jpt.core,
+ org.eclipse.jpt.db,
+ org.eclipse.jpt.db.ui,
+ org.eclipse.jpt.gen,
+ org.eclipse.jpt.utility,
+ org.eclipse.jst.j2ee.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.wst.web.ui
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.jpt.ui.internal,
+ org.eclipse.jpt.ui.internal.actions,
+ org.eclipse.jpt.ui.internal.details,
+ org.eclipse.jpt.ui.internal.java.details,
+ org.eclipse.jpt.ui.internal.java.mappings.properties,
+ org.eclipse.jpt.ui.internal.java.structure,
+ org.eclipse.jpt.ui.internal.jface,
+ org.eclipse.jpt.ui.internal.mappings,
+ org.eclipse.jpt.ui.internal.mappings.details,
+ org.eclipse.jpt.ui.internal.prefs,
+ org.eclipse.jpt.ui.internal.selection,
+ org.eclipse.jpt.ui.internal.structure,
+ org.eclipse.jpt.ui.internal.views,
+ org.eclipse.jpt.ui.internal.widgets,
+ org.eclipse.jpt.ui.internal.wizards,
+ org.eclipse.jpt.ui.internal.xml,
+ org.eclipse.jpt.ui.internal.xml.details,
+ org.eclipse.jpt.ui.internal.xml.structure
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/jpa/plugins/org.eclipse.jpt.ui/build.properties b/jpa/plugins/org.eclipse.jpt.ui/build.properties
new file mode 100644
index 0000000000..e5bfd8e928
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/build.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+###############################################################################
+javacSource = 1.5
+javacTarget = 1.5
+source.. = src/,\
+ property_files/
+output.. = bin/
+bin.includes = .,\
+ META-INF/,\
+ icons/,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.ui/component.xml b/jpa/plugins/org.eclipse.jpt.ui/component.xml
new file mode 100644
index 0000000000..36827b6240
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/component.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.ui"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.ui" fragment="false"/></component> \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/dtool16/new_jpaproject_wiz.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/dtool16/new_jpaproject_wiz.gif
new file mode 100644
index 0000000000..633768f35d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/dtool16/new_jpaproject_wiz.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/jpa_facet.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/jpa_facet.gif
new file mode 100644
index 0000000000..c0ab917511
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/jpa_facet.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/new_jpaproject_wiz.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/new_jpaproject_wiz.gif
new file mode 100644
index 0000000000..12da8074ae
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/etool16/new_jpaproject_wiz.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_details.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_details.gif
new file mode 100644
index 0000000000..3280138b67
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_details.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_perspective.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_perspective.gif
new file mode 100644
index 0000000000..c0ab917511
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_perspective.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_structure.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_structure.gif
new file mode 100644
index 0000000000..682c90a589
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/eview16/jpa_structure.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/basic.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/basic.gif
new file mode 100644
index 0000000000..a547d743e7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/basic.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddable.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddable.gif
new file mode 100644
index 0000000000..8856f78874
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddable.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embedded.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embedded.gif
new file mode 100644
index 0000000000..c2ae66497a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embedded.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddedId.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddedId.gif
new file mode 100644
index 0000000000..c1c8e210e7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/embeddedId.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity-mappings.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity-mappings.gif
new file mode 100644
index 0000000000..c349c962e2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity-mappings.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity.gif
new file mode 100644
index 0000000000..d606f482e2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/entity.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/id.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/id.gif
new file mode 100644
index 0000000000..a205ec38ab
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/id.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-many.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-many.gif
new file mode 100644
index 0000000000..48885b21fe
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-many.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-one.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-one.gif
new file mode 100644
index 0000000000..2e1e2b9387
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/many-to-one.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/mapped-superclass.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/mapped-superclass.gif
new file mode 100644
index 0000000000..8cc37645c0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/mapped-superclass.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-attribute-mapping.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-attribute-mapping.gif
new file mode 100644
index 0000000000..70a9c23541
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-attribute-mapping.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-type-mapping.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-type-mapping.gif
new file mode 100644
index 0000000000..6279478c51
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/null-type-mapping.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-many.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-many.gif
new file mode 100644
index 0000000000..1e90027861
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-many.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-one.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-one.gif
new file mode 100644
index 0000000000..578ec36aa3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/one-to-one.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence-unit.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence-unit.gif
new file mode 100644
index 0000000000..9cc45f6945
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence-unit.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence.gif
new file mode 100644
index 0000000000..d1f616d64f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/persistence.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/transient.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/transient.gif
new file mode 100644
index 0000000000..cc5d83db20
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/transient.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/version.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/version.gif
new file mode 100644
index 0000000000..202a8104f4
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/obj16/version.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/icons/full/wizban/jpa_facet_wizban.gif b/jpa/plugins/org.eclipse.jpt.ui/icons/full/wizban/jpa_facet_wizban.gif
new file mode 100644
index 0000000000..8ce181f606
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/icons/full/wizban/jpa_facet_wizban.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
new file mode 100644
index 0000000000..b92c5001be
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
@@ -0,0 +1,50 @@
+###############################################################################
+# Copyright (c) 2006 Oracle.
+# 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:
+# Oracle. - initial API and implementation
+###############################################################################
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+pluginName= Java Persistence API Tools - UI
+providerName=Eclipse.org
+
+JPA_PLATFORM="JPA Platform UI"
+
+contentExtensionName = JPA Content UI Providers
+persistentTypeMappingExtension = Persistent Type Mappings
+persistentAttributeMappingExtension = Persistent Attribute Mappings
+imageProviderExtension = Mapping Image Provider
+
+jpaWizardCategoryName = JPA
+newJpaProjectWizardName = JPA Project
+newJpaProjectWizardDesc = Create a JPA project
+
+jpaMenuName = JPA Tools
+generateEntities = Generate Entities...
+synchronizeClasses = Synchronize Classes
+addPersistentClass = Add persistent class ...
+removePersistentClass = Remove persistent class
+
+jpaPreferencePage = JPA
+
+jpaProjectPropertiesPage = JPA
+
+jpaPerspective = JPA Development
+jpaDetails = JPA Details
+jpaStructure = JPA Structure
+
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
new file mode 100644
index 0000000000..9fae188700
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension-point
+ id="jpaPlatform"
+ name="%JPA_PLATFORM"
+ schema="schema/jpaPlatform.exsd"/>
+
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+
+ <factory
+ adaptableType="org.eclipse.ui.IWorkbenchPart"
+ class="org.eclipse.jpt.ui.internal.selection.SelectionParticipantFactory">
+ <adapter type="org.eclipse.jpt.ui.internal.selection.ISelectionParticipant"/>
+ </factory>
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.jpt.ui.jpaPlatform">
+
+ <jpaPlatform
+ id="generic"
+ class="org.eclipse.jpt.ui.internal.generic.GenericPlatformUi"/>
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.newWizards">
+
+ <category
+ id="org.eclipse.jpt"
+ name="%jpaWizardCategoryName"/>
+
+ <wizard
+ id="org.eclipse.jpt.jpaProject"
+ name="%newJpaProjectWizardName"
+ icon="icons/full/etool16/new_jpaproject_wiz.gif"
+ category="org.eclipse.jpt"
+ class="org.eclipse.jpt.ui.internal.wizards.NewJpaProjectWizard"
+ project="true"
+ finalPerspective="org.eclipse.jpt.ui.jpaPerspective">
+ <description>%newJpaProjectWizardDesc</description>
+ </wizard>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+
+ <objectContribution
+ id="org.eclipse.jpt.ui.project.JPATools"
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true">
+ <menu
+ id="org.eclipse.jpt.ui.project.JPATools"
+ label="%jpaMenuName"/>
+
+ <enablement>
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa"/>
+ </enablement>
+
+ <action
+ class="org.eclipse.jpt.ui.internal.actions.GenerateEntitiesAction"
+ id="org.eclipse.jpt.ui.generateEntities"
+ label="%generateEntities"
+ menubarPath="org.eclipse.jpt.ui.project.JPATools/content">
+ </action>
+ </objectContribution>
+
+ <objectContribution
+ id="org.eclipse.jpt.ui.persistenceXmlActions"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="persistence.xml">
+ <menu
+ id="persistenceXmlJPATools"
+ label="%jpaMenuName"/>
+ <action
+ id="synchClassesAction"
+ label="%synchronizeClasses"
+ menubarPath="persistenceXmlJPATools/content"
+ class="org.eclipse.jpt.ui.internal.actions.SynchronizeClassesAction"
+ enablesFor="1"/>
+ </objectContribution>
+
+ <objectContribution
+ id="org.eclipse.jpt.ui.entityMappingsActions"
+ objectClass="org.eclipse.jpt.core.internal.content.orm.EntityMappings">
+ <action
+ id="org.eclipse.jpt.ui.addPersistentClass"
+ class="org.eclipse.jpt.ui.internal.actions.AddPersistentClassAction"
+ label="%addPersistentClass"
+ menubarPath="additions"/>
+ </objectContribution>
+
+ <objectContribution
+ id="org.eclipse.jpt.ui.xmlPersistentTypeActions"
+ objectClass="org.eclipse.jpt.core.internal.content.orm.XmlPersistentType">
+ <action
+ id="org.eclipse.jpt.ui.removePersistentClass"
+ class="org.eclipse.jpt.ui.internal.actions.RemovePersistentClassAction"
+ label="%removePersistentClass"
+ menubarPath="additions"/>
+ </objectContribution>
+ <objectContribution
+ id="org.eclipse.jpt.ui.xmlStructure"
+ adaptable="false"
+ objectClass="org.eclipse.jpt.core.internal.content.orm.XmlPersistentAttribute">
+ <action
+ id="org.eclipse.jpt.ui.addToXml"
+ class="org.eclipse.jpt.ui.internal.actions.AddPersistentAttributeToXml"
+ label="Add to XML"
+ menubarPath="additions"/>
+ <visibility>
+ <objectState
+ name="defaultedFromJava"
+ value="true"/>
+ </visibility>
+ </objectContribution>
+
+ <objectContribution
+ id="org.eclipse.jpt.ui.xmlStructure"
+ adaptable="false"
+ objectClass="org.eclipse.jpt.core.internal.content.orm.XmlPersistentAttribute">
+ <action
+ id="org.eclipse.jpt.ui.removeFromXml"
+ class="org.eclipse.jpt.ui.internal.actions.RemovePersistentAttributeFromXml"
+ label="Remove from XML"
+ menubarPath="additions"/>
+ <visibility>
+ <objectState
+ name="specifiedInXml"
+ value="true"/>
+ </visibility>
+ </objectContribution>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+
+ <page
+ id="org.eclipse.jpt.ui.jpaPreferencePage"
+ name="%jpaPreferencePage"
+ class="org.eclipse.jpt.ui.internal.prefs.JpaPreferencePage"/>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.propertyPages">
+
+ <page
+ id="org.eclipse.jpt.ui.jpaProjectPropertiesPage"
+ name="%jpaProjectPropertiesPage"
+ class="org.eclipse.jpt.ui.internal.properties.JpaProjectPropertiesPage">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jpa"/>
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.views">
+
+ <category
+ id="org.eclipse.jpt.ui"
+ name="%jpaPerspective"/>
+
+ <view
+ category="org.eclipse.jpt.ui"
+ class="org.eclipse.jpt.ui.internal.views.JpaStructureView"
+ icon="icons/full/eview16/jpa_structure.gif"
+ id="org.eclipse.jpt.ui.jpaStructureView"
+ name="%jpaStructure"/>
+
+ <view
+ category="org.eclipse.jpt.ui"
+ class="org.eclipse.jpt.ui.internal.views.JpaDetailsView"
+ icon="icons/full/eview16/jpa_details.gif"
+ id="org.eclipse.jpt.ui.jpaDetailsView"
+ name="%jpaDetails"/>
+
+ </extension>
+
+<!-- =================================================================================== -->
+<!-- Extension: Persistence Perspective -->
+<!-- =================================================================================== -->
+
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.eclipse.jpt.ui.internal.perspective.JpaPerspectiveFactory"
+ icon="icons/full/eview16/jpa_perspective.gif"
+ id="org.eclipse.jpt.ui.jpaPerspective"
+ name="%jpaPerspective"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.images">
+
+ <image facet="jpt.jpa" path="icons/full/etool16/jpa_facet.gif"/>
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+
+ <wizard-pages action="jpt.jpa.install">
+ <page class="org.eclipse.jpt.ui.internal.wizards.JpaFacetWizardPage"/>
+ </wizard-pages>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.javaCompletionProposalComputer"
+ id="Foo"
+ name="JPA Proposals">
+ <javaCompletionProposalComputer
+ class="org.eclipse.jpt.ui.internal.JpaCompletionProposalComputer"
+ categoryId="org.eclipse.jdt.ui.javaTypeProposalCategory">
+ <partition type="__dftl_partition_content_type"/>
+ <partition type="__java_string"/>
+ </javaCompletionProposalComputer>
+ </extension>
+
+</plugin>
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui.properties
new file mode 100644
index 0000000000..840cdab8b9
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui.properties
@@ -0,0 +1,68 @@
+###############################################################################
+# Copyright (c) 2006, 2007 Oracle.
+# 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:
+# Oracle. - initial API and implementation
+###############################################################################
+
+AddPersistentClassDialog_title=Add Persistent Class
+AddPersistentClassDialog_classLabel=Class:
+AddPersistentClassDialog_classDialog_title=Persistent Class Selection
+AddPersistentClassDialog_classDialog_message=Choose a class:
+AddPersistentClassDialog_mappingLabel=Map as:
+AddPersistentClassDialog_noClassError=You must specify a class
+AddPersistentClassDialog_duplicateClassWarning=File already contains that persistent class
+AddPersistentClassDialog_classNotFoundWarning=Cannot resolve class
+AddPersistentClassDialog_noMappingKeyError=You must specify a mapping type
+
+DatabaseReconnectWizardPage_database=Database Settings
+DatabaseReconnectWizardPage_databaseConnection=Database Connection
+DatabaseReconnectWizardPage_reconnectToDatabase=Reconnect to the database.
+DatabaseReconnectWizardPage_connection=Connection:
+DatabaseReconnectWizardPage_schema=Schema:
+DatabaseReconnectWizardPage_schemaInfo=(Note: Must have active connection to select schema)
+DatabaseReconnectWizardPage_addConnectionLink=<a>Add connections...</a>
+DatabaseReconnectWizardPage_reconnectLink=<a>Reconnect...</a>
+
+General_browse=Browse...
+
+GenerateEntitiesWizard_generateEntities=Generate Entities
+GenerateEntitiesWizardPage_chooseEntityTable=Choose tables to generate entities from.
+GenerateEntitiesWizardPage_generateEntities=Generate Entities from Tables
+GenerateEntitiesWizardPage_tables=Tables:
+
+JpaPreferencePage_defaultJpaLib=Default JPA implementation library:
+JpaPreferencePage_userLibsLink=<a>Configure user libraries ...</a>
+JpaPreferencePage_invalidJpaLib=Invalid Library: Must contain javax.persistence classes.
+
+JpaStructureView_viewNotAvailable=Structure is not available for the current selection.
+JpaStructureView_linkWithEditorText=Link with Editor
+JpaStructureView_linkWithEditorDesc=Link with Active Editor
+JpaStructureView_linkWithEditorTooltip=Link with Editor
+
+JpaDetailsView_viewNotAvailable=Details are not available for the current selection.
+
+NewJpaProjectWizard_title=New JPA Project
+NewJpaProjectWizard_firstPage_title=JPA Project
+NewJpaProjectWizard_firstPage_description=Configure JPA project settings.
+
+JpaFacetWizardPage_title=JPA Facet
+JpaFacetWizardPage_description=Configure JPA settings.
+JpaFacetWizardPage_platformLabel=Platform:
+JpaFacetWizardPage_connectionLabel=Connection:
+JpaFacetWizardPage_connectionLink=<a>Add connection ...</a>
+JpaFacetWizardPage_jpaLibLabel=JPA implementation library:
+JpaFacetWizardPage_jpaPrefsLink=<a>Configure default JPA implementation library ...</a>
+JpaFacetWizardPage_userLibsLink=<a>Configure user libraries ...</a>
+JpaFacetWizardPage_createOrmXmlButton=Create orm.xml
+
+PersistentAttributePage_mapAs=Map As:
+
+PersistentTypePage_mapAs=Map As:
+
+OverwriteConfirmerDialog_title=Overwrite Existing Class
+OverwriteConfirmerDialog_text=Overwrite source code for the class ''{0}''?
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_mappings.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_mappings.properties
new file mode 100644
index 0000000000..b21ef06610
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_mappings.properties
@@ -0,0 +1,160 @@
+###############################################################################
+# Copyright (c) 2006 Oracle. 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:
+# Oracle - initial API and implementation
+###############################################################################
+
+PersistentTypePage_EntityLabel=Entity
+PersistentTypePage_EmbeddableLabel=Embeddable
+PersistentTypePage_MappedSuperclassLabel=Mapped Superclass
+
+PersistentAttributePage_BasicLabel=Basic
+PersistentAttributePage_IdLabel=Id
+PersistentAttributePage_OneToManyLabel=One to Many
+PersistentAttributePage_ManyToOneLabel=Many to One
+PersistentAttributePage_ManyToManyLabel=Many to Many
+PersistentAttributePage_TransientLabel=Transient
+PersistentAttributePage_VersionLabel=Version
+PersistentAttributePage_EmbeddedLabel=Embedded
+PersistentAttributePage_EmbeddedIdLabel=Embedded Id
+PersistentAttributePage_OneToOneLabel=One to One
+
+EntityComposite_tableDefault=Default ({0})
+EntityComposite_tableNoDefaultSpecified=Default ()
+EntityComposite_inheritance=Inheritance
+
+EntityGeneralSection_nameDefaultWithOneParam=Default ({0})
+EntityGeneralSection_nameDefaultEmpty=Default ()
+EntityGeneralSection_name=Name:
+
+BasicGeneralSection_name=Name:
+BasicGeneralSection_nameDefault=Default ({0})
+BasicGeneralSection_fetchLabel=Fetch:
+BasicGeneralSection_optionalLabel=Optional:
+BasicGeneralSection_lobLabel=Lob
+BasicGeneralSection_temporalLabel=Temporal:
+BasicGeneralSection_enumeratedLabel=Enumerated:
+
+TableChooser_label=Table:
+CatalogChooser_label=Catalog:
+SchemaChooser_label=Schema:
+TableComposite_defaultEmpty=Default ()
+TableComposite_defaultWithOneParam=Default ({0})
+
+ColumnChooser_label=Column:
+ColumnTableChooser_label=Table:
+
+TargetEntityChooser_label=Target Entity:
+TargetEntityChooser_defaultEmpty=Default ()
+TargetEntityChooser_defaultWithOneParam=Default ({0})
+TargetEntityChooser_browse=Browse...
+
+NonOwningMapping_mappedByLabel=Mapped By:
+
+JoinTableComposite_add=Add...
+JoinTableComposite_defaultEmpty=Default()
+JoinTableComposite_defaultWithOneParam=Default ({0})
+JoinTableComposite_edit=Edit...
+JoinTableComposite_inverseJoinColumn=Inverse Join Columns
+
+JoinTableComposite_mappingBetweenTwoParamsDefault=Default ({0} -> {1})
+JoinTableComposite_mappingBetweenTwoParamsFirstDefault=Default ({0}) -> {1}
+JoinTableComposite_mappingBetweenTwoParamsSecDefault={0} -> Default ({1})
+JoinTableComposite_mappingBetweenTwoParamsBothDefault=Default ({0}) -> Default ({1})
+JoinTableComposite_mappingBetweenTwoParams={0} -> {1}
+JoinTableComposite_joinColumn=Join Columns
+JoinTableComposite_name=Name:
+JoinTableComposite_remove=Remove
+JoinTableComposite_overrideDefaultJoinColumns=Override Default
+JoinTableComposite_overrideDefaultInverseJoinColumns=Override Default
+
+InverseJoinColumnDialog_editInverseJoinColumn=Edit Inverse Join Column
+InverseJoinColumnDialog_defaultWithOneParam=Default ({0})
+
+JoinColumnDialog_editJoinColumn=Edit Join Column
+JoinColumnDialog_name=Name:
+JoinColumnDialog_referencedColumnName=Referenced Column Name:
+JoinColumnDialog_defaultWithOneParam=Default ({0})
+JoinColumnDialog_insertable=Insertable:
+JoinColumnDialog_updatable=Updatable:
+
+MultiRelationshipMappingComposite_general=General
+MultiRelationshipMappingComposite_joinTable=Join Table
+MultiRelationshipMappingComposite_targetEntity=Target Entity:
+MultiRelationshipMappingComposite_cascadeType=Cascade Type:
+MultiRelationshipMappingComposite_fetchType=Fetch Type:
+MultiRelationshipMappingComposite_mappedBy=Mapped By:
+
+ColumnComposite_defaultWithOneParam=Default ({0})
+ColumnComposite_defaultEmpty=Default ()
+
+JoinColumnComposite_joinColumn=Join Columns
+JoinColumnComposite_defaultEmpty=Default()
+JoinColumnComposite_name=Name:
+JoinColumnComposite_defaultWithOneParam=Default ({0})
+JoinColumnComposite_add=Add...
+JoinColumnComposite_edit=Edit...
+JoinColumnComposite_mappingBetweenTwoParams={0} -> {1}
+JoinColumnComposite_mappingBetweenTwoParamsDefault=Default ({0} -> {1})
+JoinColumnComposite_mappingBetweenTwoParamsBothDefault=Default ({0}) -> Default ({1})
+JoinColumnComposite_mappingBetweenTwoParamsFirstDefault=Default ({0}) -> {1}
+JoinColumnComposite_mappingBetweenTwoParamsSecDefault={0} -> Default ({1})
+JoinColumnComposite_remove=Remove
+JoinColumnComposite_overrideDefaultJoinColumns=Override Default
+
+PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns=Override Default
+PrimaryKeyJoinColumnsComposite_add=Add...
+PrimaryKeyJoinColumnsComposite_edit=Edit...
+PrimaryKeyJoinColumnsComposite_remove=Remove
+PrimaryKeyJoinColumnsComposite_defaultEmpty=Default()
+PrimaryKeyJoinColumnsComposite_defaultWithOneParam=Default ({0})
+PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn=Primary Key Join Columns
+PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams={0} -> {1}
+PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault=Default ({0} -> {1})
+PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault=Default ({0}) -> Default ({1})
+PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault=Default ({0}) -> {1}
+PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault={0} -> Default ({1})
+
+AttributeOverridesComposite_attributeOverrides=Attribute Overrides:
+AttributeOverridesComposite_overridDefault=Override Default
+
+InheritanceComposite_strategy=Strategy:
+InheritanceComposite_discriminatorValue=Discriminator Value:
+InheritanceComposite_discriminatorValueDefaultWithOneParam=Default ({0})
+
+DiscriminatorColumnComposite_column=Discriminator Column:
+DiscriminatorColumnComposite_discriminatorType=Discriminator Type:
+DiscriminatorColumnComposite_defaultEmpty=Default(<provider-specific>)
+
+IdMappingComposite_pk_generation=PK Generation
+IdMappingComposite_primaryKeyGeneration=Primary Key Generation
+IdMappingComposite_tableGenerator=Table Generator
+IdMappingComposite_sequenceGenerator=Sequence Generator
+
+GeneratedValueComposite_generatedValue=Generated Value
+GeneratedValueComposite_generatorName=Generator Name:
+GeneratedValueComposite_strategy=Strategy:
+
+SequenceGeneratorComposite_sequenceGenerator=Sequence Generator
+SequenceGeneratorComposite_name=Name:
+SequenceGeneratorComposite_sequence=Sequence:
+SequenceGeneratorComposite_default=Default
+
+TableGeneratorComposite_name=Name:
+TableGeneratorComposite_table=Table:
+TableGeneratorComposite_tableGenerator=Table Generator
+TableGeneratorComposite_pkColumn=Primary Key Column:
+TableGeneratorComposite_valueColumn=Value Column:
+TableGeneratorComposite_pkColumnValue=Primary Key Column Value:
+TableGeneratorComposite_default=Default
+
+OrderByComposite_orderByGroup=Order By
+OrderByComposite_orderByLabel=Order By:
+OrderByComposite_noOrdering=No Ordering
+OrderByComposite_primaryKeyOrdering=Primary Key Ordering
+OrderByComposite_customOrdering=Custom Ordering
+
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_xml.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_xml.properties
new file mode 100644
index 0000000000..8d07a707ed
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpa_ui_xml.properties
@@ -0,0 +1,36 @@
+###############################################################################
+# Copyright (c) 2006 Oracle. 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:
+# Oracle - initial API and implementation
+###############################################################################
+
+PersistentTypePage_javaClassLabel=Java Class:
+PersistentTypePage_MetadataCompleteLabel=Metadata Complete:
+PersistentTypePage_AccessLabel=Access:
+
+PersistenceUnitMetadataSection_SchemaDefault=Default
+PersistenceUnitMetadataSection_CatalogDefault=Default
+
+PersistentAttributePage_javaAttributeLabel=Java Attribute:
+
+XMLEntityMappingsPage_XmlMappingMetadataCompleteCheckBox=XML Mapping Metadata Complete
+XMLEntityMappingsPage_CascadePersistCheckBox=Cascade Persist
+XMLEntityMappingsPage_PersistenceUnitSection=Persistence Unit
+XMLEntityMappingsPage_SchemaDefault=Default ({0})
+XMLEntityMappingsPage_SchemaNoDefaultSpecified=Default
+XMLEntityMappingsPage_CatalogDefault=Default ({0})
+XMLEntityMappingsPage_CatalogNoDefaultSpecified=Default
+
+XmlSchemaChooser_SchemaChooser=Schema:
+XmlCatalogChooser_CatalogChooser=Catalog:
+
+XmlJavaClassChooser_XmlJavaClassDialog_title=Class Selection
+XmlJavaClassChooser_XmlJavaClassDialog_message=Choose a type:
+
+XmlPackageChooser_PackageDialog_title=Package Selection
+XmlPackageChooser_PackageDialog_message=Choose a folder:
+
diff --git a/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd b/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd
new file mode 100644
index 0000000000..92d1085e5e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jpt.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jpt.ui" id="jpaVendor" name="JPA UI Vendor"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="jpaPlatform" minOccurs="1" maxOccurs="unbounded"/>
+ </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="jpaPlatform">
+ <annotation>
+ <documentation>
+ Extend this extension point and you must also extend the org.eclipse.jpt.core.jpaPlatform
+ extension point. The ids must match. One jpaPlatform will be chosen per JpaProject. The
+ possible jpaPlatforms will be displayed to the user as a project property.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id must match the corresponding org.eclipse.jpt.core.jpaVendor extension id.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.jpt.ui.internal.IJpaPlatformUI"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java
new file mode 100644
index 0000000000..b90e28e3be
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java
@@ -0,0 +1,46 @@
+package org.eclipse.jpt.ui.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.jpt.ui.internal.details.IJpaDetailsProvider;
+import org.eclipse.jpt.ui.internal.java.details.JavaDetailsProvider;
+import org.eclipse.jpt.ui.internal.java.structure.JavaStructureProvider;
+import org.eclipse.jpt.ui.internal.structure.IJpaStructureProvider;
+import org.eclipse.jpt.ui.internal.xml.details.XmlDetailsProvider;
+import org.eclipse.jpt.ui.internal.xml.structure.XmlStructureProvider;
+
+public abstract class BaseJpaPlatformUi implements IJpaPlatformUi
+{
+ private Collection<IJpaDetailsProvider> detailsProviders;
+ private Collection<IJpaStructureProvider> structureProviders;
+
+ public Collection<IJpaDetailsProvider> detailsProviders() {
+ if (this.detailsProviders == null) {
+ this.detailsProviders = buildJpaDetailsProvider();
+ }
+ return this.detailsProviders;
+ }
+
+ protected Collection<IJpaDetailsProvider> buildJpaDetailsProvider() {
+ Collection<IJpaDetailsProvider> detailsProviders = new ArrayList<IJpaDetailsProvider>();
+ detailsProviders.add(new JavaDetailsProvider());
+ detailsProviders.add(new XmlDetailsProvider());
+ return detailsProviders;
+ }
+
+ public Collection<IJpaStructureProvider> structureProviders() {
+ if (this.structureProviders == null) {
+ this.structureProviders = buildJpaStructureProvider();
+ }
+ return this.structureProviders;
+ }
+
+ protected Collection<IJpaStructureProvider> buildJpaStructureProvider() {
+ Collection<IJpaStructureProvider> structureProviders = new ArrayList<IJpaStructureProvider>();
+ structureProviders.add(new JavaStructureProvider());
+ structureProviders.add(new XmlStructureProvider());
+ return structureProviders;
+ }
+
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaHelpContextIds.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaHelpContextIds.java
new file mode 100644
index 0000000000..13f2072156
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaHelpContextIds.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+
+/**
+ * Help context ids for the Dali JPA UI.
+ * <p>
+ * This interface contains constants only; it is not intended to be
+ * implemented.
+ * </p>
+ *
+ */
+public interface IJpaHelpContextIds {
+
+
+ //ContextID prefix
+ public static final String PREFIX = JpaUiPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+
+ //Persistent Type composites
+ public static final String ENTITY_ACCESS_TYPE = PREFIX + "entity_accessType"; //$NON-NLS-1$
+ public static final String ENTITY_ATTRIBUTE_OVERRIDES = PREFIX + "entity_attributeOverrides"; //$NON-NLS-1$
+ public static final String ENTITY_ATTRIBUTE_OVERRIDES_COLUMN = PREFIX + "entity_attributeOverridesColumn"; //$NON-NLS-1$
+ public static final String ENTITY_INHERITANCE_STRATEGY = PREFIX + "entity_inheritanceStrategy"; //$NON-NLS-1$
+ public static final String ENTITY_INHERITANCE_DISCRIMINATOR_TYPE = PREFIX + "entity_inheritanceDiscriminatorType"; //$NON-NLS-1$
+ public static final String ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN = PREFIX + "entity_inheritanceDiscriminatorColumn"; //$NON-NLS-1$
+ public static final String ENTITY_INHERITANCE_DISCRIMINATOR_VALUE = PREFIX + "entity_inheritanceDiscriminatorValue"; //$NON-NLS-1$
+ public static final String ENTITY_NAME = PREFIX + "entity_name"; //$NON-NLS-1$
+ public static final String ENTITY_TABLE = PREFIX + "entity_table"; //$NON-NLS-1$
+
+ //Persistent Attribute composites
+ public static final String MAPPING_CASCADE_TYPE = PREFIX + "mapping_cascadeType"; //$NON-NLS-1$
+ public static final String MAPPING_COLUMN = PREFIX + "mapping_column"; //$NON-NLS-1$
+ public static final String MAPPING_COLUMN_INSERTABLE = PREFIX + "mapping_columnInsertable"; //$NON-NLS-1$
+ public static final String MAPPING_COLUMN_TABLE = PREFIX + "mapping_columnTable"; //$NON-NLS-1$
+ public static final String MAPPING_COLUMN_UPDATABLE= PREFIX + "mapping_columnUpdatable"; //$NON-NLS-1$
+ public static final String MAPPING_EMBEDDED_ATTRIBUTE_OVERRIDES = PREFIX + "mapping_embeddedAttributeOverrides";//$NON-NLS-1$
+ public static final String MAPPING_EMBEDDED_ATTRIBUTE_OVERRIDES_COLUMN = PREFIX + "mapping_embeddedAttributeOverridesColumn";//$NON-NLS-1$
+ public static final String MAPPING_FETCH_TYPE = PREFIX + "mapping_fetchType"; //$NON-NLS-1$
+ public static final String MAPPING_GENERATED_VALUE_STRATEGY = PREFIX + "mapping_generatedValueStrategy"; //$NON-NLS-1$
+ public static final String MAPPING_GENERATED_VALUE_GENERATOR_NAME = PREFIX + "mapping_generatedValueGeneratorName"; //$NON-NLS-1$
+ public static final String MAPPING_JOIN_COLUMN_NAME = PREFIX + "mapping_joinColumnName"; //$NON-NLS-1$
+ public static final String MAPPING_JOIN_REFERENCED_COLUMN = PREFIX + "mapping_joinReferencedColumn"; //$NON-NLS-1$
+ public static final String MAPPING_JOIN_TABLE_NAME = PREFIX + "mapping_joinTableName"; //$NON-NLS-1$
+ public static final String MAPPING_JOIN_TABLE_COLUMNS = PREFIX + "mapping_joinTableJoinColumns"; //$NON-NLS-1$
+ public static final String MAPPING_JOIN_TABLE_INVERSE_JOIN_COLUMNS = PREFIX + "mapping_joinTableInverseJoinColumns"; //$NON-NLS-1$
+ public static final String MAPPING_MAP_AS = PREFIX + "mapping_mapAs"; //$NON-NLS-1$
+ public static final String MAPPING_MAPPED_BY = PREFIX + "mapping_mappedBy"; //$NON-NLS-1$
+ public static final String MAPPING_OPTIONAL = PREFIX + "mapping_optional"; //$NON-NLS-1$
+ public static final String MAPPING_TEMPORAL = PREFIX + "mapping_temporal"; //$NON-NLS-1$
+ public static final String MAPPING_ORDER_BY = PREFIX + "mapping_orderBy"; //$NON-NLS-1$
+ public static final String MAPPING_ORDER_BY_NO_ORDERING = PREFIX + "mapping_orderByNoOrdering"; //$NON-NLS-1$
+ public static final String MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING = PREFIX + "mapping_orderByPrimaryKeyOrdering"; //$NON-NLS-1$
+ public static final String MAPPING_ORDER_BY_CUSTOM_ORDERING = PREFIX + "mapping_orderByCustomOrdering"; //$NON-NLS-1$
+ public static final String MAPPING_TABLE_GENERATOR_NAME = PREFIX + "mapping_tableGeneratorName"; //$NON-NLS-1$
+ public static final String MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN = PREFIX + "mapping_tableGeneratorPrimaryKeyColumn"; //$NON-NLS-1$
+ public static final String MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN_VALUE = PREFIX + "mapping_tableGeneratorPrimaryKeyColumnValue"; //$NON-NLS-1$
+ public static final String MAPPING_TABLE_GENERATOR_TABLE= PREFIX + "mapping_tableGeneratorTable"; //$NON-NLS-1$
+ public static final String MAPPING_TABLE_GENERATOR_VALUE_COLUMN = PREFIX + "mapping_tableGeneratorValueColumn"; //$NON-NLS-1$
+ public static final String MAPPING_TARGET_ENTITY = PREFIX + "mapping_targetEntity"; //$NON-NLS-1$
+
+ //Project properties
+ public static final String PROPERTIES_JAVA_PERSISTENCE = PREFIX + "properties_javaPersistence"; //$NON-NLS-1$
+ public static final String PROPERTIES_JAVA_PERSISTENCE_CONNECTION = PREFIX + "properties_javaPersistenceConnection"; //$NON-NLS-1$
+ public static final String PROPERTIES_JAVA_PERSISTENCE_SCHEMA = PREFIX + "properties_javaPersistenceSchema"; //$NON-NLS-1$
+
+ //Dialogs, Wizards
+ public static final String DIALOG_GENERATE_ENTITIES = PREFIX + "dialog_generateEntities"; //$NON-NLS-1$
+ public static final String DIALOG_GENERATE_ENTITIES_SOURCE = PREFIX + "dialog_generateEntities_source"; //$NON-NLS-1$
+ public static final String DIALOG_GENERATE_ENTITIES_PACKAGE = PREFIX + "dialog_generateEntities_package"; //$NON-NLS-1$
+ public static final String DIALOG_GENERATE_ENTITIES_TABLES = PREFIX + "dialog_generateEntities_tables"; //$NON-NLS-1$
+ public static final String NEW_JPA_PROJECT_CONTENT_PAGE = PREFIX + "dialog_addPersistence"; //$NON-NLS-1$
+ public static final String NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH = PREFIX + "dialog_addJavaPersistence_classpath"; //$NON-NLS-1$
+ public static final String NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE = PREFIX + "dialog_addJavaPersistence_database"; //$NON-NLS-1$
+ public static final String NEW_JPA_PROJECT_CONTENT_PAGE_PACKAGING = PREFIX + "dialog_addJavaPersistence_packaging"; //$NON-NLS-1$
+ public static final String NEW_JPA_PROJECT_CREATION_PAGE = PREFIX + "dialog_addJavaPersistence"; //$NON-NLS-1$
+
+ //Other
+ public static final String PERSISTENCE_OUTLINE = PREFIX + "persistenceOutline"; //$NON-NLS-1$
+
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java
new file mode 100644
index 0000000000..5fd0052ac1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java
@@ -0,0 +1,13 @@
+package org.eclipse.jpt.ui.internal;
+
+import java.util.Collection;
+import org.eclipse.jpt.ui.internal.details.IJpaDetailsProvider;
+import org.eclipse.jpt.ui.internal.structure.IJpaStructureProvider;
+
+public interface IJpaPlatformUi
+{
+ Collection<IJpaStructureProvider> structureProviders();
+
+ Collection<IJpaDetailsProvider> detailsProviders();
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IPreferenceConstants.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IPreferenceConstants.java
new file mode 100644
index 0000000000..5b1f907890
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IPreferenceConstants.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+public interface IPreferenceConstants
+{
+ /**
+ * A named preference that controls whether the structure view's selection is linked to the active editor.
+ */
+ public static final String LINK_STRUCTURE_VIEW_TO_EDITOR= "org.eclipse.jpt.linkStructureToEditor"; //$NON-NLS-1$
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaCompletionProposalComputer.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaCompletionProposalComputer.java
new file mode 100644
index 0000000000..b425c91a72
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaCompletionProposalComputer.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer;
+import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
+import org.eclipse.jpt.core.internal.IJpaFile;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.JpaCorePlugin;
+import org.eclipse.jpt.core.internal.content.java.JavaPersistentType;
+import org.eclipse.jpt.core.internal.content.java.JpaCompilationUnit;
+
+public class JpaCompletionProposalComputer implements IJavaCompletionProposalComputer {
+
+ public JpaCompletionProposalComputer() {
+ super();
+ }
+
+ public void sessionStarted() {
+ // do nothing
+ }
+
+ @SuppressWarnings("unchecked")
+ public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+// this.xxx((JavaContentAssistInvocationContext) context);
+ return Collections.EMPTY_LIST;
+ }
+
+ private void xxx(JavaContentAssistInvocationContext context) {
+ try {
+ this.xxx_(context);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private void xxx_(JavaContentAssistInvocationContext context) throws Exception {
+ System.out.println(context.getCoreContext());
+// System.out.println("identifier prefix: " + context.computeIdentifierPrefix());
+// System.out.println("select length: " + context.getCompilationUnit().codeSelect(context.getInvocationOffset(), 0).length);
+
+ ICompilationUnit cu = context.getCompilationUnit();
+ IResource resource = cu.getCorrespondingResource();
+ System.out.println("CU resource: " + resource);
+ IFile file = (IFile) resource;
+
+ IJpaFile jpaFile = JpaCorePlugin.getJpaFile(file);
+ System.out.println("JPA file: " + jpaFile);
+
+ JpaCompilationUnit jpaCU = (JpaCompilationUnit) jpaFile.getContent();
+ System.out.println("java persistent type: " + jpaCU.candidateValuesFor(context.getInvocationOffset()));
+
+ IJpaProject jpaProject = jpaFile.getJpaProject();
+ System.out.println("JPA project: " + jpaProject);
+
+ IType iType = cu.findPrimaryType();
+ JavaPersistentType pType = jpaProject.findJavaPersistentType(iType);
+ System.out.println("java persistent type: " + pType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ return Collections.EMPTY_LIST;
+ }
+
+ public String getErrorMessage() {
+ return null;
+ }
+
+ public void sessionEnded() {
+ // do nothing
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiIcons.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiIcons.java
new file mode 100644
index 0000000000..886842dd65
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiIcons.java
@@ -0,0 +1,6 @@
+package org.eclipse.jpt.ui.internal;
+
+public class JpaUiIcons
+{
+ public static final String JPA_WIZ_BANNER = "full/wizban/jpa_facet_wizban"; //$NON-NLS-1$
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiMessages.java
new file mode 100644
index 0000000000..f427d30999
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiMessages.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JpaUiMessages extends NLS
+{
+ private static final String BUNDLE_NAME = "jpa_ui"; //$NON-NLS-1$
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, JpaUiMessages.class);
+ }
+
+ public static String AddPersistentClassDialog_title;
+
+ public static String AddPersistentClassDialog_classLabel;
+
+ public static String AddPersistentClassDialog_classDialog_title;
+
+ public static String AddPersistentClassDialog_classDialog_message;
+
+ public static String AddPersistentClassDialog_mappingLabel;
+
+ public static String AddPersistentClassDialog_noClassError;
+
+ public static String AddPersistentClassDialog_duplicateClassWarning;
+
+ public static String AddPersistentClassDialog_classNotFoundWarning;
+
+ public static String AddPersistentClassDialog_noMappingKeyError;
+
+ public static String DatabaseReconnectWizardPage_database;
+
+ public static String DatabaseReconnectWizardPage_databaseConnection;
+
+ public static String DatabaseReconnectWizardPage_reconnectToDatabase;
+
+ public static String DatabaseReconnectWizardPage_connection;
+
+ public static String DatabaseReconnectWizardPage_schema;
+
+ public static String DatabaseReconnectWizardPage_schemaInfo;
+
+ public static String DatabaseReconnectWizardPage_addConnectionLink;
+
+ public static String DatabaseReconnectWizardPage_reconnectLink;
+
+ public static String General_browse;
+
+ public static String GenerateEntitiesWizard_generateEntities;
+
+ public static String GenerateEntitiesWizardPage_chooseEntityTable;
+
+ public static String GenerateEntitiesWizardPage_generateEntities;
+
+ public static String GenerateEntitiesWizardPage_tables;
+
+ public static String JpaPreferencePage_defaultJpaLib;
+
+ public static String JpaPreferencePage_userLibsLink;
+
+ public static String JpaPreferencePage_invalidJpaLib;
+
+ public static String JpaStructureView_viewNotAvailable;
+
+ public static String JpaStructureView_linkWithEditorText;
+
+ public static String JpaStructureView_linkWithEditorDesc;
+
+ public static String JpaStructureView_linkWithEditorTooltip;
+
+ public static String JpaDetailsView_viewNotAvailable;
+
+ public static String NewJpaProjectWizard_title;
+
+ public static String NewJpaProjectWizard_firstPage_title;
+
+ public static String NewJpaProjectWizard_firstPage_description;
+
+ public static String JpaFacetWizardPage_title;
+
+ public static String JpaFacetWizardPage_description;
+
+ public static String JpaFacetWizardPage_platformLabel;
+
+ public static String JpaFacetWizardPage_connectionLabel;
+
+ public static String JpaFacetWizardPage_connectionLink;
+
+ public static String JpaFacetWizardPage_jpaLibLabel;
+
+ public static String JpaFacetWizardPage_jpaPrefsLink;
+
+ public static String JpaFacetWizardPage_userLibsLink;
+
+ public static String JpaFacetWizardPage_createOrmXmlButton;
+
+ public static String PersistentAttributePage_mapAs;
+
+ public static String PersistentTypePage_mapAs;
+
+ public static String OverwriteConfirmerDialog_title;
+
+ public static String OverwriteConfirmerDialog_text;
+
+
+ private JpaUiMessages() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiPlugin.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiPlugin.java
new file mode 100644
index 0000000000..585abcddec
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaUiPlugin.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentAttribute;
+import org.eclipse.ui.IActionFilter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class JpaUiPlugin extends AbstractUIPlugin
+{
+ private static JpaUiPlugin INSTANCE;
+
+ /**
+ * The plug-in identifier of JPA UI support
+ * (value <code>"org.eclipse.jpt.ui"</code>).
+ */
+ public final static String PLUGIN_ID = "org.eclipse.jpt.ui"; //$NON-NLS-1$
+
+ /**
+ * Returns the singleton Plugin
+ */
+ public static JpaUiPlugin getPlugin() {
+ return INSTANCE;
+ }
+
+ public static void log(IStatus status) {
+ INSTANCE.getLog().log(status);
+ }
+
+ public static void log(String msg) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null));
+ }
+
+ public static void log(Throwable throwable) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable));
+ }
+
+
+ public JpaUiPlugin() {
+ super();
+ INSTANCE = this;
+
+ Platform.getAdapterManager().registerAdapters(buildPersistentAttributeAdapterFactory(), XmlPersistentAttribute.class);
+ }
+
+ private IAdapterFactory buildPersistentAttributeAdapterFactory() {
+ return new IAdapterFactory() {
+ public Class[] getAdapterList() {
+ return new Class[] {IActionFilter.class};
+ }
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ return new IActionFilter() {
+ public boolean testAttribute(Object target, String name, String value) {
+ if (name.equals("specifiedInXml")) {
+ return !((XmlPersistentAttribute) target).isVirtual();
+ }
+ if (name.equals("defaultedFromJava")) {
+ return ((XmlPersistentAttribute) target).isVirtual();
+ }
+ throw new IllegalArgumentException();
+ }
+ };
+ }
+ };
+ }
+
+ /**
+ * This gets a .gif from the icons folder.
+ */
+ public ImageDescriptor getImageDescriptor(String key) {
+ if (! key.startsWith("icons/")) {
+ key = "icons/" + key;
+ }
+ if (! key.endsWith(".gif")) {
+ key = key + ".gif";
+ }
+ return imageDescriptorFromPlugin(PLUGIN_ID, key);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/PlatformRegistry.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/PlatformRegistry.java
new file mode 100644
index 0000000000..177a0f41f7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/PlatformRegistry.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+
+public class PlatformRegistry
+{
+ public static final PlatformRegistry INSTANCE = new PlatformRegistry();
+
+ private static final String EXTENSION_ID =
+ "jpaPlatform"; //$NON-NLS-1$
+
+ private static final String EL_PLATFORM =
+ "jpaPlatform"; //$NON-NLS-1$
+
+ private static final String AT_ID =
+ "id"; //$NON-NLS-1$
+
+ private static final String AT_CLASS =
+ "class"; //$NON-NLS-1$
+
+ // key: String jpaPlatform id value: IConfigurationElement class descriptor
+ private Map<String, IConfigurationElement> jpaPlatforms;
+
+
+ /* (non Java doc)
+ * restrict access
+ */
+ private PlatformRegistry() {
+ buildJpaPlatforms();
+ }
+
+
+ private void buildJpaPlatforms() {
+ this.jpaPlatforms = new HashMap<String, IConfigurationElement>();
+
+ for (Iterator stream = allConfigElements(); stream.hasNext(); ) {
+ buildJpaPlatform((IConfigurationElement) stream.next());
+ }
+ }
+
+ private void buildJpaPlatform(IConfigurationElement configElement) {
+ if (! configElement.getName().equals(EL_PLATFORM)) {
+ return;
+ }
+
+ String platformId = configElement.getAttribute(AT_ID);
+ String platformClass = configElement.getAttribute(AT_CLASS);
+
+ if ((platformId == null) || (platformClass == null)) {
+ if (platformId == null) {
+ reportMissingAttribute(configElement, AT_ID);
+ }
+ if (platformClass == null) {
+ reportMissingAttribute(configElement, AT_CLASS);
+ }
+ return;
+ }
+
+ if (jpaPlatforms.containsKey(platformId)) {
+ IConfigurationElement otherConfigElement = jpaPlatforms.get(platformId);
+ reportDuplicatePlatform(configElement, otherConfigElement);
+ }
+
+ jpaPlatforms.put(platformId, configElement);
+ }
+
+ public IJpaPlatformUi getJpaPlatform(String vendorId) {
+ IConfigurationElement registeredConfigElement = this.jpaPlatforms.get(vendorId);
+
+ if (registeredConfigElement == null) {
+ return null;
+ }
+
+ try {
+ return (IJpaPlatformUi) registeredConfigElement.createExecutableExtension(AT_CLASS);
+ }
+ catch (CoreException ce) {
+ reportFailedInstantiation(registeredConfigElement);
+ return null;
+ }
+ }
+
+ private Iterator allConfigElements() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint =
+ registry.getExtensionPoint(JpaUiPlugin.PLUGIN_ID, EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+
+ return new CompositeIterator(
+ new TransformationIterator(CollectionTools.iterator(extensions)) {
+ @Override
+ protected Object transform(Object next) {
+ return CollectionTools.iterator(((IExtension) next).getConfigurationElements());
+ }
+ }
+ );
+ }
+
+ // TODO externalize strings
+ private void reportMissingAttribute(IConfigurationElement configElement, String attributeName) {
+ String message =
+ "An extension element \""
+ + configElement.getName()
+ + "\" in plugin \""
+ + configElement.getContributor().getName()
+ + "\" is missing a required attribute \""
+ + attributeName
+ + "\".";
+ JpaUiPlugin.log(message);
+ }
+
+ // TODO externalize strings
+ private void reportDuplicatePlatform(
+ IConfigurationElement oneConfigElement, IConfigurationElement otherConfigElement) {
+ String message =
+ "The plugins \""
+ + oneConfigElement.getContributor().getName()
+ + "\" and \""
+ + otherConfigElement.getContributor().getName()
+ + "\" have registered a duplicate attribute \"id\" "
+ + "for the extension element \"jpaVendor\".";
+ JpaUiPlugin.log(message);
+ }
+
+ // TODO externalize strings
+ private void reportFailedInstantiation(IConfigurationElement configElement) {
+ String message =
+ "Could not instantiate the class \""
+ + configElement.getAttribute(AT_CLASS)
+ + "\" for the extension element \""
+ + configElement.getName()
+ + "\" in the plugin \""
+ + configElement.getContributor().getName()
+ + "\".";
+ JpaUiPlugin.log(message);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentAttributeToXml.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentAttributeToXml.java
new file mode 100644
index 0000000000..3a592aaddd
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentAttributeToXml.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.actions;
+
+import java.util.Iterator;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentAttribute;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentType;
+import org.eclipse.jpt.core.internal.content.orm.XmlTypeMapping;
+import org.eclipse.ui.actions.ActionDelegate;
+
+public class AddPersistentAttributeToXml extends ActionDelegate
+{
+
+ private ISelection selection;
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ super.selectionChanged(action, selection);
+ this.selection = selection;
+ }
+
+ @Override
+ public void run(IAction action) {
+ if (this.selection instanceof StructuredSelection) {
+ for (Iterator<XmlPersistentAttribute> i = ((StructuredSelection) selection).iterator(); i.hasNext(); ) {
+ XmlPersistentAttribute xmlPersistentAttribute = i.next();
+ XmlPersistentType xmlPersistentType = ((XmlTypeMapping) xmlPersistentAttribute.typeMapping()).getPersistentType();
+ xmlPersistentType.getSpecifiedAttributeMappings().add(xmlPersistentAttribute.getMapping());
+ }
+ }
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentClassAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentClassAction.java
new file mode 100644
index 0000000000..6edcb8dcd0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/AddPersistentClassAction.java
@@ -0,0 +1,39 @@
+package org.eclipse.jpt.ui.internal.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.content.orm.EntityMappingsInternal;
+import org.eclipse.jpt.ui.internal.JpaUiPlugin;
+import org.eclipse.jpt.ui.internal.dialogs.AddPersistentClassDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class AddPersistentClassAction
+ implements IObjectActionDelegate
+{
+ private EntityMappingsInternal entityMappings;
+
+
+ public AddPersistentClassAction() {
+ super();
+ }
+
+ public void run(IAction action) {
+ Shell shell = JpaUiPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell();
+ AddPersistentClassDialog dialog = new AddPersistentClassDialog(shell, entityMappings);
+
+ dialog.create();
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ entityMappings = (EntityMappingsInternal) ((StructuredSelection) selection).getFirstElement();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // do nothing
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java
new file mode 100644
index 0000000000..e37ead9d8c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java
@@ -0,0 +1,259 @@
+/*******************************************************************************
+* Copyright (c) 2007 Oracle. 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:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.ui.internal.actions;
+
+import java.util.Collection;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.gen.internal.EntityGenerator;
+import org.eclipse.jpt.gen.internal.PackageGenerator;
+import org.eclipse.jpt.ui.internal.JpaUiMessages;
+import org.eclipse.jpt.ui.internal.wizards.GenerateEntitiesWizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * GenerateEntitiesAction
+ */
+public class GenerateEntitiesAction extends ProjectAction {
+ private IWorkbenchPart targetPart;
+
+ public GenerateEntitiesAction() {
+ super();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ super.setActivePart(action, targetPart);
+ this.targetPart = targetPart;
+ }
+
+ protected void execute(IJpaProject project) {
+ GenerateEntitiesWizard wizard = new GenerateEntitiesWizard(project, this.getCurrentSelection());
+
+ WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard); //TOREVIEW
+ dialog.create();
+ int returnCode = dialog.open();
+ if (returnCode == Window.OK) {
+ IWorkspaceRunnable runnable = new GenerateEntitiesRunnable(
+ wizard.getPackageGeneratorConfig(),
+ wizard.getEntityGeneratorConfig(),
+ wizard.getSelectedTables(),
+ new OverwriteConfirmer(this.targetPart.getSite().getShell())
+ );
+ try {
+ // TODO pass in real ProgressMonitor
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+ } catch (CoreException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
+ private Shell getCurrentShell() {
+ return Display.getCurrent().getActiveShell();
+ }
+
+ // ********** runnable **********
+
+ static class GenerateEntitiesRunnable implements IWorkspaceRunnable {
+ private final PackageGenerator.Config packageConfig;
+ private final EntityGenerator.Config entityConfig;
+ private final Collection selectedTables;
+ private final EntityGenerator.OverwriteConfirmer overwriteConfirmer;
+
+ GenerateEntitiesRunnable(
+ PackageGenerator.Config packageConfig,
+ EntityGenerator.Config entityConfig,
+ Collection selectedTables,
+ EntityGenerator.OverwriteConfirmer overwriteConfirmer
+ ) {
+ super();
+ this.packageConfig = packageConfig;
+ this.entityConfig = entityConfig;
+ this.selectedTables = selectedTables;
+ this.overwriteConfirmer = overwriteConfirmer;
+ }
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("", 1000);
+ try {
+ PackageGenerator.generateEntities(this.packageConfig, this.entityConfig, this.selectedTables, this.overwriteConfirmer, monitor);
+ } catch (OperationCanceledException ex) {
+ // fall through and tell monitor we are done
+ }
+ monitor.done();
+ }
+
+ }
+
+ // ********** overwrite confirmer **********
+
+ static class OverwriteConfirmer implements EntityGenerator.OverwriteConfirmer {
+ private Shell shell;
+ private boolean overwriteAll = false;
+ private boolean skipAll = false;
+
+ OverwriteConfirmer(Shell shell) {
+ super();
+ this.shell = shell;
+ }
+
+ public boolean overwrite(String className) {
+ if (this.overwriteAll) {
+ return true;
+ }
+ if (this.skipAll) {
+ return false;
+ }
+ return this.promptUser(className);
+ }
+
+ private boolean promptUser(String className) {
+ OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.shell, className);
+ if (dialog.open() == Window.CANCEL) {
+ throw new OperationCanceledException();
+ }
+ if (dialog.yes()) {
+ return true;
+ } else if (dialog.yesToAll()) {
+ this.overwriteAll = true;
+ return true;
+ } else if (dialog.no()) {
+ return false;
+ } else if (dialog.noToAll()) {
+ this.skipAll = true;
+ return false;
+ }
+ throw new IllegalStateException();
+ }
+
+ }
+
+ // ********** dialog **********
+
+ static class OverwriteConfirmerDialog extends Dialog {
+ private final String className;
+ private boolean yes = false;
+ private boolean yesToAll = false;
+ private boolean no = false;
+ private boolean noToAll = false;
+
+ OverwriteConfirmerDialog(Shell parent, String className) {
+ super(parent);
+ this.className = className;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(JpaUiMessages.OverwriteConfirmerDialog_title);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridLayout gridLayout = (GridLayout) composite.getLayout();
+ gridLayout.numColumns = 2;
+
+ Label text = new Label(composite, SWT.LEFT);
+ text.setText(NLS.bind(JpaUiMessages.OverwriteConfirmerDialog_text, this.className));
+ text.setLayoutData(new GridData());
+
+ return composite;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ this.createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false);
+ this.createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ protected void buttonPressed(int buttonId) {
+ switch (buttonId) {
+ case IDialogConstants.YES_ID :
+ this.yesPressed();
+ break;
+ case IDialogConstants.YES_TO_ALL_ID :
+ this.yesToAllPressed();
+ break;
+ case IDialogConstants.NO_ID :
+ this.noPressed();
+ break;
+ case IDialogConstants.NO_TO_ALL_ID :
+ this.noToAllPressed();
+ break;
+ case IDialogConstants.CANCEL_ID :
+ this.cancelPressed();
+ break;
+ default :
+ break;
+ }
+ }
+
+ private void yesPressed() {
+ this.yes = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void yesToAllPressed() {
+ this.yesToAll = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void noPressed() {
+ this.no = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void noToAllPressed() {
+ this.noToAll = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ boolean yes() {
+ return this.yes;
+ }
+
+ boolean yesToAll() {
+ return this.yesToAll;
+ }
+
+ boolean no() {
+ return this.no;
+ }
+
+ boolean noToAll() {
+ return this.noToAll;
+ }
+
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/ProjectAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/ProjectAction.java
new file mode 100644
index 0000000000..14c1e55df0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/ProjectAction.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2006 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.actions;
+
+import java.util.Iterator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.JpaCorePlugin;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Override any of the #execute() methods.
+ */
+public abstract class ProjectAction implements IObjectActionDelegate {
+
+ private ISelection currentSelection;
+
+
+ public ProjectAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // do nothing
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.currentSelection = selection;
+ }
+
+ protected IStructuredSelection getCurrentSelection() {
+ if (this.currentSelection instanceof IStructuredSelection) {
+ return (IStructuredSelection) this.currentSelection;
+ }
+ return null;
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ if (this.currentSelection instanceof IStructuredSelection) {
+ for (Iterator stream = ((IStructuredSelection) this.currentSelection).iterator(); stream.hasNext(); ) {
+ this.execute(stream.next());
+ }
+ }
+ }
+
+ protected void execute(Object selection) {
+ IProject project = this.projectFromSelection(selection);
+ if (project != null) {
+ this.execute(project);
+ }
+ }
+
+ protected IProject projectFromSelection(Object selection) {
+ if (selection instanceof IProject) {
+ return (IProject) selection;
+ }
+ if (selection instanceof IJavaProject) {
+ return ((IJavaProject) selection).getProject();
+ }
+ return null;
+ }
+
+ protected void execute(IProject project) {
+ IJpaProject jpaProject = JpaCorePlugin.getJpaProject(project);
+ if (jpaProject == null) {
+ return;
+ }
+ this.execute(jpaProject);
+ }
+
+ protected void execute(IJpaProject project) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentAttributeFromXml.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentAttributeFromXml.java
new file mode 100644
index 0000000000..051813fbff
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentAttributeFromXml.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.actions;
+
+import java.util.Iterator;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentAttribute;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentType;
+import org.eclipse.jpt.core.internal.content.orm.XmlTypeMapping;
+import org.eclipse.ui.actions.ActionDelegate;
+
+public class RemovePersistentAttributeFromXml extends ActionDelegate
+{
+
+ private ISelection selection;
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ super.selectionChanged(action, selection);
+ this.selection = selection;
+ }
+
+ @Override
+ public void run(IAction action) {
+ if (this.selection instanceof StructuredSelection) {
+ for (Iterator<XmlPersistentAttribute> i = ((StructuredSelection) selection).iterator(); i.hasNext(); ) {
+ XmlPersistentAttribute xmlPersistentAttribute = i.next();
+ XmlPersistentType xmlPersistentType = ((XmlTypeMapping) xmlPersistentAttribute.typeMapping()).getPersistentType();
+ xmlPersistentType.getSpecifiedAttributeMappings().remove(xmlPersistentAttribute.getMapping());
+ }
+ }
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentClassAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentClassAction.java
new file mode 100644
index 0000000000..cdeeb2de51
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/RemovePersistentClassAction.java
@@ -0,0 +1,34 @@
+package org.eclipse.jpt.ui.internal.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.content.orm.EntityMappingsInternal;
+import org.eclipse.jpt.core.internal.content.orm.XmlPersistentType;
+import org.eclipse.jpt.core.internal.content.orm.XmlTypeMapping;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class RemovePersistentClassAction
+ implements IObjectActionDelegate
+{
+ private XmlPersistentType persistentClass;
+
+
+ public RemovePersistentClassAction() {
+ super();
+ }
+
+ public void run(IAction action) {
+ XmlTypeMapping mapping = persistentClass.getMapping();
+ ((EntityMappingsInternal) mapping.getEntityMappings()).getTypeMappings().remove(mapping);
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ persistentClass = (XmlPersistentType) ((StructuredSelection) selection).getFirstElement();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // do nothing
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/SynchronizeClassesAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/SynchronizeClassesAction.java
new file mode 100644
index 0000000000..547f3f30d1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/SynchronizeClassesAction.java
@@ -0,0 +1,29 @@
+package org.eclipse.jpt.ui.internal.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.synch.SynchronizeClassesJob;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class SynchronizeClassesAction
+ implements IObjectActionDelegate
+{
+ private IFile file;
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // no-op for now
+ }
+
+ public void run(IAction action) {
+ SynchronizeClassesJob job = new SynchronizeClassesJob(file);
+ job.schedule();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // only one element in actual selection
+ file = (IFile) ((StructuredSelection) selection).getFirstElement();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaComposite.java
new file mode 100644
index 0000000000..2ca087c363
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaComposite.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public abstract class BaseJpaComposite extends BaseJpaController
+ implements IJpaComposite
+{
+ private Composite composite;
+
+ public BaseJpaComposite(Composite parent, int style, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, style, theCommandStack, widgetFactory);
+ }
+
+ public BaseJpaComposite(Composite parent, CommandStack theCommandStack,TabbedPropertySheetWidgetFactory widgetFactory) {
+ this(parent, SWT.NULL, theCommandStack, widgetFactory);
+ }
+
+ @Override
+ protected void buildWidget(Composite parent, int style) {
+ super.buildWidget(parent);
+ this.composite = createComposite(parent, style);
+ initializeLayout(this.composite);
+ }
+
+ protected Composite createComposite(Composite parent, int style) {
+ return this.widgetFactory.createComposite(parent, style);
+ }
+
+ protected abstract void initializeLayout(Composite composite);
+
+ public Control getControl() {
+ return this.composite;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaController.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaController.java
new file mode 100644
index 0000000000..acbdabb9a7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaController.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public abstract class BaseJpaController
+{
+ protected CommandStack commandStack;
+
+ protected TabbedPropertySheetWidgetFactory widgetFactory;
+
+ //put in the populating flag to stop the circular population of the entity name combo
+ //populateEntityNameCombo is calling select() which causes entityNameComboModified() to be called
+ //this sets the name in the model which starts the circle over again. We should probably
+ //short-circuit this differently, like in the emf model, keep the property change from being fired if
+ //a change did not actually occur - KFM
+ private boolean populating;
+
+
+ public BaseJpaController(Composite parent, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super();
+ this.widgetFactory = widgetFactory;
+ buildWidget(parent);
+ this.commandStack = theCommandStack;
+ }
+
+ public BaseJpaController(Composite parent, int style, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super();
+ this.widgetFactory = widgetFactory;
+ buildWidget(parent, style);
+ this.commandStack = theCommandStack;
+ }
+
+
+ /**
+ * Override this method if using the constructor without the style bit
+ */
+ protected void buildWidget(Composite parent) {
+ // no op
+ }
+
+ /**
+ * Override this method if using the constructor with the style bit
+ */
+ protected void buildWidget(Composite parent, int style) {
+ // no op
+ }
+
+ /**
+ * This method is called from outside when setting the object of interest
+ */
+ public final void populate(EObject obj) {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ this.populating = true;
+ disengageListeners();
+ doPopulate(obj);
+ engageListeners();
+ this.populating = false;
+ }
+
+ /**
+ * This method is called (perhaps internally) when this needs to repopulate
+ * but the object of interest has not changed
+ */
+ public final void populate() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ this.populating = true;
+ doPopulate();
+ this.populating = false;
+ }
+
+ protected abstract void doPopulate(EObject obj);
+
+ protected abstract void doPopulate();
+
+ protected abstract void engageListeners();
+
+ protected abstract void disengageListeners();
+
+ protected boolean isPopulating() {
+ return this.populating;
+ }
+
+ public TabbedPropertySheetWidgetFactory getWidgetFactory() {
+ return this.widgetFactory;
+ }
+
+ public void dispose() {
+ disengageListeners();
+ }
+
+ public abstract Control getControl();
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaDetailsPage.java
new file mode 100644
index 0000000000..7509fb021a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJpaDetailsPage.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.IJpaContentNode;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public abstract class BaseJpaDetailsPage extends BaseJpaComposite
+ implements IJpaDetailsPage
+{
+ private Composite control;
+
+ public BaseJpaDetailsPage(
+ Composite parent, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, theCommandStack, widgetFactory);
+ }
+
+ public BaseJpaDetailsPage(
+ Composite parent, int style, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, style, theCommandStack, widgetFactory);
+ }
+
+ @Override
+ //using this to get a Scroll bar on the JpaDetailsView
+ protected Composite createComposite(Composite parent, int style) {
+ ScrolledForm scrolledForm = this.widgetFactory.createScrolledForm(parent);
+ //Nesting another composite because combos on the ScrolledForm didn't have a border
+ scrolledForm.getBody().setLayout(new FillLayout());
+ Composite composite = super.createComposite(scrolledForm.getBody(), style);
+ this.control = scrolledForm;
+ return composite;
+ }
+
+ public final void populate(IJpaContentNode contentNode) {
+ super.populate(contentNode);
+ }
+
+ @Override
+ protected final void doPopulate(EObject obj) {
+ doPopulate((IJpaContentNode) obj);
+ }
+
+ protected abstract void doPopulate(IJpaContentNode contentNode);
+
+
+ @Override
+ public Control getControl() {
+ return this.control;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaComposite.java
new file mode 100644
index 0000000000..960d6577ef
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaComposite.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Control;
+
+
+public interface IJpaComposite<E extends EObject> {
+
+ void populate(E model);
+
+ Control getControl();
+
+ void dispose();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsPage.java
new file mode 100644
index 0000000000..6e04707732
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsPage.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.jpt.core.internal.IJpaContentNode;
+import org.eclipse.swt.widgets.Control;
+
+public interface IJpaDetailsPage
+{
+ Control getControl();
+
+ /**
+ * Set the content for the page and populate widgets
+ */
+ void populate(IJpaContentNode contentNode);
+
+
+ /**
+ * Perform any other disposal needed
+ */
+ void dispose();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsProvider.java
new file mode 100644
index 0000000000..557e584a38
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IJpaDetailsProvider.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public interface IJpaDetailsProvider
+{
+
+ String fileContentType();
+
+ /**
+ * Build a properties page given the parent Composite and the
+ * content node id.
+ * It is legal to set the layout for the given Composite.
+ */
+ IJpaDetailsPage buildDetailsPage(Composite parentComposite, Object contentNodeId, TabbedPropertySheetWidgetFactory widgetFactory);
+
+ void dispose();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java
new file mode 100644
index 0000000000..80c583ba2c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Versant. 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: Versant. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.PageBook;
+
+/**
+ * A wrapper for a <code>PageBook</code> with convenience methods.
+ */
+public class PageBookManager extends PageBook {
+
+ private Map pageRecords;
+ private Object active;
+ private PageBook pageBook;
+ private Composite defaultComposite;
+
+ /**
+ * A <code>PageBookManager<code> is a wrapper for a <code>PageBook</code>. It provides
+ * convenience methods to add, remove, activate and inactive pages in the internal <code>PageBook</code>.
+ * If a page gets deactivated, the manager activates a default page.
+ *
+ * @param parent The parent composite to this manager
+ * @param aDefaultLabel The label on the the default page.
+ */
+ public PageBookManager(Composite parent, String aDefaultLabel) {
+ super(parent, SWT.NULL);
+ this.setLayout(new FillLayout());
+ this.pageRecords = new HashMap();
+ this.pageBook = new PageBook(this, SWT.NONE);
+ this.defaultComposite = new DefaultComposite(pageBook, aDefaultLabel);
+ this.pageBook.showPage(this.defaultComposite);
+ }
+
+ /**
+ * @param anObj Activates (flips to top in the <code>PageBook</code>) the associated <code>Composite</code>
+ * for the given <code>Object</code>. Activates the <code>DefaultComposite</code> if there is no association
+ * for the given <code>Object</code>.
+ * @return Return false if there is no <code>Composite</code> association to the given <code>Object</code> or
+ * the associated <code>Composite</code> is already active.
+ */
+ public boolean activate(Object anObj) {
+ if(anObj != null && !anObj.equals(this.active) && this.pageRecords.containsKey(anObj)) {
+ Composite composite = (Composite) this.pageRecords.get(anObj);
+ this.pageBook.showPage(composite);
+ this.active = anObj;
+ return true;
+ } else if((anObj == null || !anObj.equals(this.active)) && !this.pageRecords.containsKey(anObj)) {
+ this.pageBook.showPage(this.defaultComposite);
+ this.active = null;
+ }
+ return false;
+ }
+
+ /**
+ * @param anObj
+ * @return Returns true if the associated <code>Composite</code> has been deactivated.
+ * Returns false if there is no <code>Composite</code> for the given <code>Object</code>
+ * or the <code>Composite</code> is already inactive.
+ */
+ public boolean deactivate(Object anObj) {
+ if(anObj.equals(this.active)) {
+ this.pageBook.showPage(this.defaultComposite);
+ this.active = null;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Associates the specified <code>Object</code> with the specified <code>Composite</code>
+ * in this <code>PageBookManager</code>.
+ * If this manager previously contained a mapping for the <code>Object</code>, the old
+ * <code>Composite</code> is replaced by the specified <code>Composite</code>.
+ *
+ * @param anObj <code>Object</code> with which the specified <code>Composite</code> is to be associated.
+ * @param aComposite <code>Composite</code> to be associated with the specified <code>Object</code>.
+ *
+ * @return previous <code>Composite</code> associated with specified <code>Object</code>,
+ * or <tt>null</tt> if there was no mapping for <code>Object</code>.
+ */
+ public Composite put(Object anObj, Composite aComposite) {
+ Composite composite = (Composite) this.pageRecords.put(anObj, aComposite);
+ this.activate(anObj);
+ return composite;
+ }
+
+ /**
+ * Removes the mapping for this <code>Object</code> from this pagebookmanager if it is present.
+ *
+ * @param anObj <code>Object</code> whose mapping is to be removed from this <code>PageBookManager</code>.
+ * @return previous <code>Composite</code> associated with specified <code>Object</code>.
+ */
+ public Composite remove(Object anObj) {
+ if(anObj.equals(this.active)) {
+ this.active = null;
+ this.pageBook.showPage(this.defaultComposite);
+ }
+ return (Composite) this.pageRecords.remove(anObj);
+ }
+
+ /**
+ * @param anObj whose presence in this map is to be tested
+ * @return true if this <code>PageBookManager</code> contains a mapping for the
+ * given <code>Object</code>. False otherwise.
+ */
+ public boolean contains(Object anObj) {
+ return this.pageRecords.containsKey(anObj);
+ }
+
+ public Composite get(Object key) {
+ return (Composite) pageRecords.get(key);
+ }
+
+ /**
+ * @return The currently active composite
+ */
+ public Composite getActive() {
+ if(this.active == null) {
+ return this.defaultComposite;
+ } else {
+ return (Composite) this.pageRecords.get(this.active);
+ }
+ }
+
+ /**
+ * @return The internal <code>PageBook</code> of this <code>PageBookManager</code>.
+ * <code>Composite</code>s which should work with this manager needs to be created
+ * with this <code>Composite</code> as their parent composite.
+ */
+ public Composite getComposite() {
+ return this.pageBook;
+ }
+
+ // a default composite which is show if the active composite
+ // gets deactivated
+ private class DefaultComposite extends Composite {
+ public DefaultComposite(Composite aParent, String aDefaultLabel) {
+ super(aParent, SWT.NONE);
+ setLayout(new FillLayout(SWT.VERTICAL));
+ Label label = new Label(this, SWT.LEFT);
+ label.setText(aDefaultLabel);
+ }
+ }
+
+ public void dispose() {
+ super.dispose();
+ Collection composites = this.pageRecords.values();
+ for (Iterator i = composites.iterator(); i.hasNext(); ) {
+ ((Composite) i.next()).dispose();
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java
new file mode 100644
index 0000000000..c787d84698
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java
@@ -0,0 +1,394 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jpt.core.internal.IAttributeMapping;
+import org.eclipse.jpt.core.internal.IJpaContentNode;
+import org.eclipse.jpt.core.internal.IPersistentAttribute;
+import org.eclipse.jpt.core.internal.JpaCorePackage;
+import org.eclipse.jpt.ui.internal.JpaUiMessages;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.BasicMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.DefaultBasicMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.DefaultEmbeddedMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EmbeddedIdMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EmbeddedMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.IdMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.ManyToManyMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.ManyToOneMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.NullAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.OneToManyMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.OneToOneMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.TransientMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.VersionMappingUiProvider;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage
+{
+ private IPersistentAttribute attribute;
+ private IAttributeMapping attributeMapping;
+ private Adapter persistentAttributeListener;
+ private Adapter attributeMappingListener;
+
+ private String currentMappingKey;
+
+ private CComboViewer mappingCombo;
+
+ private Map mappingComposites;
+ protected PageBook mappingPageBook;
+ private IJpaComposite currentMappingComposite;
+
+ /**
+ * These IAtttributeMappingUiProviders will be used as elements in the attributeMapping combo
+ * The first element in the combo will be one of the defaultAttributemappingUiProviders or
+ * if none of those apply the nullAttriubteMappingUiProvider will be used. The rest of the elements
+ * will be the attributeMappingUiProviders. The defaultAttributeMappingUiProvider is
+ * determined by matching its key with the key of the current attriubteMapping.
+ */
+ private Collection<IAttributeMappingUiProvider> attributeMappingUiProviders;
+ private Collection<IAttributeMappingUiProvider> defaultAttributeMappingUiProviders;
+ private IAttributeMappingUiProvider nullAttributeMappingUiProvider;
+
+ public PersistentAttributeDetailsPage(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NONE, new BasicCommandStack(), widgetFactory);
+ persistentAttributeListener = buildAttributeListener();
+ attributeMappingListener = buildAttributeMappingListener();
+ mappingComposites = new HashMap();
+ this.attributeMappingUiProviders = buildAttributeMappingUiProviders();
+ this.defaultAttributeMappingUiProviders = buildDefaultAttributeMappingUiProviders();
+ this.nullAttributeMappingUiProvider = buildNullAttributeMappingUiProvider();
+ }
+
+ protected IAttributeMappingUiProvider buildNullAttributeMappingUiProvider() {
+ return NullAttributeMappingUiProvider.instance();
+ }
+
+ protected Collection<IAttributeMappingUiProvider> buildAttributeMappingUiProviders() {
+ Collection<IAttributeMappingUiProvider> attributeMappingUiProviders = new ArrayList<IAttributeMappingUiProvider>();
+ attributeMappingUiProviders.add(BasicMappingUiProvider.instance());
+ attributeMappingUiProviders.add(EmbeddedMappingUiProvider.instance());
+ attributeMappingUiProviders.add(EmbeddedIdMappingUiProvider.instance());
+ attributeMappingUiProviders.add(IdMappingUiProvider.instance());
+ attributeMappingUiProviders.add(ManyToManyMappingUiProvider.instance());
+ attributeMappingUiProviders.add(ManyToOneMappingUiProvider.instance());
+ attributeMappingUiProviders.add(OneToManyMappingUiProvider.instance());
+ attributeMappingUiProviders.add(OneToOneMappingUiProvider.instance());
+ attributeMappingUiProviders.add(TransientMappingUiProvider.instance());
+ attributeMappingUiProviders.add(VersionMappingUiProvider.instance());
+ return attributeMappingUiProviders;
+ }
+
+ protected Collection<IAttributeMappingUiProvider> attributeMappingUiProviders() {
+ return this.attributeMappingUiProviders;
+ }
+
+ protected Collection<IAttributeMappingUiProvider> buildDefaultAttributeMappingUiProviders() {
+ if (this.defaultAttributeMappingUiProviders == null) {
+ this.defaultAttributeMappingUiProviders = new ArrayList<IAttributeMappingUiProvider>();
+ this.defaultAttributeMappingUiProviders.add(DefaultBasicMappingUiProvider.instance());
+ this.defaultAttributeMappingUiProviders.add(DefaultEmbeddedMappingUiProvider.instance());
+ }
+ return this.defaultAttributeMappingUiProviders;
+ }
+
+ protected Collection<IAttributeMappingUiProvider> defaultAttributeMappingUiProviders() {
+ return this.defaultAttributeMappingUiProviders;
+ }
+
+ private IAttributeMappingUiProvider attributeMappingUiProvider(String key) {
+ for (IAttributeMappingUiProvider provider : attributeMappingUiProviders()) {
+ if (provider.key() == key) {
+ return provider;
+ }
+ }
+ return this.nullAttributeMappingUiProvider;
+ }
+ private IAttributeMappingUiProvider defaultAttributeMappingUiProvider(String key) {
+ for (IAttributeMappingUiProvider provider : defaultAttributeMappingUiProviders()) {
+ if (provider.key() == key) {
+ return provider;
+ }
+ }
+ return this.nullAttributeMappingUiProvider;
+ }
+
+ private Adapter buildAttributeListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ persistentAttributeChanged(notification);
+ }
+ };
+ }
+
+ private void persistentAttributeChanged(Notification notification) {
+ switch (notification.getFeatureID(IPersistentAttribute.class)) {
+ case JpaCorePackage.IPERSISTENT_ATTRIBUTE__MAPPING_KEY:
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ break;
+ }
+ }
+
+ private Adapter buildAttributeMappingListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ attributeMappingChanged(notification);
+ }
+ };
+ }
+
+ private void attributeMappingChanged(Notification notification) {
+// switch (notification.getFeatureID(IAttributeMapping.class)) {
+// case JpaCorePackage.IATTRIBUTE_MAPPING__DEFAULT:
+// Display.getDefault().asyncExec(
+// new Runnable() {
+// public void run() {
+// populate();
+// }
+// });
+// break;
+// }
+ }
+
+ protected Label buildMappingLabel(Composite parent) {
+ return getWidgetFactory().createLabel(parent, JpaUiMessages.PersistentAttributePage_mapAs);
+ }
+
+ protected CComboViewer buildMappingCombo(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent);
+ mappingCombo = new CComboViewer(combo);
+ mappingCombo.setContentProvider(buildContentProvider());
+ mappingCombo.setLabelProvider(buildLabelProvider());
+ mappingCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ mappingChanged(event);
+ }
+ });
+ return mappingCombo;
+ }
+
+ private IContentProvider buildContentProvider() {
+ return new IStructuredContentProvider() {
+ public void dispose() {
+ // do nothing
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement == null) {
+ return new Object[]{};
+ }
+ return uiProvidersFor((IPersistentAttribute) inputElement);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // do nothing
+ }
+ };
+ }
+
+ private IAttributeMappingUiProvider[] uiProvidersFor(IPersistentAttribute persistentAttribute) {
+ IAttributeMappingUiProvider[] providers = new IAttributeMappingUiProvider[attributeMappingUiProviders().size() +1];
+ providers[0] = this.nullAttributeMappingUiProvider;
+ for (IAttributeMappingUiProvider uiProvider : defaultAttributeMappingUiProviders()) {
+ if (uiProvider.key() == persistentAttribute.defaultKey()) {
+ providers[0] = uiProvider;
+ break;
+ }
+ }
+ int i = 0;
+ for (IAttributeMappingUiProvider uiProvider : attributeMappingUiProviders()) {
+ i++;
+ providers[i] = uiProvider;
+ }
+ return providers;
+ }
+
+ private IBaseLabelProvider buildLabelProvider() {
+ return new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((IAttributeMappingUiProvider) element).label();
+ }
+ };
+ }
+
+ protected PageBook buildMappingPageBook(Composite parent) {
+ mappingPageBook = new PageBook(parent, SWT.NONE);
+ return mappingPageBook;
+ }
+
+ protected IJpaComposite buildMappingComposite(PageBook pageBook, String key) {
+ if (this.attributeMapping == null || this.attributeMapping.isDefault()) {
+ return defaultAttributeMappingUiProvider(key).buildAttributeMappingComposite(pageBook, this.commandStack, getWidgetFactory());
+ }
+
+ return attributeMappingUiProvider(key).buildAttributeMappingComposite(pageBook, this.commandStack, getWidgetFactory());
+ }
+
+ private void mappingChanged(SelectionChangedEvent event) {
+ if (isPopulating()) {
+ return;
+ }
+ if (event.getSelection() instanceof StructuredSelection) {
+ IAttributeMappingUiProvider provider = (IAttributeMappingUiProvider) ((StructuredSelection) event.getSelection()).getFirstElement();
+ boolean default_ = defaultAttributeMappingUiProviders().contains(provider);
+ attribute.setMappingKey(provider.key(), default_);
+ }
+ }
+
+ @Override
+ protected void doPopulate(IJpaContentNode persistentAttributeNode) {
+ attribute = (IPersistentAttribute) persistentAttributeNode;
+ populateMappingComboAndPage();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateMappingComboAndPage();
+ }
+
+ protected void engageListeners() {
+ if (attribute != null) {
+ attribute.eAdapters().add(persistentAttributeListener);
+ if (attributeMapping != null) {
+ attributeMapping.eAdapters().add(attributeMappingListener);
+ }
+ }
+ }
+
+ protected void disengageListeners() {
+ if (attribute != null) {
+ attribute.eAdapters().remove(persistentAttributeListener);
+ if (attributeMapping != null) {
+ attributeMapping.eAdapters().remove(attributeMappingListener);
+ }
+ }
+ }
+
+ private void populateMappingComboAndPage() {
+ if (attribute == null) {
+ attributeMapping = null;
+ currentMappingKey = null;
+ mappingCombo.setInput(null);
+ mappingCombo.setSelection(StructuredSelection.EMPTY);
+
+ if (currentMappingComposite != null) {
+ currentMappingComposite.populate(null);
+ currentMappingComposite = null;
+ }
+
+ return;
+ }
+ attributeMapping = attribute.getMapping();
+ setComboData(attribute.candidateMappingKeys());
+
+ populateMappingPage(attributeMapping == null ? null : attributeMapping.getKey());
+ }
+
+ private void populateMappingPage(String mappingKey) {
+ if (currentMappingComposite != null) {
+ if (mappingKey == currentMappingKey) {
+ if (currentMappingComposite != null) {
+ currentMappingComposite.populate(attributeMapping);
+ return;
+ }
+ }
+ else {
+ currentMappingComposite.populate(null);
+ // don't return
+ }
+ }
+
+ currentMappingKey = mappingKey;
+
+ IJpaComposite composite = mappingCompositeFor(mappingKey);
+ mappingPageBook.showPage(composite.getControl());
+
+ currentMappingComposite = composite;
+ currentMappingComposite.populate(attributeMapping);
+ }
+
+ private void setComboData(Iterator availableMappingKeys) {
+ if (attribute != mappingCombo.getInput()) {
+ mappingCombo.setInput(attribute);
+ }
+ if (attributeMapping == null || attributeMapping.isDefault()) {
+ mappingCombo.setSelection(new StructuredSelection(mappingCombo.getElementAt(0)));
+ }
+ else {
+ IAttributeMappingUiProvider provider = attributeMappingUiProvider(attribute.getMappingKey());
+ if (provider != null && ! provider.equals(((StructuredSelection) mappingCombo.getSelection()).getFirstElement())) {
+ mappingCombo.setSelection(new StructuredSelection(provider));
+ }
+ }
+ }
+
+ private IJpaComposite mappingCompositeFor(String key) {
+ IJpaComposite composite = (IJpaComposite) mappingComposites.get(key);
+ if (composite != null) {
+ return composite;
+ }
+
+ composite = buildMappingComposite(mappingPageBook, key);
+
+ if (composite != null) {
+ mappingComposites.put(key, composite);
+ }
+
+ return composite;
+ }
+
+//TODO focus??
+// public boolean setFocus() {
+// super.setFocus();
+// return mappingCombo.getCombo().setFocus();
+// }
+
+ public void dispose() {
+ disengageListeners();
+ for (Iterator i = mappingComposites.values().iterator(); i.hasNext(); ) {
+ ((IJpaComposite) i.next()).dispose();
+ }
+ super.dispose();
+ }
+
+ public IPersistentAttribute getAttribute() {
+ return attribute;
+ }
+
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java
new file mode 100644
index 0000000000..31ec98dd7f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.details;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jpt.core.internal.IJpaContentNode;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.IPersistentType;
+import org.eclipse.jpt.core.internal.JpaCorePackage;
+import org.eclipse.jpt.ui.internal.JpaUiMessages;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EmbeddableUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EntityUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.MappedSuperclassUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.NullTypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public abstract class PersistentTypeDetailsPage extends BaseJpaDetailsPage
+{
+ private IPersistentType persistentType;
+ private Adapter persistentTypeListener;
+
+ private String currentMappingKey;
+
+ private CComboViewer typeMappingCombo;
+
+ /**
+ * A Map of mapping Composites of type IPersistenceComposite that is keyed on IConfigurationElement
+ */
+ private Map composites;
+
+ protected PageBook typeMappingPageBook;
+
+ private IJpaComposite visibleMappingComposite;
+
+ private Collection<ITypeMappingUiProvider> typeMappingUiProviders;
+
+ public PersistentTypeDetailsPage(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NONE, new BasicCommandStack(), widgetFactory);
+ this.persistentTypeListener = buildPersistentTypeListener();
+ this.composites = new HashMap();
+ this.typeMappingUiProviders = buildTypeMappingUiProviders();
+ }
+
+ protected Collection<ITypeMappingUiProvider> buildTypeMappingUiProviders() {
+ Collection<ITypeMappingUiProvider> typeMappingUiProviders = new ArrayList<ITypeMappingUiProvider>();
+ typeMappingUiProviders.add(new NullTypeMappingUiProvider());
+ typeMappingUiProviders.add(new EntityUiProvider());
+ typeMappingUiProviders.add(new MappedSuperclassUiProvider());
+ typeMappingUiProviders.add(new EmbeddableUiProvider());
+ return typeMappingUiProviders;
+ }
+
+ private Adapter buildPersistentTypeListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ persistentTypeChanged(notification);
+ }
+ };
+ }
+
+ private void persistentTypeChanged(Notification notification) {
+ switch (notification.getFeatureID(IPersistentType.class)) {
+ case JpaCorePackage.IPERSISTENT_TYPE__MAPPING_KEY:
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ break;
+ }
+ }
+
+ protected Label buildTypeMappingLabel(Composite parent) {
+ return getWidgetFactory().createLabel(parent, JpaUiMessages.PersistentTypePage_mapAs);
+ }
+
+ protected CComboViewer buildTypeMappingCombo(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent);
+ typeMappingCombo = new CComboViewer(combo);
+ typeMappingCombo.setContentProvider(buildContentProvider());
+ typeMappingCombo.setLabelProvider(buildLabelProvider());
+ typeMappingCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ typeMappingChanged(event);
+ }
+ });
+ return typeMappingCombo;
+ }
+
+ private IContentProvider buildContentProvider() {
+ return new IStructuredContentProvider() {
+ public void dispose() {
+ // do nothing
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return (persistentType == null) ?
+ new String[] {}:
+ PersistentTypeDetailsPage.this.typeMappingUiProviders.toArray();
+ }
+
+ public void inputChanged(
+ Viewer viewer, Object oldInput, Object newInput) {
+ // do nothing
+ }
+ };
+ }
+ private IBaseLabelProvider buildLabelProvider() {
+ return new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((ITypeMappingUiProvider) element).label();
+ }
+ };
+ }
+
+ protected PageBook buildTypeMappingPageBook(Composite parent) {
+ typeMappingPageBook = new PageBook(parent, SWT.NONE);
+ return typeMappingPageBook;
+ }
+
+ private IJpaProject getJpaProject() {
+ return getPersistentType().getJpaProject();
+ }
+
+ private ITypeMappingUiProvider typeMappingUiProvider(String key) {
+ for (ITypeMappingUiProvider provider : this.typeMappingUiProviders) {
+ if (provider.key() == key) {
+ return provider;
+ }
+ }
+ throw new IllegalArgumentException("unsupported type mapping UI provider key: " + key);
+ }
+
+ private void typeMappingChanged(SelectionChangedEvent event) {
+ if (isPopulating()) {
+ return;
+ }
+ if (event.getSelection() instanceof StructuredSelection) {
+ ITypeMappingUiProvider provider = (ITypeMappingUiProvider) ((StructuredSelection) event.getSelection()).getFirstElement();
+ persistentType.setMappingKey(provider.key());
+ }
+ }
+
+ @Override
+ protected void doPopulate(IJpaContentNode persistentTypeNode) {
+ persistentType = (IPersistentType) persistentTypeNode;
+ populateMappingComboAndPage();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateMappingComboAndPage();
+ }
+
+ protected void engageListeners() {
+ if (persistentType != null) {
+ persistentType.eAdapters().add(persistentTypeListener);
+ }
+ }
+
+ protected void disengageListeners() {
+ if (persistentType != null) {
+ persistentType.eAdapters().remove(persistentTypeListener);
+ }
+ }
+
+ private void populateMappingComboAndPage() {
+ if (persistentType == null) {
+ currentMappingKey = null;
+ typeMappingCombo.setInput(null);
+ typeMappingCombo.setSelection(StructuredSelection.EMPTY);
+
+ if (visibleMappingComposite != null) {
+ visibleMappingComposite.populate(null);
+ visibleMappingComposite = null;
+ }
+
+ return;
+ }
+
+ String mappingKey = persistentType.getMapping().getKey();
+ setComboData(mappingKey, persistentType.candidateMappingKeys());
+
+ populateMappingPage(mappingKey);
+ }
+
+ private void populateMappingPage(String mappingKey) {
+ if (visibleMappingComposite != null) {
+ if (mappingKey == currentMappingKey) {
+ if (visibleMappingComposite != null) {
+ visibleMappingComposite.populate(persistentType.getMapping());
+ return;
+ }
+ }
+ else {
+ visibleMappingComposite.populate(null);
+ // don't return
+ }
+ }
+
+ currentMappingKey = mappingKey;
+
+ IJpaComposite mappingComposite = mappingCompositeFor(mappingKey);
+ typeMappingPageBook.showPage(mappingComposite.getControl());
+
+ visibleMappingComposite = mappingComposite;
+ visibleMappingComposite.populate(persistentType.getMapping());
+ }
+
+ private void setComboData(String mappingKey, Iterator availableMappingKeys) {
+ if (persistentType != typeMappingCombo.getInput()) {
+ typeMappingCombo.setInput(persistentType);
+ }
+
+ ITypeMappingUiProvider provider = typeMappingUiProvider(mappingKey);
+ if (! provider.equals(((StructuredSelection) typeMappingCombo.getSelection()).getFirstElement())) {
+ typeMappingCombo.setSelection(new StructuredSelection(provider));
+ }
+ }
+
+ private IJpaComposite mappingCompositeFor(String key) {
+ IJpaComposite mappingComposite = (IJpaComposite) composites.get(key);
+ if (mappingComposite != null) {
+ return mappingComposite;
+ }
+
+ mappingComposite = buildMappingComposite(typeMappingPageBook, key);
+
+ if (mappingComposite != null) {
+ composites.put(key, mappingComposite);
+ }
+
+ return mappingComposite;
+ }
+
+ protected IJpaComposite buildMappingComposite(PageBook pageBook, String key) {
+ //TODO what about null composite?
+ return typeMappingUiProvider(key).buildPersistentTypeMappingComposite(pageBook, this.commandStack, getWidgetFactory());
+// return new NullComposite(pageBook, commandStack);
+ }
+
+//TODO focus??
+// public boolean setFocus() {
+// super.setFocus();
+// return typeMappingCombo.getCombo().setFocus();
+// }
+
+ public void dispose() {
+ disengageListeners();
+ for (Iterator i = composites.values().iterator(); i.hasNext(); ) {
+ ((IJpaComposite) i.next()).dispose();
+ }
+ super.dispose();
+ }
+
+ public IPersistentType getPersistentType() {
+ return persistentType;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/dialogs/AddPersistentClassDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/dialogs/AddPersistentClassDialog.java
new file mode 100644
index 0000000000..161639ad8c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/dialogs/AddPersistentClassDialog.java
@@ -0,0 +1,269 @@
+package org.eclipse.jpt.ui.internal.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.content.orm.EntityMappingsInternal;
+import org.eclipse.jpt.ui.internal.JpaUiMessages;
+import org.eclipse.jpt.ui.internal.JpaUiPlugin;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EmbeddableUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.EntityUiProvider;
+import org.eclipse.jpt.ui.internal.java.mappings.properties.MappedSuperclassUiProvider;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.progress.IProgressService;
+
+public class AddPersistentClassDialog extends StatusDialog
+{
+ private EntityMappingsInternal entityMappings;
+
+ private Label classLabel;
+
+ private Text classText;
+
+ private Button classBrowseButton;
+
+ private Label mappingLabel;
+
+ private ComboViewer mappingCombo;
+
+
+ public AddPersistentClassDialog(Shell parentShell, EntityMappingsInternal entityMappings) {
+ super(parentShell);
+ this.entityMappings = entityMappings;
+ setTitle(JpaUiMessages.AddPersistentClassDialog_title);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = (Composite) super.createDialogArea(parent);
+
+ Composite composite = new Composite(dialogArea, SWT.NULL);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(2, false));
+
+ classLabel = createLabel(composite, 2, JpaUiMessages.AddPersistentClassDialog_classLabel);
+
+ classText = createText(composite, 1);
+ classText.addModifyListener(
+ new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ }
+ );
+
+ classBrowseButton = createButton(composite, 1, JpaUiMessages.General_browse);
+ classBrowseButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ IType type = chooseType();
+ if (type != null) {
+ classText.setText(type.getFullyQualifiedName());
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ mappingLabel = createLabel(composite, 2, JpaUiMessages.AddPersistentClassDialog_mappingLabel);
+
+ mappingCombo = new ComboViewer(createCombo(composite, 2));
+ mappingCombo.setContentProvider(
+ new IStructuredContentProvider() {
+ public void dispose() {}
+
+ public Object[] getElements(Object inputElement) {
+ return new Object[] {
+ new MappedSuperclassUiProvider(),
+ new EntityUiProvider(),
+ new EmbeddableUiProvider()
+ };
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+ mappingCombo.setLabelProvider(
+ new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((ITypeMappingUiProvider) element).label();
+ }
+ });
+ mappingCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ validate();
+ }
+ });
+ mappingCombo.setInput("FOO");
+ mappingCombo.getCombo().select(1); // select Entity to begin
+
+ // TODO - F1 Help
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IDaliHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE);
+
+ //getButton(IDialogConstants.OK_ID).setEnabled(false); // disabled to start
+ applyDialogFont(dialogArea);
+
+ validate();
+
+ return dialogArea;
+ }
+
+ private Label createLabel(Composite container, int span, String text) {
+ Label label = new Label(container, SWT.NONE);
+ label.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ label.setLayoutData(gd);
+ return label;
+ }
+
+ private Text createText(Composite container, int span) {
+ Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = span;
+ gd.widthHint = 250;
+ text.setLayoutData(gd);
+ return text;
+ }
+
+ private Button createButton(Composite container, int span, String text) {
+ Button button = new Button(container, SWT.NONE);
+ button.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ button.setLayoutData(gd);
+ return button;
+ }
+
+ private Combo createCombo(Composite container, int span) {
+ Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = span;
+ combo.setLayoutData(gd);
+ return combo;
+ }
+
+ private IJpaProject getJpaProject() {
+ return entityMappings.getJpaProject();
+ }
+
+ public String getClassName() {
+ return classText.getText();
+ }
+
+ public String getMappingKey() {
+ StructuredSelection selection = (StructuredSelection) mappingCombo.getSelection();
+ return (selection.isEmpty()) ? null : ((ITypeMappingUiProvider) selection.getFirstElement()).key();
+ }
+
+ protected IType chooseType() {
+ IJavaElement[] elements= new IJavaElement[] { getJpaProject().getJavaProject() };
+ IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+
+ SelectionDialog typeSelectionDialog;
+ try {
+ typeSelectionDialog =
+ JavaUI.createTypeDialog(
+ getShell(), service, scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false, getClassName());
+ }
+ catch (JavaModelException e) {
+ JpaUiPlugin.log(e);
+ throw new RuntimeException(e);
+ }
+ typeSelectionDialog.setTitle(JpaUiMessages.AddPersistentClassDialog_classDialog_title);
+ typeSelectionDialog.setMessage(JpaUiMessages.AddPersistentClassDialog_classDialog_message);
+
+ if (typeSelectionDialog.open() == Window.OK) {
+ return (IType) typeSelectionDialog.getResult()[0];
+ }
+ return null;
+ }
+
+ private void validate() {
+ String className = getClassName();
+
+ if (StringTools.stringIsEmpty(className)) {
+ updateStatus(
+ new Status(
+ IStatus.ERROR, JpaUiPlugin.PLUGIN_ID,
+ JpaUiMessages.AddPersistentClassDialog_noClassError));
+ return;
+ }
+
+ IType type;
+ try {
+ type = getJpaProject().getJavaProject().findType(className);
+ }
+ catch (JavaModelException jme) {
+ type = null;
+ }
+
+ if (type == null) {
+ updateStatus(
+ new Status(
+ IStatus.WARNING, JpaUiPlugin.PLUGIN_ID,
+ JpaUiMessages.AddPersistentClassDialog_classNotFoundWarning));
+ return;
+ }
+
+ if (entityMappings.containsPersistentType(type)) {
+ updateStatus(
+ new Status(
+ IStatus.WARNING, JpaUiPlugin.PLUGIN_ID,
+ JpaUiMessages.AddPersistentClassDialog_duplicateClassWarning));
+ return;
+ }
+
+ String mappingKey = getMappingKey();
+ if (mappingKey == null) {
+ updateStatus(
+ new Status(
+ IStatus.ERROR, JpaUiPlugin.PLUGIN_ID,
+ JpaUiMessages.AddPersistentClassDialog_noMappingKeyError));
+ return;
+ }
+
+ updateStatus(Status.OK_STATUS);
+ }
+
+ @Override
+ protected void okPressed() {
+ entityMappings.addMapping(getClassName(), getMappingKey());
+ super.okPressed();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java
new file mode 100644
index 0000000000..d49a4f975b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java
@@ -0,0 +1,6 @@
+package org.eclipse.jpt.ui.internal.generic;
+
+import org.eclipse.jpt.ui.internal.BaseJpaPlatformUi;
+
+public class GenericPlatformUi extends BaseJpaPlatformUi
+{}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java
new file mode 100644
index 0000000000..0009105076
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+
+public interface IAttributeMappingUiProvider
+{
+ /**
+ * A unique string that corresponds to the key of a MappingProvider in the core
+ * (IJavaAttributeMappingProvider and/or IXmlAttributeMappingProvider)
+ */
+ String key();
+
+ /**
+ * A label to be displayed to the label as an option in the mapping type combo box
+ * @return
+ */
+ String label();
+
+ /**
+ * The IJpaComposite that correponds to this mapping type. This will be displayed
+ * by the PersistentAttributeDetailsPage when the mapping key matches the key given
+ * by this provider. The composites will be stored in a Map with the mapping key as the key.
+ *
+ * @param parent
+ * @param commandStack
+ * @param widgetFactory
+ * @return
+ */
+ IJpaComposite buildAttributeMappingComposite(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/ITypeMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/ITypeMappingUiProvider.java
new file mode 100644
index 0000000000..7f00a47299
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/ITypeMappingUiProvider.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public interface ITypeMappingUiProvider
+{
+ /**
+ * A unique string that corresponds to the key of a MappingProvider in the core
+ */
+ String key();
+
+ /**
+ * A label to be displayed to the label as an option in the mapping type combo box
+ * @return
+ */
+ String label();
+
+ /**
+ * The IJpaComposite that correponds to this mapping type. This will be displayed
+ * by the PersistentTypeDetailsPage when the mapping key matches the key given
+ * by this provider. The composites will be stored in a Map with the mapping key as the key.
+ *
+ * @param parent
+ * @param commandStack
+ * @param widgetFactory
+ * @return
+ */
+ IJpaComposite buildPersistentTypeMappingComposite(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaDetailsProvider.java
new file mode 100644
index 0000000000..cb3ec7d6f5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaDetailsProvider.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.details;
+
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jpt.core.internal.content.java.IJavaContentNodes;
+import org.eclipse.jpt.ui.internal.details.IJpaDetailsPage;
+import org.eclipse.jpt.ui.internal.details.IJpaDetailsProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JavaDetailsProvider
+ implements IJpaDetailsProvider
+{
+ public JavaDetailsProvider() {
+ super();
+ }
+
+ public String fileContentType() {
+ return JavaCore.JAVA_SOURCE_CONTENT_TYPE;
+ }
+
+ public IJpaDetailsPage buildDetailsPage(
+ Composite parentComposite, Object contentNodeId, TabbedPropertySheetWidgetFactory widgetFactory) {
+ if (contentNodeId.equals(IJavaContentNodes.PERSISTENT_TYPE_ID)) {
+ return new JavaPersistentTypeDetailsPage(parentComposite, widgetFactory);
+ }
+ else if (contentNodeId.equals(IJavaContentNodes.PERSISTENT_ATTRIBUTE_ID)) {
+ return new JavaPersistentAttributeDetailsPage(parentComposite, widgetFactory);
+ }
+
+ return null;
+ }
+
+ public void dispose() {
+ // no op ... for now
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java
new file mode 100644
index 0000000000..dc7a77464c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.details;
+
+import org.eclipse.jpt.ui.internal.details.PersistentAttributeDetailsPage;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JavaPersistentAttributeDetailsPage
+ extends PersistentAttributeDetailsPage
+{
+ public JavaPersistentAttributeDetailsPage(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ composite.setLayout(new GridLayout(2, false));
+
+ GridData gridData;
+
+ buildMappingLabel(composite);
+
+ CComboViewer mappingCombo = buildMappingCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ mappingCombo.getCombo().setLayoutData(gridData);
+
+ PageBook mappingPageBook = buildMappingPageBook(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ mappingPageBook.setLayoutData(gridData);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java
new file mode 100644
index 0000000000..d6f25d24f2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.details;
+
+import org.eclipse.jpt.ui.internal.details.PersistentTypeDetailsPage;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JavaPersistentTypeDetailsPage extends
+ PersistentTypeDetailsPage
+{
+
+ public JavaPersistentTypeDetailsPage(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ composite.setLayout(gridLayout);
+
+ buildTypeMappingLabel(composite);
+
+ CComboViewer typeMappingCombo = buildTypeMappingCombo(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ typeMappingCombo.getCombo().setLayoutData(gridData);
+
+ PageBook typeMappingPageBook = buildTypeMappingPageBook(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ typeMappingPageBook.setLayoutData(gridData);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/BasicMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/BasicMappingUiProvider.java
new file mode 100644
index 0000000000..583e267962
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/BasicMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.BasicComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class BasicMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final BasicMappingUiProvider INSTANCE = new BasicMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private BasicMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_BasicLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new BasicComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultBasicMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultBasicMappingUiProvider.java
new file mode 100644
index 0000000000..134d4385aa
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultBasicMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.BasicComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class DefaultBasicMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final DefaultBasicMappingUiProvider INSTANCE = new DefaultBasicMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private DefaultBasicMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return "Default (" + JpaUiMappingsMessages.PersistentAttributePage_BasicLabel + ")";
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new BasicComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultEmbeddedMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultEmbeddedMappingUiProvider.java
new file mode 100644
index 0000000000..1599b4b8f2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/DefaultEmbeddedMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EmbeddedComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class DefaultEmbeddedMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final DefaultEmbeddedMappingUiProvider INSTANCE = new DefaultEmbeddedMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private DefaultEmbeddedMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return "Default (" + JpaUiMappingsMessages.PersistentAttributePage_EmbeddedLabel + ")";
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EmbeddedComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddableUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddableUiProvider.java
new file mode 100644
index 0000000000..004bfefc48
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddableUiProvider.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EmbeddableComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddableUiProvider implements ITypeMappingUiProvider
+{
+ public String key() {
+ return IMappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentTypePage_EmbeddableLabel;
+ }
+
+ public IJpaComposite buildPersistentTypeMappingComposite(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EmbeddableComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedIdMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedIdMappingUiProvider.java
new file mode 100644
index 0000000000..4fe562b60c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedIdMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EmbeddedIdComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddedIdMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final EmbeddedIdMappingUiProvider INSTANCE = new EmbeddedIdMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private EmbeddedIdMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_EmbeddedIdLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EmbeddedIdComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedMappingUiProvider.java
new file mode 100644
index 0000000000..d8f4939842
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EmbeddedMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EmbeddedComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddedMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final EmbeddedMappingUiProvider INSTANCE = new EmbeddedMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private EmbeddedMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_EmbeddedLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EmbeddedComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EntityUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EntityUiProvider.java
new file mode 100644
index 0000000000..aafac8eb65
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/EntityUiProvider.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EntityComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EntityUiProvider implements ITypeMappingUiProvider
+{
+ public String key() {
+ return IMappingKeys.ENTITY_TYPE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentTypePage_EntityLabel;
+ }
+
+ public IJpaComposite buildPersistentTypeMappingComposite(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EntityComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/IdMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/IdMappingUiProvider.java
new file mode 100644
index 0000000000..e609865a00
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/IdMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.IdComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class IdMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final IdMappingUiProvider INSTANCE = new IdMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private IdMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_IdLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new IdComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToManyMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToManyMappingUiProvider.java
new file mode 100644
index 0000000000..6dd56dff63
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToManyMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.ManyToManyComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class ManyToManyMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final ManyToManyMappingUiProvider INSTANCE = new ManyToManyMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private ManyToManyMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_ManyToManyLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new ManyToManyComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToOneMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToOneMappingUiProvider.java
new file mode 100644
index 0000000000..a29ab51323
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/ManyToOneMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.ManyToOneComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class ManyToOneMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final ManyToOneMappingUiProvider INSTANCE = new ManyToOneMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private ManyToOneMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_ManyToOneLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new ManyToOneComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/MappedSuperclassUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/MappedSuperclassUiProvider.java
new file mode 100644
index 0000000000..af1d56f231
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/MappedSuperclassUiProvider.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.MappedSuperclassComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class MappedSuperclassUiProvider implements ITypeMappingUiProvider
+{
+ public String key() {
+ return IMappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentTypePage_MappedSuperclassLabel;
+ }
+
+ public IJpaComposite buildPersistentTypeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new MappedSuperclassComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullAttributeMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullAttributeMappingUiProvider.java
new file mode 100644
index 0000000000..1c160473b6
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullAttributeMappingUiProvider.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class NullAttributeMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final NullAttributeMappingUiProvider INSTANCE = new NullAttributeMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private NullAttributeMappingUiProvider() {
+ super();
+ }
+
+
+ public String key() {
+ return null;
+ }
+
+ public String label() {
+ return "";
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new NullComposite(parent);
+ }
+
+
+ public static class NullComposite extends Composite
+ implements IJpaComposite
+ {
+ NullComposite(Composite parent) {
+ super(parent, SWT.NONE);
+ }
+
+ public void populate(EObject model) {
+ // no op
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+ public Control getControl() {
+ return this;
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullTypeMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullTypeMappingUiProvider.java
new file mode 100644
index 0000000000..b435bd597f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/NullTypeMappingUiProvider.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.ITypeMappingUiProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class NullTypeMappingUiProvider implements ITypeMappingUiProvider
+{
+ public String key() {
+ return null;
+ }
+
+ public String label() {
+ return "";
+ }
+
+ public IJpaComposite buildPersistentTypeMappingComposite(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new NullComposite(parent);
+ }
+
+
+ public static class NullComposite extends Composite
+ implements IJpaComposite
+ {
+ private Composite composite;
+ NullComposite(Composite parent) {
+ super(parent, SWT.NONE);
+ this.composite = new Composite(parent, SWT.NONE);
+ }
+
+ public void populate(EObject model) {
+ // no op
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ public Control getControl() {
+ return this.composite;
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToManyMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToManyMappingUiProvider.java
new file mode 100644
index 0000000000..b4abe1ba3e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToManyMappingUiProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.OneToManyComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class OneToManyMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+ // singleton
+ private static final OneToManyMappingUiProvider INSTANCE = new OneToManyMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private OneToManyMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_OneToManyLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new OneToManyComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToOneMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToOneMappingUiProvider.java
new file mode 100644
index 0000000000..e145f0d8c5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/OneToOneMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.OneToOneComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class OneToOneMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final OneToOneMappingUiProvider INSTANCE = new OneToOneMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private OneToOneMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_OneToOneLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new OneToOneComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/TransientMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/TransientMappingUiProvider.java
new file mode 100644
index 0000000000..f6e8be96df
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/TransientMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.TransientComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class TransientMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final TransientMappingUiProvider INSTANCE = new TransientMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private TransientMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_TransientLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new TransientComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/VersionMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/VersionMappingUiProvider.java
new file mode 100644
index 0000000000..d645aad2f4
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/mappings/properties/VersionMappingUiProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.java.mappings.properties;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.ui.internal.details.IJpaComposite;
+import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.VersionComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class VersionMappingUiProvider
+ implements IAttributeMappingUiProvider
+{
+
+ // singleton
+ private static final VersionMappingUiProvider INSTANCE = new VersionMappingUiProvider();
+
+ /**
+ * Return the singleton.
+ */
+ public static IAttributeMappingUiProvider instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private VersionMappingUiProvider() {
+ super();
+ }
+
+ public String key() {
+ return IMappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String label() {
+ return JpaUiMappingsMessages.PersistentAttributePage_VersionLabel;
+ }
+
+ public IJpaComposite buildAttributeMappingComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new VersionComposite(parent, commandStack, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaCompilationUnitItemProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaCompilationUnitItemProvider.java
new file mode 100644
index 0000000000..1a5b207d27
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaCompilationUnitItemProvider.java
@@ -0,0 +1,30 @@
+package org.eclipse.jpt.ui.internal.java.structure;
+
+import java.util.Collection;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.jpt.core.internal.content.java.JpaJavaPackage;
+
+public class JavaCompilationUnitItemProvider extends ItemProviderAdapter
+ implements IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider
+{
+ public JavaCompilationUnitItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ @Override
+ public Collection getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(JpaJavaPackage.Literals.JPA_COMPILATION_UNIT__TYPES);
+ }
+ return childrenFeatures;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentAttributeItemProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentAttributeItemProvider.java
new file mode 100644
index 0000000000..6b7cd2c408
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentAttributeItemProvider.java
@@ -0,0 +1,92 @@
+package org.eclipse.jpt.ui.internal.java.structure;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+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;
+import org.eclipse.jpt.core.internal.IAttributeMapping;
+import org.eclipse.jpt.core.internal.IPersistentAttribute;
+import org.eclipse.jpt.core.internal.JpaCorePackage;
+import org.eclipse.jpt.core.internal.mappings.IBasic;
+import org.eclipse.jpt.core.internal.mappings.IEmbedded;
+import org.eclipse.jpt.core.internal.mappings.IEmbeddedId;
+import org.eclipse.jpt.core.internal.mappings.IId;
+import org.eclipse.jpt.core.internal.mappings.IManyToMany;
+import org.eclipse.jpt.core.internal.mappings.IManyToOne;
+import org.eclipse.jpt.core.internal.mappings.IOneToMany;
+import org.eclipse.jpt.core.internal.mappings.IOneToOne;
+import org.eclipse.jpt.core.internal.mappings.ITransient;
+import org.eclipse.jpt.core.internal.mappings.IVersion;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsImages;
+
+public class JavaPersistentAttributeItemProvider extends ItemProviderAdapter
+ implements IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider
+{
+ public JavaPersistentAttributeItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ @Override
+ public Object getImage(Object object) {
+ IAttributeMapping mapping = ((IPersistentAttribute) object).getMapping();
+
+ if (mapping instanceof IBasic) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.BASIC);
+ }
+ else if (mapping instanceof IId) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.ID);
+ }
+ else if (mapping instanceof IVersion) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.VERSION);
+ }
+ else if (mapping instanceof IEmbedded) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.EMBEDDED);
+ }
+ else if (mapping instanceof IEmbeddedId) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.EMBEDDED_ID);
+ }
+ else if (mapping instanceof IOneToOne) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.ONE_TO_ONE);
+ }
+ else if (mapping instanceof IOneToMany) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.ONE_TO_MANY);
+ }
+ else if (mapping instanceof IManyToOne) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.MANY_TO_ONE);
+ }
+ else if (mapping instanceof IManyToMany) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.MANY_TO_MANY);
+ }
+ else if (mapping instanceof ITransient) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.TRANSIENT);
+ }
+ else {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.NULL_ATTRIBUTE_MAPPING);
+ }
+ }
+
+ @Override
+ public String getText(Object object) {
+ return ((IPersistentAttribute) object).getName();
+ }
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(IPersistentAttribute.class)) {
+ case JpaCorePackage.IPERSISTENT_ATTRIBUTE__MAPPING_KEY:
+ fireNotifyChanged(new ViewerNotification(notification, notification
+ .getNotifier(), false, true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentTypeItemProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentTypeItemProvider.java
new file mode 100644
index 0000000000..8e61ddc524
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaPersistentTypeItemProvider.java
@@ -0,0 +1,88 @@
+package org.eclipse.jpt.ui.internal.java.structure;
+
+import java.util.Collection;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+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;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.core.internal.IPersistentType;
+import org.eclipse.jpt.core.internal.ITypeMapping;
+import org.eclipse.jpt.core.internal.JpaCorePackage;
+import org.eclipse.jpt.core.internal.content.java.JavaPersistentType;
+import org.eclipse.jpt.core.internal.content.java.JpaJavaPackage;
+import org.eclipse.jpt.core.internal.mappings.IEmbeddable;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IMappedSuperclass;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsImages;
+
+public class JavaPersistentTypeItemProvider extends ItemProviderAdapter
+ implements IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider
+{
+ public JavaPersistentTypeItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+
+ @Override
+ protected Collection getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(JpaJavaPackage.Literals.JAVA_PERSISTENT_TYPE__ATTRIBUTES);
+ }
+ return childrenFeatures;
+ }
+
+ @Override
+ public Object getImage(Object object) {
+ ITypeMapping mapping = ((IPersistentType) object).getMapping();
+
+
+ if (mapping instanceof IEntity) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.ENTITY);
+ }
+ else if (mapping instanceof IEmbeddable) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.EMBEDDABLE);
+ }
+ else if (mapping instanceof IMappedSuperclass) {
+ return JpaUiMappingsImages.getImage(JpaUiMappingsImages.MAPPED_SUPERCLASS);
+ }
+ else {
+ return null;
+ }
+ }
+
+ @Override
+ public String getText(Object object) {
+ IType type = ((IPersistentType) object).findJdtType();
+ return (type == null) ? "" : type.getElementName();
+ }
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(JavaPersistentType.class)) {
+ case JpaCorePackage.IPERSISTENT_TYPE__MAPPING_KEY:
+ fireNotifyChanged(
+ new ViewerNotification(
+ notification, notification.getNotifier(), false, true));
+ return;
+
+ case JpaJavaPackage.JAVA_PERSISTENT_TYPE__ATTRIBUTES:
+ fireNotifyChanged(
+ new ViewerNotification(
+ notification, notification.getNotifier(), true, false));
+ return;
+ }
+
+ super.notifyChanged(notification);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaStructureProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaStructureProvider.java
new file mode 100644
index 0000000000..6fdd02fd4e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JavaStructureProvider.java
@@ -0,0 +1,28 @@
+package org.eclipse.jpt.ui.internal.java.structure;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jpt.ui.internal.structure.IJpaStructureProvider;
+
+public class JavaStructureProvider implements IJpaStructureProvider
+{
+ public String fileContentType() {
+ return JavaCore.JAVA_SOURCE_CONTENT_TYPE;
+ }
+
+ public ITreeContentProvider buildContentProvider() {
+ return new AdapterFactoryContentProvider(new JpaCoreJavaItemProviderAdapterFactory());
+ }
+
+ public ILabelProvider buildLabelProvider() {
+ return new AdapterFactoryLabelProvider(new JpaCoreJavaItemProviderAdapterFactory());
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JpaCoreJavaItemProviderAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JpaCoreJavaItemProviderAdapterFactory.java
new file mode 100644
index 0000000000..d6ca598339
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/structure/JpaCoreJavaItemProviderAdapterFactory.java
@@ -0,0 +1,166 @@
+package org.eclipse.jpt.ui.internal.java.structure;
+
+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.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.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.jpt.core.internal.content.java.util.JpaJavaAdapterFactory;
+
+/**
+ * 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.
+ */
+public class JpaCoreJavaItemProviderAdapterFactory
+ extends JpaJavaAdapterFactory
+ implements ComposeableAdapterFactory,
+ IChangeNotifier,
+ IDisposable
+{
+ /**
+ * This keeps track of the root adapter factory that delegates to this adapter factory.
+ */
+ protected ComposedAdapterFactory parentAdapterFactory;
+
+ /**
+ * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
+ */
+ protected IChangeNotifier changeNotifier = new ChangeNotifier();
+
+ /**
+ * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
+ */
+ protected Collection supportedTypes = new ArrayList();
+
+
+ public JpaCoreJavaItemProviderAdapterFactory() {
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ }
+
+
+ protected JavaCompilationUnitItemProvider javaCompilationUnitItemProvider;
+
+ public Adapter createJpaCompilationUnitAdapter() {
+ if (javaCompilationUnitItemProvider == null) {
+ javaCompilationUnitItemProvider = new JavaCompilationUnitItemProvider(this);
+ }
+
+ return javaCompilationUnitItemProvider;
+ }
+
+ protected JavaPersistentTypeItemProvider javaPersistentTypeItemProvider;
+
+ public Adapter createJavaPersistentTypeAdapter() {
+ if (javaPersistentTypeItemProvider == null) {
+ javaPersistentTypeItemProvider = new JavaPersistentTypeItemProvider(this);
+ }
+
+ return javaPersistentTypeItemProvider;
+ }
+
+ protected JavaPersistentAttributeItemProvider javaPersistentAttributeItemProvider;
+
+ public Adapter createJavaPersistentAttributeAdapter() {
+ if (javaPersistentAttributeItemProvider == null) {
+ javaPersistentAttributeItemProvider = new JavaPersistentAttributeItemProvider(
+ this);
+ }
+
+ return javaPersistentAttributeItemProvider;
+ }
+
+ /**
+ * This returns the root adapter factory that contains this factory.
+ */
+ public ComposeableAdapterFactory getRootAdapterFactory() {
+ return parentAdapterFactory == null ?
+ this :
+ parentAdapterFactory.getRootAdapterFactory();
+ }
+
+ /**
+ * This sets the composed adapter factory that contains this factory.
+ */
+ public void setParentAdapterFactory(
+ ComposedAdapterFactory parentAdapterFactory) {
+ this.parentAdapterFactory = parentAdapterFactory;
+ }
+
+ public boolean isFactoryForType(Object type) {
+ return supportedTypes.contains(type) || super.isFactoryForType(type);
+ }
+
+ /**
+ * This implementation substitutes the factory itself as the key for the adapter.
+ */
+ public Adapter adapt(Notifier notifier, Object type) {
+ return super.adapt(notifier, this);
+ }
+
+ 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.
+ */
+ public void addListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.addListener(notifyChangedListener);
+ }
+
+ /**
+ * This removes a listener.
+ */
+ public void removeListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.removeListener(notifyChangedListener);
+ }
+
+ /**
+ * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
+ */
+ 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.
+ */
+ public void dispose() {
+ if (javaCompilationUnitItemProvider != null) {
+ javaCompilationUnitItemProvider.dispose();
+ }
+ if (javaPersistentTypeItemProvider != null) {
+ javaPersistentTypeItemProvider.dispose();
+ }
+ if (javaPersistentAttributeItemProvider != null) {
+ javaPersistentAttributeItemProvider.dispose();
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullLabelProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullLabelProvider.java
new file mode 100644
index 0000000000..6ae04981f5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullLabelProvider.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.jface;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+
+public class NullLabelProvider
+ implements ILabelProvider
+{
+ public static NullLabelProvider INSTANCE = new NullLabelProvider();
+
+
+ private NullLabelProvider() {
+ super();
+ }
+
+
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {}
+
+ public void dispose() {}
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {}
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullTreeContentProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullTreeContentProvider.java
new file mode 100644
index 0000000000..47a2268929
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jface/NullTreeContentProvider.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.jface;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class NullTreeContentProvider
+ implements ITreeContentProvider
+{
+ public static NullTreeContentProvider INSTANCE = new NullTreeContentProvider();
+
+
+ private NullTreeContentProvider() {
+ super();
+ }
+
+
+ public Object[] getChildren(Object parentElement) {
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return new Object[0];
+ }
+
+ public void dispose() {}
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsImages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsImages.java
new file mode 100644
index 0000000000..3adf38c3ce
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsImages.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings;
+
+import org.eclipse.jpt.ui.internal.JpaUiPlugin;
+
+public class JpaUiMappingsImages
+{
+ public final static String BASIC = "full/obj16/basic";
+
+ public final static String EMBEDDABLE = "full/obj16/embeddable";
+
+ public final static String EMBEDDED = "full/obj16/embedded";
+
+ public final static String EMBEDDED_ID = "full/obj16/embedded-id";
+
+ public final static String ENTITY = "full/obj16/entity";
+
+ public final static String ENTITY_MAPPINGS = "full/obj16/entity-mappings";
+
+ public final static String ID = "full/obj16/id";
+
+ public final static String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping";
+
+ public final static String MANY_TO_MANY = "full/obj16/many-to-many";
+
+ public final static String MANY_TO_ONE = "full/obj16/many-to-one";
+
+ public final static String MAPPED_SUPERCLASS = "full/obj16/mapped-superclass";
+
+ public final static String NULL_TYPE_MAPPING = "full/obj16/null-type-mapping";
+
+ public final static String ONE_TO_MANY = "full/obj16/one-to-many";
+
+ public final static String ONE_TO_ONE = "full/obj16/one-to-one";
+
+ public final static String TEMPORAL = "full/obj16/temporal";
+
+ public final static String TRANSIENT = "full/obj16/transient";
+
+ public final static String VERSION = "full/obj16/version";
+
+
+ public static Object getImage(String imageLocator) {
+ return JpaUiPlugin.getPlugin().getImageDescriptor(imageLocator).createImage();
+ }
+
+
+ private JpaUiMappingsImages() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsMessages.java
new file mode 100644
index 0000000000..ac7ab23f2e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/JpaUiMappingsMessages.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JpaUiMappingsMessages extends NLS
+{
+ private static final String BUNDLE_NAME = "jpa_ui_mappings"; //$NON-NLS-1$
+
+ public static String PersistentTypePage_EntityLabel;
+ public static String PersistentTypePage_EmbeddableLabel;
+ public static String PersistentTypePage_MappedSuperclassLabel;
+
+ public static String PersistentAttributePage_BasicLabel;
+ public static String PersistentAttributePage_TransientLabel;
+ public static String PersistentAttributePage_IdLabel;
+ public static String PersistentAttributePage_OneToManyLabel;
+ public static String PersistentAttributePage_ManyToOneLabel;
+ public static String PersistentAttributePage_ManyToManyLabel;
+ public static String PersistentAttributePage_VersionLabel;
+ public static String PersistentAttributePage_EmbeddedLabel;
+ public static String PersistentAttributePage_EmbeddedIdLabel;
+ public static String PersistentAttributePage_OneToOneLabel;
+
+
+ public static String EntityGeneralSection_nameDefaultWithOneParam;
+ public static String EntityGeneralSection_nameDefaultEmpty;
+ public static String EntityGeneralSection_name;
+
+ public static String BasicGeneralSection_name;
+ public static String BasicGeneralSection_nameDefault;
+ public static String BasicGeneralSection_fetchLabel;
+ public static String BasicGeneralSection_optionalLabel;
+ public static String BasicGeneralSection_lobLabel;
+ public static String BasicGeneralSection_temporalLabel;
+ public static String BasicGeneralSection_enumeratedLabel;
+
+ public static String EntityComposite_tableDefault;
+ public static String EntityComposite_tableNoDefaultSpecified;
+ public static String EntityComposite_inheritance;
+ public static String TableComposite_defaultEmpty;
+ public static String TableComposite_defaultWithOneParam;
+
+ public static String TableChooser_label;
+ public static String CatalogChooser_label;
+ public static String SchemaChooser_label;
+
+ public static String ColumnChooser_label;
+ public static String ColumnTableChooser_label;
+
+ public static String TargetEntityChooser_label;
+ public static String TargetEntityChooser_defaultEmpty;
+ public static String TargetEntityChooser_defaultWithOneParam;
+ public static String TargetEntityChooser_browse;
+
+ public static String NonOwningMapping_mappedByLabel;
+
+ public static String JoinTableComposite_add;
+ public static String JoinTableComposite_defaultEmpty;
+ public static String JoinTableComposite_defaultWithOneParam;
+ public static String JoinTableComposite_edit;
+ public static String JoinTableComposite_inverseJoinColumn;
+ public static String JoinTableComposite_joinColumn;
+ public static String JoinTableComposite_mappingBetweenTwoParams;
+ public static String JoinTableComposite_mappingBetweenTwoParamsDefault;
+ public static String JoinTableComposite_mappingBetweenTwoParamsBothDefault;
+ public static String JoinTableComposite_mappingBetweenTwoParamsFirstDefault;
+ public static String JoinTableComposite_mappingBetweenTwoParamsSecDefault;
+ public static String JoinTableComposite_name;
+ public static String JoinTableComposite_remove;
+ public static String JoinTableComposite_overrideDefaultJoinColumns;
+ public static String JoinTableComposite_overrideDefaultInverseJoinColumns;
+
+ public static String JoinColumnDialog_editJoinColumn;
+ public static String JoinColumnDialog_name;
+ public static String JoinColumnDialog_insertable;
+ public static String JoinColumnDialog_updatable;
+ public static String JoinColumnDialog_defaultWithOneParam;
+ public static String JoinColumnDialog_referencedColumnName;
+
+ public static String InverseJoinColumnDialog_defaultWithOneParam;
+ public static String InverseJoinColumnDialog_editInverseJoinColumn;
+
+
+ public static String MultiRelationshipMappingComposite_cascadeType;
+ public static String MultiRelationshipMappingComposite_fetchType;
+ public static String MultiRelationshipMappingComposite_general;
+ public static String MultiRelationshipMappingComposite_joinTable;
+ public static String MultiRelationshipMappingComposite_mappedBy;
+ public static String MultiRelationshipMappingComposite_targetEntity;
+
+ public static String ColumnComposite_defaultWithOneParam;
+ public static String ColumnComposite_defaultEmpty;
+
+ public static String JoinColumnComposite_defaultEmpty;
+ public static String JoinColumnComposite_defaultWithOneParam;
+ public static String JoinColumnComposite_joinColumn;
+ public static String JoinColumnComposite_name;
+ public static String JoinColumnComposite_add;
+ public static String JoinColumnComposite_edit;
+ public static String JoinColumnComposite_mappingBetweenTwoParams;
+ public static String JoinColumnComposite_mappingBetweenTwoParamsDefault;
+ public static String JoinColumnComposite_mappingBetweenTwoParamsBothDefault;
+ public static String JoinColumnComposite_mappingBetweenTwoParamsFirstDefault;
+ public static String JoinColumnComposite_mappingBetweenTwoParamsSecDefault;
+ public static String JoinColumnComposite_remove;
+ public static String JoinColumnComposite_overrideDefaultJoinColumns;
+
+ public static String PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns;
+ public static String PrimaryKeyJoinColumnsComposite_add;
+ public static String PrimaryKeyJoinColumnsComposite_edit;
+ public static String PrimaryKeyJoinColumnsComposite_remove;
+ public static String PrimaryKeyJoinColumnsComposite_defaultEmpty;
+ public static String PrimaryKeyJoinColumnsComposite_defaultWithOneParam;
+ public static String PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn;
+ public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams;
+ public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault;
+ public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault;
+ public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault;
+
+ public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault;
+ public static String AttributeOverridesComposite_attributeOverrides;
+ public static String AttributeOverridesComposite_overridDefault;
+
+ public static String InheritanceComposite_strategy;
+ public static String InheritanceComposite_discriminatorValue;
+ public static String InheritanceComposite_discriminatorValueDefaultWithOneParam;
+
+ public static String DiscriminatorColumnComposite_defaultEmpty;
+ public static String DiscriminatorColumnComposite_column;
+ public static String DiscriminatorColumnComposite_discriminatorType;
+
+ public static String GeneratedValueComposite_generatedValue;
+ public static String GeneratedValueComposite_generatorName;
+ public static String GeneratedValueComposite_strategy;
+
+ public static String TableGeneratorComposite_default;
+ public static String TableGeneratorComposite_name;
+ public static String TableGeneratorComposite_pkColumn;
+ public static String TableGeneratorComposite_pkColumnValue;
+ public static String TableGeneratorComposite_table;
+ public static String TableGeneratorComposite_tableGenerator;
+ public static String TableGeneratorComposite_valueColumn;
+
+ public static String SequenceGeneratorComposite_sequenceGenerator;
+ public static String SequenceGeneratorComposite_name;
+ public static String SequenceGeneratorComposite_sequence;
+ public static String SequenceGeneratorComposite_default;
+
+ public static String IdMappingComposite_pk_generation;
+ public static String IdMappingComposite_primaryKeyGeneration;
+ public static String IdMappingComposite_tableGenerator;
+ public static String IdMappingComposite_sequenceGenerator;
+
+ public static String OrderByComposite_orderByGroup;
+ public static String OrderByComposite_noOrdering;
+ public static String OrderByComposite_primaryKeyOrdering;
+ public static String OrderByComposite_customOrdering;
+ public static String OrderByComposite_orderByLabel;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, JpaUiMappingsMessages.class);
+ }
+
+ private JpaUiMappingsMessages() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/AbstractJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/AbstractJoinColumnDialog.java
new file mode 100644
index 0000000000..ef5cec6331
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/AbstractJoinColumnDialog.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+//if there is only 1 joinColumn and the user is editing it, they should be
+//able to define defaults. otherwise, we probably shouldn't allow it.
+public abstract class AbstractJoinColumnDialog<E extends IAbstractJoinColumn> extends Dialog {
+
+ //if creating a new JoinColumn, this will be null,
+ //specify the JoinColumnOwner instead in the appropriate construtor
+ private E joinColumn;
+
+ private Combo nameCombo;
+ private Combo referencedColumnNameCombo;
+
+
+ private boolean defaultNameSelected;
+ private String selectedName;
+ private boolean defaultReferencedColumnNameSelected;
+ private String selectedReferencedColumnName;
+
+ AbstractJoinColumnDialog(Shell parent) {
+ super(parent);
+ }
+
+ AbstractJoinColumnDialog(Shell parent, E joinColumn) {
+ super(parent);
+ this.joinColumn = joinColumn;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(getTitle());
+ }
+
+ protected String getTitle() {
+ return JpaUiMappingsMessages.JoinColumnDialog_editJoinColumn;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridLayout gridLayout = (GridLayout) composite.getLayout();
+ gridLayout.numColumns = 2;
+
+ Label nameLabel = new Label(composite, SWT.LEFT);
+ nameLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_name);
+ GridData gridData = new GridData();
+ nameLabel.setLayoutData(gridData);
+
+ this.nameCombo = new Combo(composite, SWT.LEFT);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.nameCombo.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.nameCombo, IJpaHelpContextIds.MAPPING_JOIN_COLUMN_NAME);
+ populateNameCombo();
+
+ Label referencedColumnNameLabel = new Label(composite, SWT.LEFT);
+ referencedColumnNameLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_referencedColumnName);
+ gridData = new GridData();
+ referencedColumnNameLabel.setLayoutData(gridData);
+
+ this.referencedColumnNameCombo = new Combo(composite, SWT.LEFT);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.referencedColumnNameCombo.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.referencedColumnNameCombo, IJpaHelpContextIds.MAPPING_JOIN_REFERENCED_COLUMN);
+ populateReferencedNameCombo();
+
+ return composite;
+ }
+
+ protected void populateNameCombo() {
+ if (getJoinColumn() != null) {
+ this.nameCombo.add(NLS.bind(JpaUiMappingsMessages.JoinColumnDialog_defaultWithOneParam, getJoinColumn().getDefaultName()));
+ }
+ Table table = getNameTable();
+ if (table != null) {
+ for (Iterator i = table.columnNames(); i.hasNext(); ) {
+ this.nameCombo.add((String) i.next());
+ }
+ }
+ if (getJoinColumn() != null) {
+ if (getJoinColumn().getSpecifiedName() != null) {
+ this.nameCombo.setText(getJoinColumn().getSpecifiedName());
+ }
+ else {
+ this.nameCombo.select(0);
+ }
+ }
+ }
+
+ protected Combo getNameCombo() {
+ return this.nameCombo;
+ }
+
+ protected Combo getReferencedColumnNameCombo() {
+ return this.referencedColumnNameCombo;
+ }
+
+ protected abstract Table getNameTable();
+
+ protected abstract Table getReferencedNameTable();
+
+ protected void populateReferencedNameCombo() {
+ if (getJoinColumn() != null) {
+ this.referencedColumnNameCombo.add(NLS.bind(JpaUiMappingsMessages.JoinColumnDialog_defaultWithOneParam, getJoinColumn().getDefaultReferencedColumnName()));
+ }
+ Table referencedNameTable = getReferencedNameTable();
+ if (referencedNameTable != null) {
+ for (Iterator i = referencedNameTable.columnNames(); i.hasNext(); ) {
+ this.referencedColumnNameCombo.add((String) i.next());
+ }
+ }
+ if (getJoinColumn() != null) {
+ if (getJoinColumn().getSpecifiedReferencedColumnName() != null) {
+ this.referencedColumnNameCombo.setText(getJoinColumn().getSpecifiedReferencedColumnName());
+ }
+ else {
+ this.referencedColumnNameCombo.select(0);
+ }
+ }
+ }
+
+ protected E getJoinColumn() {
+ return this.joinColumn;
+ }
+
+ protected boolean isDefaultNameSelected() {
+ return this.defaultNameSelected;
+ }
+
+ protected String getSelectedName() {
+ return this.selectedName;
+ }
+
+ protected boolean isDefaultReferencedColumnNameSelected() {
+ return this.defaultReferencedColumnNameSelected;
+ }
+
+ protected String getReferencedColumnName() {
+ return this.selectedReferencedColumnName;
+ }
+
+ public boolean close() {
+ this.defaultNameSelected = this.nameCombo.getSelectionIndex() == 0;
+ this.selectedName = this.nameCombo.getText();
+ this.defaultReferencedColumnNameSelected = this.referencedColumnNameCombo.getSelectionIndex() == 0;
+ this.selectedReferencedColumnName = this.referencedColumnNameCombo.getText();
+ return super.close();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/BasicComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/BasicComposite.java
new file mode 100644
index 0000000000..71fda3a5a5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/BasicComposite.java
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.jpt.core.internal.mappings.DefaultEagerFetchType;
+import org.eclipse.jpt.core.internal.mappings.DefaultTrueBoolean;
+import org.eclipse.jpt.core.internal.mappings.EnumType;
+import org.eclipse.jpt.core.internal.mappings.IBasic;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.core.internal.mappings.TemporalType;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.EnumComboViewer.EnumHolder;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class BasicComposite extends BaseJpaComposite
+{
+ private IBasic basic;
+
+ private ColumnComposite columnComposite;
+
+ private EnumComboViewer fetchTypeComboViewer;
+ private EnumComboViewer optionalComboViewer;
+ private LobCheckBox lobCheckBox;
+ private EnumComboViewer temporalTypeViewer;
+ private EnumComboViewer enumeratedTypeViewer;
+
+ public BasicComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ this.columnComposite = new ColumnComposite(generalComposite, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.columnComposite.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildFetchLabel(generalComposite, getWidgetFactory());
+ this.fetchTypeComboViewer = CommonWidgets.buildFetchTypeComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.fetchTypeComboViewer.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildOptionalLabel(generalComposite, getWidgetFactory());
+ this.optionalComboViewer = CommonWidgets.buildEnumComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.optionalComboViewer.getControl().setLayoutData(gridData);
+
+ this.lobCheckBox = buildLobCheckBox(generalComposite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.lobCheckBox.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildTemporalLabel(generalComposite, getWidgetFactory());
+ this.temporalTypeViewer = CommonWidgets.buildEnumComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.temporalTypeViewer.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildEnumeratedLabel(generalComposite, getWidgetFactory());
+ this.enumeratedTypeViewer = CommonWidgets.buildEnumComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.enumeratedTypeViewer.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ private LobCheckBox buildLobCheckBox(Composite parent) {
+ return new LobCheckBox(parent, this.commandStack, getWidgetFactory());
+ }
+
+ public void doPopulate(EObject obj) {
+ this.basic = (IBasic) obj;
+ if (this.basic != null) {
+ this.columnComposite.populate(this.basic.getColumn());
+ }
+ else {
+ this.columnComposite.populate(null);
+ }
+ this.fetchTypeComboViewer.populate(new FetchHolder(this.basic));
+ this.optionalComboViewer.populate(new OptionalHolder(this.basic));
+ this.lobCheckBox.populate(this.basic);
+ this.temporalTypeViewer.populate(new TemporalTypeHolder(this.basic));
+ this.enumeratedTypeViewer.populate(new EnumeratedTypeHolder(this.basic));
+ }
+
+ public void doPopulate() {
+ this.columnComposite.populate();
+ this.fetchTypeComboViewer.populate();
+ this.optionalComboViewer.populate();
+ this.lobCheckBox.populate();
+ this.temporalTypeViewer.populate();
+ this.enumeratedTypeViewer.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.columnComposite.dispose();
+ this.fetchTypeComboViewer.dispose();
+ this.optionalComboViewer.dispose();
+ this.lobCheckBox.dispose();
+ this.temporalTypeViewer.dispose();
+ this.enumeratedTypeViewer.dispose();
+ super.dispose();
+ }
+
+ protected IBasic getBasic() {
+ return this.basic;
+ }
+
+ private class FetchHolder extends EObjectImpl implements EnumHolder {
+
+ private IBasic basic;
+
+ FetchHolder(IBasic basic) {
+ super();
+ this.basic = basic;
+ }
+
+ public Object get() {
+ return this.basic.getFetch();
+ }
+
+ public void set(Object enumSetting) {
+ this.basic.setFetch((DefaultEagerFetchType) enumSetting);
+
+ }
+
+ public Class featureClass() {
+ return IBasic.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IBASIC__FETCH;
+ }
+
+ public EObject wrappedObject() {
+ return this.basic;
+ }
+
+ public Object[] enumValues() {
+ return DefaultEagerFetchType.VALUES.toArray();
+ }
+ }
+
+
+ private class OptionalHolder extends EObjectImpl implements EnumHolder {
+
+ private IBasic basic;
+
+ OptionalHolder(IBasic basic) {
+ super();
+ this.basic = basic;
+ }
+
+ public Object get() {
+ return this.basic.getOptional();
+ }
+
+ public void set(Object enumSetting) {
+ this.basic.setOptional((DefaultTrueBoolean) enumSetting);
+ }
+
+ public Class featureClass() {
+ return IBasic.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IBASIC__OPTIONAL;
+ }
+
+ public EObject wrappedObject() {
+ return this.basic;
+ }
+
+ public Object[] enumValues() {
+ return DefaultTrueBoolean.VALUES.toArray();
+ }
+ }
+
+
+ private class TemporalTypeHolder extends EObjectImpl implements EnumHolder {
+
+ private IBasic basic;
+
+ TemporalTypeHolder(IBasic basic) {
+ super();
+ this.basic = basic;
+ }
+
+ public Object get() {
+ return this.basic.getTemporal();
+ }
+
+ public void set(Object enumSetting) {
+ this.basic.setTemporal((TemporalType) enumSetting);
+ }
+
+ public Class featureClass() {
+ return IBasic.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IBASIC__TEMPORAL;
+ }
+
+ public EObject wrappedObject() {
+ return this.basic;
+ }
+
+ public Object[] enumValues() {
+ return TemporalType.VALUES.toArray();
+ }
+ }
+
+ private class EnumeratedTypeHolder extends EObjectImpl implements EnumHolder {
+
+ private IBasic basic;
+
+ EnumeratedTypeHolder(IBasic basic) {
+ super();
+ this.basic = basic;
+ }
+
+ public Object get() {
+ return this.basic.getEnumerated();
+ }
+
+ public void set(Object enumSetting) {
+ this.basic.setEnumerated((EnumType) enumSetting);
+ }
+
+ public Class featureClass() {
+ return IBasic.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IBASIC__ENUMERATED;
+ }
+
+ public EObject wrappedObject() {
+ return this.basic;
+ }
+
+ public Object[] enumValues() {
+ return EnumType.VALUES.toArray();
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
new file mode 100644
index 0000000000..cc0fab1337
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.mappings.IAbstractColumn;
+import org.eclipse.jpt.core.internal.mappings.IColumn;
+import org.eclipse.jpt.core.internal.mappings.INamedColumn;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.db.internal.Connection;
+import org.eclipse.jpt.db.internal.ConnectionListener;
+import org.eclipse.jpt.db.internal.ConnectionProfile;
+import org.eclipse.jpt.db.internal.Database;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+//TODO repopulate this panel based on the Entity table changing
+public class ColumnComposite extends BaseJpaComposite
+{
+
+ private IColumn column;
+
+ private Adapter columnListener;
+ private ConnectionListener connectionListener;
+
+ protected CCombo columnCombo;
+ protected CCombo tableCombo;
+
+ private ConnectionProfile connectionProfile;
+
+ public ColumnComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.columnListener = buildColumnListener();
+ this.connectionListener = buildConnectionListener();
+ }
+
+ private Adapter buildColumnListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ columnChanged(notification);
+ }
+ };
+ }
+
+ private ConnectionListener buildConnectionListener() {
+ return new ConnectionListener() {
+
+ public void aboutToClose(Connection connection) {
+ // not interested to this event.
+ }
+
+ public void closed(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ ColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public void modified(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ ColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public boolean okToClose(Connection connection) {
+ // not interested to this event.
+ return true;
+ }
+
+ public void opened(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ ColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public void databaseChanged(Connection connection, final Database database) {
+ return;
+ }
+
+ public void schemaChanged(Connection connection, final Schema schema) {
+ return;
+ }
+
+ public void tableChanged(Connection connection, final Table table) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if(table == getDbTable()) {
+ if (!getControl().isDisposed()) {
+ ColumnComposite.this.populateColumnCombo();
+ }
+ }
+ }
+ });
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ CommonWidgets.buildColumnLabel(composite, getWidgetFactory());
+
+ this.columnCombo = buildColumnCombo(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.columnCombo.setLayoutData(gridData);
+ helpSystem.setHelp(columnCombo, IJpaHelpContextIds.MAPPING_COLUMN);
+
+
+ CommonWidgets.buildColumnTableLabel(composite, getWidgetFactory());
+
+ this.tableCombo = buildTableCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.tableCombo.setLayoutData(gridData);
+ helpSystem.setHelp(tableCombo, IJpaHelpContextIds.MAPPING_COLUMN_TABLE);
+ }
+
+
+ private CCombo buildColumnCombo(Composite parent) {
+ final CCombo combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ combo.add(JpaUiMappingsMessages.ColumnComposite_defaultEmpty);
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String columnText = ((CCombo) e.getSource()).getText();
+ if (columnText.equals("")) { //$NON-NLS-1$
+ columnText = null;
+ if (column.getSpecifiedName() == null || column.getSpecifiedName().equals("")) { //$NON-NLS-1$
+ return;
+ }
+ }
+
+ if (columnText != null && combo.getItemCount() > 0 && columnText.equals(combo.getItem(0))) {
+ columnText = null;
+ }
+
+ if (column.getSpecifiedName() == null && columnText != null) {
+ column.setSpecifiedName(columnText);
+ }
+ if (column.getSpecifiedName() != null && !column.getSpecifiedName().equals(columnText)) {
+ column.setSpecifiedName(columnText);
+ }
+ }
+ });
+ return combo;
+ }
+
+ private CCombo buildTableCombo(Composite parent) {
+ final CCombo combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ combo.add(JpaUiMappingsMessages.ColumnComposite_defaultEmpty);
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String tableText = ((CCombo) e.getSource()).getText();
+ if (tableText.equals("")) { //$NON-NLS-1$
+ tableText = null;
+ if (column.getSpecifiedTable() == null || column.getSpecifiedTable().equals("")) { //$NON-NLS-1$
+ return;
+ }
+ }
+
+ if (tableText != null && combo.getItemCount() > 0 && tableText.equals(combo.getItem(0))) {
+ tableText = null;
+ }
+
+ if (column.getSpecifiedTable() == null && tableText != null) {
+ column.setSpecifiedTable(tableText);
+ }
+ if (column.getSpecifiedTable() != null && !column.getSpecifiedTable().equals(tableText)) {
+ column.setSpecifiedTable(tableText);
+ }
+ }
+ });
+ return combo;
+
+ }
+
+ protected void columnChanged(Notification notification) {
+ if (notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__SPECIFIED_NAME) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed() || isPopulating()) {
+ return;
+ }
+ populateColumnName();
+ }
+ });
+ }
+ else if (notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__DEFAULT_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateDefaultColumnName();
+ }
+ });
+ }
+ else if (notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateDefaultColumnTable();
+ populateColumnCombo();
+ }
+ });
+ }
+ else if (notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__SPECIFIED_TABLE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateColumnTable();
+ populateColumnCombo();
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.column != null) {
+ this.column.eAdapters().add(this.columnListener);
+ this.addConnectionListener();
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.column != null) {
+ this.removeConnectionListener();
+ this.column.eAdapters().remove(this.columnListener);
+ }
+ }
+
+ private ConnectionProfile getConnectionProfile() {
+ if(this.connectionProfile == null) {
+ IJpaProject jpaProject = this.column.getJpaProject();
+ this.connectionProfile = jpaProject.connectionProfile();
+ }
+ return this.connectionProfile;
+ }
+
+ private void addConnectionListener() {
+ this.getConnectionProfile().addConnectionListener(this.connectionListener);
+ }
+
+ private void removeConnectionListener() {
+ this.getConnectionProfile().removeConnectionListener(this.connectionListener);
+ }
+
+ private Table getDbTable() {
+ return this.column.dbTable();
+ }
+
+ private void populateColumnCombo() {
+ //TODO don't do instanceof check here - check on Table, or isRoot check on Entity
+ //this.tableCombo.setEnabled(!(this.table instanceof SingleTableInheritanceChildTableImpl));
+ populateDefaultColumnName();
+
+ if (this.getConnectionProfile().isConnected()) {
+ this.columnCombo.remove(1, this.columnCombo.getItemCount()-1);
+ Table table = getDbTable();
+ if (table != null) {
+ for (Iterator i = CollectionTools.sort(CollectionTools.list(table.columnNames())).iterator(); i.hasNext();) {
+ this.columnCombo.add((String) i.next());
+ }
+ }
+ }
+ else {
+ this.columnCombo.remove(1, this.columnCombo.getItemCount()-1);
+ }
+ populateColumnName();
+ }
+
+ protected void populateDefaultColumnName() {
+ String defaultTableName = column.getDefaultName();
+ int selectionIndex = columnCombo.getSelectionIndex();
+ columnCombo.setItem(0, NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName));
+ if (selectionIndex == 0) {
+ //combo text does not update when switching between 2 mappings of the same type
+ //that both have a default column name. clear the selection and then set it again
+ columnCombo.clearSelection();
+ columnCombo.select(0);
+ }
+ }
+
+ protected void populateColumnName() {
+ String specifiedColumnName = this.column.getSpecifiedName();
+ if (specifiedColumnName != null) {
+ if (!this.columnCombo.getText().equals(specifiedColumnName)) {
+ this.columnCombo.setText(specifiedColumnName);
+ }
+ }
+ else {
+ String defaultColumnName = this.column.getDefaultName();
+ if (!this.columnCombo.getText().equals(NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultColumnName))) {
+ this.columnCombo.select(0);
+ }
+ }
+ }
+
+ private void populateTableCombo() {
+ //TODO don't do instanceof check here - check on Table, or isRoot check on Entity
+ //this.tableCombo.setEnabled(!(this.table instanceof SingleTableInheritanceChildTableImpl));
+ populateDefaultColumnTable();
+ this.tableCombo.remove(1, this.tableCombo.getItemCount()-1);
+
+ if (this.column != null) {
+ for (Iterator i = this.column.getOwner().getTypeMapping().associatedTableNamesIncludingInherited(); i.hasNext(); ) {
+ this.tableCombo.add((String) i.next());
+ }
+ }
+ populateColumnTable();
+ }
+
+ protected void populateDefaultColumnTable() {
+ String defaultTableName = column.getDefaultTable();
+ int selectionIndex = tableCombo.getSelectionIndex();
+ tableCombo.setItem(0, NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName));
+ if (selectionIndex == 0) {
+ //combo text does not update when switching between 2 mappings of the same type
+ //that both have a default column name. clear the selection and then set it again
+ tableCombo.clearSelection();
+ tableCombo.select(0);
+ }
+ }
+
+ protected void populateColumnTable() {
+ String tableName = this.column.getSpecifiedTable();
+ String defaultTableName = this.column.getDefaultTable();
+ if (tableName != null) {
+ if (!this.tableCombo.getText().equals(tableName)) {
+ this.tableCombo.setText(tableName);
+ }
+ }
+ else {
+ if (!this.tableCombo.getText().equals(NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName))) {
+ this.tableCombo.select(0);
+ }
+ }
+ }
+
+ public void doPopulate(EObject obj) {
+ this.column = (IColumn) obj;
+ if (this.column != null) {
+ populateColumnCombo();
+ populateTableCombo();
+ }
+ }
+
+ public void doPopulate() {
+ if (this.column != null) {
+ populateColumnCombo();
+ populateTableCombo();
+ }
+ }
+
+ protected void enableWidgets(boolean enabled) {
+ this.columnCombo.setEnabled(enabled);
+ this.tableCombo.setEnabled(enabled);
+ //this.insertableComboViewer.getCombo().setEnabled(enabled);
+ //this.updatableComboViewer.getCombo().setEnabled(enabled);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CommonWidgets.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CommonWidgets.java
new file mode 100644
index 0000000000..544e530d31
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CommonWidgets.java
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.jpt.core.internal.mappings.DefaultEagerFetchType;
+import org.eclipse.jpt.core.internal.mappings.DefaultLazyFetchType;
+import org.eclipse.jpt.core.internal.mappings.IAbstractColumn;
+import org.eclipse.jpt.core.internal.mappings.IColumn;
+import org.eclipse.jpt.core.internal.mappings.IMultiRelationshipMapping;
+import org.eclipse.jpt.core.internal.mappings.ISingleRelationshipMapping;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EnumComboViewer.EnumHolder;
+import org.eclipse.jpt.ui.internal.mappings.details.StringWithDefaultChooser.StringHolder;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class CommonWidgets
+{
+ public static Label buildEntityNameLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.EntityGeneralSection_name);
+ }
+
+ public static EntityNameCombo buildEntityNameCombo(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EntityNameCombo(parent, commandStack, widgetFactory);
+ }
+
+ public static Label buildTableLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.TableChooser_label);
+ }
+
+ public static Label buildCatalogLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.CatalogChooser_label);
+ }
+
+ public static Label buildSchemaLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.SchemaChooser_label);
+ }
+
+ public static StringWithDefaultChooser buildStringWithDefaultChooser(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new StringWithDefaultChooser(parent, commandStack, widgetFactory);
+ }
+
+
+ public static Label buildFetchLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.BasicGeneralSection_fetchLabel);
+ }
+
+ public static Label buildTargetEntityLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.TargetEntityChooser_label);
+ }
+
+ public static Label buildOptionalLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.BasicGeneralSection_optionalLabel);
+ }
+
+ public static Label buildTemporalLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.BasicGeneralSection_temporalLabel);
+ }
+
+ public static Label buildEnumeratedLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.BasicGeneralSection_enumeratedLabel);
+ }
+
+ public static Label buildMappedByLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.NonOwningMapping_mappedByLabel);
+ }
+
+ public static EnumComboViewer buildFetchTypeComboViewer(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EnumComboViewer(parent, commandStack, widgetFactory);
+ }
+
+ public static EnumComboViewer buildEnumComboViewer(
+ Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new EnumComboViewer(parent, commandStack, widgetFactory);
+ }
+
+ public static EnumHolder buildMultiRelationshipMappingFetchEnumHolder(IMultiRelationshipMapping mapping) {
+ return new FetchHolder(mapping);
+ }
+
+ public static EnumHolder buildSingleRelationshipMappingFetchEnumHolder(ISingleRelationshipMapping mapping) {
+ return new SingleRelationshipMappingFetchHolder(mapping);
+ }
+
+ public static Label buildColumnLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.ColumnChooser_label);
+ }
+
+ public static Label buildColumnTableLabel(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return widgetFactory.createLabel(parent, JpaUiMappingsMessages.ColumnTableChooser_label);
+ }
+
+ public static ColumnTableHolder buildColumnTableHolder(IColumn column) {
+ return new ColumnTableHolder(column);
+ }
+
+ public static TargetEntityChooser buildTargetEntityChooser(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ return new TargetEntityChooser(parent, commandStack, widgetFactory);
+ }
+ private static class FetchHolder extends EObjectImpl implements EnumHolder {
+
+ private IMultiRelationshipMapping mapping;
+
+ FetchHolder(IMultiRelationshipMapping mapping) {
+ super();
+ this.mapping = mapping;
+ }
+
+ public Object get() {
+ return this.mapping.getFetch();
+ }
+
+ public void set(Object enumSetting) {
+ this.mapping.setFetch((DefaultLazyFetchType) enumSetting);
+
+ }
+
+ public Class featureClass() {
+ return IMultiRelationshipMapping.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IMULTI_RELATIONSHIP_MAPPING__FETCH;
+ }
+
+ public EObject wrappedObject() {
+ return this.mapping;
+ }
+
+ public Object[] enumValues() {
+ return DefaultLazyFetchType.VALUES.toArray();
+ }
+ }
+
+ private static class SingleRelationshipMappingFetchHolder extends EObjectImpl implements EnumHolder {
+
+ private ISingleRelationshipMapping mapping;
+
+ SingleRelationshipMappingFetchHolder(ISingleRelationshipMapping mapping) {
+ super();
+ this.mapping = mapping;
+ }
+
+ public Object get() {
+ return this.mapping.getFetch();
+ }
+
+ public void set(Object enumSetting) {
+ this.mapping.setFetch((DefaultEagerFetchType) enumSetting);
+
+ }
+
+ public Class featureClass() {
+ return ISingleRelationshipMapping.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.ISINGLE_RELATIONSHIP_MAPPING__FETCH;
+ }
+
+ public EObject wrappedObject() {
+ return this.mapping;
+ }
+
+ public Object[] enumValues() {
+ return DefaultEagerFetchType.VALUES.toArray();
+ }
+ }
+ private static abstract class ColumnHolder extends EObjectImpl implements StringHolder {
+ private IAbstractColumn column;
+
+ ColumnHolder(IAbstractColumn column) {
+ super();
+ this.column = column;
+ }
+
+ public Class featureClass() {
+ return IAbstractColumn.class;
+ }
+
+ public boolean supportsDefault() {
+ return true;
+ }
+
+ public EObject wrappedObject() {
+ return this.column;
+ }
+
+ protected IAbstractColumn getColumn() {
+ return this.column;
+ }
+ }
+
+ public static class ColumnTableHolder extends ColumnHolder implements StringHolder {
+
+ ColumnTableHolder(IAbstractColumn column) {
+ super(column);
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IABSTRACT_COLUMN__SPECIFIED_TABLE;
+ }
+
+ public int defaultFeatureId() {
+ return JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE;
+ }
+
+ public String defaultItem() {
+ String defaultName = getColumn().getDefaultTable();
+ if (defaultName != null) {
+ return NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultName);
+ }
+ return JpaUiMappingsMessages.ColumnComposite_defaultEmpty;
+ }
+
+ public String getString() {
+ return getColumn().getSpecifiedTable();
+ }
+
+ public void setString(String newName) {
+ getColumn().setSpecifiedTable(newName);
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java
new file mode 100644
index 0000000000..a6b6e1e979
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.mappings.DiscriminatorType;
+import org.eclipse.jpt.core.internal.mappings.IDiscriminatorColumn;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.db.internal.Connection;
+import org.eclipse.jpt.db.internal.ConnectionListener;
+import org.eclipse.jpt.db.internal.ConnectionProfile;
+import org.eclipse.jpt.db.internal.Database;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+//TODO repopulate this panel based on the Entity table changing
+public class DiscriminatorColumnComposite extends BaseJpaComposite
+{
+
+ private IDiscriminatorColumn discriminatorColumn;
+ private final Adapter discriminatorColumnListener;
+ private ConnectionListener connectionListener;
+
+ private CCombo columnCombo;
+ private CComboViewer discriminatorTypeViewer;
+
+ private ConnectionProfile connectionProfile;
+
+
+
+ public DiscriminatorColumnComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.discriminatorColumnListener = buildDiscriminatorColumnListener();
+ this.connectionListener = buildConnectionListener();
+ }
+
+ private Adapter buildDiscriminatorColumnListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ discriminatorColumnChanged(notification);
+ }
+ };
+ }
+
+ private ConnectionListener buildConnectionListener() {
+ return new ConnectionListener() {
+
+ public void aboutToClose(Connection connection) {
+ // not interested to this event.
+ }
+
+ public void closed(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ DiscriminatorColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public void modified(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ DiscriminatorColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public boolean okToClose(Connection connection) {
+ // not interested to this event.
+ return true;
+ }
+
+ public void opened(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ DiscriminatorColumnComposite.this.populateColumnCombo();
+ }
+ });
+ }
+
+ public void databaseChanged(Connection connection, final Database database) {
+ return;
+ }
+
+ public void schemaChanged(Connection connection, final Schema schema) {
+ return;
+ }
+
+ public void tableChanged(Connection connection, final Table table) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if(table == getDbTable()) {
+ if (!getControl().isDisposed()) {
+ DiscriminatorColumnComposite.this.populateColumnCombo();
+ }
+ }
+ }
+ });
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.DiscriminatorColumnComposite_column);
+
+ this.columnCombo = buildColumnCombo(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.columnCombo.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.columnCombo, IJpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN);
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.DiscriminatorColumnComposite_discriminatorType);
+
+ this.discriminatorTypeViewer = buildDiscriminatorTypeCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.discriminatorTypeViewer.getCombo().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.discriminatorTypeViewer.getCombo(), IJpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_TYPE);
+ }
+
+
+ private CCombo buildColumnCombo(Composite parent) {
+ final CCombo combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ combo.add(JpaUiMappingsMessages.ColumnComposite_defaultEmpty);
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String tableText = ((CCombo) e.getSource()).getText();
+ if (tableText.equals("")) { //$NON-NLS-1$
+ tableText = null;
+ if (discriminatorColumn.getSpecifiedName() == null || discriminatorColumn.getSpecifiedName().equals("")) { //$NON-NLS-1$
+ return;
+ }
+ }
+
+ if (tableText != null && combo.getItemCount() > 0 && tableText.equals(combo.getItem(0))) {
+ tableText = null;
+ }
+
+ if (discriminatorColumn.getSpecifiedName() == null && tableText != null) {
+ discriminatorColumn.setSpecifiedName(tableText);
+ }
+ if (discriminatorColumn.getSpecifiedName() != null && !discriminatorColumn.getSpecifiedName().equals(tableText)) {
+ discriminatorColumn.setSpecifiedName(tableText);
+ }
+ }
+ });
+ return combo;
+
+ }
+
+ private CComboViewer buildDiscriminatorTypeCombo(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent);
+ CComboViewer discriminatorTypeViewer = new CComboViewer(combo);
+ discriminatorTypeViewer.add(DiscriminatorType.VALUES.toArray());
+
+ discriminatorTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ DiscriminatorColumnComposite.this.discriminatorTypeSelectionChanged(event.getSelection());
+ }
+ });
+
+ return discriminatorTypeViewer;
+ }
+
+ void discriminatorTypeSelectionChanged(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ DiscriminatorType discriminatorType = (DiscriminatorType) ((IStructuredSelection) selection).getFirstElement();
+ if ( ! this.discriminatorColumn.getDiscriminatorType().equals(discriminatorType)) {
+ this.discriminatorColumn.setDiscriminatorType(discriminatorType);
+ }
+ }
+ }
+
+ protected void discriminatorColumnChanged(Notification notification) {
+ if (notification.getFeatureID(IDiscriminatorColumn.class) == JpaCoreMappingsPackage.IDISCRIMINATOR_COLUMN__SPECIFIED_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateColumnName();
+ }
+ });
+ }
+ else if (notification.getFeatureID(IDiscriminatorColumn.class) == JpaCoreMappingsPackage.IDISCRIMINATOR_COLUMN__DEFAULT_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateDefaultColumnName();
+ }
+ });
+ }
+
+ else if (notification.getFeatureID(IDiscriminatorColumn.class) == JpaCoreMappingsPackage.IDISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE) {
+ final DiscriminatorType discriminatorType = (DiscriminatorType) notification.getNewValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (((StructuredSelection) discriminatorTypeViewer.getSelection()).getFirstElement() != discriminatorType) {
+ discriminatorTypeViewer.setSelection(new StructuredSelection(discriminatorType));
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.discriminatorColumn != null) {
+ this.discriminatorColumn.eAdapters().add(this.discriminatorColumnListener);
+ this.addConnectionListener();
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.discriminatorColumn != null) {
+ this.removeConnectionListener();
+ this.discriminatorColumn.eAdapters().remove(this.discriminatorColumnListener);
+ }
+ }
+
+ private ConnectionProfile getConnectionProfile() {
+ if(this.connectionProfile == null) {
+ IJpaProject jpaProject = this.discriminatorColumn.getJpaProject();
+ this.connectionProfile = jpaProject.connectionProfile();
+ }
+ return this.connectionProfile;
+ }
+
+ private void addConnectionListener() {
+ this.getConnectionProfile().addConnectionListener(this.connectionListener);
+ }
+
+ private void removeConnectionListener() {
+ this.getConnectionProfile().removeConnectionListener(this.connectionListener);
+ }
+
+ private Table getDbTable() {
+ return this.discriminatorColumn.dbTable();
+ }
+
+ private void populateColumnCombo() {
+ //TODO don't do instanceof check here - check on Table, or isRoot check on Entity
+ //this.tableCombo.setEnabled(!(this.table instanceof SingleTableInheritanceChildTableImpl));
+ populateDefaultColumnName();
+
+ if (this.getConnectionProfile().isConnected()) {
+ this.columnCombo.remove(1, this.columnCombo.getItemCount()-1);
+ Table table = getDbTable();
+ if (table != null) {
+ for (Iterator i = CollectionTools.sort(CollectionTools.list(table.columnNames())).iterator(); i.hasNext();) {
+ this.columnCombo.add((String) i.next());
+ }
+ }
+ }
+ else {
+ this.columnCombo.remove(1, this.columnCombo.getItemCount()-1);
+ }
+ populateColumnName();
+ }
+
+ protected void populateDefaultColumnName() {
+ String defaultTableName = discriminatorColumn.getDefaultName();
+ int selectionIndex = columnCombo.getSelectionIndex();
+ columnCombo.setItem(0, NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName));
+ if (selectionIndex == 0) {
+ //combo text does not update when switching between 2 mappings of the same type
+ //that both have a default column name. clear the selection and then set it again
+ columnCombo.clearSelection();
+ columnCombo.select(0);
+ }
+ }
+
+ protected void populateColumnName() {
+ String tableName = this.discriminatorColumn.getSpecifiedName();
+ String defaultName = this.discriminatorColumn.getDefaultName();
+ if (tableName != null) {
+ if (!this.columnCombo.getText().equals(tableName)) {
+ this.columnCombo.setText(tableName);
+ }
+ }
+ else {
+ if (!this.columnCombo.getText().equals(NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultName))) {
+ this.columnCombo.select(0);
+ }
+ }
+ }
+ public void doPopulate(EObject obj) {
+ this.discriminatorColumn = (IDiscriminatorColumn) obj;
+ if (this.discriminatorColumn != null) {
+ populateColumnCombo();
+ popuplateDiscriminatorTypeComboViewer();
+ }
+ }
+
+ public void doPopulate() {
+ if (this.discriminatorColumn != null) {
+ populateColumnCombo();
+ }
+ }
+
+ private void popuplateDiscriminatorTypeComboViewer() {
+ if (this.discriminatorColumn.getDiscriminatorType() == DiscriminatorType.DEFAULT) {
+ if (((StructuredSelection) this.discriminatorTypeViewer.getSelection()).getFirstElement() != DiscriminatorType.DEFAULT) {
+ this.discriminatorTypeViewer.setSelection(new StructuredSelection(DiscriminatorType.DEFAULT));
+ }
+ }
+ else if (this.discriminatorColumn.getDiscriminatorType() == DiscriminatorType.CHAR) {
+ if (((StructuredSelection) this.discriminatorTypeViewer.getSelection()).getFirstElement() != DiscriminatorType.CHAR) {
+ this.discriminatorTypeViewer.setSelection(new StructuredSelection(DiscriminatorType.CHAR));
+ }
+ }
+ else if (this.discriminatorColumn.getDiscriminatorType() == DiscriminatorType.INTEGER) {
+ if (((StructuredSelection) this.discriminatorTypeViewer.getSelection()).getFirstElement() != DiscriminatorType.INTEGER) {
+ this.discriminatorTypeViewer.setSelection(new StructuredSelection(DiscriminatorType.INTEGER));
+ }
+ }
+ else {
+ if (((StructuredSelection) this.discriminatorTypeViewer.getSelection()).getFirstElement() != DiscriminatorType.STRING) {
+ this.discriminatorTypeViewer.setSelection(new StructuredSelection(DiscriminatorType.STRING));
+ }
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddableComposite.java
new file mode 100644
index 0000000000..2c98eb093f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddableComposite.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IEmbeddable;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddableComposite extends BaseJpaComposite
+{
+ private IEmbeddable embeddable;
+ private Adapter mappedSuperclassListener;
+
+ private CommandStack commandStack;
+
+
+ public EmbeddableComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.mappedSuperclassListener = buildMappedSuperclassListener();
+ }
+
+ private Adapter buildMappedSuperclassListener() {
+ return new AdapterImpl() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ mappedSuperclassChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ composite.setLayout(new FillLayout(SWT.VERTICAL));
+
+// Label accessTypeLabel = new Label(composite, SWT.LEFT);
+// accessTypeLabel.setText(DaliUiMessages.MappedSuperclassComposite_accessType);
+// this.accessTypeComboViewer = buildAccessTypeCombo(composite);
+// //eventually this will be enabled if editing xml instead of java
+// this.accessTypeComboViewer.getCombo().setEnabled(false);
+// GridData gridData = new GridData();
+// gridData.horizontalAlignment = GridData.FILL;
+// gridData.grabExcessHorizontalSpace = true;
+// this.accessTypeComboViewer.getCombo().setLayoutData(gridData);
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(this.accessTypeComboViewer.getCombo(), IDaliHelpContextIds.ENTITY_ACCESS_TYPE);
+
+ }
+
+// private ComboViewer buildAccessTypeCombo(Composite parent) {
+// ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+// viewer.add(AccessType.VALUES.toArray());
+// viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+// public void selectionChanged(SelectionChangedEvent event) {
+// if (populating) {
+// return;
+// }
+// if (event.getSelection() instanceof StructuredSelection) {
+// StructuredSelection selection = (StructuredSelection) event.getSelection();
+// editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, persistentType, OrmPackage.eINSTANCE.getPersistentType_AccessType(), selection.getFirstElement()));
+// }
+// }
+// });
+// return viewer;
+// }
+
+ @Override
+ protected void doPopulate(EObject model) {
+ this.embeddable = (IEmbeddable) model;
+ }
+
+ @Override
+ protected void doPopulate() {
+
+ }
+
+
+ protected void engageListeners() {
+// this.persistentTypeItemProvider.addListener(getPersistentTypeListener());
+// this.persistentType.eAdapters().add(this.persistentTypeItemProvider);
+ }
+
+ protected void disengageListeners() {
+// if (this.persistentType != null){
+// this.persistentType.eAdapters().remove(this.persistentTypeItemProvider);
+// this.persistentTypeItemProvider.removeListener(getPersistentTypeListener());
+// }
+ }
+
+ private void mappedSuperclassChanged(Notification notification) {
+
+ }
+
+// private INotifyChangedListener getPersistentTypeListener() {
+// if (this.persistentTypeListener == null) {
+// this.persistentTypeListener = new INotifyChangedListener() {
+// public void notifyChanged(Notification notification) {
+// if (notification.getFeatureID(PersistentType.class) == OrmPackage.PERSISTENT_TYPE__ACCESS_TYPE) {
+// final AccessType accessType = (AccessType) notification.getNewValue();
+// Display.getDefault().syncExec(new Runnable() {
+// public void run() {
+// if (((StructuredSelection) accessTypeComboViewer.getSelection()).getFirstElement() != accessType) {
+// accessTypeComboViewer.setSelection(new StructuredSelection(accessType));
+// }
+// }
+// });
+// }
+// }
+// };
+// }
+// return this.persistentTypeListener;
+// }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedAttributeOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedAttributeOverridesComposite.java
new file mode 100644
index 0000000000..e150c6766b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedAttributeOverridesComposite.java
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jpt.core.internal.mappings.IAttributeOverride;
+import org.eclipse.jpt.core.internal.mappings.IEmbedded;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddedAttributeOverridesComposite extends BaseJpaComposite
+{
+ private ListViewer listViewer;
+
+ private IEmbedded embedded;
+ private Adapter embeddedListener;
+
+ private IAttributeOverride attributeOverride;
+ private Adapter attributeOverrideListener;
+
+ protected ColumnComposite columnComposite;
+
+ private Button overrideDefaultButton;
+
+ public EmbeddedAttributeOverridesComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.embeddedListener = buildEmbeddedListener();
+ this.attributeOverrideListener = buildAttributeOverrideListener();
+ }
+
+ private Adapter buildEmbeddedListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ embeddedChanged(notification);
+ }
+ };
+ }
+
+ private Adapter buildAttributeOverrideListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ attributeOverrideChanged(notification);
+ }
+ };
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Group attributeOverridesGroup = getWidgetFactory().createGroup(
+ composite, JpaUiMappingsMessages.AttributeOverridesComposite_attributeOverrides);
+ attributeOverridesGroup.setLayout(new GridLayout(2, true));
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace= true;
+ attributeOverridesGroup.setLayoutData(gridData);
+
+ this.listViewer = buildAttributeOverridesListViewer(attributeOverridesGroup);
+ gridData = new GridData();
+ gridData.verticalSpan = 2;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace= true;
+ this.listViewer.getList().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.listViewer.getList(), IJpaHelpContextIds.MAPPING_EMBEDDED_ATTRIBUTE_OVERRIDES);
+
+ this.overrideDefaultButton = getWidgetFactory().createButton(attributeOverridesGroup, "Override Default", SWT.CHECK);
+ this.overrideDefaultButton.addSelectionListener(buildOverrideDefaultSelectionListener());
+ gridData = new GridData();
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.overrideDefaultButton.setLayoutData(gridData);
+
+
+ this.columnComposite = new ColumnComposite(attributeOverridesGroup, commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.columnComposite.getControl().setLayoutData(gridData);
+
+ }
+
+ private SelectionListener buildOverrideDefaultSelectionListener() {
+ return new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ overrideDefaultButtonSelected(e);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ overrideDefaultButtonSelected(e);
+ }
+ };
+ }
+
+ private void overrideDefaultButtonSelected(SelectionEvent e) {
+ boolean selection = this.overrideDefaultButton.getSelection();
+ if (selection) {
+ int index = this.embedded.getSpecifiedAttributeOverrides().size();
+ IAttributeOverride attributeOverride = this.embedded.createAttributeOverride(index);
+ this.embedded.getSpecifiedAttributeOverrides().add(attributeOverride);
+ attributeOverride.setName(this.attributeOverride.getName());
+ attributeOverride.getColumn().setSpecifiedName(this.attributeOverride.getColumn().getName());
+ }
+ else {
+ this.embedded.getSpecifiedAttributeOverrides().remove(this.attributeOverride);
+ }
+ }
+
+
+ private ListViewer buildAttributeOverridesListViewer(Composite parent) {
+ ListViewer listViewer = new ListViewer(parent, SWT.SINGLE | SWT.BORDER);
+ listViewer.setLabelProvider(buildAttributeOverridesLabelProvider());
+ listViewer.setContentProvider(buildAttributeOverridesContentProvider());
+
+ listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ attributeOverridesListSelectionChanged(event);
+ }
+ });
+
+ return listViewer;
+ }
+
+ protected void attributeOverridesListSelectionChanged(SelectionChangedEvent event) {
+ if (((StructuredSelection) event.getSelection()).isEmpty()) {
+ this.columnComposite.populate(null);
+ this.columnComposite.enableWidgets(false);
+ this.overrideDefaultButton.setSelection(false);
+ this.overrideDefaultButton.setEnabled(false);
+ }
+ else {
+ this.attributeOverride = getSelectedAttributeOverride();
+ boolean specifiedOverride = this.embedded.getSpecifiedAttributeOverrides().contains(this.attributeOverride);
+ this.overrideDefaultButton.setSelection(specifiedOverride);
+ this.columnComposite.populate(this.attributeOverride.getColumn());
+ this.columnComposite.enableWidgets(specifiedOverride);
+ this.overrideDefaultButton.setEnabled(true);
+ }
+ }
+
+ private ILabelProvider buildAttributeOverridesLabelProvider() {
+ return new LabelProvider() {
+ public String getText(Object element) {
+ //TODO also display column name somehow
+ return ((IAttributeOverride) element).getName();
+ }
+ };
+ }
+
+
+ private IContentProvider buildAttributeOverridesContentProvider() {
+ return new IStructuredContentProvider() {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((IEmbedded) inputElement).getAttributeOverrides().toArray();
+ }
+ };
+ }
+
+ private IAttributeOverride getSelectedAttributeOverride() {
+ return (IAttributeOverride) ((StructuredSelection) this.listViewer.getSelection()).getFirstElement();
+ }
+
+
+ public void doPopulate(EObject obj) {
+ this.embedded = (IEmbedded) obj;
+ if (this.embedded == null) {
+ this.attributeOverride = null;
+ this.columnComposite.populate(null);
+ return;
+ }
+
+ if (this.listViewer.getInput() != this.embedded) {
+ this.listViewer.setInput(this.embedded);
+ }
+ if (!this.embedded.getAttributeOverrides().isEmpty()) {
+ if (this.listViewer.getSelection().isEmpty()) {
+ IAttributeOverride attributeOverride = this.embedded.getAttributeOverrides().get(0);
+ this.listViewer.setSelection(new StructuredSelection(attributeOverride));
+ }
+ else {
+ this.columnComposite.enableWidgets(true);
+ this.columnComposite.populate(((IAttributeOverride)((StructuredSelection) this.listViewer.getSelection()).getFirstElement()).getColumn());
+ }
+ }
+ else {
+ this.columnComposite.populate(null);
+ this.columnComposite.enableWidgets(false);
+ }
+ }
+
+ @Override
+ protected void doPopulate() {
+ this.columnComposite.doPopulate();
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.embedded != null) {
+ this.embedded.eAdapters().add(this.embeddedListener);
+ for (IAttributeOverride attributeOverride : this.embedded.getAttributeOverrides()) {
+ attributeOverride.eAdapters().add(this.attributeOverrideListener);
+ }
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.embedded != null) {
+ this.embedded.eAdapters().remove(this.embeddedListener);
+ for (IAttributeOverride attributeOverride : this.embedded.getAttributeOverrides()) {
+ attributeOverride.eAdapters().remove(this.attributeOverrideListener);
+ }
+ }
+ }
+
+
+ protected void embeddedChanged(Notification notification) {
+ switch (notification.getFeatureID(IEmbedded.class)) {
+ case JpaCoreMappingsPackage.IEMBEDDED__SPECIFIED_ATTRIBUTE_OVERRIDES :
+ case JpaCoreMappingsPackage.IEMBEDDED__DEFAULT_ATTRIBUTE_OVERRIDES :
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (listViewer.getList().isDisposed()) {
+ return;
+ }
+ listViewer.refresh();
+ columnComposite.enableWidgets(!listViewer.getSelection().isEmpty());
+ if (listViewer.getSelection().isEmpty()) {
+ columnComposite.populate(null);
+ }
+ }
+ });
+ if (notification.getEventType() == Notification.ADD) {
+ ((IAttributeOverride) notification.getNewValue()).eAdapters().add(this.attributeOverrideListener);
+ final Object newValue = notification.getNewValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (listViewer.getList().isDisposed()) {
+ return;
+ }
+ listViewer.setSelection(new StructuredSelection(newValue));
+ }
+ });
+ }
+ else if (notification.getEventType() == Notification.ADD_MANY) {
+ List addedList = (List) notification.getNewValue();
+ for (Iterator<IAttributeOverride> i = addedList.iterator(); i.hasNext(); ) {
+ IAttributeOverride override = i.next();
+ override.eAdapters().add(this.attributeOverrideListener);
+ }
+ }
+ else if (notification.getEventType() == Notification.REMOVE) {
+ ((IAttributeOverride) notification.getOldValue()).eAdapters().remove(this.attributeOverrideListener);
+ }
+ else if (notification.getEventType() == Notification.REMOVE_MANY) {
+ List removedList = (List) notification.getOldValue();
+ for (Iterator<IAttributeOverride> i = removedList.iterator(); i.hasNext(); ) {
+ IAttributeOverride override = i.next();
+ override.eAdapters().remove(this.attributeOverrideListener);
+ }
+ }
+ break;
+ default :
+ break;
+ }
+ }
+
+ protected void attributeOverrideChanged(Notification notification) {
+ switch (notification.getFeatureID(IAttributeOverride.class)) {
+ case JpaCoreMappingsPackage.IATTRIBUTE_OVERRIDE__NAME :
+ final IAttributeOverride attributeOverride = (IAttributeOverride) notification.getNotifier();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ listViewer.refresh(attributeOverride);
+ }
+ });
+ break;
+ default :
+ break;
+ }
+ }
+
+ public void dispose() {
+ this.columnComposite.dispose();
+ super.dispose();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedComposite.java
new file mode 100644
index 0000000000..734a9c8676
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedComposite.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IEmbedded;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddedComposite extends BaseJpaComposite
+{
+ private IEmbedded embedded;
+
+ private EmbeddedAttributeOverridesComposite attributeOverridesComposite;
+
+ public EmbeddedComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ GridData gridData;
+
+ this.attributeOverridesComposite = new EmbeddedAttributeOverridesComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.attributeOverridesComposite.getControl().setLayoutData(gridData);
+ }
+
+
+ public void doPopulate(EObject obj) {
+ this.embedded = (IEmbedded) obj;
+ this.attributeOverridesComposite.populate(obj);
+ }
+
+ public void doPopulate() {
+ this.attributeOverridesComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.attributeOverridesComposite.dispose();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedIdComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedIdComposite.java
new file mode 100644
index 0000000000..13111065c2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EmbeddedIdComposite.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EmbeddedIdComposite extends BaseJpaComposite
+{
+ public EmbeddedIdComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+
+ }
+
+
+ public void doPopulate(EObject obj) {
+ }
+
+ public void doPopulate() {
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java
new file mode 100644
index 0000000000..309527f3a2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.ITable;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.StringWithDefaultChooser.StringHolder;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EntityComposite extends BaseJpaComposite
+{
+ private IEntity entity;
+
+ private EntityNameCombo entityNameCombo;
+
+ private TableComposite tableComposite;
+ private InheritanceComposite inheritanceComposite;
+ private OverridesComposite attributeOverridesComposite;
+
+ public EntityComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ Control inheritanceControl = buildInheritanceComposite(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ inheritanceControl.setLayoutData(gridData);
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ CommonWidgets.buildEntityNameLabel(generalComposite, getWidgetFactory());
+
+ this.entityNameCombo =
+ CommonWidgets.buildEntityNameCombo(generalComposite, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.entityNameCombo.getCombo().setLayoutData(gridData);
+
+
+ this.tableComposite = new TableComposite(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.tableComposite.getControl().setLayoutData(gridData);
+
+ this.attributeOverridesComposite = new OverridesComposite(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.attributeOverridesComposite.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ private Control buildInheritanceComposite(Composite composite) {
+ Section section = getWidgetFactory().createSection(composite, SWT.FLAT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
+ section.setText(JpaUiMappingsMessages.EntityComposite_inheritance);
+
+ Composite inheritanceClient = getWidgetFactory().createComposite(section);
+ section.setClient(inheritanceClient);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ inheritanceClient.setLayout(layout);
+
+ this.inheritanceComposite = new InheritanceComposite(inheritanceClient, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.inheritanceComposite.getControl().setLayoutData(gridData);
+
+ return section;
+ }
+
+ //TODO talk to JavaEditor people about what we can do to hook in TabbedProperties for the JavaEditor
+
+ public void doPopulate(EObject obj) {
+ this.entity = (IEntity) obj;
+ this.entityNameCombo.populate(obj);
+ this.attributeOverridesComposite.populate(obj);
+ this.inheritanceComposite.populate(obj);
+ if (this.entity != null) {
+ this.tableComposite.populate(this.entity.getTable());
+ }
+ else {
+ this.tableComposite.populate(null);
+ }
+ }
+
+ public void doPopulate() {
+ this.entityNameCombo.populate();
+ this.tableComposite.populate();
+ this.attributeOverridesComposite.populate();
+ this.inheritanceComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.entityNameCombo.dispose();
+ this.tableComposite.dispose();
+ this.attributeOverridesComposite.dispose();
+ this.inheritanceComposite.dispose();
+ super.dispose();
+ }
+
+ protected IEntity getEntity() {
+ return this.entity;
+ }
+
+
+ private abstract class TableHolder extends EObjectImpl implements StringHolder {
+ private ITable table;
+
+ TableHolder(ITable table) {
+ super();
+ this.table = table;
+ }
+
+ public Class featureClass() {
+ return ITable.class;
+ }
+
+ public boolean supportsDefault() {
+ return true;
+ }
+
+ public EObject wrappedObject() {
+ return this.table;
+ }
+
+ public ITable getTable() {
+ return this.table;
+ }
+ }
+
+ private class TableNameHolder extends TableHolder implements StringHolder {
+
+ TableNameHolder(ITable table) {
+ super(table);
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.ITABLE__SPECIFIED_NAME;
+ }
+
+ public int defaultFeatureId() {
+ return JpaCoreMappingsPackage.ITABLE__DEFAULT_NAME;
+ }
+
+ public String defaultItem() {
+ String defaultName = getTable().getDefaultName();
+ if (defaultName != null) {
+ return NLS.bind(JpaUiMappingsMessages.EntityComposite_tableDefault, defaultName);
+ }
+ return JpaUiMappingsMessages.EntityComposite_tableNoDefaultSpecified;
+ }
+
+ public String getString() {
+ return getTable().getSpecifiedName();
+ }
+
+ public void setString(String newName) {
+ getTable().setSpecifiedName(newName);
+ }
+ }
+
+ private class TableCatalogHolder extends TableHolder implements StringHolder {
+
+ TableCatalogHolder(ITable table) {
+ super(table);
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.ITABLE__SPECIFIED_CATALOG;
+ }
+
+ public int defaultFeatureId() {
+ return JpaCoreMappingsPackage.ITABLE__DEFAULT_CATALOG;
+ }
+
+ public String defaultItem() {
+ String defaultCatalog = getTable().getDefaultCatalog();
+ if (defaultCatalog != null) {
+ return NLS.bind(JpaUiMappingsMessages.EntityComposite_tableDefault, defaultCatalog);
+ }
+ return JpaUiMappingsMessages.EntityComposite_tableNoDefaultSpecified;
+ }
+
+ public String getString() {
+ return getTable().getSpecifiedCatalog();
+ }
+
+ public void setString(String newName) {
+ getTable().setSpecifiedCatalog(newName);
+ }
+ }
+
+ private class TableSchemaHolder extends TableHolder implements StringHolder {
+
+ TableSchemaHolder(ITable table) {
+ super(table);
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.ITABLE__SPECIFIED_SCHEMA;
+ }
+
+ public int defaultFeatureId() {
+ return JpaCoreMappingsPackage.ITABLE__DEFAULT_SCHEMA;
+ }
+
+ public String defaultItem() {
+ String defaultSchema = getTable().getDefaultSchema();
+ if (defaultSchema != null) {
+ return NLS.bind(JpaUiMappingsMessages.EntityComposite_tableDefault, defaultSchema);
+ }
+ return JpaUiMappingsMessages.EntityComposite_tableNoDefaultSpecified;
+ }
+
+ public String getString() {
+ return getTable().getSpecifiedSchema();
+ }
+
+ public void setString(String newName) {
+ getTable().setSpecifiedSchema(newName);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityNameCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityNameCombo.java
new file mode 100644
index 0000000000..15f4c0047b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityNameCombo.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Arrays;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.details.BaseJpaController;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+// TODO get Default updating appropriately based on Entity name default
+
+public class EntityNameCombo extends BaseJpaController
+{
+ private IEntity entity;
+ private Adapter entityListener;
+
+ private CCombo combo;
+
+
+ public EntityNameCombo(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, commandStack, widgetFactory);
+ buildEntityListener();
+ }
+
+
+ private void buildEntityListener() {
+ entityListener = new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ entityChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void buildWidget(Composite parent) {
+ combo = this.widgetFactory.createCCombo(parent, SWT.FLAT);
+ combo.addModifyListener(
+ new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ comboModified(e);
+ }
+ });
+ }
+
+ private void comboModified(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+
+ String text = ((CCombo) e.getSource()).getText();
+ if (text.equals(combo.getItem(0))) {
+ text = null;
+ }
+
+ entity.setSpecifiedName(text);
+
+ // TODO Does this need to be done?
+ //this.editingDomain.getCommandStack().execute(SetCommand.create(this.editingDomain, this.entity, MappingsPackage.eINSTANCE.getEntity_SpecifiedName(), text));
+ }
+
+ private void entityChanged(Notification notification) {
+ switch (notification.getFeatureID(IEntity.class)) {
+ case JpaCoreMappingsPackage.IENTITY__SPECIFIED_NAME :
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ break;
+ case JpaCoreMappingsPackage.IENTITY__DEFAULT_NAME :
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ break;
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (entity != null) {
+ entity.eAdapters().add(entityListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (entity != null) {
+ entity.eAdapters().remove(entityListener);
+ }
+ }
+
+ @Override
+ public void doPopulate(EObject obj) {
+ entity = (IEntity) obj;
+ populateCombo();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateCombo();
+ }
+
+ private void populateCombo() {
+ if (entity == null) {
+ combo.clearSelection();
+ combo.setItems(new String[] {});
+ return;
+ }
+
+ String defaultItem = NLS.bind(JpaUiMappingsMessages.EntityGeneralSection_nameDefaultWithOneParam, entity.getDefaultName());
+ String specifiedName = entity.getSpecifiedName();
+
+ if (specifiedName == null) {
+ setComboData(defaultItem, new String[] {defaultItem});
+ }
+ else {
+ setComboData(specifiedName, new String[] {defaultItem});
+ }
+ }
+
+ private void setComboData(String text, String[] items) {
+ if (! Arrays.equals(items, combo.getItems())) {
+ combo.setItems(items);
+ }
+
+ if (! text.equals(combo.getText())) {
+ combo.setText(text);
+ }
+ }
+
+ public CCombo getCombo() {
+ return combo;
+ }
+
+ @Override
+ public Control getControl() {
+ return getCombo();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EnumComboViewer.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EnumComboViewer.java
new file mode 100644
index 0000000000..43d624385b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EnumComboViewer.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.ui.internal.details.BaseJpaController;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class EnumComboViewer extends BaseJpaController
+{
+ private EnumHolder enumHolder;
+ private Adapter enumListener;
+
+ private CComboViewer comboViewer;
+
+
+ public EnumComboViewer(Composite parent, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, theCommandStack, widgetFactory);
+ buildListener();
+ }
+
+
+ private void buildListener() {
+ this.enumListener = new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ modelChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void buildWidget(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent);
+ this.comboViewer = new CComboViewer(combo);
+
+ this.comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ EnumComboViewer.this.selectionChanged(event.getSelection());
+ }
+ });
+ }
+
+ void selectionChanged(ISelection sel) {
+ if (sel instanceof IStructuredSelection) {
+ Object selection = ((IStructuredSelection) sel).getFirstElement();
+ if ( ! this.enumHolder.get().equals(selection)) {
+ this.enumHolder.set(selection);
+// this.editingDomain.getCommandStack().execute(
+// SetCommand.create(
+// this.editingDomain,
+// this.basicMapping,
+// OrmPackage.eINSTANCE.getBasicMapping_Optional(),
+// optional
+// )
+// );
+ }
+ }
+ }
+
+ private void modelChanged(Notification notification) {
+ if (notification.getFeatureID(this.enumHolder.featureClass()) ==
+ this.enumHolder.featureId()) {
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.enumHolder != null && this.enumHolder.wrappedObject() != null) {
+ this.enumHolder.wrappedObject().eAdapters().add(this.enumListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.enumHolder != null && this.enumHolder.wrappedObject() != null) {
+ this.enumHolder.wrappedObject().eAdapters().remove(this.enumListener);
+ }
+ }
+
+ public final void populate(EnumHolder enumHolder) {
+ super.populate(enumHolder);
+ }
+
+ @Override
+ public void doPopulate(EObject obj) {
+ this.enumHolder = (EnumHolder) obj;
+ populateCombo();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateCombo();
+ }
+
+ private void populateCombo() {
+ this.comboViewer.getCombo().removeAll();
+ if (this.enumHolder.wrappedObject() == null) {
+ return;
+ }
+
+ this.comboViewer.add(this.enumHolder.enumValues());
+
+ Object modelSetting = this.enumHolder.get();
+
+ if (((IStructuredSelection) this.comboViewer.getSelection()).getFirstElement() != modelSetting) {
+ this.comboViewer.setSelection(new StructuredSelection(modelSetting));
+ }
+ }
+
+
+ @Override
+ public Control getControl() {
+ return this.comboViewer.getCombo();
+ }
+
+
+ /**
+ * An interface to wrap an object that supports accessType
+ * An object of this type must be passed in to populate(EObject)
+ */
+ public static interface EnumHolder extends EObject {
+ /**
+ * Return the num setting from the wrapped object
+ * @return
+ */
+ Object get();
+
+ /**
+ * Set the enum setting on the wrapped object
+ * @param fetch
+ */
+ void set(Object enumSetting);
+
+ /**
+ * Return the Class of the wrapped object
+ * @return
+ */
+ Class featureClass();
+
+ /**
+ * Return the feature id of enum setting on the wrapped object
+ * @return
+ */
+ int featureId();
+
+ /**
+ * The wrapped EObject that the enum setting is stored on
+ * @return
+ */
+ EObject wrappedObject();
+
+ Object[] enumValues();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java
new file mode 100644
index 0000000000..6e768231ec
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.mappings.GenerationType;
+import org.eclipse.jpt.core.internal.mappings.IGeneratedValue;
+import org.eclipse.jpt.core.internal.mappings.IId;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.core.internal.platform.IGeneratorRepository;
+import org.eclipse.jpt.core.internal.platform.NullGeneratorRepository;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class GeneratedValueComposite extends BaseJpaComposite
+{
+ private IId id;
+ private IGeneratedValue generatedValue;
+ private Adapter generatedValueListener;
+
+ private ComboViewer strategyComboViewer;
+
+ private CCombo generatorNameCombo;
+
+ protected boolean populating;
+
+ public GeneratedValueComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.generatedValueListener = buildGeneratedValueListener();
+ }
+
+ private Adapter buildGeneratedValueListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ generatedValueChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ composite.setLayout(layout);
+
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.GeneratedValueComposite_strategy);
+
+ this.strategyComboViewer = buildStrategyComboViewer(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.strategyComboViewer.getCombo().setLayoutData(gridData);
+ helpSystem.setHelp(this.strategyComboViewer.getCombo(), IJpaHelpContextIds.MAPPING_GENERATED_VALUE_STRATEGY);
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.GeneratedValueComposite_generatorName);
+
+ this.generatorNameCombo = buildGeneratorNameCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.generatorNameCombo.setLayoutData(gridData);
+ helpSystem.setHelp(this.generatorNameCombo, IJpaHelpContextIds.MAPPING_GENERATED_VALUE_GENERATOR_NAME);
+
+ // TODO
+ // buildGeneratorNameSelectionButton( this);
+ }
+
+ private ComboViewer buildStrategyComboViewer(Composite parent) {
+ ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+ viewer.add(GenerationType.VALUES.toArray());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (populating) {
+ return;
+ }
+ if (event.getSelection() instanceof StructuredSelection) {
+ StructuredSelection selection = (StructuredSelection) event.getSelection();
+ GenerationType selectedType = (GenerationType) selection.getFirstElement();
+ if (generatedValue == null) {
+ createGeneratedValue();
+ }
+ if (!generatedValue.getStrategy().equals(selectedType)) {
+ generatedValue.setStrategy(selectedType);
+ }
+ }
+ }
+ });
+ return viewer;
+ }
+
+ protected CCombo buildGeneratorNameCombo(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ combo.add(JpaUiMappingsMessages.TableComposite_defaultEmpty);
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String generatorName = ((CCombo) e.getSource()).getText();
+
+ if (generatorName.equals("")) { //$NON-NLS-1$
+ if (generatedValue.getGenerator() == null || generatedValue.getGenerator().equals("")) {
+ return;
+ }
+ generatorName = null;
+ }
+ if (generatedValue == null) {
+ createGeneratedValue();
+ }
+ generatedValue.setGenerator(generatorName);
+ }
+ });
+ return combo;
+ }
+
+ private void createGeneratedValue() {
+ IGeneratedValue generatedValue = this.id.createGeneratedValue();
+ this.id.setGeneratedValue(generatedValue);
+ }
+
+
+ protected void generatedValueChanged(Notification notification) {
+ if (notification.getFeatureID(IGeneratedValue.class) == JpaCoreMappingsPackage.IGENERATED_VALUE__STRATEGY) {
+ final GenerationType strategy = (GenerationType) notification.getNewValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ if (selectedStrategy() != strategy) {
+ strategyComboViewer.setSelection(new StructuredSelection(strategy));
+ }
+ }
+ });
+ }
+ else if (notification.getFeatureID(IGeneratedValue.class) == JpaCoreMappingsPackage.IGENERATED_VALUE__GENERATOR) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateGeneratorName();
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void doPopulate(EObject obj) {
+ this.id = (IId) obj;
+ if (this.id == null) {
+ this.generatedValue= null;
+ }
+ else {
+ this.generatedValue = this.id.getGeneratedValue();
+ }
+ if (this.generatedValue == null) {
+ this.strategyComboViewer.getCombo().deselectAll();
+ this.populating = false;
+ return;
+ }
+ populateStrategyCombo();
+ populateGeneratorNameCombo();
+ }
+
+ @Override
+ protected void doPopulate() {
+
+ }
+
+ protected void engageListeners() {
+ if (this.generatedValue != null) {
+ this.generatedValue.eAdapters().add(this.generatedValueListener);
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.generatedValue != null) {
+ this.generatedValue.eAdapters().remove(this.generatedValueListener);
+ }
+ }
+
+ private IGeneratorRepository getGeneratorRepository() {
+ return NullGeneratorRepository.instance(); //this.id.getJpaProject().getPlatform().generatorRepository(this.id.typeMapping().getPersistentType());
+ }
+
+ private void populateGeneratorNameCombo() {
+ this.generatorNameCombo.removeAll();
+ for (Iterator<String> i = getGeneratorRepository().generatorNames(); i.hasNext(); ){
+ this.generatorNameCombo.add(i.next());
+ }
+
+ populateGeneratorName();
+ }
+ private void populateGeneratorName() {
+ String generatorName = this.generatedValue.getGenerator();
+ if (generatorName == null || generatorName.equals("")) {
+ this.generatorNameCombo.clearSelection();
+ }
+ else if (!this.generatorNameCombo.getText().equals(generatorName)) {
+ this.generatorNameCombo.setText(generatorName);
+ }
+ }
+
+ private void populateStrategyCombo() {
+ GenerationType selectedType = selectedStrategy();
+ GenerationType strategy = this.generatedValue.getStrategy();
+ if (strategy == GenerationType.AUTO) {
+ if (selectedType != GenerationType.AUTO) {
+ this.strategyComboViewer.setSelection(new StructuredSelection(GenerationType.AUTO));
+ }
+ }
+ else if (strategy == GenerationType.SEQUENCE) {
+ if (selectedType != GenerationType.SEQUENCE) {
+ this.strategyComboViewer.setSelection(new StructuredSelection(GenerationType.SEQUENCE));
+ }
+ }
+ else if (strategy == GenerationType.IDENTITY) {
+ if (selectedType != GenerationType.IDENTITY) {
+ this.strategyComboViewer.setSelection(new StructuredSelection(GenerationType.IDENTITY));
+ }
+ }
+ else if (strategy == GenerationType.TABLE) {
+ if (selectedType != GenerationType.TABLE) {
+ this.strategyComboViewer.setSelection(new StructuredSelection(GenerationType.TABLE));
+ }
+ }
+ else {
+ if (selectedType != GenerationType.DEFAULT) {
+ this.strategyComboViewer.setSelection(new StructuredSelection(GenerationType.DEFAULT));
+ }
+ }
+ // TODO first initialization
+ }
+
+ private GenerationType selectedStrategy() {
+ return (GenerationType) ((StructuredSelection) this.strategyComboViewer.getSelection()).getFirstElement();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
new file mode 100644
index 0000000000..85cf93c07f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jpt.core.internal.mappings.IGenerator;
+import org.eclipse.jpt.core.internal.mappings.IId;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+/**
+ * GeneratorComposite
+ */
+public abstract class GeneratorComposite<E extends IGenerator> extends BaseJpaComposite
+{
+ private IId id;
+ private E generator;
+ private Adapter generatorListener;
+
+ protected ITextViewer nameViewer;
+
+ public GeneratorComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.generatorListener = buildGeneratorListner();
+ }
+
+ private Adapter buildGeneratorListner() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ generatorChanged(notification);
+ }
+ };
+ }
+
+ /**
+ * Builds the Generator specifiedName viewer.
+ *
+ * @param parent
+ * @return
+ */
+ protected ITextViewer buildNameViewer(Composite parent) {
+ final TextViewer textViewer = new TextViewer(parent, SWT.SINGLE | SWT.BORDER);
+ textViewer.setDocument(new Document());
+ textViewer.addTextListener(new ITextListener() {
+ public void textChanged(TextEvent event) {
+ if (isPopulating()) {
+ return;
+ }
+
+ String name = textViewer.getDocument().get();
+ if (name.equals("")) { //$NON-NLS-1$
+ if (getGenerator().getName() == null) {
+ return;
+ }
+ name = null;
+ }
+ IGenerator generator = getGenerator();
+ if (generator == null) {
+ generator = createGenerator();
+ }
+ generator.setName(name);
+ }
+ });
+ return textViewer;
+ }
+
+ protected abstract E createGenerator();
+
+ @Override
+ protected void doPopulate(EObject obj) {
+ this.id = (IId) obj;
+ if (this.id == null) {
+ this.generator = null;
+ return;
+ }
+ this.generator = generator(this.id);
+ if (this.generator == null) {
+ clear();
+ return;
+ }
+ populateNameViewer();
+ return;
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateNameViewer();
+ }
+
+ protected void engageListeners() {
+ if (this.generator != null) {
+ this.generator.eAdapters().add(this.generatorListener);
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.generator != null) {
+ this.generator.eAdapters().remove(this.generatorListener);
+ }
+ }
+
+ protected abstract E generator(IId id);
+
+ protected IId idMapping() {
+ return this.id;
+ }
+
+ protected void generatorChanged(Notification notification) {
+ if (notification.getFeatureID(IGenerator.class) == JpaCoreMappingsPackage.IGENERATOR__NAME) {
+ final String name = notification.getNewStringValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ if (nameViewer.getDocument().get() == null || !nameViewer.getDocument().get().equals(name)) {
+ if (name == null) {
+ clearNameViewer();
+ }
+ else {
+ nameViewer.getDocument().set(name);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ private void populateNameViewer() {
+ String name = this.getGenerator().getName();
+ if (name != null) {
+ if (!this.nameViewer.getDocument().get().equals(name)) {
+ this.nameViewer.getDocument().set(name);
+ }
+ }
+ else {
+ this.clearNameViewer();
+ }
+ }
+
+ protected E getGenerator() {
+ return this.generator;
+ }
+
+ protected void clear() {
+ this.clearNameViewer();
+ }
+
+ protected void clearNameViewer() {
+ this.nameViewer.getDocument().set(""); //$NON-NLS-1$
+ }
+
+ public void dispose() {
+ disengageListeners();
+ super.dispose();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/IdComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/IdComposite.java
new file mode 100644
index 0000000000..088dce9e41
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/IdComposite.java
@@ -0,0 +1,437 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.jpt.core.internal.mappings.IGeneratedValue;
+import org.eclipse.jpt.core.internal.mappings.IId;
+import org.eclipse.jpt.core.internal.mappings.ISequenceGenerator;
+import org.eclipse.jpt.core.internal.mappings.ITableGenerator;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.core.internal.mappings.TemporalType;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.EnumComboViewer.EnumHolder;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class IdComposite extends BaseJpaComposite
+{
+ private IId id;
+ private Adapter idListener;
+
+ private ColumnComposite columnComposite;
+
+ private EnumComboViewer temporalTypeViewer;
+
+ private Section pkGenerationSection;
+ private Button primaryKeyGenerationCheckBox;
+ private GeneratedValueComposite generatedValueComposite;
+
+ private Section tableGenSection;
+ private Button tableGeneratorCheckBox;
+ private TableGeneratorComposite tableGeneratorComposite;
+
+ private Section sequenceGenSection;
+ private Button sequenceGeneratorCheckBox;
+ private SequenceGeneratorComposite sequenceGeneratorComposite;
+
+
+ public IdComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.idListener = buildIdListener();
+ }
+
+ private Adapter buildIdListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ idMappingChanged(notification);
+ }
+ };
+ }
+ void idMappingChanged(Notification notification) {
+ switch (notification.getFeatureID(IId.class)) {
+ case JpaCoreMappingsPackage.IID__TABLE_GENERATOR :
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ IdComposite.this.populateTableGeneratorComposite();
+ }
+ });
+ break;
+ case JpaCoreMappingsPackage.IID__SEQUENCE_GENERATOR :
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ IdComposite.this.populateSequenceGeneratorComposite();
+ }
+ });
+ break;
+ case JpaCoreMappingsPackage.IID__GENERATED_VALUE :
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ IdComposite.this.populateGeneratedValueComposite();
+ }
+ });
+ break;
+ }
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ Control generationControl = buildGenerationComposite(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generationControl.setLayoutData(gridData);
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ this.columnComposite = new ColumnComposite(generalComposite, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.columnComposite.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildTemporalLabel(generalComposite, getWidgetFactory());
+ this.temporalTypeViewer = CommonWidgets.buildEnumComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.temporalTypeViewer.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ private Control buildGenerationComposite(Composite composite) {
+ this.pkGenerationSection = getWidgetFactory().createSection(composite, SWT.FLAT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
+ this.pkGenerationSection.setText(JpaUiMappingsMessages.IdMappingComposite_primaryKeyGeneration);
+
+ Composite generationClient = getWidgetFactory().createComposite(this.pkGenerationSection);
+ this.pkGenerationSection.setClient(generationClient);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ generationClient.setLayout(layout);
+
+ this.primaryKeyGenerationCheckBox = buildPrimaryKeyGenerationCheckBox(generationClient);
+ GridData gridData = new GridData();
+ this.primaryKeyGenerationCheckBox.setLayoutData(gridData);
+
+ this.generatedValueComposite = new GeneratedValueComposite(generationClient, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalIndent = 20;
+ this.generatedValueComposite.getControl().setLayoutData(gridData);
+
+ this.tableGenSection = getWidgetFactory().createSection(generationClient, SWT.FLAT | ExpandableComposite.TWISTIE);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.tableGenSection.setLayoutData(gridData);
+
+ this.tableGenSection.setText(JpaUiMappingsMessages.IdMappingComposite_tableGenerator);
+
+ Composite tableGenClient = getWidgetFactory().createComposite(this.tableGenSection);
+ this.tableGenSection.setClient(tableGenClient);
+
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ tableGenClient.setLayout(layout);
+
+ this.tableGeneratorCheckBox = buildTableGeneratorCheckBox(tableGenClient);
+ gridData = new GridData();
+ this.tableGeneratorCheckBox.setLayoutData(gridData);
+
+ this.tableGeneratorComposite = new TableGeneratorComposite(tableGenClient, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalIndent = 20;
+ this.tableGeneratorComposite.getControl().setLayoutData(gridData);
+
+
+
+ this.sequenceGenSection = getWidgetFactory().createSection(generationClient, SWT.FLAT | ExpandableComposite.TWISTIE);
+ this.sequenceGenSection.setText(JpaUiMappingsMessages.IdMappingComposite_sequenceGenerator);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.sequenceGenSection.setLayoutData(gridData);
+
+ Composite sequenceGenClient = getWidgetFactory().createComposite(this.sequenceGenSection);
+ this.sequenceGenSection.setClient(sequenceGenClient);
+
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ sequenceGenClient.setLayout(layout);
+
+ this.sequenceGeneratorCheckBox = buildSequenceGeneratorCheckBox(sequenceGenClient);
+ gridData = new GridData();
+ this.sequenceGeneratorCheckBox.setLayoutData(gridData);
+
+ this.sequenceGeneratorComposite = new SequenceGeneratorComposite(sequenceGenClient, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalIndent = 20;
+ this.sequenceGeneratorComposite.getControl().setLayoutData(gridData);
+
+ return this.pkGenerationSection;
+ }
+
+ private Button buildPrimaryKeyGenerationCheckBox(Composite parent) {
+ Button button = getWidgetFactory().createButton(parent,JpaUiMappingsMessages.IdMappingComposite_primaryKeyGeneration, SWT.CHECK);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ IdComposite.this.primaryKeyGenerationCheckBoxClicked(e);
+ }
+ });
+ return button;
+ }
+
+ void primaryKeyGenerationCheckBoxClicked(SelectionEvent e) {
+ boolean mappingHasGeneratedValue = this.id.getGeneratedValue() != null;
+ boolean checked = this.primaryKeyGenerationCheckBox.getSelection();
+ if (checked == mappingHasGeneratedValue) {
+ return;
+ }
+ IGeneratedValue generatedValue = null;
+ if (checked) {
+ generatedValue = this.id.createGeneratedValue();
+ }
+ this.id.setGeneratedValue(generatedValue);
+ }
+
+ private Button buildTableGeneratorCheckBox(Composite parent) {
+ Button button = getWidgetFactory().createButton(parent,JpaUiMappingsMessages.IdMappingComposite_tableGenerator, SWT.CHECK);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ IdComposite.this.tableGeneratorCheckBoxClicked(e);
+ }
+ });
+ return button;
+ }
+
+ void tableGeneratorCheckBoxClicked(SelectionEvent e) {
+ boolean mappingHasTableGenerator = this.id.getTableGenerator() != null;
+ boolean checked = this.tableGeneratorCheckBox.getSelection();
+ if (checked == mappingHasTableGenerator) {
+ return;
+ }
+ ITableGenerator tableGenerator = null;
+ if (checked) {
+ tableGenerator = this.id.createTableGenerator();
+ }
+ this.id.setTableGenerator(tableGenerator);
+ if (checked) {
+ IGeneratedValue generatedValue = this.id.getGeneratedValue();
+ if (generatedValue != null && generatedValue.getGenerator() != null) {
+ tableGenerator.setName(generatedValue.getGenerator());
+ }
+ }
+ }
+
+ private Button buildSequenceGeneratorCheckBox(Composite parent) {
+ Button button = getWidgetFactory().createButton(parent,JpaUiMappingsMessages.IdMappingComposite_sequenceGenerator, SWT.CHECK);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ IdComposite.this.sequenceGeneratorCheckBoxClicked(e);
+ }
+ });
+ return button;
+ }
+
+ void sequenceGeneratorCheckBoxClicked(SelectionEvent e) {
+ boolean mappingHasSequenceGenerator = this.id.getSequenceGenerator() != null;
+ boolean checked = this.sequenceGeneratorCheckBox.getSelection();
+ if (checked == mappingHasSequenceGenerator) {
+ return;
+ }
+ ISequenceGenerator sequenceGenerator = null;
+ if (checked) {
+ sequenceGenerator = this.id.createSequenceGenerator();
+ }
+ this.id.setSequenceGenerator(sequenceGenerator);
+ if (checked) {
+ IGeneratedValue generatedValue = this.id.getGeneratedValue();
+ if (generatedValue != null && generatedValue.getGenerator() != null) {
+ sequenceGenerator.setName(generatedValue.getGenerator());
+ }
+ }
+ }
+
+
+
+ public void doPopulate(EObject obj) {
+ this.id = (IId) obj;
+ if (this.id != null) {
+ this.columnComposite.populate(this.id.getColumn());
+ }
+ else {
+ this.columnComposite.populate(null);
+ this.generatedValueComposite.populate(null);
+ this.tableGeneratorComposite.populate(null);
+ this.sequenceGeneratorComposite.populate(null);
+ return;
+ }
+ this.pkGenerationSection.setExpanded(true);
+ this.temporalTypeViewer.populate(new TemporalTypeHolder(this.id));
+ populateGeneratedValueComposite();
+ populateSequenceGeneratorComposite();
+ populateTableGeneratorComposite();
+ }
+
+ public void doPopulate() {
+ this.columnComposite.populate();
+ this.temporalTypeViewer.populate();
+ this.generatedValueComposite.populate();
+ this.tableGeneratorComposite.populate();
+ this.sequenceGeneratorComposite.populate();
+ }
+
+ private void populateTableGeneratorComposite() {
+ this.tableGeneratorComposite.populate(this.id);
+ boolean tableGeneratorExists = this.id.getTableGenerator() != null;
+ this.tableGeneratorCheckBox.setSelection(tableGeneratorExists);
+ if (tableGeneratorExists) {
+ this.tableGenSection.setExpanded(true);
+ }
+ }
+
+ private void populateSequenceGeneratorComposite() {
+ this.sequenceGeneratorComposite.populate(this.id);
+ boolean sequenceGeneratorExists = this.id.getSequenceGenerator() != null;
+ this.sequenceGeneratorCheckBox.setSelection(sequenceGeneratorExists);
+ if (sequenceGeneratorExists) {
+ this.sequenceGenSection.setExpanded(true);
+ }
+ }
+
+ private void populateGeneratedValueComposite() {
+ this.generatedValueComposite.populate(this.id);
+ this.primaryKeyGenerationCheckBox.setSelection(this.id.getGeneratedValue() != null);
+ }
+
+
+ protected void engageListeners() {
+ if (this.id !=null) {
+ this.id.eAdapters().add(this.idListener);
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.id !=null) {
+ this.id.eAdapters().remove(this.idListener);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ this.columnComposite.dispose();
+ this.temporalTypeViewer.dispose();
+ this.generatedValueComposite.dispose();
+ this.tableGeneratorComposite.dispose();
+ this.sequenceGeneratorComposite.dispose();
+ super.dispose();
+ }
+
+ protected IId getId() {
+ return this.id;
+ }
+
+ private class TemporalTypeHolder extends EObjectImpl implements EnumHolder {
+
+ private IId id;
+
+ TemporalTypeHolder(IId id) {
+ super();
+ this.id = id;
+ }
+
+ public Object get() {
+ return this.id.getTemporal();
+ }
+
+ public void set(Object enumSetting) {
+ this.id.setTemporal((TemporalType) enumSetting);
+ }
+
+ public Class featureClass() {
+ return IId.class;
+ }
+
+ public int featureId() {
+ return JpaCoreMappingsPackage.IID__TEMPORAL;
+ }
+
+ public EObject wrappedObject() {
+ return this.id;
+ }
+
+ public Object[] enumValues() {
+ return TemporalType.VALUES.toArray();
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InheritanceComposite.java
new file mode 100644
index 0000000000..a7a09945df
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InheritanceComposite.java
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.InheritanceType;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.CComboViewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class InheritanceComposite extends BaseJpaComposite {
+
+ private IEntity entity;
+ private final Adapter entityListener;
+
+ private CComboViewer strategyViewer;
+ private DiscriminatorColumnComposite discriminatorColumnComposite;
+ private CCombo discriminatorValueCombo;
+
+ private PrimaryKeyJoinColumnsComposite pkJoinColumnsComposite;
+
+ public InheritanceComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.entityListener = buildEntityListener();
+ }
+
+ private Adapter buildEntityListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ entityChanged(notification);
+ }
+ };
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ GridData gridData;
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.InheritanceComposite_strategy);
+
+ this.strategyViewer = buildStrategyCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.strategyViewer.getCombo().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.strategyViewer.getCombo(), IJpaHelpContextIds.ENTITY_INHERITANCE_STRATEGY);
+
+ this.discriminatorColumnComposite = new DiscriminatorColumnComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.discriminatorColumnComposite.getControl().setLayoutData(gridData);
+
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.InheritanceComposite_discriminatorValue);
+
+ this.discriminatorValueCombo = buildDiscriminatorValueCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.discriminatorValueCombo.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.discriminatorValueCombo, IJpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_VALUE);
+
+ this.pkJoinColumnsComposite = new PrimaryKeyJoinColumnsComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessVerticalSpace = true;
+ this.pkJoinColumnsComposite.getControl().setLayoutData(gridData);
+ }
+
+ private CComboViewer buildStrategyCombo(Composite parent) {
+ CCombo combo = getWidgetFactory().createCCombo(parent);
+ CComboViewer strategyViewer = new CComboViewer(combo);
+ strategyViewer.add(InheritanceType.VALUES.toArray());
+
+ strategyViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ InheritanceComposite.this.strategySelectionChanged(event.getSelection());
+ }
+ });
+
+ return strategyViewer;
+ }
+
+ void strategySelectionChanged(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ InheritanceType inheritanceType = (InheritanceType) ((IStructuredSelection) selection).getFirstElement();
+ if ( ! this.entity.getInheritanceStrategy().equals(inheritanceType)) {
+ this.entity.setInheritanceStrategy(inheritanceType);
+ }
+ }
+ }
+
+
+ private CCombo buildDiscriminatorValueCombo(Composite parent) {
+ final CCombo combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String discriminatorValue = entity.getSpecifiedDiscriminatorValue();
+ String value = ((CCombo) e.getSource()).getText();
+ if (value.equals("")) { //$NON-NLS-1$
+ value = null;
+ if (discriminatorValue == null || discriminatorValue.equals("")) { //$NON-NLS-1$
+ return;
+ }
+ }
+
+ if (value != null && combo.getItemCount() > 0 && value.equals(combo.getItem(0))) {
+ value = null;
+ }
+
+ if (discriminatorValue == null || !discriminatorValue.equals(value)) {
+ entity.setSpecifiedDiscriminatorValue(value);
+ }
+ }
+ });
+ return combo;
+ }
+
+ public void doPopulate(EObject obj) {
+ this.entity = (IEntity) obj;
+ if (this.entity != null) {
+ this.discriminatorColumnComposite.populate(this.entity.getDiscriminatorColumn());
+ populateStrategyComboViewer();
+ populateDiscriminatorValueCombo();
+ this.pkJoinColumnsComposite.populate(this.entity);
+ }
+ else {
+ this.discriminatorColumnComposite.populate(null);
+ }
+ }
+
+ public void doPopulate() {
+ if (this.entity != null) {
+ this.discriminatorColumnComposite.populate();
+// popuplateStrategyComboViewer();
+// popuplateDiscriminatorValueCombo();
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.entity != null) {
+ this.entity.eAdapters().add(this.entityListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.entity != null) {
+ this.entity.eAdapters().remove(this.entityListener);
+ }
+ }
+
+ private void populateStrategyComboViewer() {
+ if (this.entity.getInheritanceStrategy() == InheritanceType.DEFAULT) {
+ if (((StructuredSelection) this.strategyViewer.getSelection()).getFirstElement() != InheritanceType.DEFAULT) {
+ this.strategyViewer.setSelection(new StructuredSelection(InheritanceType.DEFAULT));
+ }
+ }
+ else if (this.entity.getInheritanceStrategy() == InheritanceType.JOINED) {
+ if (((StructuredSelection) this.strategyViewer.getSelection()).getFirstElement() != InheritanceType.JOINED) {
+ this.strategyViewer.setSelection(new StructuredSelection(InheritanceType.JOINED));
+ }
+ }
+ else if (this.entity.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE) {
+ if (((StructuredSelection) this.strategyViewer.getSelection()).getFirstElement() != InheritanceType.SINGLE_TABLE) {
+ this.strategyViewer.setSelection(new StructuredSelection(InheritanceType.SINGLE_TABLE));
+ }
+ }
+ else {
+ if (((StructuredSelection) this.strategyViewer.getSelection()).getFirstElement() != InheritanceType.TABLE_PER_CLASS) {
+ this.strategyViewer.setSelection(new StructuredSelection(InheritanceType.TABLE_PER_CLASS));
+ }
+ }
+ }
+
+ private void populateDiscriminatorValueCombo() {
+ String specifiedValue = this.entity.getSpecifiedDiscriminatorValue();
+ String defaultValue = this.entity.getDefaultDiscriminatorValue();
+
+ if (this.entity.discriminatorValueIsAllowed()) {
+ this.discriminatorValueCombo.setEnabled(true);
+ if (this.discriminatorValueCombo.getItemCount() == 0) {
+ this.discriminatorValueCombo.add(JpaUiMappingsMessages.DiscriminatorColumnComposite_defaultEmpty);
+ }
+ if (defaultValue != null) {
+ this.discriminatorValueCombo.setItem(0, NLS.bind(JpaUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultValue));
+ }
+ else {
+ this.discriminatorValueCombo.setItem(0, JpaUiMappingsMessages.DiscriminatorColumnComposite_defaultEmpty);
+ }
+ }
+ else {
+ this.discriminatorValueCombo.setEnabled(false);
+ if (this.discriminatorValueCombo.getItemCount() == 1) {
+ this.discriminatorValueCombo.setText("");
+ this.discriminatorValueCombo.removeAll();
+ }
+ }
+
+ if (specifiedValue != null) {
+ if (!this.discriminatorValueCombo.getText().equals(specifiedValue)) {
+ this.discriminatorValueCombo.setText(specifiedValue);
+ }
+ }
+ else {
+ if (this.discriminatorValueCombo.getSelectionIndex() != 0) {
+ this.discriminatorValueCombo.select(0);
+ }
+ }
+ }
+
+ private void entityChanged(Notification notification) {
+ if (notification.getFeatureID(IEntity.class) == JpaCoreMappingsPackage.IENTITY__INHERITANCE_STRATEGY) {
+ final InheritanceType inheritanceType = (InheritanceType) notification.getNewValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (((StructuredSelection) strategyViewer.getSelection()).getFirstElement() != inheritanceType) {
+ strategyViewer.setSelection(new StructuredSelection(inheritanceType));
+ }
+ }
+ });
+ }
+ else if (notification.getFeatureID(IEntity.class) == JpaCoreMappingsPackage.IENTITY__SPECIFIED_DISCRIMINATOR_VALUE) {
+ final String columnName = (String) notification.getNewValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (discriminatorValueCombo.getText() == null || !discriminatorValueCombo.getText().equals(columnName)) {
+ if (columnName == null) {
+ discriminatorValueCombo.select(0);
+ }
+ else {
+ discriminatorValueCombo.setText(columnName);
+ }
+ }
+ }
+ });
+ }
+ else if (notification.getFeatureID(IEntity.class) == JpaCoreMappingsPackage.IENTITY__DEFAULT_DISCRIMINATOR_VALUE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ populateDiscriminatorValueCombo();
+ }
+ });
+ }
+ }
+
+ public void dispose() {
+ this.discriminatorColumnComposite.dispose();
+ this.pkJoinColumnsComposite.dispose();
+ super.dispose();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InverseJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InverseJoinColumnDialog.java
new file mode 100644
index 0000000000..a9ff08f392
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/InverseJoinColumnDialog.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IJoinTable;
+import org.eclipse.jpt.core.internal.mappings.IMultiRelationshipMapping;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+
+public class InverseJoinColumnDialog extends JoinColumnInJoinTableDialog {
+
+ InverseJoinColumnDialog(Shell parent, IJoinTable joinTable) {
+ super(parent, joinTable);
+ }
+
+ InverseJoinColumnDialog(Shell parent, IJoinColumn joinColumn) {
+ super(parent, joinColumn);
+ }
+
+ protected String getTitle() {
+ return JpaUiMappingsMessages.InverseJoinColumnDialog_editInverseJoinColumn;
+ }
+
+ protected void populateNameCombo() {
+ if (getJoinTable() == null) {
+ return;
+ }
+ if (getJoinColumn() != null) {
+ getNameCombo().add(NLS.bind(JpaUiMappingsMessages.InverseJoinColumnDialog_defaultWithOneParam, getJoinColumn().getDefaultName()));
+ }
+ Table joinDBTable = getJoinTable().dbTable();
+ if (joinDBTable != null) {
+ for (Iterator i = joinDBTable.columnNames(); i.hasNext(); ) {
+ getNameCombo().add((String) i.next());
+ }
+ }
+ if (getJoinColumn() != null && getJoinColumn().getSpecifiedReferencedColumnName() != null) {
+ getNameCombo().setText(getJoinColumn().getSpecifiedName());
+ }
+ else {
+ getNameCombo().select(0);
+ }
+ }
+
+ protected void populateReferencedNameCombo() {
+ if (getJoinTable() == null) {
+ return;
+ }
+ if (getJoinColumn() != null) {
+ getReferencedColumnNameCombo().add(NLS.bind(JpaUiMappingsMessages.InverseJoinColumnDialog_defaultWithOneParam, getJoinColumn().getDefaultReferencedColumnName()));
+ }
+ IMultiRelationshipMapping multiRelationshipMapping = (IMultiRelationshipMapping) getJoinTable().eContainer();
+ IEntity targetEntity = multiRelationshipMapping.getResolvedTargetEntity();
+ if (targetEntity != null) {
+ Table referencedDbTable = targetEntity.primaryDbTable();
+ if (referencedDbTable != null) {
+ for (Iterator i = referencedDbTable.columnNames(); i.hasNext(); ) {
+ getReferencedColumnNameCombo().add((String) i.next());
+ }
+ }
+ }
+ if (getJoinColumn() != null && getJoinColumn().getSpecifiedReferencedColumnName() != null) {
+ getReferencedColumnNameCombo().setText(getJoinColumn().getSpecifiedReferencedColumnName());
+ }
+ else {
+ getReferencedColumnNameCombo().select(0);
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java
new file mode 100644
index 0000000000..7269ee6266
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java
@@ -0,0 +1,412 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.internal.mappings.DefaultTrueBoolean;
+import org.eclipse.jpt.core.internal.mappings.IAbstractColumn;
+import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.INamedColumn;
+import org.eclipse.jpt.core.internal.mappings.ISingleRelationshipMapping;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JoinColumnComposite
+ extends BaseJpaComposite
+{
+ private ISingleRelationshipMapping singleRelationshipMapping;
+ private final Adapter singleRelationshipMappingListener;
+ private final Adapter joinColumnListener;
+
+
+ private Group joinColumnsGroup;
+ Button overrideDefaultJoinColumnsCheckBox;
+ ListViewer joinColumnsListViewer;
+ private Button joinColumnsRemoveButton;
+ private Button joinColumnsEditButton;
+
+
+
+ public JoinColumnComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.singleRelationshipMappingListener = buildSingleRelationshipMappingListener();
+ this.joinColumnListener = buildJoinColumnListener();
+ }
+
+
+ private Adapter buildSingleRelationshipMappingListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ singleRelationshipMappingChanged(notification);
+ }
+ };
+ }
+
+ private Adapter buildJoinColumnListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ joinColumnChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ composite.setLayout(layout);
+
+ this.overrideDefaultJoinColumnsCheckBox =
+ getWidgetFactory().createButton(
+ composite,
+ JpaUiMappingsMessages.JoinColumnComposite_overrideDefaultJoinColumns,
+ SWT.CHECK);
+ this.overrideDefaultJoinColumnsCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (JoinColumnComposite.this.overrideDefaultJoinColumnsCheckBox.getSelection()) {
+ IJoinColumn defaultJoinColumn = JoinColumnComposite.this.singleRelationshipMapping.getDefaultJoinColumns().get(0);
+ String columnName = defaultJoinColumn.getDefaultName();
+ String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
+
+ IJoinColumn joinColumn = JoinColumnComposite.this.singleRelationshipMapping.createJoinColumn(0);
+ JoinColumnComposite.this.singleRelationshipMapping.getSpecifiedJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(columnName);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ } else {
+ JoinColumnComposite.this.singleRelationshipMapping.getSpecifiedJoinColumns().clear();
+ }
+ }
+ });
+
+ this.joinColumnsGroup =
+ getWidgetFactory().createGroup(
+ composite,
+ JpaUiMappingsMessages.JoinColumnComposite_joinColumn);
+ this.joinColumnsGroup.setLayout(new GridLayout(2, false));
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.joinColumnsGroup.setLayoutData(gridData);
+
+ this.joinColumnsListViewer = new ListViewer(this.joinColumnsGroup, SWT.BORDER | SWT.MULTI);
+ this.joinColumnsListViewer.setContentProvider(buildJoinColumnsListContentProvider());
+ this.joinColumnsListViewer.setLabelProvider(buildJoinColumnsListLabelProvider());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.verticalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.joinColumnsListViewer.getList().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.joinColumnsListViewer.getList(), IJpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS);
+
+ Button addJoinColumnButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinColumnComposite_add, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ addJoinColumnButton.setLayoutData(gridData);
+ addJoinColumnButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ addJoinColumn();
+ }
+ });
+
+ this.joinColumnsEditButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinColumnComposite_edit, SWT.NONE);
+ this.joinColumnsEditButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ editJoinColumn();
+ }
+ });
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ this.joinColumnsEditButton.setLayoutData(gridData);
+
+ this.joinColumnsRemoveButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinColumnComposite_remove, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ this.joinColumnsRemoveButton.setLayoutData(gridData);
+ this.joinColumnsRemoveButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ removeJoinColumn();
+ }
+ });
+
+ this.joinColumnsListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateEnablement();
+ }
+ });
+
+ }
+ private IContentProvider buildJoinColumnsListContentProvider() {
+ return new IStructuredContentProvider(){
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // do nothing
+ }
+ public void dispose() {
+ // do nothing
+ }
+ public Object[] getElements(Object inputElement) {
+ return ((ISingleRelationshipMapping) inputElement).getJoinColumns().toArray();
+ }
+ };
+ }
+
+ private ILabelProvider buildJoinColumnsListLabelProvider() {
+ return new LabelProvider() {
+ public String getText(Object element) {
+ IJoinColumn joinColumn = (IJoinColumn) element;
+ return (JoinColumnComposite.this.singleRelationshipMapping.getSpecifiedJoinColumns().size() == 0) ?
+ buildDefaultJoinColumnLabel(joinColumn)
+ :
+ buildJoinColumnLabel(joinColumn);
+ }
+ };
+ }
+
+ String buildDefaultJoinColumnLabel(IJoinColumn joinColumn) {
+ return NLS.bind(JpaUiMappingsMessages.JoinColumnComposite_mappingBetweenTwoParamsDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+
+ String buildJoinColumnLabel(IJoinColumn joinColumn) {
+ if (joinColumn.getSpecifiedName() == null) {
+ if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinColumnComposite_mappingBetweenTwoParamsBothDefault, joinColumn.getName(),joinColumn.getReferencedColumnName());
+ }
+ return NLS.bind(JpaUiMappingsMessages.JoinColumnComposite_mappingBetweenTwoParamsFirstDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinColumnComposite_mappingBetweenTwoParamsSecDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else {
+ return NLS.bind(JpaUiMappingsMessages.JoinColumnComposite_mappingBetweenTwoParams, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ }
+
+ protected void joinColumnChanged(Notification notification) {
+ if (notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__SPECIFIED_NAME
+ || notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__DEFAULT_NAME
+ || notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__SPECIFIED_TABLE
+ || notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__SPECIFIED_REFERENCED_COLUMN_NAME
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__DEFAULT_REFERENCED_COLUMN_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ joinColumnsListViewer.refresh();
+ }
+ });
+ }
+ }
+
+ void addJoinColumn() {
+ JoinColumnDialog dialog = new JoinColumnDialog(this.getControl().getShell(), this.singleRelationshipMapping);
+ this.addJoinColumnFromDialog(dialog);
+ }
+
+ private void addJoinColumnFromDialog(JoinColumnDialog dialog) {
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ int index = this.singleRelationshipMapping.getJoinColumns().size();
+ IJoinColumn joinColumn = this.singleRelationshipMapping.createJoinColumn(index);
+ this.singleRelationshipMapping.getSpecifiedJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(dialog.getSelectedName());
+ joinColumn.setSpecifiedReferencedColumnName(dialog.getReferencedColumnName());
+ }
+
+ void editJoinColumn() {
+ IJoinColumn joinColumn = getSelectedJoinColumn();
+ JoinColumnDialog dialog = new JoinColumnDialog(this.getControl().getShell(), joinColumn);
+ editJoinColumnFromDialog(dialog, joinColumn);
+ }
+
+ private IJoinColumn getSelectedJoinColumn() {
+ return (IJoinColumn) ((StructuredSelection) this.joinColumnsListViewer.getSelection()).getFirstElement();
+ }
+
+ private void editJoinColumnFromDialog(JoinColumnDialog dialog, IJoinColumn joinColumn) {
+ if (dialog.open() == Window.OK) {
+ editJoinColumnDialogOkd(dialog, joinColumn);
+ }
+ }
+
+ private void editJoinColumnDialogOkd(JoinColumnDialog dialog, IJoinColumn joinColumn) {
+ String name = dialog.getSelectedName();
+ String referencedColumnName = dialog.getReferencedColumnName();
+
+ if (dialog.isDefaultNameSelected()) {
+ if (joinColumn.getSpecifiedName() != null) {
+ joinColumn.setSpecifiedName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedName() == null || !joinColumn.getSpecifiedName().equals(name)){
+ joinColumn.setSpecifiedName(name);
+ }
+ if (dialog.isDefaultReferencedColumnNameSelected()) {
+ if (joinColumn.getSpecifiedReferencedColumnName() != null) {
+ joinColumn.setSpecifiedReferencedColumnName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null || !joinColumn.getSpecifiedReferencedColumnName().equals(referencedColumnName)){
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ DefaultTrueBoolean insertable = dialog.getInsertable();
+ if (joinColumn.getInsertable() != insertable) {
+ joinColumn.setInsertable(insertable);
+ }
+
+ DefaultTrueBoolean updatable = dialog.getUpdatable();
+ if (joinColumn.getUpdatable() != updatable) {
+ joinColumn.setUpdatable(updatable);
+ }
+ }
+
+ void removeJoinColumn() {
+ ISelection selection = this.joinColumnsListViewer.getSelection();
+ if (selection instanceof StructuredSelection) {
+ for (Iterator stream = ((StructuredSelection) selection).iterator(); stream.hasNext(); ) {
+ this.singleRelationshipMapping.getJoinColumns().remove(stream.next());
+ }
+ }
+ }
+
+ protected void singleRelationshipMappingChanged(Notification notification) {
+ if (notification.getFeatureID(ISingleRelationshipMapping.class) == JpaCoreMappingsPackage.ISINGLE_RELATIONSHIP_MAPPING__SPECIFIED_JOIN_COLUMNS) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ JoinColumnComposite.this.joinColumnsListViewer.refresh();
+ JoinColumnComposite.this.overrideDefaultJoinColumnsCheckBox.setSelection(singleRelationshipMapping.containsSpecifiedJoinColumns());
+ JoinColumnComposite.this.updateEnablement();
+ }
+ });
+ if (notification.getEventType() == Notification.ADD) {
+ ((IJoinColumn) notification.getNewValue()).eAdapters().add(this.joinColumnListener);
+ }
+ else if (notification.getEventType() == Notification.REMOVE) {
+ ((IJoinColumn) notification.getOldValue()).eAdapters().remove(this.joinColumnListener);
+ }
+ }
+ }
+
+ private void enableGroup(Group group, boolean enabled) {
+ group.setEnabled(enabled);
+ for (int i = 0; i < group.getChildren().length; i++) {
+ group.getChildren()[i].setEnabled(enabled);
+ }
+ }
+
+
+
+ protected void engageListeners() {
+ if (this.singleRelationshipMapping != null) {
+ this.singleRelationshipMapping.eAdapters().add(this.singleRelationshipMappingListener);
+ for (Iterator i = this.singleRelationshipMapping.getJoinColumns().iterator(); i.hasNext(); ) {
+ ((IJoinColumn) i.next()).eAdapters().add(this.joinColumnListener);
+ }
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.singleRelationshipMapping != null) {
+ for (Iterator i = this.singleRelationshipMapping.getJoinColumns().iterator(); i.hasNext(); ) {
+ ((IJoinColumn) i.next()).eAdapters().remove(this.joinColumnListener);
+ }
+ this.singleRelationshipMapping.eAdapters().remove(this.singleRelationshipMappingListener);
+ }
+ }
+
+ public void doPopulate(EObject obj) {
+ this.singleRelationshipMapping = (ISingleRelationshipMapping) obj;
+ if (this.singleRelationshipMapping == null) {
+ this.joinColumnsListViewer.setInput(null);
+ return;
+ }
+
+ this.joinColumnsListViewer.setInput(this.singleRelationshipMapping);
+
+
+ updateEnablement();
+ this.overrideDefaultJoinColumnsCheckBox.setSelection(this.singleRelationshipMapping.containsSpecifiedJoinColumns());
+ }
+
+ @Override
+ protected void doPopulate() {
+ this.joinColumnsListViewer.setInput(this.singleRelationshipMapping);
+ }
+
+ void updateEnablement() {
+ boolean groupEnabledState = this.singleRelationshipMapping.containsSpecifiedJoinColumns();
+ enableGroup(this.joinColumnsGroup, groupEnabledState);
+
+ this.joinColumnsRemoveButton.setEnabled(groupEnabledState && !((StructuredSelection) this.joinColumnsListViewer.getSelection()).isEmpty());
+ this.joinColumnsEditButton.setEnabled(groupEnabledState && ((StructuredSelection) this.joinColumnsListViewer.getSelection()).size() == 1);
+ }
+
+ public void dispose() {
+ disengageListeners();
+ super.dispose();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnDialog.java
new file mode 100644
index 0000000000..abba08a809
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnDialog.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.mappings.DefaultTrueBoolean;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.ISingleRelationshipMapping;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+
+public class JoinColumnDialog extends AbstractJoinColumnDialog<IJoinColumn> {
+ private DefaultTrueBoolean insertable;
+ private ComboViewer insertableComboViewer;
+
+ private DefaultTrueBoolean updatable;
+ private ComboViewer updatableComboViewer;
+
+ private ISingleRelationshipMapping singleRelationshipMapping;
+
+ JoinColumnDialog(Shell parent, ISingleRelationshipMapping singleRelationshipMapping) {
+ super(parent);
+ this.singleRelationshipMapping = singleRelationshipMapping;
+ }
+
+ JoinColumnDialog(Shell parent, IJoinColumn joinColumn) {
+ super(parent, joinColumn);
+ this.singleRelationshipMapping = (ISingleRelationshipMapping) joinColumn.eContainer();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Label insertableLabel = new Label(composite, SWT.LEFT);
+ insertableLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_insertable);
+ insertableLabel.setLayoutData(new GridData());
+
+ this.insertableComboViewer = this.buildInsertableComboViewer(composite);
+ this.insertableComboViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+ helpSystem.setHelp(this.insertableComboViewer.getCombo(), IJpaHelpContextIds.MAPPING_COLUMN_INSERTABLE);
+
+ Label updatableLabel = new Label(composite, SWT.LEFT);
+ updatableLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_updatable);
+ updatableLabel.setLayoutData(new GridData());
+
+ this.updatableComboViewer = this.buildUpdatableComboViewer(composite);
+ this.updatableComboViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+ helpSystem.setHelp(this.updatableComboViewer.getCombo(), IJpaHelpContextIds.MAPPING_COLUMN_UPDATABLE);
+
+ return composite;
+ }
+
+ private ComboViewer buildInsertableComboViewer(Composite parent) {
+ ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+ viewer.add(DefaultTrueBoolean.VALUES.toArray());
+ DefaultTrueBoolean sel = (this.joinColumn() == null) ? DefaultTrueBoolean.DEFAULT : this.joinColumn().getInsertable();
+ viewer.setSelection(new StructuredSelection(sel));
+ return viewer;
+ }
+
+ private ComboViewer buildUpdatableComboViewer(Composite parent) {
+ ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+ viewer.add(DefaultTrueBoolean.VALUES.toArray());
+ DefaultTrueBoolean sel = (this.joinColumn() == null) ? DefaultTrueBoolean.DEFAULT : this.joinColumn().getUpdatable();
+ viewer.setSelection(new StructuredSelection(sel));
+ return viewer;
+ }
+
+ protected Table getNameTable() {
+ return this.singleRelationshipMapping.typeMapping().primaryDbTable();
+ }
+
+ protected Table getReferencedNameTable() {
+ IEntity targetEntity = this.singleRelationshipMapping.getResolvedTargetEntity();
+ if (targetEntity != null) {
+ return targetEntity.primaryDbTable();
+ }
+ return null;
+ }
+
+ private IJoinColumn joinColumn() {
+ return this.getJoinColumn();
+ }
+
+ public DefaultTrueBoolean getInsertable() {
+ return this.insertable;
+ }
+
+ public DefaultTrueBoolean getUpdatable() {
+ return this.updatable;
+ }
+
+ public boolean close() {
+ ISelection selection = this.insertableComboViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ this.insertable = (DefaultTrueBoolean) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ selection = this.updatableComboViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ this.updatable = (DefaultTrueBoolean) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ return super.close();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInAssociationOverrideDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInAssociationOverrideDialog.java
new file mode 100644
index 0000000000..e4fae53f25
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInAssociationOverrideDialog.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.core.internal.IAttributeMapping;
+import org.eclipse.jpt.core.internal.mappings.DefaultTrueBoolean;
+import org.eclipse.jpt.core.internal.mappings.IAssociationOverride;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.ISingleRelationshipMapping;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+
+public class JoinColumnInAssociationOverrideDialog extends AbstractJoinColumnDialog<IJoinColumn> {
+ private DefaultTrueBoolean insertable;
+ private ComboViewer insertableComboViewer;
+
+ private DefaultTrueBoolean updatable;
+ private ComboViewer updatableComboViewer;
+
+ private IAssociationOverride associationOverride;
+
+ JoinColumnInAssociationOverrideDialog(Shell parent, IAssociationOverride associationOverride) {
+ super(parent);
+ this.associationOverride = associationOverride;
+ }
+
+ JoinColumnInAssociationOverrideDialog(Shell parent, IJoinColumn joinColumn) {
+ super(parent, joinColumn);
+ this.associationOverride = (IAssociationOverride) joinColumn.eContainer();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Label insertableLabel = new Label(composite, SWT.LEFT);
+ insertableLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_insertable);
+ insertableLabel.setLayoutData(new GridData());
+
+ this.insertableComboViewer = this.buildInsertableComboViewer(composite);
+ this.insertableComboViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+ helpSystem.setHelp(this.insertableComboViewer.getCombo(), IJpaHelpContextIds.MAPPING_COLUMN_INSERTABLE);
+
+ Label updatableLabel = new Label(composite, SWT.LEFT);
+ updatableLabel.setText(JpaUiMappingsMessages.JoinColumnDialog_updatable);
+ updatableLabel.setLayoutData(new GridData());
+
+ this.updatableComboViewer = this.buildUpdatableComboViewer(composite);
+ this.updatableComboViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+ helpSystem.setHelp(this.updatableComboViewer.getCombo(), IJpaHelpContextIds.MAPPING_COLUMN_UPDATABLE);
+
+ return composite;
+ }
+
+ private ComboViewer buildInsertableComboViewer(Composite parent) {
+ ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+ viewer.add(DefaultTrueBoolean.VALUES.toArray());
+ DefaultTrueBoolean sel = (this.joinColumn() == null) ? DefaultTrueBoolean.DEFAULT : this.joinColumn().getInsertable();
+ viewer.setSelection(new StructuredSelection(sel));
+ return viewer;
+ }
+
+ private ComboViewer buildUpdatableComboViewer(Composite parent) {
+ ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+ viewer.add(DefaultTrueBoolean.VALUES.toArray());
+ DefaultTrueBoolean sel = (this.joinColumn() == null) ? DefaultTrueBoolean.DEFAULT : this.joinColumn().getUpdatable();
+ viewer.setSelection(new StructuredSelection(sel));
+ return viewer;
+ }
+
+ protected Table getNameTable() {
+ return this.associationOverride.typeMapping().primaryDbTable();
+ }
+
+ protected Table getReferencedNameTable() {
+ IAttributeMapping attributeMapping = this.associationOverride.getOwner().attributeMapping(this.associationOverride.getName());
+ if (attributeMapping == null) {
+ return null;
+ }
+ IEntity targetEntity = ((ISingleRelationshipMapping) attributeMapping).getResolvedTargetEntity();
+ if (targetEntity != null) {
+ return targetEntity.primaryDbTable();
+ }
+ return null;
+ }
+
+ private IJoinColumn joinColumn() {
+ return this.getJoinColumn();
+ }
+
+ public DefaultTrueBoolean getInsertable() {
+ return this.insertable;
+ }
+
+ public DefaultTrueBoolean getUpdatable() {
+ return this.updatable;
+ }
+
+ public boolean close() {
+ ISelection selection = this.insertableComboViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ this.insertable = (DefaultTrueBoolean) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ selection = this.updatableComboViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ this.updatable = (DefaultTrueBoolean) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+ return super.close();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInJoinTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInJoinTableDialog.java
new file mode 100644
index 0000000000..5a8a7479c2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnInJoinTableDialog.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IJoinTable;
+import org.eclipse.jpt.core.internal.mappings.IMultiRelationshipMapping;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.swt.widgets.Shell;
+
+//if there is only 1 joinColumn and the user is editing it, they should be
+//able to define defaults. otherwise, we probably shouldn't allow it.
+public class JoinColumnInJoinTableDialog extends AbstractJoinColumnDialog<IJoinColumn> {
+
+ private IJoinTable joinTable;
+
+ JoinColumnInJoinTableDialog(Shell parent, IJoinTable joinTable) {
+ super(parent);
+ this.joinTable = joinTable;
+ }
+
+ JoinColumnInJoinTableDialog(Shell parent, IJoinColumn joinColumn) {
+ super(parent, joinColumn);
+ this.joinTable = (IJoinTable) joinColumn.eContainer();
+ }
+ protected IJoinTable getJoinTable() {
+ return this.joinTable;
+ }
+
+ protected Table getNameTable() {
+ return getJoinTable().dbTable();
+ }
+
+ protected Table getReferencedNameTable() {
+ IMultiRelationshipMapping multiRelationshipMapping = (IMultiRelationshipMapping) getJoinTable().eContainer();
+ return multiRelationshipMapping.typeMapping().primaryDbTable();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnsComposite.java
new file mode 100644
index 0000000000..1a5f05e849
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnsComposite.java
@@ -0,0 +1,347 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jpt.core.internal.mappings.IAbstractColumn;
+import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.INamedColumn;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JoinColumnsComposite extends BaseJpaComposite
+{
+
+ private Owner owner;
+ private final Adapter joinColumnsOwnerListener;
+
+ private ListViewer joinColumnsListViewer;
+
+ private final Adapter joinColumnListener;
+
+ private Group joinColumnsGroup;
+ private Button joinColumnsAddButton;
+ private Button joinColumnsRemoveButton;
+ private Button joinColumnsEditButton;
+
+
+ public JoinColumnsComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.joinColumnsOwnerListener = buildJoinColumnsOwnerListener();
+ this.joinColumnListener = buildJoinColumnListener();
+ }
+
+ private Adapter buildJoinColumnsOwnerListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ joinColumnsOwnerChanged(notification);
+ }
+ };
+ }
+
+ private Adapter buildJoinColumnListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ joinColumnChanged(notification, joinColumnsListViewer);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ this.joinColumnsGroup =
+ getWidgetFactory().createGroup(
+ composite,
+ JpaUiMappingsMessages.JoinTableComposite_joinColumn);
+ this.joinColumnsGroup.setLayout(new GridLayout(2, false));
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.joinColumnsGroup.setLayoutData(gridData);
+
+ this.joinColumnsListViewer = new ListViewer(this.joinColumnsGroup, SWT.BORDER | SWT.MULTI);
+ this.joinColumnsListViewer.setContentProvider(buildJoinColumnsListContentProvider());
+ this.joinColumnsListViewer.setLabelProvider(buildJoinColumnsListLabelProvider());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.verticalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.joinColumnsListViewer.getList().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.joinColumnsListViewer.getList(), IJpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS);
+
+ this.joinColumnsAddButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinTableComposite_add, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ this.joinColumnsAddButton.setLayoutData(gridData);
+ this.joinColumnsAddButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ owner.addJoinColumn();
+ }
+ });
+
+ this.joinColumnsEditButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinTableComposite_edit, SWT.NONE);
+ this.joinColumnsEditButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ editJoinColumn();
+ }
+ });
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ this.joinColumnsEditButton.setLayoutData(gridData);
+
+ this.joinColumnsRemoveButton = getWidgetFactory().createButton(this.joinColumnsGroup, JpaUiMappingsMessages.JoinTableComposite_remove, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ this.joinColumnsRemoveButton.setLayoutData(gridData);
+ this.joinColumnsRemoveButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ removeJoinColumn();
+ }
+ });
+
+ this.joinColumnsListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateJoinColumnsEnablement();
+ }
+ });
+ }
+
+ private IContentProvider buildJoinColumnsListContentProvider() {
+ return new IStructuredContentProvider(){
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((Owner) inputElement).getJoinColumns().toArray();
+ }
+ };
+ }
+
+ private ILabelProvider buildJoinColumnsListLabelProvider() {
+ return new LabelProvider() {
+ public String getText(Object element) {
+ IJoinColumn joinColumn = (IJoinColumn) element;
+ return (JoinColumnsComposite.this.owner.containsSpecifiedJoinColumns()) ?
+ buildJoinColumnLabel(joinColumn)
+ :
+ buildDefaultJoinColumnLabel(joinColumn);
+ }
+ };
+ }
+
+ private String buildDefaultJoinColumnLabel(IJoinColumn joinColumn) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+
+ private String buildJoinColumnLabel(IJoinColumn joinColumn) {
+ if (joinColumn.getSpecifiedName() == null) {
+ if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsBothDefault, joinColumn.getName(),joinColumn.getReferencedColumnName());
+ }
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsFirstDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsSecDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParams, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ }
+
+ void editJoinColumn() {
+ this.owner.editJoinColumn(getSelectedJoinColumn());
+ }
+
+ void removeJoinColumn() {
+ ISelection selection = this.joinColumnsListViewer.getSelection();
+ if (selection instanceof StructuredSelection) {
+ for (Iterator stream = ((StructuredSelection) selection).iterator(); stream.hasNext(); ) {
+ this.owner.getJoinColumns().remove(stream.next());
+ }
+ }
+ }
+
+ private IJoinColumn getSelectedJoinColumn() {
+ return (IJoinColumn) ((StructuredSelection) this.joinColumnsListViewer.getSelection()).getFirstElement();
+ }
+
+ protected void joinColumnsOwnerChanged(Notification notification) {
+ if (notification.getFeatureID(owner.owningFeatureClass()) == owner.specifiedJoinColumnsFeatureId()) {
+ if (notification.getEventType() == Notification.ADD) {
+ ((IJoinColumn) notification.getNewValue()).eAdapters().add(this.joinColumnListener);
+ }
+ else if (notification.getEventType() == Notification.REMOVE) {
+ ((IJoinColumn) notification.getOldValue()).eAdapters().remove(this.joinColumnListener);
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ joinColumnsListViewer.refresh();
+ updateJoinColumnsEnablement();
+ }
+ });
+ }
+ }
+
+ private void enableGroup(Group group, boolean enabled) {
+ group.setEnabled(enabled);
+ for (int i = 0; i < group.getChildren().length; i++) {
+ group.getChildren()[i].setEnabled(enabled);
+ }
+ }
+ protected void joinColumnChanged(Notification notification, final ListViewer listViewer) {
+ if (notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__SPECIFIED_NAME
+ || notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__DEFAULT_NAME
+ || notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__SPECIFIED_TABLE
+ || notification.getFeatureID(IAbstractColumn.class) == JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__SPECIFIED_REFERENCED_COLUMN_NAME
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__DEFAULT_REFERENCED_COLUMN_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ listViewer.refresh();
+ }
+ });
+ }
+ }
+
+ protected void engageListeners() {
+ if (this.owner != null) {
+ this.owner.getEObject().eAdapters().add(this.joinColumnsOwnerListener);
+ for (IJoinColumn joinColumn : this.owner.getJoinColumns()) {
+ joinColumn.eAdapters().add(this.joinColumnListener);
+ }
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.owner != null) {
+ for (IJoinColumn joinColumn : this.owner.getJoinColumns()) {
+ joinColumn.eAdapters().remove(this.joinColumnListener);
+ }
+ this.owner.getEObject().eAdapters().remove(this.joinColumnsOwnerListener);
+ }
+ }
+
+ public void doPopulate(EObject obj) {
+ this.owner = (Owner) obj;
+ if (this.owner == null) {
+ this.joinColumnsListViewer.setInput(null);
+ return;
+ }
+
+ this.joinColumnsListViewer.setInput(this.owner);
+
+ updateEnablement();
+ }
+
+ @Override
+ protected void doPopulate() {
+ }
+
+ private void updateEnablement() {
+ updateJoinColumnsEnablement();
+ }
+
+ void updateJoinColumnsEnablement() {
+ boolean groupEnabledState = this.owner.containsSpecifiedJoinColumns();
+ enableGroup(this.joinColumnsGroup, groupEnabledState);
+
+ this.joinColumnsRemoveButton.setEnabled(groupEnabledState && !((StructuredSelection) this.joinColumnsListViewer.getSelection()).isEmpty());
+ this.joinColumnsEditButton.setEnabled(groupEnabledState && ((StructuredSelection) this.joinColumnsListViewer.getSelection()).size() == 1);
+ }
+
+ protected void enableWidgets(boolean enabled) {
+ enableGroup(this.joinColumnsGroup, enabled);
+ this.joinColumnsAddButton.setEnabled(enabled);
+ this.joinColumnsEditButton.setEnabled(enabled);
+ this.joinColumnsRemoveButton.setEnabled(enabled);
+ this.joinColumnsListViewer.getList().setEnabled(enabled);
+ }
+
+ public interface Owner {
+ int specifiedJoinColumnsFeatureId();
+
+ Class owningFeatureClass();
+
+ EObject getEObject();
+
+ boolean containsSpecifiedJoinColumns();
+
+ List<IJoinColumn> getJoinColumns();
+
+ List<IJoinColumn> getSpecifiedJoinColumns();
+
+ IJoinColumn createJoinColumn(int index);
+
+ void addJoinColumn();
+
+ void editJoinColumn(IJoinColumn joinColumn);
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
new file mode 100644
index 0000000000..2c0c44aa72
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
@@ -0,0 +1,491 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.List;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.JpaEObject;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IJoinTable;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.db.internal.Connection;
+import org.eclipse.jpt.db.internal.ConnectionListener;
+import org.eclipse.jpt.db.internal.ConnectionProfile;
+import org.eclipse.jpt.db.internal.Database;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.JoinColumnsComposite.Owner;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class JoinTableComposite extends BaseJpaComposite
+{
+
+ private IJoinTable joinTable;
+ private final Adapter joinTableListener;
+
+ protected TableCombo tableCombo;
+
+ private ConnectionProfile connectionProfile;
+ private ConnectionListener connectionListener;
+
+ private Button overrideDefaultJoinColumnsCheckBox;
+ private JoinColumnsComposite joinColumnsComposite;
+
+ private Button overrideDefaultInverseJoinColumnsCheckBox;
+ private JoinColumnsComposite inverseJoinColumnsComposite;
+
+ public JoinTableComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.joinTableListener = buildJoinTableListener();
+ this.connectionListener = buildConnectionListener();
+ }
+
+ private Adapter buildJoinTableListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ joinTableChanged(notification);
+ }
+ };
+ }
+
+ private ConnectionListener buildConnectionListener() {
+ return new ConnectionListener() {
+
+ public void aboutToClose(Connection connection) {
+ // not interested to this event.
+ }
+
+ public void closed(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ JoinTableComposite.this.tableCombo.populate();
+ }
+ });
+ }
+
+ public void modified(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ JoinTableComposite.this.tableCombo.populate();
+ }
+ });
+ }
+
+ public boolean okToClose(Connection connection) {
+ // not interested to this event.
+ return true;
+ }
+
+ public void opened(Connection connection) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ JoinTableComposite.this.tableCombo.populate();
+ }
+ });
+ }
+
+ public void databaseChanged(Connection connection, final Database database) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if(database == JoinTableComposite.this.tableCombo.getDatabase()) {
+ if (!getControl().isDisposed()) {
+ JoinTableComposite.this.tableCombo.populate();
+ }
+ }
+ }
+ });
+ }
+
+ public void schemaChanged(Connection connection, final Schema schema) {
+ getControl().getDisplay().asyncExec( new Runnable() {
+ public void run() {
+ if(schema == JoinTableComposite.this.tableCombo.getTableSchema()) {
+ if (!getControl().isDisposed()) {
+ JoinTableComposite.this.tableCombo.populate();
+ }
+ }
+ }
+ });
+ }
+
+ public void tableChanged(Connection connection, final Table table) {
+ // not interested to this event.
+ }
+ };
+ }
+
+ private ConnectionProfile getConnectionProfile() {
+ if(this.connectionProfile == null) {
+ IJpaProject jpaProject = this.joinTable.getJpaProject();
+ this.connectionProfile = jpaProject.connectionProfile();
+ }
+ return this.connectionProfile;
+ }
+
+ private void addConnectionListener() {
+ this.getConnectionProfile().addConnectionListener(this.connectionListener);
+ }
+
+ private void removeConnectionListener() {
+ this.getConnectionProfile().removeConnectionListener(this.connectionListener);
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.JoinTableComposite_name);
+
+ this.tableCombo = new TableCombo(composite, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.tableCombo.getCombo().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.tableCombo.getCombo(), IJpaHelpContextIds.MAPPING_JOIN_TABLE_NAME);
+
+ this.overrideDefaultJoinColumnsCheckBox =
+ getWidgetFactory().createButton(
+ composite,
+ JpaUiMappingsMessages.JoinTableComposite_overrideDefaultJoinColumns,
+ SWT.CHECK);
+ this.overrideDefaultJoinColumnsCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (JoinTableComposite.this.overrideDefaultJoinColumnsCheckBox.getSelection()) {
+ IJoinColumn defaultJoinColumn = JoinTableComposite.this.joinTable.getDefaultJoinColumns().get(0);
+ String columnName = defaultJoinColumn.getDefaultName();
+ String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
+ IJoinColumn joinColumn = JoinTableComposite.this.joinTable.createJoinColumn(0);
+ JoinTableComposite.this.joinTable.getSpecifiedJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(columnName);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ } else {
+ JoinTableComposite.this.joinTable.getSpecifiedJoinColumns().clear();
+ }
+ }
+ });
+
+ this.joinColumnsComposite = new JoinColumnsComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.joinColumnsComposite.getControl().setLayoutData(gridData);
+
+ this.overrideDefaultInverseJoinColumnsCheckBox = getWidgetFactory().createButton(composite, JpaUiMappingsMessages.JoinTableComposite_overrideDefaultInverseJoinColumns, SWT.CHECK);
+ this.overrideDefaultInverseJoinColumnsCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (JoinTableComposite.this.overrideDefaultInverseJoinColumnsCheckBox.getSelection()) {
+ IJoinColumn defaultJoinColumn = JoinTableComposite.this.joinTable.getDefaultInverseJoinColumns().get(0);
+ String columnName = defaultJoinColumn.getDefaultName();
+ String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
+ IJoinColumn joinColumn = JoinTableComposite.this.joinTable.createInverseJoinColumn(0);
+ JoinTableComposite.this.joinTable.getSpecifiedInverseJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(columnName);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ } else {
+ JoinTableComposite.this.joinTable.getSpecifiedInverseJoinColumns().clear();
+ }
+ }
+ });
+ this.inverseJoinColumnsComposite = new JoinColumnsComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.inverseJoinColumnsComposite.getControl().setLayoutData(gridData);
+ }
+
+ private String buildDefaultJoinColumnLabel(IJoinColumn joinColumn) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+
+ private String buildJoinColumnLabel(IJoinColumn joinColumn) {
+ if (joinColumn.getSpecifiedName() == null) {
+ if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsBothDefault, joinColumn.getName(),joinColumn.getReferencedColumnName());
+ }
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsFirstDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParamsSecDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else {
+ return NLS.bind(JpaUiMappingsMessages.JoinTableComposite_mappingBetweenTwoParams, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ }
+
+ void addJoinColumn() {
+ JoinColumnInJoinTableDialog dialog = new JoinColumnInJoinTableDialog(this.getControl().getShell(), this.joinTable);
+ this.addJoinColumnFromDialog(dialog);
+ }
+
+ private void addJoinColumnFromDialog(JoinColumnInJoinTableDialog dialog) {
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ int index = this.joinTable.getJoinColumns().size();
+ IJoinColumn joinColumn = this.joinTable.createJoinColumn(index);
+ this.joinTable.getSpecifiedJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(dialog.getSelectedName());
+ joinColumn.setSpecifiedReferencedColumnName(dialog.getReferencedColumnName());
+ }
+
+ void addInverseJoinColumn() {
+ InverseJoinColumnDialog dialog = new InverseJoinColumnDialog(this.getControl().getShell(), this.joinTable);
+ this.addInverseJoinColumnFromDialog(dialog);
+ }
+
+ private void addInverseJoinColumnFromDialog(InverseJoinColumnDialog dialog) {
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ int index = this.joinTable.getInverseJoinColumns().size();
+ IJoinColumn joinColumn = this.joinTable.createInverseJoinColumn(index);
+ this.joinTable.getSpecifiedInverseJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(dialog.getSelectedName());
+ joinColumn.setSpecifiedReferencedColumnName(dialog.getReferencedColumnName());
+ }
+
+ void editJoinColumn(IJoinColumn joinColumn) {
+ JoinColumnInJoinTableDialog dialog = new JoinColumnInJoinTableDialog(this.getControl().getShell(), joinColumn);
+ editJoinColumnFromDialog(dialog, joinColumn);
+ }
+
+ private void editJoinColumnFromDialog(JoinColumnInJoinTableDialog dialog, IJoinColumn joinColumn) {
+ if (dialog.open() == Window.OK) {
+ editJoinColumnDialogOkd(dialog, joinColumn);
+ }
+ }
+
+ private void editJoinColumnDialogOkd(JoinColumnInJoinTableDialog dialog, IJoinColumn joinColumn) {
+ String name = dialog.getSelectedName();
+ String referencedColumnName = dialog.getReferencedColumnName();
+
+ if (dialog.isDefaultNameSelected()) {
+ if (joinColumn.getSpecifiedName() != null) {
+ joinColumn.setSpecifiedName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedName() == null || !joinColumn.getSpecifiedName().equals(name)){
+ joinColumn.setSpecifiedName(name);
+ }
+
+ if (dialog.isDefaultReferencedColumnNameSelected()) {
+ if (joinColumn.getSpecifiedReferencedColumnName() != null) {
+ joinColumn.setSpecifiedReferencedColumnName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null || !joinColumn.getSpecifiedReferencedColumnName().equals(referencedColumnName)){
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+ }
+
+
+ void editInverseJoinColumn(IJoinColumn joinColumn) {
+ InverseJoinColumnDialog dialog = new InverseJoinColumnDialog(getControl().getShell(), joinColumn);
+ editJoinColumnFromDialog(dialog, joinColumn);
+ }
+
+ protected void joinTableChanged(Notification notification) {
+ if (notification.getFeatureID(IJoinTable.class) == JpaCoreMappingsPackage.IJOIN_TABLE__SPECIFIED_JOIN_COLUMNS) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ overrideDefaultJoinColumnsCheckBox.setSelection(joinTable.containsSpecifiedJoinColumns());
+ }
+ });
+ }
+ else if (notification.getFeatureID(IJoinTable.class) == JpaCoreMappingsPackage.IJOIN_TABLE__SPECIFIED_INVERSE_JOIN_COLUMNS) {
+
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ overrideDefaultInverseJoinColumnsCheckBox.setSelection(joinTable.containsSpecifiedInverseJoinColumns());
+ }
+ });
+ }
+ }
+
+ protected void engageListeners() {
+ if (this.joinTable != null) {
+ this.joinTable.eAdapters().add(this.joinTableListener);
+ this.addConnectionListener();
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.joinTable != null) {
+ this.joinTable.eAdapters().remove(this.joinTableListener);
+ this.removeConnectionListener();
+ }
+ }
+
+ public void doPopulate(EObject obj) {
+ this.joinTable = (IJoinTable) obj;
+ if (this.joinTable == null) {
+ this.joinColumnsComposite.populate(null);
+ this.inverseJoinColumnsComposite.populate(null);
+ return;
+ }
+
+ this.tableCombo.populate(this.joinTable);
+ this.joinColumnsComposite.populate(new JoinColumnsOwner(this.joinTable));
+ this.inverseJoinColumnsComposite.populate(new InverseJoinColumnsOwner(this.joinTable));
+
+ this.overrideDefaultJoinColumnsCheckBox.setSelection(this.joinTable.containsSpecifiedJoinColumns());
+ this.overrideDefaultInverseJoinColumnsCheckBox.setSelection(this.joinTable.containsSpecifiedInverseJoinColumns());
+ }
+
+ @Override
+ protected void doPopulate() {
+ this.tableCombo.populate();
+ this.joinColumnsComposite.populate();
+ this.inverseJoinColumnsComposite.populate();
+ }
+
+ @Override
+ public void dispose() {
+ this.tableCombo.dispose();
+ this.joinColumnsComposite.dispose();
+ this.inverseJoinColumnsComposite.dispose();
+ super.dispose();
+ }
+
+ private class JoinColumnsOwner extends JpaEObject implements Owner {
+
+ private IJoinTable joinTable;
+
+ public JoinColumnsOwner(IJoinTable joinTable) {
+ super();
+ this.joinTable = joinTable;
+ }
+
+ public void addJoinColumn() {
+ JoinTableComposite.this.addJoinColumn();
+ }
+
+ public boolean containsSpecifiedJoinColumns() {
+ return this.joinTable.containsSpecifiedJoinColumns();
+ }
+
+ public IJoinColumn createJoinColumn(int index) {
+ return this.joinTable.createJoinColumn(index);
+ }
+
+ public List<IJoinColumn> getJoinColumns() {
+ return this.joinTable.getJoinColumns();
+ }
+
+ public List<IJoinColumn> getSpecifiedJoinColumns() {
+ return this.joinTable.getSpecifiedJoinColumns();
+ }
+
+ public int specifiedJoinColumnsFeatureId() {
+ return JpaCoreMappingsPackage.IJOIN_TABLE__SPECIFIED_JOIN_COLUMNS;
+ }
+
+ public Class owningFeatureClass() {
+ return IJoinTable.class;
+ }
+
+ public void editJoinColumn(IJoinColumn joinColumn) {
+ JoinTableComposite.this.editJoinColumn(joinColumn);
+ }
+
+ public EObject getEObject() {
+ return this.joinTable;
+ }
+ }
+
+ private class InverseJoinColumnsOwner extends JpaEObject implements Owner {
+
+ private IJoinTable joinTable;
+
+ public InverseJoinColumnsOwner(IJoinTable joinTable) {
+ super();
+ this.joinTable = joinTable;
+ }
+
+ public void addJoinColumn() {
+ JoinTableComposite.this.addInverseJoinColumn();
+ }
+
+ public boolean containsSpecifiedJoinColumns() {
+ return this.joinTable.containsSpecifiedInverseJoinColumns();
+ }
+
+ public IJoinColumn createJoinColumn(int index) {
+ return this.joinTable.createJoinColumn(index);
+ }
+
+ public List<IJoinColumn> getJoinColumns() {
+ return this.joinTable.getInverseJoinColumns();
+ }
+
+ public List<IJoinColumn> getSpecifiedJoinColumns() {
+ return this.joinTable.getSpecifiedInverseJoinColumns();
+ }
+
+ public int specifiedJoinColumnsFeatureId() {
+ return JpaCoreMappingsPackage.IJOIN_TABLE__SPECIFIED_INVERSE_JOIN_COLUMNS;
+ }
+
+ public Class owningFeatureClass() {
+ return IJoinTable.class;
+ }
+
+ public void editJoinColumn(IJoinColumn joinColumn) {
+ JoinTableComposite.this.editInverseJoinColumn(joinColumn);
+ }
+
+ public EObject getEObject() {
+ return this.joinTable;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/LobCheckBox.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/LobCheckBox.java
new file mode 100644
index 0000000000..67aa811fa4
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/LobCheckBox.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IBasic;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.details.BaseJpaController;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class LobCheckBox extends BaseJpaController
+{
+ private IBasic basicMapping;
+ private Adapter basicMappingListener;
+
+ private Button button;
+
+
+ public LobCheckBox(Composite parent, CommandStack theCommandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, theCommandStack, widgetFactory);
+ buildBasicMappingListener();
+ }
+
+ private void buildBasicMappingListener() {
+ this.basicMappingListener = new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ bsaicMappingChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void buildWidget(Composite parent) {
+ this.button = getWidgetFactory().createButton(
+ parent,
+ JpaUiMappingsMessages.BasicGeneralSection_lobLabel,
+ SWT.CHECK);
+
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent event) {
+ LobCheckBox.this.lobSelectionChanged();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ LobCheckBox.this.lobSelectionChanged();
+ }
+ });
+ }
+
+ void lobSelectionChanged() {
+ boolean lob = this.button.getSelection();
+ if (this.basicMapping.isLob() != lob) {
+ this.basicMapping.setLob(lob);
+ }
+ }
+
+ private void bsaicMappingChanged(Notification notification) {
+ if (notification.getFeatureID(IBasic.class) ==
+ JpaCoreMappingsPackage.IBASIC__LOB) {
+ Display.getDefault().asyncExec(
+ new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.basicMapping != null) {
+ this.basicMapping.eAdapters().add(this.basicMappingListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.basicMapping != null) {
+ this.basicMapping.eAdapters().remove(this.basicMappingListener);
+ }
+ }
+
+ @Override
+ public void doPopulate(EObject obj) {
+ this.basicMapping = (IBasic) obj;
+ populateButton();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateButton();
+ }
+
+ private void populateButton() {
+ boolean lob = false;
+ if (this.basicMapping != null) {
+ lob = this.basicMapping.isLob();
+ }
+
+ if (this.button.getSelection() != lob) {
+ this.button.setSelection(lob);
+ }
+ }
+
+
+ @Override
+ public Control getControl() {
+ return this.button;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToManyComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToManyComposite.java
new file mode 100644
index 0000000000..5f11b8cc44
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToManyComposite.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IManyToMany;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class ManyToManyComposite extends BaseJpaComposite
+{
+ private IManyToMany manyToMany;
+
+ private TargetEntityChooser targetEntityChooser;
+
+ private EnumComboViewer fetchTypeComboViewer;
+
+ private MappedByCombo mappedByCombo;
+
+ private JoinTableComposite joinTableComposite;
+
+ private OrderByComposite orderByComposite;
+
+ public ManyToManyComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ Control joinTableControl = buildJoinTableControl(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ joinTableControl.setLayoutData(gridData);
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ this.targetEntityChooser = CommonWidgets.buildTargetEntityChooser(generalComposite, commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.targetEntityChooser.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildFetchLabel(generalComposite, getWidgetFactory());
+ this.fetchTypeComboViewer = CommonWidgets.buildFetchTypeComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.fetchTypeComboViewer.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildMappedByLabel(generalComposite, getWidgetFactory());
+ this.mappedByCombo = new MappedByCombo(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.mappedByCombo.getControl().setLayoutData(gridData);
+
+ this.orderByComposite = new OrderByComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalSpan = 3;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.orderByComposite.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ private Control buildJoinTableControl(Composite composite) {
+ Section section = getWidgetFactory().createSection(composite, SWT.FLAT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
+ section.setText(JpaUiMappingsMessages.MultiRelationshipMappingComposite_joinTable);
+
+ Composite joinTableClient = getWidgetFactory().createComposite(section);
+ section.setClient(joinTableClient);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ joinTableClient.setLayout(layout);
+
+ this.joinTableComposite = new JoinTableComposite(joinTableClient, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.joinTableComposite.getControl().setLayoutData(gridData);
+
+ return section;
+ }
+
+ public void doPopulate(EObject obj) {
+ this.manyToMany = (IManyToMany) obj;
+ this.targetEntityChooser.populate(this.manyToMany);
+ this.fetchTypeComboViewer.populate(CommonWidgets.buildMultiRelationshipMappingFetchEnumHolder(this.manyToMany));
+ this.mappedByCombo.populate(this.manyToMany);
+ if (this.manyToMany != null) {
+ this.joinTableComposite.populate(this.manyToMany.getJoinTable());
+ this.orderByComposite.populate(this.manyToMany.getOrderBy());
+ }
+ else {
+ this.joinTableComposite.populate(null);
+ this.orderByComposite.populate(null);
+ }
+ }
+
+ public void doPopulate() {
+ this.targetEntityChooser.populate();
+ this.fetchTypeComboViewer.populate();
+ this.mappedByCombo.populate();
+ this.joinTableComposite.populate();
+ this.orderByComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.targetEntityChooser.dispose();
+ this.fetchTypeComboViewer.dispose();
+ this.mappedByCombo.dispose();
+ this.joinTableComposite.dispose();
+ this.orderByComposite.dispose();
+ super.dispose();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToOneComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToOneComposite.java
new file mode 100644
index 0000000000..fe39c5af4e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ManyToOneComposite.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IManyToOne;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class ManyToOneComposite extends BaseJpaComposite
+{
+ private IManyToOne manyToOne;
+
+ private TargetEntityChooser targetEntityChooser;
+
+ private EnumComboViewer fetchTypeComboViewer;
+
+ private JoinColumnComposite joinColumnComposite;
+
+ public ManyToOneComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ this.targetEntityChooser = CommonWidgets.buildTargetEntityChooser(generalComposite, commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.targetEntityChooser.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildFetchLabel(generalComposite, getWidgetFactory());
+ this.fetchTypeComboViewer = CommonWidgets.buildFetchTypeComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.fetchTypeComboViewer.getControl().setLayoutData(gridData);
+
+ this.joinColumnComposite = new JoinColumnComposite(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.joinColumnComposite.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ public void doPopulate(EObject obj) {
+ this.manyToOne = (IManyToOne) obj;
+ this.targetEntityChooser.populate(this.manyToOne);
+ this.fetchTypeComboViewer.populate(CommonWidgets.buildSingleRelationshipMappingFetchEnumHolder(this.manyToOne));
+ this.joinColumnComposite.populate(this.manyToOne);
+ }
+
+ public void doPopulate() {
+ this.targetEntityChooser.populate();
+ this.fetchTypeComboViewer.populate();
+ this.joinColumnComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.targetEntityChooser.dispose();
+ this.fetchTypeComboViewer.dispose();
+ this.joinColumnComposite.dispose();
+ super.dispose();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java
new file mode 100644
index 0000000000..98133a8ffe
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java
@@ -0,0 +1,149 @@
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.INonOwningMapping;
+import org.eclipse.jpt.core.internal.mappings.IRelationshipMapping;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaController;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class MappedByCombo extends BaseJpaController
+{
+ private INonOwningMapping nonOwningMapping;
+ private Adapter nonOwningMappingListener;
+
+ private CCombo combo;
+
+ public MappedByCombo(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, commandStack, widgetFactory);
+ this.nonOwningMappingListener = buildListener();
+ }
+
+ private Adapter buildListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ nonOwningMappingChanged(notification);
+ }
+ };
+ }
+ @Override
+ protected void buildWidget(Composite parent) {
+ this.combo = getWidgetFactory().createCCombo(parent, SWT.FLAT);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(combo,IJpaHelpContextIds.MAPPING_MAPPED_BY);
+ this.combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String mappedBy = ((CCombo) e.getSource()).getText();
+ if (mappedBy.equals("")) { //$NON-NLS-1$
+ mappedBy = null;
+ if (getNonOwningMapping().getMappedBy() == null || getNonOwningMapping().getMappedBy().equals("")) { //$NON-NLS-1$
+ return;
+ }
+ }
+ if (getNonOwningMapping().getMappedBy() == null || !getNonOwningMapping().getMappedBy().equals(mappedBy)) {
+ getNonOwningMapping().setMappedBy(mappedBy);
+ }
+ }
+ });
+ }
+
+ private INonOwningMapping getNonOwningMapping() {
+ return this.nonOwningMapping;
+ }
+
+ @Override
+ protected void doPopulate(EObject obj) {
+ this.nonOwningMapping = (INonOwningMapping) obj;
+
+ if (this.nonOwningMapping == null) {
+ return;
+ }
+
+ populateCombo();
+ }
+
+ private void populateCombo() {
+ populateChoices();
+ populateMappedByText();
+ }
+
+ private void populateChoices() {
+ if (this.combo.getItemCount() > 0) {
+ this.combo.removeAll();
+ }
+ for (Iterator<String> i = this.nonOwningMapping.possibleMappedByAttributeNames(); i.hasNext(); ) {
+ this.combo.add(i.next());
+ }
+ }
+
+ private void populateMappedByText() {
+ String mappedBy = this.nonOwningMapping.getMappedBy();
+ if (mappedBy != null) {
+ if (!this.combo.getText().equals(mappedBy)) {
+ this.combo.setText(mappedBy);
+ }
+ }
+ }
+
+ @Override
+ protected void doPopulate() {
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.nonOwningMapping != null) {
+ this.nonOwningMapping.eAdapters().add(this.nonOwningMappingListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.nonOwningMapping != null) {
+ this.nonOwningMapping.eAdapters().remove(this.nonOwningMappingListener);
+ }
+ }
+
+ protected void nonOwningMappingChanged(Notification notification) {
+ if (notification.getFeatureID(INonOwningMapping.class) == JpaCoreMappingsPackage.INON_OWNING_MAPPING__MAPPED_BY) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateMappedByText();
+ }
+ });
+ }
+ else if (notification.getFeatureID(IRelationshipMapping.class) == JpaCoreMappingsPackage.IRELATIONSHIP_MAPPING__RESOLVED_TARGET_ENTITY) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ populateChoices();
+ }
+ });
+ }
+ }
+
+ @Override
+ public Control getControl() {
+ return this.combo;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java
new file mode 100644
index 0000000000..b0eb06e082
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IMappedSuperclass;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class MappedSuperclassComposite extends BaseJpaComposite
+{
+ private IMappedSuperclass mappedSuperclass;
+ private Adapter mappedSuperclassListener;
+
+ private CommandStack commandStack;
+
+
+ public MappedSuperclassComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.mappedSuperclassListener = buildMappedSuperclassListener();
+ }
+
+ private Adapter buildMappedSuperclassListener() {
+ return new AdapterImpl() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ mappedSuperclassChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ composite.setLayout(new FillLayout(SWT.VERTICAL));
+
+// Label accessTypeLabel = new Label(composite, SWT.LEFT);
+// accessTypeLabel.setText(DaliUiMessages.MappedSuperclassComposite_accessType);
+// this.accessTypeComboViewer = buildAccessTypeCombo(composite);
+// //eventually this will be enabled if editing xml instead of java
+// this.accessTypeComboViewer.getCombo().setEnabled(false);
+// GridData gridData = new GridData();
+// gridData.horizontalAlignment = GridData.FILL;
+// gridData.grabExcessHorizontalSpace = true;
+// this.accessTypeComboViewer.getCombo().setLayoutData(gridData);
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(this.accessTypeComboViewer.getCombo(), IDaliHelpContextIds.ENTITY_ACCESS_TYPE);
+
+ }
+
+// private ComboViewer buildAccessTypeCombo(Composite parent) {
+// ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);
+// viewer.add(AccessType.VALUES.toArray());
+// viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+// public void selectionChanged(SelectionChangedEvent event) {
+// if (populating) {
+// return;
+// }
+// if (event.getSelection() instanceof StructuredSelection) {
+// StructuredSelection selection = (StructuredSelection) event.getSelection();
+// editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, persistentType, OrmPackage.eINSTANCE.getPersistentType_AccessType(), selection.getFirstElement()));
+// }
+// }
+// });
+// return viewer;
+// }
+
+ @Override
+ protected void doPopulate(EObject model) {
+ this.mappedSuperclass = (IMappedSuperclass) model;
+ }
+
+ @Override
+ protected void doPopulate() {
+
+ }
+
+
+ protected void engageListeners() {
+// this.persistentTypeItemProvider.addListener(getPersistentTypeListener());
+// this.persistentType.eAdapters().add(this.persistentTypeItemProvider);
+ }
+
+ protected void disengageListeners() {
+// if (this.persistentType != null){
+// this.persistentType.eAdapters().remove(this.persistentTypeItemProvider);
+// this.persistentTypeItemProvider.removeListener(getPersistentTypeListener());
+// }
+ }
+
+ private void mappedSuperclassChanged(Notification notification) {
+
+ }
+
+// private INotifyChangedListener getPersistentTypeListener() {
+// if (this.persistentTypeListener == null) {
+// this.persistentTypeListener = new INotifyChangedListener() {
+// public void notifyChanged(Notification notification) {
+// if (notification.getFeatureID(PersistentType.class) == OrmPackage.PERSISTENT_TYPE__ACCESS_TYPE) {
+// final AccessType accessType = (AccessType) notification.getNewValue();
+// Display.getDefault().syncExec(new Runnable() {
+// public void run() {
+// if (((StructuredSelection) accessTypeComboViewer.getSelection()).getFirstElement() != accessType) {
+// accessTypeComboViewer.setSelection(new StructuredSelection(accessType));
+// }
+// }
+// });
+// }
+// }
+// };
+// }
+// return this.persistentTypeListener;
+// }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToManyComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToManyComposite.java
new file mode 100644
index 0000000000..8cb80807e3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToManyComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IOneToMany;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class OneToManyComposite extends BaseJpaComposite
+{
+ private IOneToMany oneToMany;
+
+ private EnumComboViewer fetchTypeComboViewer;
+
+ private TargetEntityChooser targetEntityChooser;
+
+ private MappedByCombo mappedByCombo;
+
+ private OrderByComposite orderByComposite;
+
+ private JoinTableComposite joinTableComposite;
+
+ public OneToManyComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralControl(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ Control joinTableControl = buildJoinTableControl(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ joinTableControl.setLayoutData(gridData);
+ }
+
+ private Control buildGeneralControl(Composite composite) {
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ GridData gridData;
+
+ this.targetEntityChooser = CommonWidgets.buildTargetEntityChooser(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.targetEntityChooser.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildFetchLabel(generalComposite, getWidgetFactory());
+ this.fetchTypeComboViewer = CommonWidgets.buildFetchTypeComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.fetchTypeComboViewer.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildMappedByLabel(generalComposite, getWidgetFactory());
+ this.mappedByCombo = new MappedByCombo(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.mappedByCombo.getControl().setLayoutData(gridData);
+
+
+ this.orderByComposite = new OrderByComposite(composite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalSpan = 3;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.orderByComposite.getControl().setLayoutData(gridData);
+
+
+ return generalComposite;
+ }
+
+ private Control buildJoinTableControl(Composite composite) {
+ Section section = getWidgetFactory().createSection(composite, SWT.FLAT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
+ section.setText(JpaUiMappingsMessages.MultiRelationshipMappingComposite_joinTable);
+
+ Composite joinTableClient = getWidgetFactory().createComposite(section);
+ section.setClient(joinTableClient);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ joinTableClient.setLayout(layout);
+
+ this.joinTableComposite = new JoinTableComposite(joinTableClient, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.joinTableComposite.getControl().setLayoutData(gridData);
+
+ return section;
+ }
+
+ public void doPopulate(EObject obj) {
+ this.oneToMany = (IOneToMany) obj;
+ this.fetchTypeComboViewer.populate(CommonWidgets.buildMultiRelationshipMappingFetchEnumHolder(this.oneToMany));
+ this.targetEntityChooser.populate(this.oneToMany);
+ this.mappedByCombo.populate(this.oneToMany);
+ if (this.oneToMany != null) {
+ this.joinTableComposite.populate(this.oneToMany.getJoinTable());
+ this.orderByComposite.populate(this.oneToMany.getOrderBy());
+ }
+ else {
+ this.joinTableComposite.populate(null);
+ this.orderByComposite.populate(null);
+ }
+ }
+
+ public void doPopulate() {
+ this.fetchTypeComboViewer.populate();
+ this.targetEntityChooser.populate();
+ this.mappedByCombo.populate();
+ this.joinTableComposite.populate();
+ this.orderByComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.fetchTypeComboViewer.dispose();
+ this.targetEntityChooser.dispose();
+ this.mappedByCombo.dispose();
+ this.joinTableComposite.dispose();
+ this.orderByComposite.dispose();
+ super.dispose();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToOneComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToOneComposite.java
new file mode 100644
index 0000000000..c2201b65f4
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OneToOneComposite.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.mappings.IOneToOne;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class OneToOneComposite extends BaseJpaComposite
+{
+ private IOneToOne oneToOne;
+
+ private TargetEntityChooser targetEntityChooser;
+
+ private EnumComboViewer fetchTypeComboViewer;
+
+ private MappedByCombo mappedByCombo;
+
+ private JoinColumnComposite joinColumnComposite;
+
+ public OneToOneComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ }
+
+ private IOneToOne getOneToOne() {
+ return this.oneToOne;
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control generalControl = buildGeneralComposite(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ generalControl.setLayoutData(gridData);
+
+ }
+
+ private Control buildGeneralComposite(Composite composite) {
+// IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ Composite generalComposite = getWidgetFactory().createComposite(composite);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ generalComposite.setLayout(layout);
+
+ this.targetEntityChooser = CommonWidgets.buildTargetEntityChooser(generalComposite, this.commandStack, getWidgetFactory());
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.targetEntityChooser.getControl().setLayoutData(gridData);
+
+
+ CommonWidgets.buildFetchLabel(generalComposite, getWidgetFactory());
+ this.fetchTypeComboViewer = CommonWidgets.buildFetchTypeComboViewer(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.fetchTypeComboViewer.getControl().setLayoutData(gridData);
+
+ CommonWidgets.buildMappedByLabel(generalComposite, getWidgetFactory());
+ this.mappedByCombo = new MappedByCombo(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ this.mappedByCombo.getControl().setLayoutData(gridData);
+
+
+ this.joinColumnComposite = new JoinColumnComposite(generalComposite, this.commandStack, getWidgetFactory());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.joinColumnComposite.getControl().setLayoutData(gridData);
+
+ return generalComposite;
+ }
+
+ public void doPopulate(EObject obj) {
+ this.oneToOne = (IOneToOne) obj;
+ this.targetEntityChooser.populate(this.oneToOne);
+ this.fetchTypeComboViewer.populate(CommonWidgets.buildSingleRelationshipMappingFetchEnumHolder(this.oneToOne));
+ this.mappedByCombo.populate(this.oneToOne);
+ this.joinColumnComposite.populate(this.oneToOne);
+ }
+
+ public void doPopulate() {
+ this.targetEntityChooser.populate();
+ this.fetchTypeComboViewer.populate();
+ this.mappedByCombo.populate();
+ this.joinColumnComposite.populate();
+ }
+
+ protected void engageListeners() {
+ }
+
+ protected void disengageListeners() {
+ }
+
+ @Override
+ public void dispose() {
+ this.targetEntityChooser.dispose();
+ this.fetchTypeComboViewer.dispose();
+ this.mappedByCombo.dispose();
+ this.joinColumnComposite.dispose();
+ super.dispose();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OrderByComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OrderByComposite.java
new file mode 100644
index 0000000000..ae5495f424
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OrderByComposite.java
@@ -0,0 +1,295 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jpt.core.internal.mappings.IOrderBy;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.core.internal.mappings.OrderingType;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+/**
+ *
+ */
+public class OrderByComposite extends BaseJpaComposite {
+
+ private IOrderBy orderBy;
+ private Adapter orderingListener;
+
+ private Button noOrderingRadioButton;
+ private Button primaryKeyOrderingRadioButton;
+ private Button customOrderingRadioButton;
+
+ private ITextViewer orderingTextViewer;
+
+
+ public OrderByComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, commandStack, widgetFactory);
+ this.orderingListener = buildOrderingListener();
+ }
+
+ private Adapter buildOrderingListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ orderByChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Group orderByGroup = getWidgetFactory().createGroup(composite, JpaUiMappingsMessages.OrderByComposite_orderByGroup);
+ orderByGroup.setLayout(new GridLayout(1, false));
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ orderByGroup.setLayoutData(gridData);
+
+ this.noOrderingRadioButton = buildNoOrderingRadioButton(orderByGroup);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.noOrderingRadioButton.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.noOrderingRadioButton, IJpaHelpContextIds.MAPPING_ORDER_BY_NO_ORDERING);
+
+
+ this.primaryKeyOrderingRadioButton = buildPrimaryKeyOrderingRadioButton(orderByGroup);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.primaryKeyOrderingRadioButton.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.primaryKeyOrderingRadioButton, IJpaHelpContextIds.MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING);
+
+ this.customOrderingRadioButton = buildCustomOrderingRadioButton(orderByGroup);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.customOrderingRadioButton.setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.customOrderingRadioButton, IJpaHelpContextIds.MAPPING_ORDER_BY_CUSTOM_ORDERING);
+
+
+ this.orderingTextViewer = buildOrderByTestViewer(orderByGroup);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalIndent = 15;
+ this.orderingTextViewer.getTextWidget().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.orderingTextViewer.getTextWidget(), IJpaHelpContextIds.MAPPING_ORDER_BY);
+ }
+
+ private Button buildNoOrderingRadioButton(Composite parent) {
+ Button button = getWidgetFactory().createButton(
+ parent,
+ JpaUiMappingsMessages.OrderByComposite_noOrdering,
+ SWT.RADIO);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+ public void widgetSelected(SelectionEvent e) {
+ OrderByComposite.this.noOrderingRadioButtonSelected(e);
+ }
+ });
+
+ return button;
+ }
+
+ void noOrderingRadioButtonSelected(SelectionEvent e) {
+ if (!((Button) e.widget).getSelection()) {
+ //ignore case where radio button is deselected
+ return;
+ }
+ if (this.orderBy.getType() == OrderingType.NONE) {
+ return;
+ }
+ this.orderBy.setType(OrderingType.NONE);
+ this.orderBy.setValue(null);
+ }
+
+ private Button buildPrimaryKeyOrderingRadioButton(Composite parent) {
+ Button button = getWidgetFactory().createButton(
+ parent,
+ JpaUiMappingsMessages.OrderByComposite_primaryKeyOrdering,
+ SWT.RADIO);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+ public void widgetSelected(SelectionEvent e) {
+ OrderByComposite.this.primaryKeyOrderingRadioButtonSelected(e);
+ }
+ });
+ return button;
+ }
+
+ void primaryKeyOrderingRadioButtonSelected(SelectionEvent e) {
+ if (!((Button) e.widget).getSelection()) {
+ //ignore case where radio button is deselected
+ return;
+ }
+ if (this.orderBy.getType() == OrderingType.PRIMARY_KEY) {
+ return;
+ }
+ this.orderBy.setType(OrderingType.PRIMARY_KEY);
+ }
+
+ private Button buildCustomOrderingRadioButton(Composite parent) {
+ Button button = getWidgetFactory().createButton(
+ parent,
+ JpaUiMappingsMessages.OrderByComposite_customOrdering,
+ SWT.RADIO);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+ public void widgetSelected(SelectionEvent e) {
+ OrderByComposite.this.customOrderingRadioButtonSelected(e);
+ }
+ });
+
+ return button;
+ }
+
+ void customOrderingRadioButtonSelected(SelectionEvent e) {
+ if (!((Button) e.widget).getSelection()) {
+ //ignore case where radio button is deselected
+ return;
+ }
+ if (this.orderBy.getType() == OrderingType.CUSTOM) {
+ return;
+ }
+ this.orderBy.setType(OrderingType.CUSTOM);
+ }
+
+ private ITextViewer buildOrderByTestViewer(Composite parent) {
+ final TextViewer textViewer = new TextViewer(parent, SWT.SINGLE | SWT.BORDER);
+ textViewer.setDocument(new Document());
+ textViewer.addTextListener(new ITextListener() {
+ public void textChanged(TextEvent event) {
+ orderingTextViewerChanged();
+ }
+ });
+ return textViewer;
+ }
+
+ private void orderingTextViewerChanged() {
+ if (isPopulating()) {
+ return;
+ }
+ String orderByValue = this.orderingTextViewer.getDocument().get();
+ if (orderByValue.equals(this.orderBy.getValue())) {
+ return;
+ }
+ this.orderBy.setValue(orderByValue);
+ }
+
+ private void orderByChanged(Notification notification) {
+ if (notification.getFeatureID(IOrderBy.class) == JpaCoreMappingsPackage.IORDER_BY__VALUE
+ || notification.getFeatureID(IOrderBy.class) == JpaCoreMappingsPackage.IORDER_BY__TYPE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ populate();
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void doPopulate(EObject obj) {
+ this.orderBy = (IOrderBy) obj;
+ if (this.orderBy == null) {
+ return;
+ }
+ populateOrderingRadioButtons();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateOrderingRadioButtons();
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.orderBy != null) {
+ this.orderBy.eAdapters().add(this.orderingListener);
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.orderBy != null) {
+ this.orderBy.eAdapters().remove(this.orderingListener);
+ }
+ }
+
+ private void populateOrderingRadioButtons() {
+ if (this.orderBy.getType() == OrderingType.NONE) {
+ this.primaryKeyOrderingRadioButton.setSelection(false);
+ this.customOrderingRadioButton.setSelection(false);
+ this.noOrderingRadioButton.setSelection(true);
+ if (!"".equals(this.orderingTextViewer.getDocument().get())) {
+ this.orderingTextViewer.getDocument().set("");
+ }
+ }
+ else if (this.orderBy.getType() == OrderingType.PRIMARY_KEY) {
+ this.customOrderingRadioButton.setSelection(false);
+ this.noOrderingRadioButton.setSelection(false);
+ this.primaryKeyOrderingRadioButton.setSelection(true);
+ String value = this.orderBy.getValue();
+ if (value != null && !value.equals(this.orderingTextViewer.getDocument().get())) {
+ this.orderingTextViewer.getDocument().set(value);
+ }
+ else {
+ if (!"".equals(this.orderingTextViewer.getDocument().get())) {
+ this.orderingTextViewer.getDocument().set("");
+ }
+ }
+ }
+ else if (this.orderBy.getType() == OrderingType.CUSTOM) {
+ this.noOrderingRadioButton.setSelection(false);
+ this.primaryKeyOrderingRadioButton.setSelection(false);
+ this.customOrderingRadioButton.setSelection(true);
+ String value = this.orderBy.getValue();
+ if (value != null && !value.equals(this.orderingTextViewer.getDocument().get())) {
+ this.orderingTextViewer.getDocument().set(value);
+ }
+ }
+
+ this.orderingTextViewer.setEditable(this.orderBy.getType() == OrderingType.CUSTOM);
+ this.orderingTextViewer.getTextWidget().setEnabled(this.orderBy.getType() == OrderingType.CUSTOM);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java
new file mode 100644
index 0000000000..5b58f6be1a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java
@@ -0,0 +1,494 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.List;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.internal.JpaEObject;
+import org.eclipse.jpt.core.internal.mappings.IAssociationOverride;
+import org.eclipse.jpt.core.internal.mappings.IAttributeOverride;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IOverride;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.JoinColumnsComposite.Owner;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class OverridesComposite extends BaseJpaComposite
+{
+ private ListViewer listViewer;
+
+ private IEntity entity;
+ private Adapter entityListener;
+
+ private IOverride selectedOverride;
+ private Adapter overrideListener;
+
+ protected PageBook overridePageBook;
+
+ protected ColumnComposite columnComposite;
+ protected JoinColumnsComposite joinColumnsComposite;
+
+ private Button overrideDefaultButton;
+
+ public OverridesComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.entityListener = buildEntityListener();
+ this.overrideListener = buildOverrideListener();
+ }
+
+ private Adapter buildEntityListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ entityChanged(notification);
+ }
+ };
+ }
+
+ private Adapter buildOverrideListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ overrideChanged(notification);
+ }
+ };
+ }
+
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Group attributeOverridesGroup = getWidgetFactory().createGroup(
+ composite, JpaUiMappingsMessages.AttributeOverridesComposite_attributeOverrides);
+ attributeOverridesGroup.setLayout(new GridLayout(2, true));
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace= true;
+ attributeOverridesGroup.setLayoutData(gridData);
+
+ this.listViewer = buildAttributeOverridesListViewer(attributeOverridesGroup);
+ gridData = new GridData();
+ gridData.verticalSpan = 2;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace= true;
+ this.listViewer.getList().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.listViewer.getList(), IJpaHelpContextIds.ENTITY_ATTRIBUTE_OVERRIDES);
+
+ this.overrideDefaultButton = getWidgetFactory().createButton(attributeOverridesGroup, "Override Default", SWT.CHECK);
+ this.overrideDefaultButton.addSelectionListener(buildOverrideDefaultSelectionListener());
+ gridData = new GridData();
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.overrideDefaultButton.setLayoutData(gridData);
+
+
+ this.overridePageBook = buildOverridePageBook(attributeOverridesGroup);
+ gridData = new GridData();
+ gridData.verticalAlignment = SWT.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ this.overridePageBook.setLayoutData(gridData);
+
+ this.joinColumnsComposite = new JoinColumnsComposite(this.overridePageBook, this.commandStack, getWidgetFactory());
+ this.columnComposite = new ColumnComposite(this.overridePageBook, this.commandStack, getWidgetFactory());
+ this.overridePageBook.showPage(this.joinColumnsComposite.getControl());
+ }
+
+ protected PageBook buildOverridePageBook(Composite parent) {
+ return new PageBook(parent, SWT.NONE);
+ }
+
+ private SelectionListener buildOverrideDefaultSelectionListener() {
+ return new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ overrideDefaultButtonSelected(e);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ overrideDefaultButtonSelected(e);
+ }
+ };
+ }
+
+ private void overrideDefaultButtonSelected(SelectionEvent e) {
+ boolean selection = this.overrideDefaultButton.getSelection();
+ if (selection) {
+ if (getSelectedOverride() instanceof IAttributeOverride) {
+ int index = this.entity.getSpecifiedAttributeOverrides().size();
+ IAttributeOverride attributeOverride = this.entity.createAttributeOverride(index);
+ this.entity.getSpecifiedAttributeOverrides().add(attributeOverride);
+ attributeOverride.setName(this.selectedOverride.getName());
+ attributeOverride.getColumn().setSpecifiedName(((IAttributeOverride) this.selectedOverride).getColumn().getName());
+ }
+ else {
+ int index = this.entity.getSpecifiedAssociationOverrides().size();
+ IAssociationOverride associationOverride = this.entity.createAssociationOverride(index);
+ String name = this.selectedOverride.getName();
+ this.entity.getSpecifiedAssociationOverrides().add(associationOverride);
+ associationOverride.setName(name);
+ //attributeOverride.getColumn().setSpecifiedName(this.attributeOverride.getColumn().getName());
+ }
+ }
+ else {
+ if (getSelectedOverride() instanceof IAttributeOverride) {
+ this.entity.getSpecifiedAttributeOverrides().remove(this.selectedOverride);
+ }
+ else {
+ this.entity.getSpecifiedAssociationOverrides().remove(this.selectedOverride);
+ }
+ }
+ }
+
+
+ private ListViewer buildAttributeOverridesListViewer(Composite parent) {
+ ListViewer listViewer = new ListViewer(parent, SWT.SINGLE | SWT.BORDER);
+ listViewer.setLabelProvider(buildAttributeOverridesLabelProvider());
+ listViewer.setContentProvider(buildAttributeOverridesContentProvider());
+
+ listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ overridesListSelectionChanged(event);
+ }
+ });
+
+ return listViewer;
+ }
+
+ protected void overridesListSelectionChanged(SelectionChangedEvent event) {
+ if (((StructuredSelection) event.getSelection()).isEmpty()) {
+ this.columnComposite.populate(null);
+ this.columnComposite.enableWidgets(false);
+ this.overrideDefaultButton.setSelection(false);
+ this.overrideDefaultButton.setEnabled(false);
+ }
+ else {
+ this.selectedOverride = getSelectedOverride();
+ if (this.selectedOverride instanceof IAttributeOverride) {
+ boolean specifiedOverride = this.entity.getSpecifiedAttributeOverrides().contains(this.selectedOverride);
+ this.overrideDefaultButton.setSelection(specifiedOverride);
+ this.overridePageBook.showPage(this.columnComposite.getControl());
+ this.columnComposite.populate(((IAttributeOverride) this.selectedOverride).getColumn());
+ this.columnComposite.enableWidgets(specifiedOverride);
+ this.overrideDefaultButton.setEnabled(true);
+ }
+ else {
+ boolean specifiedOverride = this.entity.getSpecifiedAssociationOverrides().contains(this.selectedOverride);
+ this.overrideDefaultButton.setSelection(specifiedOverride);
+ this.overridePageBook.showPage(this.joinColumnsComposite.getControl());
+ this.joinColumnsComposite.populate(new JoinColumnsOwner((IAssociationOverride) getSelectedOverride()));
+ this.joinColumnsComposite.enableWidgets(specifiedOverride);
+ this.overrideDefaultButton.setEnabled(true);
+ }
+ }
+ }
+
+ private ILabelProvider buildAttributeOverridesLabelProvider() {
+ return new LabelProvider() {
+ public String getText(Object element) {
+ //TODO also display column name somehow
+ return ((IOverride) element).getName();
+ }
+ };
+ }
+
+
+ private IContentProvider buildAttributeOverridesContentProvider() {
+ return new IStructuredContentProvider() {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ IEntity entity = (IEntity) inputElement;
+ return CollectionTools.addAll(entity.getAttributeOverrides().toArray(), entity.getAssociationOverrides());
+ }
+ };
+ }
+
+ private IOverride getSelectedOverride() {
+ return (IOverride) ((StructuredSelection) this.listViewer.getSelection()).getFirstElement();
+ }
+
+
+ public void doPopulate(EObject obj) {
+ this.entity = (IEntity) obj;
+ if (this.entity == null) {
+ this.selectedOverride = null;
+ this.columnComposite.populate(null);
+ this.joinColumnsComposite.populate(null);
+ return;
+ }
+
+ if (this.listViewer.getInput() != entity) {
+ this.listViewer.setInput(entity);
+ }
+ if (!this.entity.getAttributeOverrides().isEmpty()) {
+ if (this.listViewer.getSelection().isEmpty()) {
+ IOverride override = this.entity.getAttributeOverrides().get(0);
+ this.listViewer.setSelection(new StructuredSelection(override));
+ }
+ else {
+ Object selection = ((StructuredSelection) this.listViewer.getSelection()).getFirstElement();
+ if (selection instanceof IAttributeOverride) {
+ this.overridePageBook.showPage(this.columnComposite.getControl());
+ this.columnComposite.enableWidgets(true);
+ this.columnComposite.populate(((IAttributeOverride) selection).getColumn());
+ }
+ else {
+ this.overridePageBook.showPage(this.joinColumnsComposite.getControl());
+ this.joinColumnsComposite.enableWidgets(true);
+ this.joinColumnsComposite.populate(new JoinColumnsOwner((IAssociationOverride) selection));
+ }
+ }
+ }
+ else {
+ this.columnComposite.populate(null);
+ this.columnComposite.enableWidgets(false);
+ }
+ }
+
+ @Override
+ protected void doPopulate() {
+ this.columnComposite.doPopulate();
+ this.joinColumnsComposite.doPopulate();
+ }
+
+ @Override
+ protected void engageListeners() {
+ if (this.entity != null) {
+ this.entity.eAdapters().add(this.entityListener);
+ for (IOverride attributeOverride : this.entity.getAttributeOverrides()) {
+ attributeOverride.eAdapters().add(this.overrideListener);
+ }
+ for (IOverride attributeOverride : this.entity.getAssociationOverrides()) {
+ attributeOverride.eAdapters().add(this.overrideListener);
+ }
+ }
+ }
+
+ @Override
+ protected void disengageListeners() {
+ if (this.entity != null) {
+ this.entity.eAdapters().remove(this.entityListener);
+ for (IOverride attributeOverride : this.entity.getAttributeOverrides()) {
+ attributeOverride.eAdapters().remove(this.overrideListener);
+ }
+ for (IOverride attributeOverride : this.entity.getAssociationOverrides()) {
+ attributeOverride.eAdapters().remove(this.overrideListener);
+ }
+ }
+ }
+
+
+ protected void entityChanged(Notification notification) {
+ switch (notification.getFeatureID(IEntity.class)) {
+ case JpaCoreMappingsPackage.IENTITY__SPECIFIED_ATTRIBUTE_OVERRIDES :
+ case JpaCoreMappingsPackage.IENTITY__SPECIFIED_ASSOCIATION_OVERRIDES :
+ if (notification.getEventType() == Notification.ADD) {
+ ((IOverride) notification.getNewValue()).eAdapters().add(this.overrideListener);
+ final Object newValue = notification.getNewValue();
+ ((IOverride) newValue).eAdapters().add(this.overrideListener);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (listViewer.getList().isDisposed()) {
+ return;
+ }
+ listViewer.setSelection(new StructuredSelection(newValue));
+ }
+ });
+ }
+ else if (notification.getEventType() == Notification.ADD_MANY) {
+ List<IOverride> addedList = (List<IOverride>) notification.getNewValue();
+ for (IOverride override : addedList) {
+ override.eAdapters().add(this.overrideListener);
+ }
+ }
+ else if (notification.getEventType() == Notification.REMOVE) {
+ ((IOverride) notification.getOldValue()).eAdapters().remove(this.overrideListener);
+ }
+ else if (notification.getEventType() == Notification.REMOVE_MANY) {
+ List<IOverride> removedList = (List<IOverride>) notification.getOldValue();
+ for (IOverride override : removedList) {
+ override.eAdapters().remove(this.overrideListener);
+ }
+ }
+ break;
+ case JpaCoreMappingsPackage.IENTITY__DEFAULT_ATTRIBUTE_OVERRIDES :
+ case JpaCoreMappingsPackage.IENTITY__DEFAULT_ASSOCIATION_OVERRIDES :
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (listViewer.getList().isDisposed()) {
+ return;
+ }
+ listViewer.refresh();
+ }
+ });
+ break;
+ }
+ }
+
+ protected void overrideChanged(Notification notification) {
+ switch (notification.getFeatureID(IOverride.class)) {
+ case JpaCoreMappingsPackage.IOVERRIDE__NAME :
+ final IOverride override = (IOverride) notification.getNotifier();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ OverridesComposite.this.listViewer.update(override, null);
+ }
+ });
+ break;
+ default :
+ break;
+ }
+ }
+
+ public void dispose() {
+ this.columnComposite.dispose();
+ this.joinColumnsComposite.dispose();
+ super.dispose();
+ }
+
+
+ void addJoinColumn() {
+ JoinColumnInAssociationOverrideDialog dialog = new JoinColumnInAssociationOverrideDialog(this.getControl().getShell(), (IAssociationOverride) getSelectedOverride());
+ this.addJoinColumnFromDialog(dialog);
+ }
+
+ private void addJoinColumnFromDialog(JoinColumnInAssociationOverrideDialog dialog) {
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ int index = ((IAssociationOverride) getSelectedOverride()).getJoinColumns().size();
+ IJoinColumn joinColumn = ((IAssociationOverride) getSelectedOverride()).createJoinColumn(index);
+ ((IAssociationOverride) getSelectedOverride()).getSpecifiedJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(dialog.getSelectedName());
+ joinColumn.setSpecifiedReferencedColumnName(dialog.getReferencedColumnName());
+ }
+
+ void editJoinColumn(IJoinColumn joinColumn) {
+ JoinColumnInAssociationOverrideDialog dialog = new JoinColumnInAssociationOverrideDialog(this.getControl().getShell(), joinColumn);
+ editJoinColumnFromDialog(dialog, joinColumn);
+ }
+
+ private void editJoinColumnFromDialog(JoinColumnInAssociationOverrideDialog dialog, IJoinColumn joinColumn) {
+ if (dialog.open() == Window.OK) {
+ editJoinColumnDialogOkd(dialog, joinColumn);
+ }
+ }
+
+ private void editJoinColumnDialogOkd(JoinColumnInAssociationOverrideDialog dialog, IJoinColumn joinColumn) {
+ String name = dialog.getSelectedName();
+ String referencedColumnName = dialog.getReferencedColumnName();
+
+ if (dialog.isDefaultNameSelected()) {
+ if (joinColumn.getSpecifiedName() != null) {
+ joinColumn.setSpecifiedName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedName() == null || !joinColumn.getSpecifiedName().equals(name)){
+ joinColumn.setSpecifiedName(name);
+ }
+
+ if (dialog.isDefaultReferencedColumnNameSelected()) {
+ if (joinColumn.getSpecifiedReferencedColumnName() != null) {
+ joinColumn.setSpecifiedReferencedColumnName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null || !joinColumn.getSpecifiedReferencedColumnName().equals(referencedColumnName)){
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+ }
+
+ private class JoinColumnsOwner extends JpaEObject implements Owner {
+
+ IAssociationOverride associationOverride;
+
+ public JoinColumnsOwner(IAssociationOverride associationOverride) {
+ super();
+ this.associationOverride = associationOverride;
+ }
+
+ public void addJoinColumn() {
+ OverridesComposite.this.addJoinColumn();
+ }
+
+ public boolean containsSpecifiedJoinColumns() {
+ return this.associationOverride.containsSpecifiedJoinColumns();
+ }
+
+ public IJoinColumn createJoinColumn(int index) {
+ return this.associationOverride.createJoinColumn(index);
+ }
+
+ public List<IJoinColumn> getJoinColumns() {
+ return this.associationOverride.getJoinColumns();
+ }
+
+ public List<IJoinColumn> getSpecifiedJoinColumns() {
+ return this.associationOverride.getSpecifiedJoinColumns();
+ }
+
+ public int specifiedJoinColumnsFeatureId() {
+ return JpaCoreMappingsPackage.IASSOCIATION_OVERRIDE__SPECIFIED_JOIN_COLUMNS;
+ }
+
+ public Class owningFeatureClass() {
+ return IAssociationOverride.class;
+ }
+
+ public void editJoinColumn(IJoinColumn joinColumn) {
+ OverridesComposite.this.editJoinColumn(joinColumn);
+ }
+
+ public EObject getEObject() {
+ return this.associationOverride;
+ }
+ }
+
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnDialog.java
new file mode 100644
index 0000000000..a389ed2a32
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnDialog.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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: Oracle. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.IPrimaryKeyJoinColumn;
+import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.swt.widgets.Shell;
+
+public class PrimaryKeyJoinColumnDialog extends AbstractJoinColumnDialog<IPrimaryKeyJoinColumn> {
+
+ private IEntity entity;
+
+ PrimaryKeyJoinColumnDialog(Shell parent, IEntity entity) {
+ super(parent);
+ this.entity = entity;
+ }
+
+ PrimaryKeyJoinColumnDialog(Shell parent, IPrimaryKeyJoinColumn joinColumn) {
+ super(parent, joinColumn);
+ this.entity = (IEntity) joinColumn.eContainer();
+ }
+
+ protected Table getNameTable() {
+ return this.entity.primaryDbTable();
+ }
+
+ protected Table getReferencedNameTable() {
+ return this.entity.parentEntity().primaryDbTable();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java
new file mode 100644
index 0000000000..ea1ee1cd77
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java
@@ -0,0 +1,402 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import java.util.Iterator;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.IEntity;
+import org.eclipse.jpt.core.internal.mappings.INamedColumn;
+import org.eclipse.jpt.core.internal.mappings.IPrimaryKeyJoinColumn;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+public class PrimaryKeyJoinColumnsComposite extends BaseJpaComposite
+{
+ private IEntity entity;
+ private final Adapter entityListener;
+ private final Adapter pkJoinColumnListener;
+
+ ListViewer pkJoinColumnsListViewer;
+
+ private Group pkJoinColumnsGroup;
+ Button overrideDefaultJoinColumnsCheckBox;
+ private Button pkJoinColumnsRemoveButton;
+ private Button pkJoinColumnsEditButton;
+
+
+ public PrimaryKeyJoinColumnsComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, SWT.NULL, commandStack, widgetFactory);
+ this.entityListener = buildEntityListener();
+ this.pkJoinColumnListener = buildPkJoinColumnListener();
+ }
+
+ private Adapter buildEntityListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ entityChanged(notification);
+ }
+ };
+ }
+
+ private Adapter buildPkJoinColumnListener() {
+ return new AdapterImpl() {
+ public void notifyChanged(Notification notification) {
+ pkJoinColumnChanged(notification);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ GridData gridData = new GridData();
+ this.overrideDefaultJoinColumnsCheckBox = getWidgetFactory().createButton(
+ composite,
+ JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns,
+ SWT.CHECK);
+ this.overrideDefaultJoinColumnsCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (PrimaryKeyJoinColumnsComposite.this.overrideDefaultJoinColumnsCheckBox.getSelection()) {
+ IPrimaryKeyJoinColumn defaultJoinColumn = PrimaryKeyJoinColumnsComposite.this.entity.getDefaultPrimaryKeyJoinColumns().get(0);
+ String columnName = defaultJoinColumn.getDefaultName();
+ String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
+
+ IPrimaryKeyJoinColumn pkJoinColumn = PrimaryKeyJoinColumnsComposite.this.entity.createPrimaryKeyJoinColumn(0);
+ PrimaryKeyJoinColumnsComposite.this.entity.getSpecifiedPrimaryKeyJoinColumns().add(pkJoinColumn);
+ pkJoinColumn.setSpecifiedName(columnName);
+ pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ } else {
+ PrimaryKeyJoinColumnsComposite.this.entity.getSpecifiedPrimaryKeyJoinColumns().clear();
+ }
+ }
+ });
+
+ this.pkJoinColumnsGroup =
+ getWidgetFactory().createGroup(
+ composite,
+ JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn);
+ this.pkJoinColumnsGroup.setLayout(new GridLayout(2, false));
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 2;
+ this.pkJoinColumnsGroup.setLayoutData(gridData);
+
+ this.pkJoinColumnsListViewer = new ListViewer(this.pkJoinColumnsGroup, SWT.BORDER | SWT.MULTI);
+ this.pkJoinColumnsListViewer.setContentProvider(buildJoinColumnsListContentProvider());
+ this.pkJoinColumnsListViewer.setLabelProvider(buildJoinColumnsListLabelProvider());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.verticalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ this.pkJoinColumnsListViewer.getList().setLayoutData(gridData);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.pkJoinColumnsListViewer.getList(), IJpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS);
+
+ Button addJoinColumnButton = new Button(this.pkJoinColumnsGroup, SWT.NONE);
+ addJoinColumnButton.setText(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_add);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ addJoinColumnButton.setLayoutData(gridData);
+ addJoinColumnButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ addPrimaryKeyJoinColumn();
+ }
+ });
+
+ this.pkJoinColumnsEditButton = new Button(this.pkJoinColumnsGroup, SWT.NONE);
+ this.pkJoinColumnsEditButton.setText(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_edit);
+ this.pkJoinColumnsEditButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ editPrimaryKeyJoinColumn();
+ }
+ });
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ this.pkJoinColumnsEditButton.setLayoutData(gridData);
+
+ this.pkJoinColumnsRemoveButton = new Button(this.pkJoinColumnsGroup, SWT.NONE);
+ this.pkJoinColumnsRemoveButton.setText(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_remove);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ this.pkJoinColumnsRemoveButton.setLayoutData(gridData);
+ this.pkJoinColumnsRemoveButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ removePrimaryKeyJoinColumn();
+ }
+ });
+
+ this.pkJoinColumnsListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updatePrimaryKeyJoinColumnsEnablement();
+ }
+ });
+ }
+
+ private IContentProvider buildJoinColumnsListContentProvider() {
+ return new IStructuredContentProvider(){
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // do nothing
+ }
+
+ public void dispose() {
+ // do nothing
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((IEntity) inputElement).getPrimaryKeyJoinColumns().toArray();
+ }
+ };
+ }
+
+ private ILabelProvider buildJoinColumnsListLabelProvider() {
+ return new LabelProvider() {
+ public String getText(Object element) {
+ IPrimaryKeyJoinColumn joinColumn = (IPrimaryKeyJoinColumn) element;
+ return (PrimaryKeyJoinColumnsComposite.this.entity.containsSpecifiedPrimaryKeyJoinColumns()) ?
+ buildJoinColumnLabel(joinColumn)
+ :
+ buildDefaultJoinColumnLabel(joinColumn);
+ }
+ };
+ }
+
+ String buildDefaultJoinColumnLabel(IPrimaryKeyJoinColumn joinColumn) {
+ return NLS.bind(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+
+ String buildJoinColumnLabel(IPrimaryKeyJoinColumn joinColumn) {
+ if (joinColumn.getSpecifiedName() == null) {
+ if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault, joinColumn.getName(),joinColumn.getReferencedColumnName());
+ }
+ return NLS.bind(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null) {
+ return NLS.bind(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ else {
+ return NLS.bind(JpaUiMappingsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams, joinColumn.getName(), joinColumn.getReferencedColumnName());
+ }
+ }
+
+
+ void addPrimaryKeyJoinColumn() {
+ PrimaryKeyJoinColumnDialog dialog = new PrimaryKeyJoinColumnDialog(this.getControl().getShell(), this.entity);
+ addJoinColumnFromDialog(dialog);
+ }
+
+ private void addJoinColumnFromDialog(PrimaryKeyJoinColumnDialog dialog) {
+ if (dialog.open() == Window.OK) {
+ int index = this.entity.getSpecifiedPrimaryKeyJoinColumns().size();
+ String name = dialog.getSelectedName();
+ String referencedColumnName = dialog.getReferencedColumnName();
+ IPrimaryKeyJoinColumn joinColumn = this.entity.createPrimaryKeyJoinColumn(index);
+ this.entity.getSpecifiedPrimaryKeyJoinColumns().add(joinColumn);
+ joinColumn.setSpecifiedName(name);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+ }
+
+ private IPrimaryKeyJoinColumn getSelectedJoinColumn() {
+ return (IPrimaryKeyJoinColumn) ((StructuredSelection) this.pkJoinColumnsListViewer.getSelection()).getFirstElement();
+ }
+
+ void editPrimaryKeyJoinColumn() {
+ IPrimaryKeyJoinColumn joinColumn = getSelectedJoinColumn();
+ PrimaryKeyJoinColumnDialog dialog = new PrimaryKeyJoinColumnDialog(this.getControl().getShell(), joinColumn);
+ editJoinColumnFromDialog(dialog, joinColumn);
+ }
+
+ private void editJoinColumnFromDialog(PrimaryKeyJoinColumnDialog dialog, IPrimaryKeyJoinColumn joinColumn) {
+ if (dialog.open() == Window.OK) {
+ editJoinColumnDialogOkd(dialog, joinColumn);
+ }
+ }
+
+ private void editJoinColumnDialogOkd(PrimaryKeyJoinColumnDialog dialog, IPrimaryKeyJoinColumn joinColumn) {
+ String name = dialog.getSelectedName();
+ String referencedColumnName = dialog.getReferencedColumnName();
+
+ if (dialog.isDefaultNameSelected()) {
+ if (joinColumn.getSpecifiedName() != null) {
+ joinColumn.setSpecifiedName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedName() == null || !joinColumn.getSpecifiedName().equals(name)){
+ joinColumn.setSpecifiedName(name);
+ }
+
+ if (dialog.isDefaultReferencedColumnNameSelected()) {
+ if (joinColumn.getSpecifiedReferencedColumnName() != null) {
+ joinColumn.setSpecifiedReferencedColumnName(null);
+ }
+ }
+ else if (joinColumn.getSpecifiedReferencedColumnName() == null || !joinColumn.getSpecifiedReferencedColumnName().equals(referencedColumnName)){
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+ }
+
+ void removePrimaryKeyJoinColumn() {
+ ISelection selection = this.pkJoinColumnsListViewer.getSelection();
+ if (selection instanceof StructuredSelection) {
+ for (Iterator i = ((StructuredSelection) selection).iterator(); i.hasNext(); ) {
+ this.entity.getPrimaryKeyJoinColumns().remove(i.next());
+ }
+ }
+ }
+
+ void updatePrimaryKeyJoinColumnsEnablement() {
+ boolean groupEnabledState = this.entity.containsSpecifiedPrimaryKeyJoinColumns();
+ enableGroup(this.pkJoinColumnsGroup, groupEnabledState);
+
+ this.pkJoinColumnsRemoveButton.setEnabled(groupEnabledState && !((StructuredSelection) this.pkJoinColumnsListViewer.getSelection()).isEmpty());
+ this.pkJoinColumnsEditButton.setEnabled(groupEnabledState && ((StructuredSelection) this.pkJoinColumnsListViewer.getSelection()).size() == 1);
+ }
+
+ private void enableGroup(Group group, boolean enabled) {
+ group.setEnabled(enabled);
+ for (int i = 0; i < group.getChildren().length; i++) {
+ group.getChildren()[i].setEnabled(enabled);
+ }
+ }
+
+
+ public void doPopulate(EObject obj) {
+ this.entity = (IEntity) obj;
+ if (this.entity == null) {
+ this.pkJoinColumnsListViewer.setInput(null);
+ return;
+ }
+
+ this.pkJoinColumnsListViewer.setInput(this.entity);
+
+
+ updatePrimaryKeyJoinColumnsEnablement();
+ this.overrideDefaultJoinColumnsCheckBox.setSelection(this.entity.containsSpecifiedPrimaryKeyJoinColumns());
+ }
+
+ @Override
+ protected void doPopulate() {
+ }
+
+ protected void engageListeners() {
+ if (this.entity != null) {
+ this.entity.eAdapters().add(this.entityListener);
+ for (IPrimaryKeyJoinColumn pkJoinColumn : this.entity.getPrimaryKeyJoinColumns()) {
+ pkJoinColumn.eAdapters().add(this.pkJoinColumnListener);
+ }
+ //this.addConnectionListener();
+ }
+ }
+
+ protected void disengageListeners() {
+ if (this.entity != null) {
+ //this.removeConnectionListener();
+ for (IPrimaryKeyJoinColumn pkJoinColumn : this.entity.getPrimaryKeyJoinColumns()) {
+ pkJoinColumn.eAdapters().remove(this.pkJoinColumnListener);
+ }
+ this.entity.eAdapters().remove(this.entityListener);
+ }
+ }
+
+ protected void entityChanged(Notification notification) {
+ if (notification.getFeatureID(IEntity.class) == JpaCoreMappingsPackage.IENTITY__SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS) {
+ if (notification.getEventType() == Notification.ADD) {
+ ((IPrimaryKeyJoinColumn) notification.getNewValue()).eAdapters().add(this.pkJoinColumnListener);
+ }
+ else if (notification.getEventType() == Notification.REMOVE) {
+ ((IPrimaryKeyJoinColumn) notification.getOldValue()).eAdapters().remove(this.pkJoinColumnListener);
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ pkJoinColumnsListViewer.refresh();
+ overrideDefaultJoinColumnsCheckBox.setSelection(entity.containsSpecifiedPrimaryKeyJoinColumns());
+ updatePrimaryKeyJoinColumnsEnablement();
+ }
+ });
+ }
+ }
+
+ protected void pkJoinColumnChanged(Notification notification) {
+ if (notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__SPECIFIED_NAME
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__SPECIFIED_REFERENCED_COLUMN_NAME
+ || notification.getFeatureID(INamedColumn.class) == JpaCoreMappingsPackage.INAMED_COLUMN__DEFAULT_NAME
+ || notification.getFeatureID(IAbstractJoinColumn.class) == JpaCoreMappingsPackage.IABSTRACT_JOIN_COLUMN__DEFAULT_REFERENCED_COLUMN_NAME) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ pkJoinColumnsListViewer.refresh();
+ }
+ });
+ }
+ }
+
+
+ public void dispose() {
+ disengageListeners();
+ super.dispose();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
new file mode 100644
index 0000000000..60838f587a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.details;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.mappings.IId;
+import org.eclipse.jpt.core.internal.mappings.ISequenceGenerator;
+import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
+import org.eclipse.jpt.db.internal.ConnectionProfile;
+import org.eclipse.jpt.ui.internal.mappings.JpaUiMappingsMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+/**
+ * SequenceGeneratorComposite
+ */
+public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGenerator>
+{
+ private Combo sequenceNameCombo;
+
+ private ModifyListener sequenceNameComboListener;
+
+ private ConnectionProfile connectionProfile;
+
+ public SequenceGeneratorComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
+ super(parent, commandStack, widgetFactory);
+ }
+
+ protected ISequenceGenerator createGenerator() {
+ ISequenceGenerator sequenceGenerator = idMapping().createSequenceGenerator();
+ idMapping().setSequenceGenerator(sequenceGenerator);
+ return sequenceGenerator;
+ }
+
+ protected ISequenceGenerator generator(IId idMapping) {
+ return idMapping.getSequenceGenerator();
+ }
+
+ @Override
+ protected void initializeLayout(Composite composite) {
+ GridLayout layout = new GridLayout(2, false);
+ composite.setLayout(layout);
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.SequenceGeneratorComposite_name);
+
+ this.nameViewer = buildNameViewer(composite);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.nameViewer.getTextWidget().setLayoutData(gridData);
+
+ getWidgetFactory().createLabel(composite, JpaUiMappingsMessages.SequenceGeneratorComposite_sequence);
+
+ this.sequenceNameCombo = buildSequenceNameCombo(composite);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ this.sequenceNameCombo.setLayoutData(gridData);
+ }
+
+ private Combo buildSequenceNameCombo(Composite parent) {
+ Combo combo = new Combo(parent, SWT.DROP_DOWN);
+ combo.add(""); //$NON-NLS-1$
+ combo.select(0);
+ combo.addModifyListener(getSequenceNameListener());
+ return combo;
+ }
+
+ private ModifyListener getSequenceNameListener() {
+ if (this.sequenceNameComboListener == null) {
+ this.sequenceNameComboListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (isPopulating()) {
+ return;
+ }
+ String text = ((Combo) e.getSource()).getText();
+ if (text != null && sequenceNameCombo.getItemCount() > 0 && text.equals(sequenceNameCombo.getItem(0))) {
+ text = null;
+ }
+ ISequenceGenerator generator = getGenerator();
+ if (generator == null) {
+ generator = createGenerator();
+ }
+ generator.setSpecifiedSequenceName(text);
+ }
+ };
+ }
+ return this.sequenceNameComboListener;
+ }
+
+ protected void generatorChanged(Notification notification) {
+ super.generatorChanged(notification);
+ if (notification.getFeatureID(ISequenceGenerator.class) == JpaCoreMappingsPackage.ISEQUENCE_GENERATOR__SPECIFIED_SEQUENCE_NAME) {
+ final String sequenceName = notification.getNewStringValue();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl().isDisposed()) {
+ return;
+ }
+ if (sequenceName == null) {
+ sequenceNameCombo.select(0);
+ }
+ else if (!sequenceNameCombo.getText().equals(sequenceName)) {
+ sequenceNameCombo.setText(sequenceName);
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void doPopulate(EObject obj) {
+ super.doPopulate(obj);
+ if (obj == null) {
+ return;
+ }
+ populateSequenceNameCombo();
+ }
+
+ @Override
+ protected void doPopulate() {
+ populateSequenceNameCombo();
+ }
+
+ private ConnectionProfile getConnectionProfile() {
+ if(this.connectionProfile == null) {
+ IJpaProject jpaProject = getGenerator().getJpaProject();
+ this.connectionProfile = jpaProject.connectionProfile();
+ }